1 23 24 29 30 package com.sun.enterprise.admin.dottedname; 31 32 import java.util.Set ; 33 import javax.management.ObjectName ; 34 import javax.management.MalformedObjectNameException ; 35 36 public class DottedNameRegistryTest extends junit.framework.TestCase 37 { 38 DottedNameRegistry1To1Impl 39 createNew() 40 { 41 return( new DottedNameRegistry1To1Impl() ); 42 } 43 44 public void 45 testCreation() 46 { 47 createNew(); 48 } 49 50 public void 51 testNewIsEmpty() 52 { 53 assertEquals( 0, createNew().allDottedNameStrings().size() ); 54 } 55 56 public void 57 testAdd() 58 throws MalformedObjectNameException 59 { 60 final DottedNameRegistry1To1Impl registry = createNew(); 61 final String dottedName = "a.b.c"; 62 final ObjectName objectName = new ObjectName ( ":name=test" ); 63 64 registry.add( dottedName, objectName ); 65 66 assertEquals( objectName, registry.dottedNameToObjectName( dottedName ) ); 67 assertEquals( dottedName, registry.objectNameToDottedName( objectName ) ); 68 69 assertEquals( 1, registry.allDottedNameStrings().size() ); 70 assertEquals( 1, registry.allObjectNames().size() ); 71 assertEquals( dottedName, (String )registry.allDottedNameStrings().iterator().next() ); 72 } 73 74 public void 75 testRemove() 76 throws MalformedObjectNameException 77 { 78 final DottedNameRegistry1To1Impl registry = createNew(); 79 final String dottedName = "a.b.c"; 80 final ObjectName objectName = new ObjectName ( ":name=test" ); 81 82 registry.add( dottedName, objectName ); 83 registry.remove( dottedName, objectName ); 84 85 assertEquals( 0, registry.allDottedNameStrings().size() ); 86 assertEquals( 0, registry.allObjectNames().size() ); 87 } 88 89 public void 90 testReplaceWorks() 91 throws MalformedObjectNameException 92 { 93 final DottedNameRegistry1To1Impl registry = createNew(); 94 final String dottedName1 = "a.b.c"; 95 final String dottedName2 = "a.b.c.d"; 96 final ObjectName objectName = new ObjectName ( ":name=test" ); 97 98 registry.add( dottedName1, objectName ); 99 registry.add( dottedName2, objectName ); 100 assertEquals( dottedName2, registry.objectNameToDottedName( objectName ) ); 101 } 102 103 104 public void 105 test1To1Mapping() 106 throws MalformedObjectNameException 107 { 108 final DottedNameRegistry1To1Impl registry = createNew(); 109 final String dottedName1 = "a.b.c"; 110 final String dottedName2 = "a.b.c.d"; 111 final ObjectName objectName = new ObjectName ( ":name=test" ); 112 113 registry.add( dottedName1, objectName ); 114 registry.add( dottedName2, objectName ); 115 116 assertEquals( 1, registry.allDottedNameStrings().size() ); 117 assertEquals( dottedName2, (String )registry.allDottedNameStrings().iterator().next() ); 118 } 119 120 147 } 148 149 150 151 152 153 154 155 156 157 158 | Popular Tags |