package hudson.tasks._ant;

import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
import hudson.tasks.Ant;
import org.jvnet.hudson.test.HudsonTestCase;
import org.jvnet.hudson.test.SingleFileSCM;

/**
 * @author Kohsuke Kawaguchi
 */
public class AntTargetAnnotationTest extends HudsonTestCase {
    @Override
    protected void setUp() throws Exception {
        super.setUp();
        AntTargetNote.ENABLED = true;
    }

    public void test1() throws Exception {
        FreeStyleProject p = createFreeStyleProject();
        p.getBuildersList().add(new Ant("foo",null,null,null,null));
        p.setScm(new SingleFileSCM("build.xml",getClass().getResource("simple-build.xml")));
        FreeStyleBuild b = buildAndAssertSuccess(p);

        AntTargetNote.ENABLED = true;
        try {
            HtmlPage c = createWebClient().getPage(b, "console");
            System.out.println(c.asText());

            HtmlElement o = c.getElementById("console-outline");
            assertEquals(2,o.selectNodes("LI").size());
        } finally {
            AntTargetNote.ENABLED = false;
        }
    }
}

@@ -315,16 +315,66 @@
 FileSCM;
+%0Aimport org.mozilla.javascript.tools.debugger.Dim;
 %0A%0A/**%0A *
@@ -470,136 +470,10 @@
 e %7B%0A
-    @Override%0A    protected void setUp() throws Exception %7B%0A        super.setUp();%0A        AntTargetNote.ENABLED = true;%0A    %7D%0A%0A
+//
     
@@ -511,16 +511,18 @@
 ption %7B%0A
+//
         
@@ -568,16 +568,18 @@
 ject();%0A
+//
         
@@ -635,24 +635,26 @@
 ull,null));%0A
+//
         p.se
@@ -730,24 +730,26 @@
 ld.xml%22)));%0A
+//
         Free
@@ -789,17 +789,21 @@
 ess(p);%0A
-%0A
+//%0A//
         
@@ -832,16 +832,18 @@
 = true;%0A
+//
         
@@ -844,24 +844,26 @@
       try %7B%0A
+//
             
@@ -867,37 +867,135 @@
    H
-tmlPage c = createWebClient()
+udsonTestCase.WebClient wc = createWebClient();%0A//            wc.interactiveJavaScriptDebugger();%0A//            HtmlPage c = wc
 .get
@@ -1010,24 +1010,26 @@
 %22console%22);%0A
+//
             
@@ -1060,17 +1060,21 @@
 ext());%0A
-%0A
+//%0A//
         
@@ -1130,16 +1130,18 @@
 line%22);%0A
+//
         
@@ -1188,16 +1188,18 @@
 ize());%0A
+//
         
@@ -1210,16 +1210,18 @@
 nally %7B%0A
+//
         
@@ -1255,16 +1255,18 @@
  false;%0A
+//
         
@@ -1267,16 +1267,18 @@
       %7D%0A
+//
     %7D%0A%7D%0A

commenting out the test while I work on the Rhino/HtmlUnit problem