KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > openedit > store > convert > ExcelConverterTest


1 /*
2  * Created on Sep 23, 2004
3  */

4 package com.openedit.store.convert;
5
6 import java.io.File JavaDoc;
7 import java.util.ArrayList JavaDoc;
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 /**
16  * @author Matthew Avery, mavery@einnovation.com
17  */

18 public class ExcelConverterTest extends StoreTestCase
19 {
20     
21     public ExcelConverterTest( String JavaDoc name )
22     {
23         super( name );
24     }
25     
26     public void testWriteAndRead() throws Exception JavaDoc
27     {
28         
29         GenericExcelConvert converter = new GenericExcelConvert();
30         converter.convert(getStore(), new ArrayList JavaDoc());
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 JavaDoc
44     {
45         File JavaDoc testfile = new File JavaDoc( getRoot().getParentFile(), "etc/testupload/inventory.xls");
46         
47         File JavaDoc uploadDir = new File JavaDoc( getRoot(), "/store/upload" );
48         uploadDir.mkdir();
49
50         OutputFiller filler = new OutputFiller();
51         File JavaDoc newFile = new File JavaDoc( uploadDir, "inventory.xls" );
52         filler.fill( testfile, newFile );
53     }
54
55 }
56
Popular Tags