1 4 package com.openedit.store.convert; 5 6 import java.io.File ; 7 import java.util.ArrayList ; 8 9 import com.openedit.store.Category; 10 import com.openedit.store.Product; 11 import com.openedit.store.StoreTestCase; 12 import com.openedit.store.excelconvert.GenericExcelConvert; 13 import com.openedit.util.OutputFiller; 14 15 18 public class ExcelConverterTest extends StoreTestCase 19 { 20 21 public ExcelConverterTest( String name ) 22 { 23 super( name ); 24 } 25 26 public void testWriteAndRead() throws Exception 27 { 28 29 GenericExcelConvert converter = new GenericExcelConvert(); 30 converter.convert(getStore(), new ArrayList ()); 31 32 Product product = getStore().getProduct("cup1"); 33 34 assertNotNull( "Should have a product with ID cup1", product ); 35 36 assertEquals( 3, product.getInventoryItems().size() ); 37 38 Category catalog = (Category)product.getCatalogs().iterator().next(); 39 assertNotNull( "Should have a catalog", catalog ); 40 assertEquals("mugs",catalog.getId()); 41 42 } 43 public void setUp() throws Exception 44 { 45 File testfile = new File ( getRoot().getParentFile(), "etc/testupload/inventory.xls"); 46 47 File uploadDir = new File ( getRoot(), "/store/upload" ); 48 uploadDir.mkdir(); 49 50 OutputFiller filler = new OutputFiller(); 51 File newFile = new File ( uploadDir, "inventory.xls" ); 52 filler.fill( testfile, newFile ); 53 } 54 55 } 56 | Popular Tags |