< prev index next >

application/tests/org.openjdk.jmc.rjmx.test/src/test/java/org/openjdk/jmc/rjmx/test/subscription/AttributeDescriptorTest.java

Print this page




 108          * Class under test for boolean equals(Object)
 109          */
 110         @Test
 111         public void testEqualsObject() throws Exception {
 112                 MRI descriptor = createDescriptor1();
 113                 MRI anotherDescriptor = createDescriptor1();
 114                 assertTrue(descriptor.equals(anotherDescriptor));
 115         }
 116 
 117         /*
 118          * Class under test for String toString()
 119          */
 120         @Test
 121         public void testToString() throws Exception {
 122                 // Should be interned.
 123                 assertTrue(createDescriptor1().toString() == createDescriptor1().toString());
 124         }
 125 
 126         @Test
 127         public void testCreateFromQualifiedName1() throws Exception {
 128                 MRI descriptor = MRI.createFromQualifiedName("attribute://java.lang:type=OperatingSystem/Arch"); //$NON-NLS-1$
 129                 assertEquals(createDescriptor1(), descriptor);
 130         }
 131 
 132         @Test
 133         public void testCreateFromQualifiedName2() throws Exception {
 134                 MRI descriptor = MRI.createFromQualifiedName("attribute://java.lang:type=OperatingSystem/Arch/Sub"); //$NON-NLS-1$
 135                 assertEquals(Type.ATTRIBUTE, descriptor.getType());
 136                 assertEquals("java.lang:type=OperatingSystem", descriptor.getObjectName().getCanonicalName()); //$NON-NLS-1$
 137                 assertEquals("Arch/Sub", descriptor.getDataPath()); //$NON-NLS-1$
 138         }
 139 
 140         @Test
 141         public void testMalformedQualifiedName1() throws Exception {
 142                 try {
 143                         MRI.createFromQualifiedName("smurf://java.lang:type=OperatingSystem/Arch"); //$NON-NLS-1$
 144                 } catch (IllegalArgumentException iae) {
 145                         return;
 146                 }
 147                 assertTrue("Should not be possible to create an attribute with the type smurf!", false); //$NON-NLS-1$
 148         }
 149 
 150         @Test
 151         public void testMalformedQualifiedName2() throws Exception {
 152                 try {
 153                         MRI.createFromQualifiedName("java.lang:type=OperatingSystem/Arch"); //$NON-NLS-1$
 154                 } catch (IllegalArgumentException iae) {
 155                         return;
 156                 }
 157                 assertTrue("Should not be possible to create an attribute name without specifying a type!", false); //$NON-NLS-1$
 158         }
 159 
 160         private MRI createDescriptor1() throws Exception {
 161                 return new MRI(Type.ATTRIBUTE, new ObjectName("java.lang:type=OperatingSystem"), "Arch"); //$NON-NLS-1$ //$NON-NLS-2$
 162         }
 163 
 164 }


 108          * Class under test for boolean equals(Object)
 109          */
 110         @Test
 111         public void testEqualsObject() throws Exception {
 112                 MRI descriptor = createDescriptor1();
 113                 MRI anotherDescriptor = createDescriptor1();
 114                 assertTrue(descriptor.equals(anotherDescriptor));
 115         }
 116 
 117         /*
 118          * Class under test for String toString()
 119          */
 120         @Test
 121         public void testToString() throws Exception {
 122                 // Should be interned.
 123                 assertTrue(createDescriptor1().toString() == createDescriptor1().toString());
 124         }
 125 
 126         @Test
 127         public void testCreateFromQualifiedName1() throws Exception {
 128                 MRI descriptor = MRI.createFromQualifiedName("attribute://java.lang:type=OperatingSystem/Arch");
 129                 assertEquals(createDescriptor1(), descriptor);
 130         }
 131 
 132         @Test
 133         public void testCreateFromQualifiedName2() throws Exception {
 134                 MRI descriptor = MRI.createFromQualifiedName("attribute://java.lang:type=OperatingSystem/Arch/Sub");
 135                 assertEquals(Type.ATTRIBUTE, descriptor.getType());
 136                 assertEquals("java.lang:type=OperatingSystem", descriptor.getObjectName().getCanonicalName());
 137                 assertEquals("Arch/Sub", descriptor.getDataPath());
 138         }
 139 
 140         @Test
 141         public void testMalformedQualifiedName1() throws Exception {
 142                 try {
 143                         MRI.createFromQualifiedName("smurf://java.lang:type=OperatingSystem/Arch");
 144                 } catch (IllegalArgumentException iae) {
 145                         return;
 146                 }
 147                 assertTrue("Should not be possible to create an attribute with the type smurf!", false);
 148         }
 149 
 150         @Test
 151         public void testMalformedQualifiedName2() throws Exception {
 152                 try {
 153                         MRI.createFromQualifiedName("java.lang:type=OperatingSystem/Arch");
 154                 } catch (IllegalArgumentException iae) {
 155                         return;
 156                 }
 157                 assertTrue("Should not be possible to create an attribute name without specifying a type!", false);
 158         }
 159 
 160         private MRI createDescriptor1() throws Exception {
 161                 return new MRI(Type.ATTRIBUTE, new ObjectName("java.lang:type=OperatingSystem"), "Arch");
 162         }
 163 
 164 }
< prev index next >