From: Andreas S. <sch...@us...> - 2002-05-23 18:24:27
|
User: schaefera Date: 02/05/23 11:24:26 Added: src/main/org/jboss/test/foedeployer/test SimpleConversionTestCase.java Log: Added a test case for the Foe-Deployer creating a WL application, deploys it on the JBoss server and checks if it finally got deployed as JBoss application. If necessary it will deploy the foe-deployer first (if not already done) because it is an optinal service. Revision Changes Path 1.1 jbosstest/src/main/org/jboss/test/foedeployer/test/SimpleConversionTestCase.java Index: SimpleConversionTestCase.java =================================================================== /* * JBoss, the OpenSource J2EE webOS * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.foedeployer.test; import java.io.IOException; import java.net.InetAddress; import java.rmi.RemoteException; import java.util.Set; import javax.ejb.CreateException; import javax.ejb.Handle; import javax.management.ObjectName; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.rmi.PortableRemoteObject; import junit.extensions.TestSetup; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jboss.test.JBossTestCase; import org.jboss.test.JBossTestSetup; import org.jboss.test.foedeployer.ejb.interfaces.SecretManager; import org.jboss.test.foedeployer.ejb.interfaces.SecretManagerHome; /** * Test of a simple WebLogic Application Conversion * * @author <a href="mailto:an...@jb...">Andreas Schaefer</a>. * @author <a href="mailto:lou...@uk...">Alex Loubyansky</a> * @version $Revision: 1.1 $ * * <p><b>Revisions:</b> * * <p><b>20011206 Andreas Schaefer:</b> * <ul> * <li> Creation * </ul> **/ public class SimpleConversionTestCase extends JBossTestCase { // Constants ----------------------------------------------------- public static final String FOE_DEPLOYER = "foe-deployer.sar"; public static final String FOE_DEPLOYER_NAME = "jboss:service=FoeDeployer"; public static final String CONVERTOR_DEPLOYER_QUERY_NAME = "jboss:service=Convertor,*"; public static final String SIMPLE_APPLICATION = "foe-deployer-test"; public static final String SECRET_SESSION_JNDI_NAME = "ejb/SecretManager"; // Attributes ---------------------------------------------------- // Static -------------------------------------------------------- /** * Setup the test suite. */ public static Test suite() { TestSuite lSuite = new TestSuite(); lSuite.addTest( new TestSuite( SimpleConversionTestCase.class ) ); // Create an initializer for the test suite TestSetup lWrapper = new JBossTestSetup( lSuite ) { protected void setUp() throws Exception { super.setUp(); } protected void tearDown() throws Exception { super.tearDown(); } }; return lWrapper; } // Constructors -------------------------------------------------- public SimpleConversionTestCase( String pName ) { super( pName ); } // Public -------------------------------------------------------- /** * Test a simple conversion **/ public void testSimpleConversion() throws Exception { log.debug("+++ testSimpleConversion"); // First check if foe-deployer is deployed boolean lIsInitiallyDeployed = getServer().isRegistered( new ObjectName( FOE_DEPLOYER_NAME ) ); if( !lIsInitiallyDeployed ) { deploy( FOE_DEPLOYER ); } boolean lIsDeployed = getServer().isRegistered( new ObjectName( FOE_DEPLOYER_NAME ) ); assertTrue( "Foe-Deployer is not deployed", lIsDeployed ); // Count number of convertors (must be a list one) int lCount = getServer().queryNames( new ObjectName( CONVERTOR_DEPLOYER_QUERY_NAME ), null ).size(); assertTrue( "No Convertor found on web server", lCount > 0 ); // Deploy the simple application deploy( SIMPLE_APPLICATION + ".wlar" ); // Access the Session Bean and invoke some methods on it SecretManager lSession = getSecretManagerEJB(); String lKey = "xxx"; String lSecret = "the sun is shining brightly"; lSession.createSecret( lKey, lSecret ); lSession.getSecret( lKey ); lSession.removeSecret( lKey ); // Undeploy converted application to clean up undeploy( SIMPLE_APPLICATION + ".jar" ); // Only undeploy if deployed here if( !lIsInitiallyDeployed ) { undeploy( FOE_DEPLOYER ); } } // Z implementation ---------------------------------------------- // Y overrides --------------------------------------------------- // Package protected --------------------------------------------- // Protected ----------------------------------------------------- // Private ------------------------------------------------------- private SecretManager getSecretManagerEJB() throws Exception { getLog().debug("+++ getSecretManagerEJB()"); Object lObject = getInitialContext().lookup( SECRET_SESSION_JNDI_NAME ); SecretManagerHome lHome = (SecretManagerHome) PortableRemoteObject.narrow( lObject, SecretManagerHome.class ); getLog().debug( "Found SecretManagerBean" ); return lHome.create(); } // Inner classes ------------------------------------------------- } |