[jbpm-commits] JBoss JBPM SVN: r2517 - projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/test.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri Oct 10 03:54:54 EDT 2008
Author: thomas.diesler at jboss.com
Date: 2008-10-10 03:54:54 -0400 (Fri, 10 Oct 2008)
New Revision: 2517
Added:
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/test/IntegrationTestCase.java
Modified:
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/test/IntegrationTestHelper.java
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/test/IntegrationTestSetup.java
Log:
Add IntegrationTestCase
Added: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/test/IntegrationTestCase.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/test/IntegrationTestCase.java (rev 0)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/test/IntegrationTestCase.java 2008-10-10 07:54:54 UTC (rev 2517)
@@ -0,0 +1,77 @@
+/*
+ * 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.jbpm.api.test;
+
+// $Id$
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.management.MBeanServerConnection;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * An integration test case
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Sep-2008
+ */
+public class IntegrationTestCase extends CTSTestCase
+{
+ // Provide logging
+ final Logger log = LoggerFactory.getLogger(IntegrationTestCase.class);
+
+ private IntegrationTestHelper delegate = new IntegrationTestHelper();
+
+ public File getArchiveFile(String archive)
+ {
+ return delegate.getArchiveFile(archive);
+ }
+
+ public URL getArchiveURL(String archive) throws MalformedURLException
+ {
+ return delegate.getArchiveFile(archive).toURI().toURL();
+ }
+
+ public boolean isTargetJBoss500()
+ {
+ return delegate.isTargetJBoss500();
+ }
+
+ public boolean isTargetJBoss423()
+ {
+ return delegate.isTargetJBoss423();
+ }
+
+ public boolean isTargetJBoss422()
+ {
+ return delegate.isTargetJBoss422();
+ }
+
+ public MBeanServerConnection getServer()
+ {
+ return delegate.getServer();
+ }
+}
Property changes on: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/test/IntegrationTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/test/IntegrationTestHelper.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/test/IntegrationTestHelper.java 2008-10-10 06:56:39 UTC (rev 2516)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/test/IntegrationTestHelper.java 2008-10-10 07:54:54 UTC (rev 2517)
@@ -27,109 +27,141 @@
import java.util.Hashtable;
import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
import javax.naming.InitialContext;
import javax.naming.NamingException;
+import org.jbpm.api.model.builder.ObjectNameFactory;
+
/**
* An integration test helper that deals with test deployment/undeployment, etc.
- *
+ *
* @author Thomas.Diesler at jboss.org
* @since 14-Oct-2004
*/
public class IntegrationTestHelper extends CTSTestHelper
{
- private static final String SYSPROP_TEST_ARCHIVE_DIRECTORY = "test.archive.directory";
+ private static final String SYSPROP_TEST_ARCHIVE_DIRECTORY = "test.archive.directory";
- private static MBeanServerConnection server;
- private static String testArchiveDir;
+ private static MBeanServerConnection server;
+ private static String testArchiveDir;
+ private String integrationTarget;
- /** Deploy the given archive
- */
- public void deploy(String archive) throws Exception
- {
- URL url = getArchiveFile(archive).toURI().toURL();
- getDeployer().deploy(url);
- }
+ /**
+ * Deploy the given archive
+ */
+ public void deploy(String archive) throws Exception
+ {
+ URL url = getArchiveFile(archive).toURI().toURL();
+ getDeployer().deploy(url);
+ }
- /** Undeploy the given archive
- */
- public void undeploy(String archive) throws Exception
- {
- URL url = getArchiveFile(archive).toURI().toURL();
- getDeployer().undeploy(url);
- }
+ /**
+ * Undeploy the given archive
+ */
+ public void undeploy(String archive) throws Exception
+ {
+ URL url = getArchiveFile(archive).toURI().toURL();
+ getDeployer().undeploy(url);
+ }
- @SuppressWarnings("unchecked")
- public MBeanServerConnection getServer()
- {
- if (server == null)
+ public boolean isTargetJBoss500()
+ {
+ String target = getIntegrationTarget();
+ return target.startsWith("jboss500");
+ }
+
+ public boolean isTargetJBoss423()
+ {
+ String target = getIntegrationTarget();
+ return target.startsWith("jboss423");
+ }
+
+ public boolean isTargetJBoss422()
+ {
+ String target = getIntegrationTarget();
+ return target.startsWith("jboss422");
+ }
+
+ private String getIntegrationTarget()
+ {
+ if (integrationTarget == null)
+ {
+ // Read the JBoss SpecificationVersion
+ String jbossVersion;
+ try
{
- Hashtable jndiEnv = null;
- try
- {
- InitialContext iniCtx = new InitialContext();
- jndiEnv = iniCtx.getEnvironment();
- server = (MBeanServerConnection)iniCtx.lookup("jmx/invoker/RMIAdaptor");
- }
- catch (NamingException ex)
- {
- throw new RuntimeException("Cannot obtain MBeanServerConnection using jndi props: " + jndiEnv, ex);
- }
+ ObjectName oname = ObjectNameFactory.create("jboss.system:type=ServerConfig");
+ jbossVersion = (String)getServer().getAttribute(oname, "SpecificationVersion");
}
- return server;
- }
+ catch (Exception ex)
+ {
+ throw new IllegalStateException("Cannot obtain jboss version", ex);
+ }
- private ArchiveDeployer getDeployer()
- {
- return new JBossArchiveDeployer(getServer());
- }
+ if (jbossVersion.startsWith("5.0.0"))
+ integrationTarget = "jboss500";
+ else if (jbossVersion.startsWith("4.2.3"))
+ integrationTarget = "jboss423";
+ else if (jbossVersion.startsWith("4.2.2"))
+ integrationTarget = "jboss422";
+ else
+ throw new IllegalStateException("Unsupported jboss version: " + jbossVersion);
+ }
+ return integrationTarget;
+ }
- /** Try to discover the URL for the deployment archive */
- public URL getArchiveURL(String archive) throws MalformedURLException
- {
- return getArchiveFile(archive).toURI().toURL();
- }
+ @SuppressWarnings("unchecked")
+ public MBeanServerConnection getServer()
+ {
+ if (server == null)
+ {
+ Hashtable jndiEnv = null;
+ try
+ {
+ InitialContext iniCtx = new InitialContext();
+ jndiEnv = iniCtx.getEnvironment();
+ server = (MBeanServerConnection)iniCtx.lookup("jmx/invoker/RMIAdaptor");
+ }
+ catch (NamingException ex)
+ {
+ throw new RuntimeException("Cannot obtain MBeanServerConnection using jndi props: " + jndiEnv, ex);
+ }
+ }
+ return server;
+ }
- /** Try to discover the File for the deployment archive */
- public File getArchiveFile(String archive)
- {
- File file = new File(archive);
- if (file.exists())
- return file;
+ private ArchiveDeployer getDeployer()
+ {
+ return new JBossArchiveDeployer(getServer());
+ }
- file = new File(getTestArchiveDir() + "/" + archive);
- if (file.exists())
- return file;
+ /** Try to discover the URL for the deployment archive */
+ public URL getArchiveURL(String archive) throws MalformedURLException
+ {
+ return getArchiveFile(archive).toURI().toURL();
+ }
- String notSet = (getTestArchiveDir() == null ? " System property '" + SYSPROP_TEST_ARCHIVE_DIRECTORY + "' not set." : "");
- throw new IllegalArgumentException("Cannot obtain '" + getTestArchiveDir() + "/" + archive + "'." + notSet);
- }
+ /** Try to discover the File for the deployment archive */
+ public File getArchiveFile(String archive)
+ {
+ File file = new File(archive);
+ if (file.exists())
+ return file;
- /** Try to discover the URL for the test resource */
- public URL getResourceURL(String resource) throws MalformedURLException
- {
- return getResourceFile(resource).toURI().toURL();
- }
+ file = new File(getTestArchiveDir() + "/" + archive);
+ if (file.exists())
+ return file;
- /** Try to discover the File for the test resource */
- public File getResourceFile(String resource)
- {
- File file = new File(resource);
- if (file.exists())
- return file;
+ String notSet = (getTestArchiveDir() == null ? " System property '" + SYSPROP_TEST_ARCHIVE_DIRECTORY + "' not set." : "");
+ throw new IllegalArgumentException("Cannot obtain '" + getTestArchiveDir() + "/" + archive + "'." + notSet);
+ }
- file = new File(getTestResourcesDir() + "/" + resource);
- if (file.exists())
- return file;
+ public String getTestArchiveDir()
+ {
+ if (testArchiveDir == null)
+ testArchiveDir = System.getProperty(SYSPROP_TEST_ARCHIVE_DIRECTORY, "target/test-libs");
- throw new IllegalArgumentException("Cannot obtain '" + getTestResourcesDir() + "/" + resource + "'");
- }
-
- public String getTestArchiveDir()
- {
- if (testArchiveDir == null)
- testArchiveDir = System.getProperty(SYSPROP_TEST_ARCHIVE_DIRECTORY, "target/test-libs");
-
- return testArchiveDir;
- }
+ return testArchiveDir;
+ }
}
Modified: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/test/IntegrationTestSetup.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/test/IntegrationTestSetup.java 2008-10-10 06:56:39 UTC (rev 2516)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/test/IntegrationTestSetup.java 2008-10-10 07:54:54 UTC (rev 2517)
@@ -30,7 +30,6 @@
import java.util.StringTokenizer;
import javax.management.MBeanServerConnection;
-import javax.naming.NamingException;
/**
* A test setup that deploys/undeploys archives
@@ -60,16 +59,26 @@
return delegate.getArchiveFile(archive).toURI().toURL();
}
- public File getResourceFile(String resource)
+ public boolean isTargetJBoss500()
{
- return delegate.getResourceFile(resource);
+ return delegate.isTargetJBoss500();
}
-
- public URL getResourceURL(String resource) throws MalformedURLException
+
+ public boolean isTargetJBoss423()
{
- return delegate.getResourceFile(resource).toURI().toURL();
+ return delegate.isTargetJBoss423();
}
-
+
+ public boolean isTargetJBoss422()
+ {
+ return delegate.isTargetJBoss422();
+ }
+
+ public MBeanServerConnection getServer()
+ {
+ return delegate.getServer();
+ }
+
private void getArchiveArray(String archiveList)
{
if (archiveList != null)
@@ -141,9 +150,4 @@
}
super.tearDown();
}
-
- public MBeanServerConnection getServer() throws NamingException
- {
- return delegate.getServer();
- }
}
More information about the jbpm-commits
mailing list