1 22 package org.jboss.test.system.controller.configure.value.inject.test; 23 24 import java.util.List ; 25 26 import javax.management.InvalidAttributeValueException ; 27 import javax.management.ObjectName ; 28 29 import junit.framework.Test; 30 31 import org.jboss.joinpoint.spi.JoinpointException; 32 import org.jboss.mx.util.ObjectNameFactory; 33 import org.jboss.system.ServiceContext; 34 import org.jboss.test.AbstractTestDelegate; 35 import org.jboss.test.system.controller.AbstractControllerTest; 36 import org.jboss.test.system.controller.support.Simple; 37 import org.jboss.test.system.controller.support.SimpleMBean; 38 39 45 public class NewInjectionValueUnitTestCase extends AbstractControllerTest 46 { 47 private static ObjectName OTHER = ObjectNameFactory.create("jboss.test:type=depends"); 48 49 public static Test suite() 50 { 51 return suite(NewInjectionValueUnitTestCase.class); 52 } 53 54 public static AbstractTestDelegate getDelegate(Class clazz) throws Exception 55 { 56 return getNewControllerDelegate(clazz); 57 } 58 59 public NewInjectionValueUnitTestCase(String name) 60 { 61 super(name); 62 } 63 64 public void testInjection() throws Exception 65 { 66 ObjectName name = SimpleMBean.OBJECT_NAME; 67 68 List <ObjectName > names = assertDeploy(name); 69 try 70 { 71 Simple test = getSimple(); 72 Simple other = getMBean(Simple.class, OTHER, "Instance"); 73 74 assertEquals(other, test.getSimple()); 75 } 76 finally 77 { 78 assertUndeploy(name, names); 79 } 80 } 81 82 public void testInjectionNoBean() throws Exception 83 { 84 assertDeployFailure(SimpleMBean.OBJECT_NAME, ServiceContext.INSTALLED, null); 85 } 86 87 public void testInjectionBeanEmpty() throws Exception 88 { 89 assertDeployFailure(SimpleMBean.OBJECT_NAME, ServiceContext.INSTALLED, null); 90 } 91 92 public void testInjectionNotFound() throws Exception 93 { 94 assertDeployFailure(SimpleMBean.OBJECT_NAME, ServiceContext.INSTALLED, null); 95 } 96 97 public void testInjectionWrongType() throws Exception 98 { 99 assertDeployFailure(SimpleMBean.OBJECT_NAME, InvalidAttributeValueException .class); 100 } 101 102 public void testInjectionProperty() throws Exception 103 { 104 ObjectName name = SimpleMBean.OBJECT_NAME; 105 106 List <ObjectName > names = assertDeploy(name); 107 try 108 { 109 Simple test = getSimple(); 110 111 assertEquals("PropertyInjection", test.getAString()); 112 } 113 finally 114 { 115 assertUndeploy(name, names); 116 } 117 } 118 119 public void testInjectionPropertyState() throws Exception 120 { 121 ObjectName name = SimpleMBean.OBJECT_NAME; 122 123 List <ObjectName > names = assertDeploy(name); 124 try 125 { 126 Simple test = getSimple(); 127 128 assertEquals("Instantiated", test.getAString()); 129 } 130 finally 131 { 132 assertUndeploy(name, names); 133 } 134 } 135 136 public void testInjectionPropertyNotFound() throws Exception 137 { 138 assertDeployFailure(SimpleMBean.OBJECT_NAME, JoinpointException.class); 139 } 140 141 public void testInjectionPropertyWrongType() throws Exception 142 { 143 assertDeployFailure(SimpleMBean.OBJECT_NAME, InvalidAttributeValueException .class); 144 } 145 } 146 | Popular Tags |