antoine     2003/07/30 08:25:51

  Modified:    src/etc/testcases/taskdefs java.xml
               src/testcases/org/apache/tools/ant/taskdefs JavaTest.java
  Log:
  TestCase fixed, works now also on nagoya (Solaris).
  The problem was that I did not allow enough time for java to start.
  1 second is OK, 400 millis were not enough.
  
  Revision  Changes    Path
  1.7       +7 -2      ant/src/etc/testcases/taskdefs/java.xml
  
  Index: java.xml
  ===================================================================
  RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/java.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- java.xml  30 Jul 2003 13:56:06 -0000      1.6
  +++ java.xml  30 Jul 2003 15:25:51 -0000      1.7
  @@ -1,7 +1,10 @@
   <?xml version="1.0"?>
   
   <project name="java-test" basedir="." default="foo">
  -
  +  <!-- this property gets overridden programmatically-->
  +  <property name="timeToWait" value="4"/>
  +  <!-- this property gets overridden programmatically-->
  +  <property name="logFile" value="spawn.log"/>
     <property name="app"
       value="org.apache.tools.ant.taskdefs.JavaTest$$EntryPoint" />
   
  @@ -119,6 +122,8 @@
         <arg value="${logFile}" />
       </java>
     </target>
  -
  +  <target name="cleanup">
  +      <delete file="${logFile}"/>
  +  </target>
     <target name="foo" />
   </project>
  
  
  
  1.12      +42 -31    
ant/src/testcases/org/apache/tools/ant/taskdefs/JavaTest.java
  
  Index: JavaTest.java
  ===================================================================
  RCS file: 
/home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/JavaTest.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- JavaTest.java     30 Jul 2003 13:56:06 -0000      1.11
  +++ JavaTest.java     30 Jul 2003 15:25:51 -0000      1.12
  @@ -62,26 +62,30 @@
   /**
    * stress out java task
    * @author steve loughran
  - * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Bailliez</a> 
  + * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Bailliez</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Donal Quinlan</a>
    * */
   public class JavaTest extends BuildFileTest {
   
       private static final int TIME_TO_WAIT = 4;
  +    // wait 1 second extra to allow for java to start ...
  +    // this time was OK on a Win NT machine and on nagoya
  +    private static final int SECURITY_MARGIN = 1000;
  +
       private boolean runFatalTests=false;
  -    
  -    public JavaTest(String name) { 
  +
  +    public JavaTest(String name) {
           super(name);
  -    }    
  -    
  +    }
  +
       /**
  -     * configure the project. 
  +     * configure the project.
        * if the property junit.run.fatal.tests is set we run
        * the fatal tests
        */
  -    public void setUp() { 
  +    public void setUp() {
           configureProject("src/etc/testcases/taskdefs/java.xml");
  -        
  +
           //final String propname="tests-classpath.value";
           //String testClasspath=System.getProperty(propname);
           //System.out.println("Test cp="+testClasspath);
  @@ -92,28 +96,30 @@
       }
   
       public void tearDown() {
  +        // remove log file from testSpawn
  +        project.executeTarget("cleanup");
       }
   
       public void testNoJarNoClassname(){
           expectBuildExceptionContaining("testNoJarNoClassname",
               "parameter validation",
  -            "Classname must not be null.");   
  +            "Classname must not be null.");
       }
   
       public void testJarNoFork() {
           expectBuildExceptionContaining("testJarNoFork",
               "parameter validation",
  -            "Cannot execute a jar in non-forked mode. " 
  -                + "Please set fork='true'. ");        
  +            "Cannot execute a jar in non-forked mode. "
  +                + "Please set fork='true'. ");
       }
  -      
  -    public void testJarAndClassName() { 
  +
  +    public void testJarAndClassName() {
           expectBuildException("testJarAndClassName",
               "Should not be able to set both classname AND jar");
       }
  -                
   
  -    public void testClassnameAndJar() { 
  +
  +    public void testClassnameAndJar() {
           expectBuildException("testClassnameAndJar",
               "Should not be able to set both classname AND jar");
       }
  @@ -121,7 +127,7 @@
       public void testRun() {
           executeTarget("testRun");
       }
  -        
  +
   
   
       /** this test fails but we ignore the return value;
  @@ -132,7 +138,7 @@
               executeTarget("testRunFail");
           }
       }
  -    
  +
       public void testRunFailFoe() {
           if(runFatalTests) {
               expectBuildExceptionContaining("testRunFailFoe",
  @@ -148,32 +154,32 @@
       }
   
       public void testExcepting() {
  -        expectLogContaining("testExcepting", 
  +        expectLogContaining("testExcepting",
                               "Exception raised inside called program");
       }
  -    
  +
       public void testExceptingFork() {
  -        expectLogContaining("testExceptingFork", 
  +        expectLogContaining("testExceptingFork",
                               "Java Result:");
       }
  -    
  +
       public void testExceptingFoe() {
           expectBuildExceptionContaining("testExceptingFoe",
               "passes exception through",
               "Exception raised inside called program");
       }
  -    
  +
       public void testExceptingFoeFork() {
           expectBuildExceptionContaining("testExceptingFoeFork",
               "exceptions turned into error codes",
  -            "Java returned:");        
  -    }   
  -        
  +            "Java returned:");
  +    }
  +
       public void testResultPropertyZero() {
           executeTarget("testResultPropertyZero");
           assertEquals("0",project.getProperty("exitcode"));
       }
  -    
  +
       public void testResultPropertyNonZero() {
           executeTarget("testResultPropertyNonZero");
           assertEquals("-1",project.getProperty("exitcode"));
  @@ -188,10 +194,15 @@
           project.setProperty("timeToWait", Long.toString(TIME_TO_WAIT));
           project.executeTarget("testSpawn");
           try {
  -            Thread.sleep(TIME_TO_WAIT * 1000 + 400);
  +            Thread.sleep(TIME_TO_WAIT * 1000 + SECURITY_MARGIN);
           } catch (Exception ex) {
               System.out.println("my sleep was interrupted");
           }
  +        // let's be nice with the next generation of developers
  +        if (!logFile.exists()) {
  +            System.out.println("suggestion: increase the constant"
  +            + " SECURITY_MARGIN to give more time for java to start.");
  +        }
           assertTrue("log file exists", logFile.exists());
       }
   
  @@ -200,7 +211,7 @@
        * than normal JRE runtime
        */
       public static class EntryPoint {
  -        
  +
       /**
        * this entry point is used by the java.xml tests to
        * generate failure strings to handle
  @@ -228,15 +239,15 @@
               }
           }
       }
  -    
  +
       /**
        * entry point class with no dependencies other
        * than normal JRE runtime
        */
       public static class ExceptingEntryPoint {
  -        
  +
           /**
  -         * throw a run time exception which does not need 
  +         * throw a run time exception which does not need
            * to be in the signature of the entry point
            */
           public static void main(String[] argv) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to