1 15 package hivemind.test.config; 16 17 import java.util.List ; 18 import java.util.Map ; 19 20 import org.apache.hivemind.ApplicationRuntimeException; 21 import org.apache.hivemind.Registry; 22 import org.apache.hivemind.xml.XmlTestCase; 23 24 26 public class TestUniqueElementAttribute extends XmlTestCase 27 { 28 31 public void testUniquenessViolated() throws Exception 32 { 33 Registry r = 34 buildFrameworkRegistry( 35 new String [] { "UniqueAttributeDefinition.xml", "UniqueAttributeBroken.xml" }); 36 37 Map elements = (Map ) r.getConfiguration("hivemind.test.parse.MyExtensionPoint"); 38 39 try 40 { 41 elements.size(); 43 44 unreachable(); 45 } 46 catch (ApplicationRuntimeException ex) 47 { 48 assertExceptionSubstring( 49 ex, 50 "already contained in map"); 51 } 52 53 } 54 55 58 public void testFalseUniqueAttributeConstraint() throws Exception 59 { 60 Registry r = 61 buildFrameworkRegistry( 62 new String [] { "UniqueAttributeDefinition.xml", "UniqueAttributeBroken.xml" }); 63 64 List elements = (List ) r.getConfiguration("hivemind.test.parse.MyExtensionPoint2"); 65 66 assertEquals(3, elements.size()); 67 } 68 69 72 public void testNoUniqueAttributeConstraint() throws Exception 73 { 74 Registry r = 75 buildFrameworkRegistry( 76 new String [] { "UniqueAttributeDefinition.xml", "UniqueAttributeBroken.xml" }); 77 78 List elements = (List ) r.getConfiguration("hivemind.test.parse.MyExtensionPoint3"); 79 80 assertEquals(3, elements.size()); 81 82 } 83 84 } 85 | Popular Tags |