[Jboss-cvs] JBossAS SVN: r56214 - in trunk/ejb3: . src/test/org/jboss/ejb3/test src/test/org/jboss/ejb3/test/iiop/unit
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Aug 24 07:15:24 EDT 2006
Author: wolfc
Date: 2006-08-24 07:15:15 -0400 (Thu, 24 Aug 2006)
New Revision: 56214
Added:
trunk/ejb3/src/test/org/jboss/ejb3/test/CustomJNDIJBossTestCase.java
trunk/ejb3/src/test/org/jboss/ejb3/test/CustomJNDIJBossTestServices.java
trunk/ejb3/src/test/org/jboss/ejb3/test/CustomJNDIJBossTestSetup.java
Modified:
trunk/ejb3/build-test.xml
trunk/ejb3/src/test/org/jboss/ejb3/test/iiop/unit/IiopRemoteUnitTestCase.java
Log:
EJBTHREE-667: getHandle unit test
Modified: trunk/ejb3/build-test.xml
===================================================================
--- trunk/ejb3/build-test.xml 2006-08-24 09:17:08 UTC (rev 56213)
+++ trunk/ejb3/build-test.xml 2006-08-24 11:15:15 UTC (rev 56214)
@@ -2666,8 +2666,8 @@
<path refid="asm.asm.classpath"/>
<path refid="hibernate.hibernate.classpath"/>
<pathelement location="${build.classes}"/>
- <pathelement location="${resources}/test"/> <!-- TODO: now I can't override jndi.properties -->
<path refid="${client.run.classpath}"/>
+ <pathelement location="${resources}/test"/>
<path refid="jboss.jbossws.classpath"/>
<path refid="apache.xerces.classpath"/>
<path refid="sun.jaf.classpath"/>
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/CustomJNDIJBossTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/CustomJNDIJBossTestCase.java 2006-08-24 09:17:08 UTC (rev 56213)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/CustomJNDIJBossTestCase.java 2006-08-24 11:15:15 UTC (rev 56214)
@@ -0,0 +1,128 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test;
+
+import java.util.StringTokenizer;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.test.JBossTestCase;
+
+/**
+ * This test case will use custom.jndi.properties to find the deployer.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class CustomJNDIJBossTestCase extends JBossTestCase
+{
+
+ public CustomJNDIJBossTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ public void initDelegate()
+ {
+ delegate = new CustomJNDIJBossTestServices(getClass().getName());
+ try
+ {
+ delegate.init();
+ }
+ catch (Exception e)
+ {
+ log.error("Failed to init delegate", e);
+ }
+ }
+
+ /**
+ * Get a JBossTestSetup that does login and deployment in setUp/tearDown
+ *
+ * @param test a Test
+ * @param jarNames is a comma seperated list of deployments
+ */
+ public static Test getDeploySetup(final Test test, final String jarNames)
+ throws Exception
+ {
+ CustomJNDIJBossTestSetup wrapper = new CustomJNDIJBossTestSetup(test)
+ {
+ protected void setUp() throws Exception
+ {
+ deploymentException = null;
+ try
+ {
+ this.delegate.init();
+
+ if (this.getDelegate().isSecureTest())
+ this.delegate.login();
+
+ if (jarNames == null) return;
+
+ // deploy the comma seperated list of jars
+ StringTokenizer st = new StringTokenizer(jarNames, ", ");
+ while (st != null && st.hasMoreTokens())
+ {
+ String jarName = st.nextToken();
+ this.redeploy(jarName);
+ this.getLog().debug("deployed package: " + jarName);
+ }
+ }
+ catch (Exception ex)
+ {
+ // Throw this in testServerFound() instead.
+ deploymentException = ex;
+ }
+ }
+
+ protected void tearDown() throws Exception
+ {
+ if (jarNames == null) return; //Nothing to Undeploy
+
+ // undeploy the comma seperated list of jars
+ StringTokenizer st = new StringTokenizer(jarNames, ", ");
+ String[] depoyments = new String[st.countTokens()];
+ for (int i = depoyments.length - 1; i >= 0; i--)
+ depoyments[i] = st.nextToken();
+ for (int i = 0; i < depoyments.length; i++)
+ {
+ String jarName = depoyments[i];
+ this.undeploy(jarName);
+ this.getLog().debug("undeployed package: " + jarName);
+ }
+
+ if (this.getDelegate().isSecureTest())
+ this.delegate.logout();
+ }
+ };
+ return wrapper;
+ }
+
+ public static Test getDeploySetup(final Class clazz, final String jarName)
+ throws Exception
+ {
+ TestSuite suite = new TestSuite();
+ suite.addTest(new TestSuite(clazz));
+ return getDeploySetup(suite, jarName);
+ }
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/CustomJNDIJBossTestServices.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/CustomJNDIJBossTestServices.java 2006-08-24 09:17:08 UTC (rev 56213)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/CustomJNDIJBossTestServices.java 2006-08-24 11:15:15 UTC (rev 56214)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import javax.naming.InitialContext;
+
+import org.jboss.test.JBossTestServices;
+
+/**
+ * This class provides services for JBoss unit tests.
+ * If found it uses custom.jndi.properties to establish a connection with
+ * the Main Deployer.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class CustomJNDIJBossTestServices extends JBossTestServices
+{
+
+ public CustomJNDIJBossTestServices(String className)
+ {
+ super(className);
+ }
+
+ protected Properties getCustomJNDIProperties() throws IOException
+ {
+ InputStream in = getClass().getClassLoader().getResourceAsStream("custom.jndi.properties");
+ if(in == null)
+ {
+ log.debug("no custom.jndi.properties found using defaults");
+ return null;
+ }
+ Properties props = new Properties();
+ props.load(in);
+ in.close();
+ return props;
+ }
+
+ @Override
+ public void init() throws Exception
+ {
+ if(initialContext == null)
+ {
+ initialContext = new InitialContext(getCustomJNDIProperties());
+ log.debug("initialContext.getEnvironment()=" + initialContext.getEnvironment());
+ jndiEnv = initialContext.getEnvironment();
+
+ log.debug("server = " + getServer());
+ }
+ }
+
+ protected boolean isSecureTest()
+ {
+ return Boolean.getBoolean("jbosstest.secure");
+ }
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/CustomJNDIJBossTestSetup.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/CustomJNDIJBossTestSetup.java 2006-08-24 09:17:08 UTC (rev 56213)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/CustomJNDIJBossTestSetup.java 2006-08-24 11:15:15 UTC (rev 56214)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossTestServices;
+import org.jboss.test.JBossTestSetup;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class CustomJNDIJBossTestSetup extends JBossTestSetup
+{
+
+ public CustomJNDIJBossTestSetup(Test test) throws Exception
+ {
+ super(test);
+ }
+
+ @Override
+ protected JBossTestServices createTestServices()
+ {
+ return new CustomJNDIJBossTestServices(getClass().getName());
+ }
+
+ protected CustomJNDIJBossTestServices getDelegate()
+ {
+ return (CustomJNDIJBossTestServices) this.delegate;
+ }
+}
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/iiop/unit/IiopRemoteUnitTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/iiop/unit/IiopRemoteUnitTestCase.java 2006-08-24 09:17:08 UTC (rev 56213)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/iiop/unit/IiopRemoteUnitTestCase.java 2006-08-24 11:15:15 UTC (rev 56214)
@@ -35,6 +35,7 @@
import junit.framework.Test;
+import org.jboss.ejb3.test.CustomJNDIJBossTestCase;
import org.jboss.ejb3.test.iiop.HomedStatelessHome;
import org.jboss.ejb3.test.iiop.MyStatefulHome;
import org.jboss.ejb3.test.iiop.TxTester;
@@ -53,7 +54,7 @@
* @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
* @version $Revision$
*/
-public class IiopRemoteUnitTestCase extends JBossTestCase
+public class IiopRemoteUnitTestCase extends CustomJNDIJBossTestCase
{
public IiopRemoteUnitTestCase(String name)
@@ -263,8 +264,7 @@
{
try
{
- System.err.println(ResourceManager.getInitialEnvironment(null));
- InitialContext ctx = new InitialContext();
+ System.err.println(IiopRemoteUnitTestCase.class.getClassLoader().getResource("jacorb.properties"));
}
catch(Throwable t)
{
More information about the jboss-cvs-commits
mailing list