Changeset 6072


Ignore:
Timestamp:
03/29/10 09:19:09 (10 years ago)
Author:
melissa
Message:
  • Added more generic metadata configuration test.
  • Fixed a handful of bugs exposed during testing.
Location:
trunk/components
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/bio-formats/build.xml

    r6045 r6072  
    9494  </target> 
    9595 
     96  <target name="test-metadata" depends="compile-tests" 
     97    description="test metadata level support for a single file" if="doTests"> 
     98    <testng sourcedir="${test.dir}" 
     99      classpath="${test-classes.dir}:${classes.dir}:${component.classpath}" 
     100      testname="Metadata tests"> 
     101      <classfileset file="${test-classes.dir}/loci/formats/utests/MetadataConfigurableTest.class"/> 
     102      <sysproperty key="testng.filename" value="${testng.filename}"/> 
     103      <jvmarg value="-mx${testng.memory}"/> 
     104    </testng> 
     105  </target> 
     106 
    96107</project> 
  • trunk/components/bio-formats/src/loci/formats/ImageReader.java

    r6071 r6072  
    186186  /* @see loci.formats.IMetadataConfigurable#getSupportedMetadataLevels() */ 
    187187  public Set<MetadataLevel> getSupportedMetadataLevels() { 
    188     return getReader().getSupportedMetadataLevels(); 
     188    return getReaders()[0].getSupportedMetadataLevels(); 
    189189  } 
    190190 
    191191  /* @see loci.formats.IMetadataConfigurable#getMetadataOptions() */ 
    192192  public MetadataOptions getMetadataOptions() { 
    193     return getReader().getMetadataOptions(); 
     193    return getReaders()[0].getMetadataOptions(); 
    194194  } 
    195195 
  • trunk/components/bio-formats/src/loci/formats/in/LeicaReader.java

    r6071 r6072  
    984984 
    985985        for (int k=0; k<numDims; k++) { 
    986           addSeriesMeta(time + k + " coordinate", in.readInt()); 
    987         } 
     986          if (in.getFilePointer() < in.length()) { 
     987            addSeriesMeta(time + k + " coordinate", in.readInt()); 
     988          } 
     989          else break; 
     990        } 
     991        if (in.getFilePointer() >= in.length()) break; 
    988992        addSeriesMeta("Time-marker " + j, getString(64)); 
    989993      } 
  • trunk/components/bio-formats/test/loci/formats/utests/DeltavisionMetadataConfigurableTest.java

    r6069 r6072  
    2929import java.security.MessageDigest; 
    3030 
     31import loci.common.DataTools; 
    3132import loci.formats.FormatException; 
    3233import loci.formats.in.DeltavisionReader; 
     
    115116    try { 
    116117      MessageDigest md = MessageDigest.getInstance("SHA-1");  
    117       return toHex(md.digest(buf)); 
     118      return DataTools.bytesToHex(md.digest(buf)); 
    118119    } 
    119120    catch (Exception e) { 
     
    122123  } 
    123124 
    124   private String toHex(byte[] data) { 
    125     StringBuilder buf = new StringBuilder(); 
    126     for (int i = 0; i < data.length; i++) { 
    127       int halfbyte = (data[i] >>> 4) & 0x0F; 
    128       int two_halfs = 0; 
    129       do { 
    130         if ((0 <= halfbyte) && (halfbyte <= 9)) { 
    131           buf.append((char) ('0' + halfbyte)); 
    132         } 
    133         else { 
    134           buf.append((char) ('a' + (halfbyte - 10))); 
    135         } 
    136         halfbyte = data[i] & 0x0F; 
    137       } while(two_halfs++ < 1); 
    138     } 
    139     return buf.toString(); 
    140   } 
    141  
    142125} 
  • trunk/components/common/src/loci/common/DataTools.java

    r6050 r6072  
    393393  } 
    394394 
     395  /** Translates the given byte array into a String of hexadecimal digits. */ 
     396  public static String bytesToHex(byte[] b) { 
     397    StringBuffer sb = new StringBuffer(); 
     398    for (int i=0; i<b.length; i++) { 
     399      String a = Integer.toHexString(b[i] & 0xff); 
     400      if (a.length() == 1) sb.append("0"); 
     401      sb.append(a); 
     402    } 
     403    return sb.toString(); 
     404  } 
     405 
    395406  // -- Word decoding - primitive types to bytes -- 
    396407 
  • trunk/components/test-suite/src/loci/tests/testng/TestTools.java

    r6026 r6072  
    4444import java.util.List; 
    4545 
     46import loci.common.DataTools; 
    4647import loci.common.DateTools; 
    4748import loci.common.Location; 
     
    8384      md.update(b); 
    8485      byte[] digest = md.digest(); 
    85       StringBuffer sb = new StringBuffer(); 
    86       for (int i=0; i<digest.length; i++) { 
    87         String a = Integer.toHexString(digest[i] & 0xff); 
    88         if (a.length() == 1) sb.append("0"); 
    89         sb.append(a); 
    90       } 
    91       return sb.toString(); 
     86      return DataTools.bytesToHex(digest); 
    9287    } 
    9388    catch (NoSuchAlgorithmException e) { } 
Note: See TracChangeset for help on using the changeset viewer.