public void testAddScriptFromJavaScriptSourceFile() {

    File file1 =
        TestUtils.createFileFromString("test", ".js", ""); // $NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
    File mochiBase =
        TestUtils.createFileFromString(
            "MochiBase", ".js", ""); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    String src =
        "/**\n * @sdoc "
            + file1.getName()
            + "\n*/\nMochiKit.MochiKit.SUBMODULES = [\r\n\""
            + FileUtils.stripExtension(mochiBase.getName())
            + "\"];"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    File file = TestUtils.createFileFromString("base", ".js", src); // $NON-NLS-1$ //$NON-NLS-2$

    String uri = CoreUIUtils.getURI(file);

    String[] sdocs;
    sdocs = ProfilesViewHelper.addScriptFromJavaScriptSource(FileUtils.uriToURL(uri));

    assertEquals("Two sdoc files found", 2, sdocs.length); // $NON-NLS-1$
    assertEquals(CoreUIUtils.getURI(file1), sdocs[0]);
    assertEquals(CoreUIUtils.getURI(mochiBase), sdocs[1]);

    String[] sdocs2 = ProfilesViewHelper.addScriptFromJavaScriptSource(file.getParentFile(), src);

    assertEquals("Two sdoc files found", 2, sdocs2.length); // $NON-NLS-1$
    assertEquals(CoreUIUtils.getURI(file1), sdocs2[0]);
    assertEquals(CoreUIUtils.getURI(mochiBase), sdocs2[1]);
  }
  public void testFindScriptDocFile() {

    File file =
        TestUtils.createFileFromString(
            "base", ".js", "a"); // $NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
    // No sdoc file, returns false
    assertEquals(null, ProfilesViewHelper.findScriptDocFile(file.getAbsolutePath()));

    // create sdoc file, now finds path
    String filePath = file.getAbsolutePath();
    filePath = StringUtils.replace(filePath, ".js", ".sdoc"); // $NON-NLS-1$ //$NON-NLS-2$
    File sdocFile = TestUtils.createFileFromString(filePath, "b"); // $NON-NLS-1$
    assertEquals(
        CoreUIUtils.getURI(sdocFile.getAbsolutePath()),
        CoreUIUtils.getURI(ProfilesViewHelper.findScriptDocFile(file.getAbsolutePath())));
  }
  public void testAddSDocFromJavaScriptSource() {

    File file =
        TestUtils.createFileFromString("test", ".js", ""); // $NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
    String src = "/**\n * @sdoc " + file.getName() + "\n*/"; // $NON-NLS-1$ //$NON-NLS-2$
    String[] sdocs = ProfilesViewHelper.addSDocFromJavaScriptSource(file.getParentFile(), src);
    assertEquals("One sdoc file found", 1, sdocs.length); // $NON-NLS-1$
    assertEquals(CoreUIUtils.getURI(file), sdocs[0]);
  }
  public void testAddScriptTagsFromHTMLSource() {

    String jsURL = "http://www.aptana.com/lib/swfobject.js"; // $NON-NLS-1$
    File file1 =
        TestUtils.createFileFromString(
            "test1", ".js", ""); // $NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
    File file2 =
        TestUtils.createFileFromString(
            "test2", ".js", ""); // $NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
    File file3 =
        TestUtils.createFileFromString(
            "test2", ".js", ""); // $NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$

    String src =
        "<html><head><script src=\""
            + jsURL
            + "\"/><script src=\""
            + file1.getName()
            + "\" /><script src=\""
            + file2.getName()
            + "\"><script src=\""
            + file3.getName()
            + "\"></script></head><body></body></html>"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                                                         // //$NON-NLS-4$
    File parentFile = file1.getParentFile();

    HTMLParser parser = null;
    HTMLParseState parseState = null;

    try {
      parser = new HTMLParser();
      parseState = new HTMLParseState();
      parseState.setEditState(src, src, 0, 0);
      parser.parse(parseState);
    } catch (ParserInitializationException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (LexerException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    String[] sdocs = ProfilesViewHelper.addScriptTagsFromHTMLSource(parentFile, src, parseState);
    assertEquals("Three JS files found", 3, sdocs.length); // $NON-NLS-1$
    assertEquals(jsURL, sdocs[0]);
    assertEquals(CoreUIUtils.getURI(file1), sdocs[1]);
    assertEquals(CoreUIUtils.getURI(file2), sdocs[2]);
  }
 public void testStripQuerystring() {
   assertEquals(
       "test.js",
       ProfilesViewHelper //$NON-NLS-1$
           .stripQuerystring("test.js?query=q")); // $NON-NLS-1$
 }