1 15 package hivemind.test.parse; 16 17 import org.apache.hivemind.Location; 18 import org.apache.hivemind.Resource; 19 import org.apache.hivemind.impl.DefaultErrorHandler; 20 import org.apache.hivemind.impl.LocationImpl; 21 import org.apache.hivemind.parse.ModuleDescriptor; 22 import org.apache.hivemind.schema.impl.SchemaImpl; 23 import org.apache.hivemind.test.HiveMindTestCase; 24 import org.apache.hivemind.util.ClasspathResource; 25 26 31 public class TestModuleDescriptor extends HiveMindTestCase 32 { 33 public void testAddDupeSchema() throws Exception 34 { 35 ModuleDescriptor md = new ModuleDescriptor(getClassResolver(), new DefaultErrorHandler()); 36 md.setModuleId("foo"); 37 38 Resource r = new ClasspathResource(getClassResolver(), "/foo/bar"); 39 Location l1 = new LocationImpl(r, 20); 40 Location l2 = new LocationImpl(r, 97); 41 42 SchemaImpl s1 = new SchemaImpl("test"); 43 s1.setId("bar"); 44 s1.setLocation(l1); 45 46 SchemaImpl s2 = new SchemaImpl("test"); 47 s2.setId("bar"); 48 s2.setLocation(l2); 49 50 interceptLogging(md.getClass().getName()); 51 52 md.addSchema(s1); 53 md.addSchema(s2); 54 55 assertLoggedMessagePattern("Schema foo.bar conflicts with existing schema at classpath:/foo/bar, line 20\\."); 56 57 assertSame(s1, md.getSchema("bar")); 58 } 59 60 } | Popular Tags |