1 50 package org.apache.avalon.meta.info.test; 51 52 import org.apache.avalon.meta.info.Descriptor; 53 import org.apache.avalon.meta.info.Service; 54 import org.apache.avalon.meta.info.ReferenceDescriptor; 55 import org.apache.avalon.meta.info.EntryDescriptor; 56 import org.apache.avalon.framework.Version; 57 58 64 public class ServiceTestCase extends AbstractDescriptorTestCase 65 { 66 private ReferenceDescriptor m_reference; 67 private EntryDescriptor[] m_entries; 68 69 public ServiceTestCase( String name ) 70 { 71 super( name ); 72 } 73 74 protected Descriptor getDescriptor() 75 { 76 return new Service(m_reference, m_entries, getProperties()); 77 } 78 79 public void setUp() 80 { 81 m_reference = new ReferenceDescriptor(ServiceTestCase.class.getName(), Version.getVersion("1.2.3")); 82 m_entries = new EntryDescriptor[] { 83 new EntryDescriptor("key", String .class.getName()) 84 }; 85 } 86 87 public void testConstructor() 88 { 89 try 90 { 91 new Service(null); 92 fail("Did not throw the expected NullPointerException"); 93 } 94 catch(NullPointerException npe) 95 { 96 } 98 } 99 100 protected void checkDescriptor(Descriptor desc) 101 { 102 super.checkDescriptor(desc); 103 Service service = (Service)desc; 104 105 assertEquals( m_reference, service.getReference()); 106 assertEquals( m_reference.getClassname(), service.getClassname()); 107 assertEquals( m_reference.getVersion(), service.getVersion()); 108 109 assertEquals( m_entries.length, service.getEntries().length ); 110 assertTrue( service.matches(m_reference)); 111 112 EntryDescriptor[] serviceEntries = service.getEntries(); 113 for (int i = 0; i < m_entries.length; i++) 114 { 115 assertEquals( m_entries[i], serviceEntries[i]); 116 } 117 } 118 } | Popular Tags |