1 7 package org.jdesktop.swing.data; 8 9 import junit.framework.TestCase; 10 11 23 public abstract class AbstractMetaDataProviderTst extends TestCase { 24 25 protected MetaData[] defaultMetaData; 26 27 public void testEmptyProvider() { 28 MetaDataProvider provider = createEmptyMetaDataProvider(); 29 assertNotNull("provider must not be null", provider); 30 assertEquals("fieldCount must be 0", 0, provider.getFieldCount()); 31 } 32 33 public void testFilledProvider() { 34 MetaDataProvider provider = createFilledMetaDataProvider(); 35 assertNotNull("provider must not be null", provider); 36 assertEquals("fieldCount must be ", defaultMetaData.length, provider.getFieldCount()); 37 38 39 } 40 41 45 public void testFieldSequence() { 46 MetaDataProvider provider = createFilledMetaDataProvider(); 47 String [] fieldNames = provider.getFieldNames(); 48 assertEquals("fieldCount must be same as metaData length", defaultMetaData.length, provider.getFieldCount()); 49 for (int i = 0; i < fieldNames.length; i++) { 50 assertEquals("fieldname must equal metaData", defaultMetaData[i].getName(), fieldNames[i]); 51 } 52 53 } 54 protected void setUp() throws Exception { 55 super.setUp(); 56 defaultMetaData = createDefaultMetaData(); 57 } 58 59 protected MetaData[] createDefaultMetaData() { 60 MetaData[] metas = new MetaData[3]; 61 metas[0] = new MetaData("firstName", String .class, "First Name"); 62 metas[1] = new MetaData("second", Boolean .class, "Has Money"); 63 metas[2] = new MetaData("amount", Number .class, "Total Funds"); 64 return metas; 65 } 66 67 protected abstract MetaDataProvider createFilledMetaDataProvider(); 68 69 protected abstract MetaDataProvider createEmptyMetaDataProvider(); 70 } 71 | Popular Tags |