[jbpm-commits] JBoss JBPM SVN: r2311 - in projects/jbpm-spec/trunk: modules/api/src/main/java/org/jboss/bpm/test and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Sep 23 08:40:07 EDT 2008


Author: thomas.diesler at jboss.com
Date: 2008-09-23 08:40:07 -0400 (Tue, 23 Sep 2008)
New Revision: 2311

Added:
   projects/jbpm-spec/trunk/modules/api/src/main/java/org/jboss/bpm/test/IntegrationTestCase.java
Modified:
   projects/jbpm-spec/trunk/eclipse/jBPMCodeStyle.xml
   projects/jbpm-spec/trunk/modules/api/src/main/java/org/jboss/bpm/test/IntegrationTestHelper.java
Log:
Add IntegrationTestCase

Modified: projects/jbpm-spec/trunk/eclipse/jBPMCodeStyle.xml
===================================================================
--- projects/jbpm-spec/trunk/eclipse/jBPMCodeStyle.xml	2008-09-23 10:00:14 UTC (rev 2310)
+++ projects/jbpm-spec/trunk/eclipse/jBPMCodeStyle.xml	2008-09-23 12:40:07 UTC (rev 2311)
@@ -70,7 +70,7 @@
 <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
 <setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/>
 <setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
+<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="140"/>
 <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
 <setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
 <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>

Added: projects/jbpm-spec/trunk/modules/api/src/main/java/org/jboss/bpm/test/IntegrationTestCase.java
===================================================================
--- projects/jbpm-spec/trunk/modules/api/src/main/java/org/jboss/bpm/test/IntegrationTestCase.java	                        (rev 0)
+++ projects/jbpm-spec/trunk/modules/api/src/main/java/org/jboss/bpm/test/IntegrationTestCase.java	2008-09-23 12:40:07 UTC (rev 2311)
@@ -0,0 +1,60 @@
+/*
+ * 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.bpm.test;
+
+// $Id$
+
+import junit.framework.TestCase;
+
+public abstract class IntegrationTestCase extends TestCase
+{
+  private IntegrationTestHelper delegate = new IntegrationTestHelper();
+  
+  /** Deploy the given archive
+   */
+  public void deploy(String archive) throws Exception
+  {
+    delegate.deploy(archive);
+  }
+
+  /** Undeploy the given archive
+   */
+  public void undeploy(String archive) throws Exception
+  {
+    delegate.undeploy(archive);
+  }
+
+  public boolean isTargetJBoss500()
+  {
+    return delegate.isTargetJBoss500();
+  }
+
+  public boolean isTargetJBoss423()
+  {
+    return delegate.isTargetJBoss423();
+  }
+
+  public boolean isTargetJBoss422()
+  {
+    return delegate.isTargetJBoss422();
+  }
+}


Property changes on: projects/jbpm-spec/trunk/modules/api/src/main/java/org/jboss/bpm/test/IntegrationTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: projects/jbpm-spec/trunk/modules/api/src/main/java/org/jboss/bpm/test/IntegrationTestHelper.java
===================================================================
--- projects/jbpm-spec/trunk/modules/api/src/main/java/org/jboss/bpm/test/IntegrationTestHelper.java	2008-09-23 10:00:14 UTC (rev 2310)
+++ projects/jbpm-spec/trunk/modules/api/src/main/java/org/jboss/bpm/test/IntegrationTestHelper.java	2008-09-23 12:40:07 UTC (rev 2311)
@@ -27,119 +27,187 @@
 import java.util.Hashtable;
 
 import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 
+import org.jboss.bpm.model.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
 {
-   private static final String SYSPROP_TEST_ARCHIVE_DIRECTORY = "test.archive.directory";
-   private static final String SYSPROP_TEST_RESOURCES_DIRECTORY = "test.resources.directory";
+  private static final String SYSPROP_TEST_ARCHIVE_DIRECTORY = "test.archive.directory";
+  private static final String SYSPROP_TEST_RESOURCES_DIRECTORY = "test.resources.directory";
+  private static final String SYSPROP_TARGET_CONTAINER = "jbpm.target.container";
 
-   private static MBeanServerConnection server;
-   private static String testArchiveDir;
-   private static String testResourcesDir;
+  private static MBeanServerConnection server;
+  private static String testArchiveDir;
+  private static String testResourcesDir;
+  private static 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 static 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");
+  }
+
+  public String getIntegrationTarget()
+  {
+    if (integrationTarget == null)
+    {
+      integrationTarget = System.getProperty(SYSPROP_TARGET_CONTAINER);
+
+      if (integrationTarget == null)
+        throw new IllegalStateException("Cannot obtain system property: " + SYSPROP_TARGET_CONTAINER);
+
+      // Read the JBoss SpecificationVersion
+      String jbossVersion = null;
+      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");
+        if (jbossVersion == null)
+          throw new IllegalStateException("Cannot obtain jboss version");
+
+        if (jbossVersion.startsWith("5.0.0"))
+          jbossVersion = "jboss500";
+        else if (jbossVersion.startsWith("4.2.3"))
+          jbossVersion = "jboss423";
+        else if (jbossVersion.startsWith("4.2.2"))
+          jbossVersion = "jboss422";
+        else
+          throw new IllegalStateException("Unsupported jboss version: " + jbossVersion);
       }
-      return server;
-   }
+      catch (IllegalStateException ex)
+      {
+        throw ex;
+      }
+      catch (Exception ex)
+      {
+        // ignore, we are not running on jboss-4.2 or greater
+      }
 
-   private ArchiveDeployer getDeployer()
-   {
-      return new JBossArchiveDeployer(getServer());
-   }
+      if (integrationTarget.startsWith(jbossVersion) == false)
+        throw new IllegalStateException("Integration target mismatch: " + integrationTarget + ".startsWith(" + 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 static 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;
+  /** Try to discover the URL for the test resource */
+  public URL getResourceURL(String resource) throws MalformedURLException
+  {
+    return getResourceFile(resource).toURI().toURL();
+  }
 
-      throw new IllegalArgumentException("Cannot obtain '" + getTestResourcesDir() + "/" + resource + "'");
-   }
+  /** Try to discover the File for the test resource */
+  public File getResourceFile(String resource)
+  {
+    File file = new File(resource);
+    if (file.exists())
+      return file;
 
-   public static String getTestArchiveDir()
-   {
-      if (testArchiveDir == null)
-         testArchiveDir = System.getProperty(SYSPROP_TEST_ARCHIVE_DIRECTORY, "target/test-libs");
+    file = new File(getTestResourcesDir() + "/" + resource);
+    if (file.exists())
+      return file;
 
-      return testArchiveDir;
-   }
+    throw new IllegalArgumentException("Cannot obtain '" + getTestResourcesDir() + "/" + resource + "'");
+  }
 
-   public static String getTestResourcesDir()
-   {
-      if (testResourcesDir == null)
-         testResourcesDir = System.getProperty(SYSPROP_TEST_RESOURCES_DIRECTORY, "target/test-resource");
+  public static String getTestArchiveDir()
+  {
+    if (testArchiveDir == null)
+      testArchiveDir = System.getProperty(SYSPROP_TEST_ARCHIVE_DIRECTORY, "target/test-libs");
 
-      return testResourcesDir;
-   }
+    return testArchiveDir;
+  }
+
+  public static String getTestResourcesDir()
+  {
+    if (testResourcesDir == null)
+      testResourcesDir = System.getProperty(SYSPROP_TEST_RESOURCES_DIRECTORY, "target/test-resource");
+
+    return testResourcesDir;
+  }
 }




More information about the jbpm-commits mailing list