1 22 package org.jboss.test.kernel.deployment.jboss.test; 23 24 import java.util.List ; 25 import java.util.Properties ; 26 27 import javax.naming.InitialContext ; 28 29 import org.jboss.test.JBossTestCase; 30 import org.jboss.test.kernel.deployment.jboss.beans.configpojo.ConfigPOJO; 31 32 38 public class ConfigPOJOUnitTestCase extends JBossTestCase 39 { 40 public ConfigPOJOUnitTestCase(String test) 41 { 42 super(test); 43 } 44 45 public void testConfigPOJO() throws Exception 46 { 47 try 48 { 49 deploy("testkernel-configpojo.beans"); 50 51 InitialContext ctx = new InitialContext (); 52 ConfigPOJO config = (ConfigPOJO) ctx.lookup("test/kernel/deployment/config/pojo"); 53 assertEquals("joe", config.getUserId()); 54 assertEquals("secret", config.getPassword()); 55 List roles = config.getRoles(); 56 assertEquals("trader", (String )roles.get(0)); 57 assertEquals("manager", (String )roles.get(1)); 58 } 59 catch (Exception e) 60 { 61 getLog().info("Caught exception", e); 62 throw e; 63 } 64 finally 65 { 66 undeploy("testkernel-configpojo.beans"); 67 } 68 } 69 70 public void testConfigProperties() throws Exception 71 { 72 try 73 { 74 deploy("testkernel-configproperties.beans"); 75 76 InitialContext ctx = new InitialContext (); 77 Properties props = (Properties ) ctx.lookup("test/kernel/deployment/config/properties"); 78 assertEquals("value1", props.getProperty("config.property1")); 79 assertEquals("value2", props.getProperty("config.property2")); 80 assertEquals("value3", props.getProperty("config.property3")); 81 } 82 catch (Exception e) 83 { 84 getLog().info("Caught exception", e); 85 throw e; 86 } 87 finally 88 { 89 undeploy("testkernel-configproperties.beans"); 90 } 91 } 92 } 93 | Popular Tags |