1 22 package org.jboss.test.system.controller.configure.value.depends.test; 23 24 import javax.management.MalformedObjectNameException ; 25 import javax.management.ObjectName ; 26 27 import org.jboss.deployment.DeploymentException; 28 import org.jboss.mx.util.ObjectNameFactory; 29 import org.jboss.test.system.controller.AbstractControllerTest; 30 import org.jboss.test.system.controller.support.Simple; 31 import org.jboss.test.system.controller.support.SimpleMBean; 32 33 39 public abstract class DependencyValueTest extends AbstractControllerTest 40 { 41 static ObjectName DEPENDS = ObjectNameFactory.create("jboss.test:type=depends"); 42 43 public DependencyValueTest(String name) 44 { 45 super(name); 46 } 47 48 public void testDependency() throws Exception 49 { 50 ObjectName name = SimpleMBean.OBJECT_NAME; 51 assertInstall(name); 52 try 53 { 54 Simple simple = getSimple(); 55 assertEquals(DEPENDS, simple.getObjectName()); 56 } 57 finally 58 { 59 assertUninstall(name); 60 } 61 } 62 63 public void testDependencyNested() throws Exception 64 { 65 ObjectName name = SimpleMBean.OBJECT_NAME; 66 assertInstall(name); 67 try 68 { 69 Simple simple = getSimple(); 70 assertEquals(DEPENDS, simple.getObjectName()); 71 } 72 finally 73 { 74 assertUninstall(name); 75 } 76 } 77 78 public void testExplicitProxyType() throws Exception 79 { 80 proxyTest(); 81 } 82 83 public void testImplicitProxyType() throws Exception 84 { 85 proxyTest(); 86 } 87 88 public void testNoValue() throws Exception 89 { 90 assertDeployFailure(SimpleMBean.OBJECT_NAME, MalformedObjectNameException .class); 91 } 92 93 public void testEmptyValue() throws Exception 94 { 95 assertDeployFailure(SimpleMBean.OBJECT_NAME, MalformedObjectNameException .class); 96 } 97 98 public void testInvalidValue() throws Exception 99 { 100 assertDeployFailure(SimpleMBean.OBJECT_NAME, MalformedObjectNameException .class); 101 } 102 103 public void testUnknownElement() throws Exception 104 { 105 assertDeployFailure(SimpleMBean.OBJECT_NAME, MalformedObjectNameException .class); 106 } 107 108 public void testPatternValue() throws Exception 109 { 110 assertDeployFailure(SimpleMBean.OBJECT_NAME, MalformedObjectNameException .class); 111 } 112 113 public void testBrokenSetAttribute() throws Exception 114 { 115 assertDeployFailure(SimpleMBean.OBJECT_NAME, Error .class); 116 } 117 118 public void testNoAttributeInfoType() throws Exception 119 { 120 assertDeployFailure(SimpleMBean.OBJECT_NAME, DeploymentException.class); 121 } 122 123 public void testAttributeInfoTypeNotFound() throws Exception 124 { 125 assertDeployFailure(SimpleMBean.OBJECT_NAME, ClassNotFoundException .class); 126 } 127 128 public void testProxyTypeNotFound() throws Exception 129 { 130 assertDeployFailure(SimpleMBean.OBJECT_NAME, ClassNotFoundException .class); 131 } 132 133 public void testProxyTypeNotInterface() throws Exception 134 { 135 assertDeployFailure(SimpleMBean.OBJECT_NAME, IllegalArgumentException .class); 136 } 137 138 protected void proxyTest() throws Exception 139 { 140 ObjectName name = SimpleMBean.OBJECT_NAME; 141 assertInstall(name); 142 try 143 { 144 Simple simple = getSimple(); 145 Simple dependency = getMBean(Simple.class, DEPENDS, "Instance"); 146 147 assertFalse(simple.isTouched()); 148 assertFalse(dependency.isTouched()); 149 150 simple.touchProxy(); 151 152 assertFalse(simple.isTouched()); 153 assertTrue(dependency.isTouched()); 154 } 155 finally 156 { 157 assertUninstall(name); 158 } 159 } 160 161 protected Simple getDependency() throws Exception 162 { 163 return getMBean(Simple.class, DEPENDS, "Instance"); 164 } 165 } 166 | Popular Tags |