[jbossws-commits] JBossWS SVN: r4139 - in spi/trunk: src/test/java/org/jboss/test/wsf/spi/tools and 1 other directory.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Fri Aug 3 04:58:16 EDT 2007


Author: heiko.braun at jboss.com
Date: 2007-08-03 04:58:16 -0400 (Fri, 03 Aug 2007)
New Revision: 4139

Added:
   spi/trunk/spi.iml
   spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CalculatorBean.java
   spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTestCase.java
   spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTracker.java
   spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTrackerFactory.java
   spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CommandlineTestBase.java
Modified:
   spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTestCase.java
   spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTracker.java
Log:
Added WSProvide test case

Added: spi/trunk/spi.iml
===================================================================
--- spi/trunk/spi.iml	                        (rev 0)
+++ spi/trunk/spi.iml	2007-08-03 08:58:16 UTC (rev 4139)
@@ -0,0 +1,198 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module version="4" relativePaths="true" type="JAVA_MODULE">
+  <component name="ModuleRootManager" />
+  <component name="NewModuleRootManager" inherit-compiler-output="false">
+    <output url="file://$MODULE_DIR$/output/classes" />
+    <exclude-output />
+    <output-test url="file://$MODULE_DIR$/output/test/classes" />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/thirdparty/jboss-common-core-sources.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/thirdparty/jboss-javaee.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/thirdparty/jboss-xml-binding-sources.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/thirdparty/jboss-common-core.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/thirdparty/dom4j.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/thirdparty/jboss-dependency.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/thirdparty/getopt.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/thirdparty/jboss-logging-spi.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/thirdparty/jboss-logging-log4j.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/thirdparty/jboss-microcontainer.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/thirdparty/jboss-dependency-src.zip!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/thirdparty/servlet-api.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/thirdparty/junit.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/thirdparty/jaxb-api.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/thirdparty/jaxws-api.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/thirdparty/jaxrpc-api.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/thirdparty/ant.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/thirdparty/jboss-xml-binding.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/thirdparty/activation.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/thirdparty/jboss-microcontainer-src.zip!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module" module-name="common" />
+    <orderEntryProperties />
+  </component>
+</module>
+

Added: spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CalculatorBean.java
===================================================================
--- spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CalculatorBean.java	                        (rev 0)
+++ spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CalculatorBean.java	2007-08-03 08:58:16 UTC (rev 4139)
@@ -0,0 +1,36 @@
+/*
+ * 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.test.wsf.spi.tools;
+
+// We just need to load it, therefore we skip the JSR 181 annotations here
+public class CalculatorBean
+{
+   public int add(int a, int b)
+   {
+      return a+b;
+   }
+
+   public int subtract(int a, int b)
+   {
+      return a-b;
+   }
+}


Property changes on: spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CalculatorBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTestCase.java
===================================================================
--- spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTestCase.java	2007-08-03 08:57:11 UTC (rev 4138)
+++ spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTestCase.java	2007-08-03 08:58:16 UTC (rev 4139)
@@ -33,60 +33,16 @@
  * @author Heiko.Braun at jboss.com
  * @version $Revision$
  */
-public class CmdConsumeTestCase extends TestCase
+public class CmdConsumeTestCase extends CommandlineTestBase
 {
 
-   SecurityManager systemDefault = System.getSecurityManager();
-   SecurityManager interceptor = new InterceptedSecurity();
-
-   class InterceptedSecurity extends  SecurityManager
-   {
-      private final SecurityManager parent = systemDefault;
-
-      public void checkPermission(Permission perm)
-      {
-         if (parent != null)
-         {
-            parent.checkPermission(perm);
-         }
-      }
-
-      public void checkExit(int status)
-      {
-         String msg = (status == 0) ? "WSConsume did exit without errors" : "WSConsume did exit with an error";
-         throw new InterceptedExit(msg, status);
-      }
-   }
-
-   class InterceptedExit extends SecurityException
-   {
-      private int exitCode;
-
-      public InterceptedExit(String s, int code)
-      {
-         super(s);
-         this.exitCode = code;
-      }
-
-
-      public int getExitCode()
-      {
-         return exitCode;
-      }
-   }
-
-   private void swapSecurityManager()
-   {
-      if(System.getSecurityManager() instanceof InterceptedSecurity)
-         System.setSecurityManager(systemDefault);
-      else
-         System.setSecurityManager(interceptor);
-   }
-
    protected void setUp() throws Exception
    {
       super.setUp();
 
+      // cleanup events
+      CmdConsumeTracker.LAST_EVENT = "";
+      
       // enforce loading of the tracker implemenation
       System.setProperty(
         "org.jboss.wsf.spi.tools.ConsumerFactoryImpl",
@@ -94,22 +50,6 @@
         );
    }
 
-   /*
-      new LongOpt("binding", LongOpt.REQUIRED_ARGUMENT, null, 'b'),
-         new LongOpt("catalog", LongOpt.REQUIRED_ARGUMENT, null, 'c'),
-         new LongOpt("package", LongOpt.REQUIRED_ARGUMENT, null, 'p'),
-         new LongOpt("wsdlLocation", LongOpt.REQUIRED_ARGUMENT, null, 'w'),
-         new LongOpt("output", LongOpt.REQUIRED_ARGUMENT, null, 'o'),
-         new LongOpt("source", LongOpt.REQUIRED_ARGUMENT, null, 's'),
-         new LongOpt("target", LongOpt.REQUIRED_ARGUMENT, null, 't'),
-         new LongOpt("keep", LongOpt.NO_ARGUMENT, null, 'k'),
-         new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'),
-         new LongOpt("quiet", LongOpt.NO_ARGUMENT, null, 'q'),
-         new LongOpt("verbose", LongOpt.NO_ARGUMENT, null, 'v'),
-         new LongOpt("load-consumer", LongOpt.NO_ARGUMENT, null, 'l'),
-
-   */
-
    public void testInvalidBindingOption() throws Exception
    {
       executeCmd("-b", true);
@@ -118,50 +58,19 @@
    public void testValidBindingOption() throws Exception
    {
       executeCmd("-b binding-file.xml Service.wsdl", false);
-      assertEquals(CmdConsumeTracker.LAST_EVENT, "setBindingFiles");
+      assertTrue("setBindingFiles() not invoked",  CmdConsumeTracker.LAST_EVENT.indexOf("setBindingFiles")!=-1);
    }
 
    public void testMissingOptions() throws Exception
    {
-      executeCmd("", false);  // strange, shouldn't this exit(1) ?
+      executeCmd(null, true);
    }
 
    // TODO: add arbitrary combinations on a case by case basis
 
-   /**
-    * Pass a number of arguments to WSConsume and specify if
-    * you expect this to cause an exception.
-    *
-    * @param arguments
-    * @param expectedException
-    * @throws Exception
-    */
-   private void executeCmd(String arguments,  boolean expectedException) throws Exception
-   {
-      swapSecurityManager();
 
-      String[] args = arguments.split("\\s");
-      try
-      {
-         WSConsume.main(args);
-         if(expectedException)
-            fail("Did expect exception on args: " +args);
-      }
-      catch (InterceptedExit e)
-      {
-         boolean positivStatus = (e.getExitCode() == 0);
-         if( (expectedException && positivStatus)
-           || (!expectedException && !positivStatus) )
-         {
-            String s = expectedException ? "Did expect an exception, but " : "Did not expect an exception, but ";
-            String s2 = positivStatus ? "status was positiv" : "status was negativ";
-            throw new Exception(s+s2);
-         }
-
-      }
-      finally
-      {
-         swapSecurityManager();
-      }
+   void runDelegate(String[] args) throws Exception
+   {
+      WSConsume.main(args);
    }
 }

Modified: spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTracker.java
===================================================================
--- spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTracker.java	2007-08-03 08:57:11 UTC (rev 4138)
+++ spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTracker.java	2007-08-03 08:58:16 UTC (rev 4139)
@@ -38,52 +38,52 @@
 
    public void setBindingFiles(List<File> bindingFiles)
    {
-      CmdConsumeTracker.LAST_EVENT = "setBindingFiles";
+      LAST_EVENT += "setBindingFiles";
    }
 
    public void setCatalog(File catalog)
    {
-      CmdConsumeTracker.LAST_EVENT = "setCatalog";
+      LAST_EVENT += "setCatalog";
    }
 
    public void setOutputDirectory(File directory)
    {
-      CmdConsumeTracker.LAST_EVENT = "setOutputDirectory";
+      LAST_EVENT += "setOutputDirectory";
    }
 
    public void setSourceDirectory(File directory)
    {
-      CmdConsumeTracker.LAST_EVENT = "setSourceDirectory";
+      LAST_EVENT += "setSourceDirectory";
    }
 
    public void setGenerateSource(boolean generateSource)
    {
-      CmdConsumeTracker.LAST_EVENT = "setGenerateSource";
+      LAST_EVENT += "setGenerateSource";
    }
 
    public void setTargetPackage(String targetPackage)
    {
-      CmdConsumeTracker.LAST_EVENT = "setTargetPackage";
+      LAST_EVENT += "setTargetPackage";
    }
 
    public void setWsdlLocation(String wsdlLocation)
    {
-      CmdConsumeTracker.LAST_EVENT = "setWsdlLocation";
+      LAST_EVENT += "setWsdlLocation";
    }
 
    public void setMessageStream(PrintStream messageStream)
    {
-      CmdConsumeTracker.LAST_EVENT = "setMessageStream";
+      LAST_EVENT += "setMessageStream";
    }
 
    public void setAdditionalCompilerClassPath(List<String> classPath)
    {
-      CmdConsumeTracker.LAST_EVENT = "setAdditionalCompilerClassPath";
+      LAST_EVENT += "setAdditionalCompilerClassPath";
    }
 
    public void setTarget(String target)
    {
-      CmdConsumeTracker.LAST_EVENT = "setTarget";
+      LAST_EVENT += "setTarget";
    }
 
    public void consume(URL wsdl)

Added: spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTestCase.java
===================================================================
--- spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTestCase.java	                        (rev 0)
+++ spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTestCase.java	2007-08-03 08:58:16 UTC (rev 4139)
@@ -0,0 +1,78 @@
+/*
+ * 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.test.wsf.spi.tools;
+
+import org.jboss.wsf.spi.tools.cmd.WSProvide;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ * @version $Revision$
+ */
+public class CmdProvideTestCase extends CommandlineTestBase
+{
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+
+      // clear events
+      CmdProvideTracker.LAST_EVENT = "";
+
+      // enforce loading of the tracker implemenation
+      System.setProperty(
+        "org.jboss.wsf.spi.tools.ProviderFactoryImpl",
+        "org.jboss.test.wsf.spi.tools.CmdProvideTrackerFactory"
+      );
+   }
+
+   /** <pre>
+ *  usage: WSProvideTask [options] &lt;endpoint class name&gt;
+ *  options:
+ *  -h, --help                  Show this help message
+ *  -k, --keep                  Keep/Generate Java source
+ *  -w, --wsdl                  Enable WSDL file generation
+ *  -c, --classpath=&lt;path&lt;      The classpath that contains the endpoint
+ *  -o, --output=&lt;directory&gt;    The directory to put generated artifacts
+ *  -r, --resource=&lt;directory&gt;  The directory to put resource artifacts
+ *  -s, --source=&lt;directory&gt;    The directory to put Java source
+ *  -q, --quiet                 Be somewhat more quiet
+ *  -t, --show-traces           Show full exception stack traces
+ *  -l, --load-provider           Load the provider and exit (debug utility)
+ * </pre>
+    * */
+
+   public void testMissingOptions() throws Exception
+   {
+      executeCmd(null, true);   
+   }
+
+   public void testValidOutputDir() throws Exception
+   {
+      executeCmd("-o outputDir org.jboss.test.wsf.spi.tools.CalculatorBean", false);
+      assertTrue("setOutputDirectory() not invoked", CmdProvideTracker.LAST_EVENT.indexOf("setOutputDirectory")!=-1);
+   }
+
+   void runDelegate(String[] args) throws Exception
+   {
+      WSProvide.main(args);
+   }
+}


Property changes on: spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTracker.java
===================================================================
--- spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTracker.java	                        (rev 0)
+++ spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTracker.java	2007-08-03 08:58:16 UTC (rev 4139)
@@ -0,0 +1,82 @@
+/*
+ * 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.test.wsf.spi.tools;
+
+import org.jboss.wsf.spi.tools.WSContractProvider;
+
+import java.io.File;
+import java.io.PrintStream;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ * @version $Revision$
+ */
+public class CmdProvideTracker extends WSContractProvider
+{
+
+   public static String LAST_EVENT = "";
+
+   public void setGenerateWsdl(boolean generateWsdl)
+   {
+      LAST_EVENT += "setGenerateWsdl";
+   }
+
+   public void setGenerateSource(boolean generateSource)
+   {
+      LAST_EVENT += "setGenerateSource";
+   }
+
+   public void setOutputDirectory(File directory)
+   {
+      LAST_EVENT += "setOutputDirectory";
+   }
+
+   public void setResourceDirectory(File directory)
+   {
+      LAST_EVENT += "setResourceDirectory";
+   }
+
+   public void setSourceDirectory(File directory)
+   {
+      LAST_EVENT += "setSourceDirectory";
+   }
+
+   public void setClassLoader(ClassLoader loader)
+   {
+      LAST_EVENT += "setClassLoader";
+   }
+
+   public void provide(String endpointClass)
+   {
+
+   }
+
+   public void provide(Class<?> endpointClass)
+   {
+
+   }
+
+   public void setMessageStream(PrintStream messageStream)
+   {
+      LAST_EVENT += "setMessageStream";
+   }
+}


Property changes on: spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTracker.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTrackerFactory.java
===================================================================
--- spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTrackerFactory.java	                        (rev 0)
+++ spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTrackerFactory.java	2007-08-03 08:58:16 UTC (rev 4139)
@@ -0,0 +1,38 @@
+/*
+ * 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.test.wsf.spi.tools;
+
+import org.jboss.wsf.spi.tools.WSContractProviderFactory;
+import org.jboss.wsf.spi.tools.WSContractProvider;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ * @version $Revision$
+ */
+public class CmdProvideTrackerFactory implements WSContractProviderFactory
+{
+
+   public WSContractProvider createProvider(ClassLoader loader)
+   {
+      return new CmdProvideTracker();  
+   }
+}


Property changes on: spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTrackerFactory.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CommandlineTestBase.java
===================================================================
--- spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CommandlineTestBase.java	                        (rev 0)
+++ spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CommandlineTestBase.java	2007-08-03 08:58:16 UTC (rev 4139)
@@ -0,0 +1,113 @@
+/*
+ * 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.test.wsf.spi.tools;
+
+import junit.framework.TestCase;
+
+import java.security.Permission;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ * @version $Revision$
+ */
+public abstract class CommandlineTestBase extends TestCase
+{
+   SecurityManager systemDefault = System.getSecurityManager();
+   SecurityManager interceptor = new InterceptedSecurity();
+
+   protected void swapSecurityManager()
+   {
+      if(System.getSecurityManager() instanceof InterceptedSecurity)
+         System.setSecurityManager(systemDefault);
+      else
+         System.setSecurityManager(interceptor);
+   }
+
+   class InterceptedSecurity extends  SecurityManager
+   {
+      private final SecurityManager parent = systemDefault;
+
+      public void checkPermission(Permission perm)
+      {
+         if (parent != null)
+         {
+            parent.checkPermission(perm);
+         }
+      }
+
+      public void checkExit(int status)
+      {
+         String msg = (status == 0) ? "Delegate did exit without errors" : "Delegate did exit with an error";
+         throw new InterceptedExit(msg, status);
+      }
+   }
+
+   protected class InterceptedExit extends SecurityException
+   {
+      private int exitCode;
+
+      public InterceptedExit(String s, int code)
+      {
+         super(s);
+         this.exitCode = code;
+      }
+
+
+      public int getExitCode()
+      {
+         return exitCode;
+      }
+   }
+
+   protected void executeCmd(String arguments,  boolean expectedException) throws Exception
+   {
+      swapSecurityManager();
+
+      String[] args = arguments!=null ? arguments.split("\\s"): new String[0];
+      try
+      {
+         runDelegate(args);
+         if(expectedException)
+            fail("Did expect exception on args: " +args);
+      }
+      catch (CommandlineTestBase.InterceptedExit e)
+      {
+         boolean positivStatus = (e.getExitCode() == 0);
+         if( (expectedException && positivStatus)
+           || (!expectedException && !positivStatus) )
+         {
+            String s = expectedException ? "Did expect an exception, but " : "Did not expect an exception, but ";
+            String s2 = positivStatus ? "status was positiv" : "status was negativ";
+            throw new Exception(s+s2);
+         }
+
+      }
+      finally
+      {
+         swapSecurityManager();
+      }
+   }
+
+   // the actual tools execution
+   abstract void runDelegate(String[] args) throws Exception;
+   
+}


Property changes on: spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CommandlineTestBase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF




More information about the jbossws-commits mailing list