Changeset 4808


Ignore:
Timestamp:
02/16/09 14:58:38 (11 years ago)
Author:
melissa
Message:

Added TestNG test to ensure that file conversion works. Closes #341.

Location:
trunk/components/test-suite
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/test-suite/build.properties

    r4618 r4808  
    2020 
    2121testng.memory            = 512m 
     22writer-test.class        = loci/tests/testng/FormatWriterTest.class 
  • trunk/components/test-suite/build.xml

    r4612 r4808  
    1717  <taskdef name="testng" classpath="${component.classpath}" 
    1818    classname="org.testng.TestNGAntTask"/> 
     19 
     20  <target name="test-convert" depends="compile" 
     21    description="run automated tests on writers"> 
     22    <testng sourcedir="${dest.dir}" 
     23      classpath="${classes.dir}:${component.classpath}" 
     24      annotations="Javadoc" groups="all" testname="Writer tests" 
     25      listener="loci.tests.testng.DotTestListener" 
     26      suitename="LOCI software test suite"> 
     27      <classfileset file="${classes.dir}/${writer-test.class}"/> 
     28      <sysproperty key="testng.filename" value="${testng.filename}"/> 
     29      <sysproperty key="lurawave.license" value="${lurawave.license}"/> 
     30      <jvmarg value="-mx${testng.memory}"/> 
     31    </testng> 
     32  </target> 
    1933 
    2034  <target name="test-all" depends="compile" 
  • trunk/components/test-suite/src/loci/tests/testng/FormatReaderTest.java

    r4550 r4808  
    329329      MetadataRetrieve retrieve = (MetadataRetrieve) reader.getMetadataStore(); 
    330330      success = MetadataTools.isOMEXMLMetadata(retrieve); 
    331       if (!success) msg = shortClassName(retrieve); 
     331      if (!success) msg = TestTools.shortClassName(retrieve); 
    332332 
    333333      for (int i=0; i<reader.getSeriesCount() && success; i++) { 
     
    633633        config.setSeries(i); 
    634634 
    635         String md5 = md5(reader.openBytes(0)); 
     635        String md5 = TestTools.md5(reader.openBytes(0)); 
    636636        String expected = config.getMD5(); 
    637637 
     
    698698              success = false; 
    699699              if (result) { 
    700                 msg = shortClassName(readers[j]) + " flagged \"" + 
    701                   used[i] + "\" but so did " + shortClassName(r); 
     700                msg = TestTools.shortClassName(readers[j]) + " flagged \"" + 
     701                  used[i] + "\" but so did " + TestTools.shortClassName(r); 
    702702              } 
    703703              else { 
    704                 msg = shortClassName(readers[j]) + 
     704                msg = TestTools.shortClassName(readers[j]) + 
    705705                  " skipped \"" + used[i] + "\""; 
    706706              } 
     
    756756        line.append(" indexed=" + reader.isIndexed()); 
    757757        line.append(" falseColor=" + reader.isFalseColor()); 
    758         line.append(" md5=" + md5(reader.openBytes(0))); 
     758        line.append(" md5=" + TestTools.md5(reader.openBytes(0))); 
    759759        line.append("]"); 
    760760      } 
     
    826826    } 
    827827 
    828     LogTools.print(timestamp() + "Initializing " + id + ": "); 
     828    LogTools.print(TestTools.timestamp() + "Initializing " + id + ": "); 
    829829    try { 
    830830      reader.setId(id); 
     
    857857  } 
    858858 
    859   /** Calculate the MD5 of a byte array. */ 
    860   private static String md5(byte[] b) { 
    861     try { 
    862       MessageDigest md = MessageDigest.getInstance("MD5"); 
    863       md.reset(); 
    864       md.update(b); 
    865       byte[] digest = md.digest(); 
    866       StringBuffer sb = new StringBuffer(); 
    867       for (int i=0; i<digest.length; i++) { 
    868         String a = Integer.toHexString(0xff & digest[i]); 
    869         if (a.length() == 1) a = "0" + a; 
    870         sb.append(a); 
    871       } 
    872       return sb.toString(); 
    873     } 
    874     catch (NoSuchAlgorithmException e) { LogTools.trace(e); } 
    875     return null; 
    876   } 
    877  
    878859  /** Outputs test result and generates appropriate assertion. */ 
    879860  private static void result(String testName, boolean success) { 
     
    886867   */ 
    887868  private static void result(String testName, boolean success, String msg) { 
    888     LogTools.println("\t" + timestamp() + ": " + testName + ": " + 
     869    LogTools.println("\t" + TestTools.timestamp() + ": " + testName + ": " + 
    889870      (success ? "PASSED" : "FAILED") + (msg == null ? "" : " (" + msg + ")")); 
    890871    if (msg == null) assert success; 
     
    892873  } 
    893874 
    894   /** Gets the class name sans package for the given object. */ 
    895   private static String shortClassName(Object o) { 
    896     String name = o.getClass().getName(); 
    897     int dot = name.lastIndexOf("."); 
    898     return dot < 0 ? name : name.substring(dot + 1); 
    899   } 
    900  
    901   /** Gets a timestamp for the current moment. */ 
    902   private static String timestamp() { 
    903     return DataTools.convertDate(System.currentTimeMillis(), DataTools.UNIX); 
    904   } 
    905  
    906875} 
Note: See TracChangeset for help on using the changeset viewer.