1 50 package org.apache.avalon.meta.info.test; 51 52 import org.apache.avalon.meta.info.InfoDescriptor; 53 import org.apache.avalon.meta.info.Descriptor; 54 import org.apache.avalon.framework.Version; 55 56 62 public class InfoDescriptorTestCase extends AbstractDescriptorTestCase 63 { 64 private final String m_name = "name"; 65 private final String m_classname = InfoDescriptorTestCase.class.getName(); 66 private final Version m_version = Version.getVersion("1.2.3"); 67 private final String m_lifestyle = InfoDescriptor.SINGLETON; 68 private final String m_schema = "schema"; 69 70 public InfoDescriptorTestCase ( String name ) 71 { 72 super( name ); 73 } 74 75 protected Descriptor getDescriptor() 76 { 77 return new InfoDescriptor( 78 m_name, m_classname, m_version, m_lifestyle, m_schema, getProperties()); 79 } 80 81 protected void checkDescriptor( Descriptor desc ) 82 { 83 super.checkDescriptor( desc ); 84 InfoDescriptor info = (InfoDescriptor) desc; 85 assertEquals( m_name, info.getName() ); 86 assertEquals( m_classname, info.getClassname() ); 87 assertEquals( m_version, info.getVersion() ); 88 assertEquals( m_lifestyle, info.getLifestyle() ); 89 assertEquals( m_schema, info.getConfigurationSchema() ); 90 } 91 92 public void testConstructor() 93 { 94 try 95 { 96 new InfoDescriptor( 97 m_name, null, m_version, m_lifestyle, m_schema, getProperties() ); 98 fail("Did not throw the proper NullPointerException"); 99 } 100 catch (NullPointerException npe) 101 { 102 } 104 105 try 106 { 107 new InfoDescriptor( 108 m_name, "foo/fake/ClassName", m_version, m_lifestyle, 109 m_schema, getProperties()); 110 fail("Did not throw the proper IllegalArgumentException"); 111 } 112 catch (IllegalArgumentException iae) 113 { 114 } 116 117 try 118 { 119 new InfoDescriptor( 120 m_name, m_classname, m_version, InfoDescriptor.POOLED, 121 m_schema, getProperties() ); 122 new InfoDescriptor( 123 m_name, m_classname, m_version, InfoDescriptor.SINGLETON, 124 m_schema, getProperties() ); 125 new InfoDescriptor( 126 m_name, m_classname, m_version, InfoDescriptor.THREAD, 127 m_schema, getProperties() ); 128 new InfoDescriptor( 129 m_name, m_classname, m_version, InfoDescriptor.TRANSIENT, 130 m_schema, getProperties() ); 131 132 134 new InfoDescriptor( 135 m_name, m_classname, m_version, "Fake Lifestyle", 136 m_schema, getProperties() ); 137 138 fail( "Did not throw the proper IllegalArgumentException" ); 139 } 140 catch ( IllegalArgumentException iae ) 141 { 142 } 144 } 145 } | Popular Tags |