1 7 package org.jboss.test.foedeployer.test; 8 9 import java.io.IOException ; 10 import java.net.InetAddress ; 11 import java.rmi.RemoteException ; 12 import java.util.Set ; 13 import javax.ejb.CreateException ; 14 import javax.ejb.Handle ; 15 import javax.management.ObjectName ; 16 import javax.naming.InitialContext ; 17 import javax.naming.NamingException ; 18 import javax.rmi.PortableRemoteObject ; 19 20 import junit.extensions.TestSetup; 21 import junit.framework.Test; 22 import junit.framework.TestCase; 23 import junit.framework.TestSuite; 24 25 import org.jboss.test.JBossTestCase; 26 import org.jboss.test.JBossTestSetup; 27 28 import org.jboss.test.foedeployer.ejb.simple.SecretManager; 29 import org.jboss.test.foedeployer.ejb.simple.SecretManagerHome; 30 31 38 public class SimpleConversionTestCase 39 extends JBossTestCase 40 { 41 public static final String FOE_DEPLOYER = "foe-deployer-3.2.sar"; 43 public static final String FOE_DEPLOYER_NAME = "jboss:service=FoeDeployer"; 44 public static final String CONVERTOR_DEPLOYER_QUERY_NAME = "jboss:service=Convertor,*"; 45 public static final String SIMPLE_APPLICATION = "foe-deployer-simple-test"; 46 public static final String SECRET_SESSION_JNDI_NAME = "ejb/SecretManager"; 47 48 52 public static Test suite() throws Exception 53 { 54 TestSuite lSuite = new TestSuite(); 55 lSuite.addTest( new TestSuite( SimpleConversionTestCase.class ) ); 56 57 TestSetup lWrapper = new JBossTestSetup( lSuite ) 59 { 60 protected void setUp() throws Exception 61 { 62 super.setUp(); 63 } 64 protected void tearDown() throws Exception 65 { 66 super.tearDown(); 67 } 68 }; 69 return lWrapper; 70 } 71 72 public SimpleConversionTestCase( String pName ) 74 { 75 super( pName ); 76 } 77 78 82 public void testSimpleConversion() 83 throws Exception 84 { 85 try 86 { 87 log.debug("+++ testSimpleConversion"); 88 89 boolean lIsInitiallyDeployed = getServer().isRegistered( new ObjectName ( FOE_DEPLOYER_NAME ) ); 91 if(!lIsInitiallyDeployed) 92 deploy(FOE_DEPLOYER); 93 94 boolean lIsDeployed = getServer().isRegistered(new ObjectName (FOE_DEPLOYER_NAME)); 95 assertTrue("Foe-Deployer is not deployed", lIsDeployed); 96 97 int lCount = getServer().queryNames(new ObjectName (CONVERTOR_DEPLOYER_QUERY_NAME), null).size(); 99 assertTrue("No Convertor found on web server", lCount > 0); 100 101 deploy(SIMPLE_APPLICATION + ".wlar"); 103 104 deploy(SIMPLE_APPLICATION + ".jar"); 107 108 SecretManager session = getSecretManagerEJB(); 110 String key = "xxx"; 111 String secret = "the sun is shining brightly"; 112 113 session.createSecret( key, secret ); 114 assertTrue( "the secret read is not equal to secret set", secret.equals(session.getSecret(key)) ); 115 session.removeSecret(key); 116 117 undeploy(SIMPLE_APPLICATION + ".jar"); 119 undeploy(SIMPLE_APPLICATION + ".wlar"); 121 122 if(!lIsInitiallyDeployed) 124 undeploy(FOE_DEPLOYER); 125 } 126 catch(Exception e) 127 { 128 e.printStackTrace(); 129 throw e; 130 } 131 } 132 133 private SecretManager getSecretManagerEJB() 135 throws Exception 136 { 137 log.debug("+++ getSecretManagerEJB()"); 138 Object lObject = getInitialContext().lookup( SECRET_SESSION_JNDI_NAME ); 139 SecretManagerHome lHome = (SecretManagerHome) PortableRemoteObject.narrow( 140 lObject, 141 SecretManagerHome.class 142 ); 143 log.debug( "Found SecretManagerBean" ); 144 return lHome.create(); 145 } 146 } 147 | Popular Tags |