1 22 package org.jboss.test.system.controller.configure.attribute.test; 23 24 import java.util.Arrays ; 25 import java.util.Collection ; 26 import java.util.List ; 27 28 import javax.management.MalformedObjectNameException ; 29 import javax.management.ObjectName ; 30 31 import org.jboss.deployment.DeploymentException; 32 import org.jboss.mx.util.ObjectNameFactory; 33 import org.jboss.test.system.controller.AbstractControllerTest; 34 import org.jboss.test.system.controller.support.Simple; 35 import org.jboss.test.system.controller.support.SimpleMBean; 36 37 43 public abstract class DependsListAttributeTest extends AbstractControllerTest 44 { 45 static ObjectName DEPENDS1 = ObjectNameFactory.create("jboss.test:type=depends1"); 46 static ObjectName [] DEPENDSLIST1 = new ObjectName [] { DEPENDS1 }; 47 static ObjectName DEPENDS2 = ObjectNameFactory.create("jboss.test:type=depends2"); 48 static ObjectName [] DEPENDSLIST2 = new ObjectName [] { DEPENDS2 }; 49 static ObjectName [] DEPENDSLIST = new ObjectName [] { DEPENDS1, DEPENDS2 }; 50 51 public DependsListAttributeTest(String name) 52 { 53 super(name); 54 } 55 56 protected void assertEquals(ObjectName [] expected, Collection <ObjectName > actual) 57 { 58 List <ObjectName > expectedList = Arrays.asList(expected); 59 assertEquals(expectedList, actual); 60 } 61 62 public void testDependsListAttributeNone() throws Exception 63 { 64 ObjectName name = SimpleMBean.OBJECT_NAME; 65 assertInstall(name); 66 try 67 { 68 Simple simple = getSimple(); 69 assertNull(simple.getObjectNamesAttribute1()); 70 assertNull(simple.getObjectNamesAttribute2()); 71 } 72 finally 73 { 74 assertUninstall(name); 75 } 76 } 77 78 public void testDependsListAttributeOne() throws Exception 79 { 80 ObjectName name = SimpleMBean.OBJECT_NAME; 81 assertInstall(name); 82 try 83 { 84 Simple simple = getSimple(); 85 assertEquals(DEPENDSLIST1, simple.getObjectNamesAttribute1()); 86 assertNull(simple.getObjectNamesAttribute2()); 87 } 88 finally 89 { 90 assertUninstall(name); 91 } 92 } 93 94 public void testDependsListAttributeTwo() throws Exception 95 { 96 ObjectName name = SimpleMBean.OBJECT_NAME; 97 assertInstall(name); 98 try 99 { 100 Simple simple = getSimple(); 101 assertEquals(DEPENDSLIST1, simple.getObjectNamesAttribute1()); 102 assertEquals(DEPENDSLIST2, simple.getObjectNamesAttribute2()); 103 } 104 finally 105 { 106 assertUninstall(name); 107 } 108 } 109 110 public void testDependsListAttributeMultiple() throws Exception 111 { 112 ObjectName name = SimpleMBean.OBJECT_NAME; 113 assertInstall(name); 114 try 115 { 116 Simple simple = getSimple(); 117 assertEquals(DEPENDSLIST, simple.getObjectNamesAttribute1()); 118 assertNull(simple.getObjectNamesAttribute2()); 119 } 120 finally 121 { 122 assertUninstall(name); 123 } 124 } 125 126 public void testDependsListAttributeNested() throws Exception 127 { 128 ObjectName name = SimpleMBean.OBJECT_NAME; 129 assertInstall(name); 130 try 131 { 132 Simple simple = getSimple(); 133 assertEquals(DEPENDSLIST1, simple.getObjectNamesAttribute1()); 134 assertNull(simple.getObjectNamesAttribute2()); 135 } 136 finally 137 { 138 assertUninstall(name); 139 } 140 } 141 142 public void testDependsListAttributeNoValue() throws Exception 143 { 144 assertDeployFailure(SimpleMBean.OBJECT_NAME, MalformedObjectNameException .class); 145 } 146 147 public void testDependsListAttributeEmptyValue() throws Exception 148 { 149 assertDeployFailure(SimpleMBean.OBJECT_NAME, MalformedObjectNameException .class); 150 } 151 152 public void testDependsListAttributeInvalidValue() throws Exception 153 { 154 assertDeployFailure(SimpleMBean.OBJECT_NAME, MalformedObjectNameException .class); 155 } 156 157 public void testDependsListAttributeUnknownElement() throws Exception 158 { 159 assertDeployFailure(SimpleMBean.OBJECT_NAME, MalformedObjectNameException .class); 160 } 161 162 public void testDependsListAttributePatternValue() throws Exception 163 { 164 assertDeployFailure(SimpleMBean.OBJECT_NAME, MalformedObjectNameException .class); 165 } 166 167 public void testDependsListAttributeNotFound() throws Exception 168 { 169 assertDeployFailure(SimpleMBean.OBJECT_NAME, DeploymentException.class); 170 } 171 172 public void testDependsListAttributeBrokenSetAttribute() throws Exception 173 { 174 assertDeployFailure(SimpleMBean.OBJECT_NAME, Error .class); 175 } 176 } 177 | Popular Tags |