Changeset 4809


Ignore:
Timestamp:
02/16/09 21:00:27 (11 years ago)
Author:
melissa
Message:

Fixed a couple of bugs in the conversion test, as well as a couple of bugs exposed by the conversion test.

Location:
trunk/components
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/bio-formats/src/loci/formats/FormatReader.java

    r4681 r4809  
    192192      // verify key contains at least one alphabetic character 
    193193      if (!key.matches(".*[a-zA-Z].*")) return; 
     194 
     195      // remove <, > and & to prevent XML parsing errors 
     196      String[] invalidSequences = new String[] { 
     197        "&lt;", "&gt;", "&amp;", "<", ">", "&" 
     198      }; 
     199      for (int i=0; i<invalidSequences.length; i++) { 
     200        key = key.replaceAll(invalidSequences[i], ""); 
     201        val = val.replaceAll(invalidSequences[i], ""); 
     202      } 
    194203    } 
    195204 
  • trunk/components/bio-formats/src/loci/formats/ImageReader.java

    r4590 r4809  
    444444  /* @see IFormatReader#close(boolean) */ 
    445445  public void close(boolean fileOnly) throws IOException { 
    446     if (currentId == null) return; // nothing to close 
    447     getReader().close(fileOnly); 
     446    for (int i=0; i<readers.length; i++) { 
     447      readers[i].close(fileOnly); 
     448    } 
    448449    if (!fileOnly) currentId = null; 
    449450  } 
  • trunk/components/test-suite/src/loci/tests/testng/FormatWriterTest.java

    r4808 r4809  
    4141import loci.formats.*; 
    4242import loci.formats.out.*; 
    43 import loci.formats.meta.MetadataRetrieve; 
    44 import loci.formats.meta.MetadataStore; 
     43import loci.formats.meta.*; 
    4544import org.testng.SkipException; 
    4645 
     
    102101   */ 
    103102  public void testWriterConsistency(IFormatWriter writer) { 
    104     if (!initFile()) return; 
    105     String file = reader.getCurrentFile(); 
    106103    String testName = 
    107104      TestTools.shortClassName(writer) + " testWriterConsistency"; 
     105    if (!initFile()) { 
     106      result(testName, false, null); 
     107      return; 
     108    } 
     109    String file = reader.getCurrentFile(); 
    108110    boolean success = true; 
    109111    String msg = null; 
     
    113115        success = true; 
    114116        result(testName, success, msg); 
     117        return; 
    115118      } 
    116119 
     
    119122      String suffix = "." + writer.getSuffixes()[0]; 
    120123      File tmpFile = File.createTempFile(prefix, suffix); 
    121       tmpFile.deleteOnExit(); 
    122       String filename = tmpFile.getAbsolutePath(); 
     124      //tmpFile.deleteOnExit(); 
     125      String convertedFile = tmpFile.getAbsolutePath(); 
     126 
     127      IMetadata meta = (IMetadata) reader.getMetadataStore(); 
     128      writer.setMetadataRetrieve((MetadataRetrieve) meta); 
    123129 
    124130      // convert the input file 
    125       writer.setId(filename); 
     131      writer.setId(convertedFile); 
    126132 
    127133      int seriesCount = writer.canDoStacks() ? reader.getSeriesCount() : 1; 
     
    141147      // verify that the dimensions are accurate 
    142148 
    143       reader.setId(filename); 
     149      reader.setId(convertedFile); 
    144150 
    145151      boolean seriesMatch = reader.getSeriesCount() == config.getNumSeries(); 
     
    186192 
    187193          success = msg == null; 
    188           if (!success) { 
    189             result(testName, success, msg); 
    190           } 
     194          if (!success) break; 
    191195        } 
    192196      } 
     
    210214    try { 
    211215      if (reader == null) reader = new ImageReader(); 
     216      reader.close(); 
     217      MetadataStore store = MetadataTools.createOMEXMLMetadata(); 
     218      reader.setMetadataStore(store); 
    212219      reader.setId(id); 
    213220 
     
    243250  { 
    244251    if (s1.equals(s2)) return null; 
    245     return label + " mismatch (got " + s1 + ", expected " + s2 + 
    246       ") in series " + series; 
     252    return label + " mismatch [got " + s1 + ", expected " + s2 + 
     253      "] in series " + series; 
    247254  } 
    248255 
Note: See TracChangeset for help on using the changeset viewer.