Changeset 5949 for branches/cleanup


Ignore:
Timestamp:
02/23/10 05:04:32 (10 years ago)
Author:
callan
Message:

#464 Some further POI fork tests with an Excel document

Location:
branches/cleanup/components/bio-formats/test/loci/formats/utests
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • branches/cleanup/components/bio-formats/test/loci/formats/utests/POIServiceTest.java

    r5944 r5949  
    2626import static org.testng.AssertJUnit.*; 
    2727 
    28 import java.io.FileNotFoundException; 
    2928import java.io.IOException; 
     29import java.net.URL; 
     30import java.util.Vector; 
    3031 
     32import loci.common.RandomAccessInputStream; 
    3133import loci.common.services.DependencyException; 
    3234import loci.common.services.ServiceFactory; 
     
    4850  private POIService service; 
    4951 
     52  private static final String TEST_XLS = "test.xls"; 
     53 
     54  private static final String WORKBOOK_DOCUMENT = "Root Entry/Workbook"; 
     55 
     56  private static final int WORKBOOK_LENGTH = 9604; 
     57 
    5058  @BeforeMethod 
    51   public void setUp() throws DependencyException { 
     59  public void setUp() throws DependencyException, IOException { 
    5260    ServiceFactory sf = new ServiceFactory(); 
    5361    service = sf.getInstance(POIService.class); 
     62    URL file = this.getClass().getResource(TEST_XLS); 
     63    service.initialize(file.getPath()); 
    5464  } 
    5565 
    56   @Test(expectedExceptions={FileNotFoundException.class}) 
    57   public void testInitialize() throws IOException { 
    58     service.initialize("."); 
     66  @Test 
     67  public void testDocuments() { 
     68    Vector<String> documents = service.getDocumentList(); 
     69    for (String document : documents) { 
     70      if (document.equals(WORKBOOK_DOCUMENT)) { 
     71        return; 
     72      } 
     73    } 
     74    fail("Unable to find document: " + WORKBOOK_DOCUMENT); 
    5975  } 
    6076 
     77  @Test 
     78  public void testWorkbookDocumentAsStream() throws IOException { 
     79    RandomAccessInputStream stream =  
     80      service.getDocumentStream(WORKBOOK_DOCUMENT);  
     81    assertNotNull(stream); 
     82    assertEquals(WORKBOOK_LENGTH, stream.length()); 
     83  } 
     84 
     85  @Test 
     86  public void testWorkbookDocumentBytes() throws IOException { 
     87    byte[] bytes = service.getDocumentBytes(WORKBOOK_DOCUMENT);  
     88    assertNotNull(bytes); 
     89    assertEquals(WORKBOOK_LENGTH, bytes.length); 
     90  } 
     91 
     92  @Test 
     93  public void testWorkbookFileSize() { 
     94    assertEquals(WORKBOOK_LENGTH, service.getFileSize(WORKBOOK_DOCUMENT)); 
     95  } 
    6196} 
Note: See TracChangeset for help on using the changeset viewer.