[jbossws-commits] JBossWS SVN: r7419 - framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Fri Jun 6 15:31:34 EDT 2008


Author: heiko.braun at jboss.com
Date: 2008-06-06 15:31:34 -0400 (Fri, 06 Jun 2008)
New Revision: 7419

Added:
   framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/PluginBase.java
   framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderPlugin.java
   framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderPluginDelegate.java
Modified:
   framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSConsumerTestCase.java
   framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderTestCase.java
Log:
svn merge -r7407:7417 https://svn.jboss.org/repos/jbossws/framework/trunk

Copied: framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/PluginBase.java (from rev 7417, framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/PluginBase.java)
===================================================================
--- framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/PluginBase.java	                        (rev 0)
+++ framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/PluginBase.java	2008-06-06 19:31:34 UTC (rev 7419)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ws.jaxws.smoke.tools;
+
+import org.jboss.wsf.test.JBossWSTest;
+
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.StringTokenizer;
+import java.util.ArrayList;
+import java.io.File;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class PluginBase extends JBossWSTest
+{
+   protected Object delegate = null;
+   protected ClassLoader origClassLoader;
+
+   protected void dispatch(String methodName) throws Exception
+   {
+      try
+      {
+         delegate.getClass().getMethod(methodName).invoke(delegate);
+      }
+      catch (InvocationTargetException e)
+      {
+         e.printStackTrace();
+         throw e;
+      }
+   }
+
+   protected void maskClasspath() throws Exception
+   {
+      String classpath = System.getProperty("surefire.test.class.path");
+      List<URL> jarURLs = new LinkedList<URL>();
+      StringBuffer jarURLString = new StringBuffer();
+      List<URL> classDirUrls = new LinkedList<URL>();
+
+      if (classpath != null && !classpath.equals(""))
+      {
+         StringTokenizer st = new StringTokenizer(classpath, File.pathSeparator, false);
+         while (st.hasMoreTokens())
+         {
+            String s = st.nextToken();
+            if(s.endsWith(".jar"))  // JBWS-2175: skip target/classes and target/test-classes
+            {
+               jarURLs.add( new File(s).toURL() );
+               jarURLString.append( s ).append(File.pathSeparator);
+            }
+            else
+            {
+               classDirUrls.add( new File(s).toURL() );
+            }
+         }
+
+      }
+
+      List<URL> jarFirstClasspath = new ArrayList<URL>();
+
+	  // Replace the ThreadContextLoader to prevent loading from target/classes and target/test-classes
+      jarFirstClasspath.addAll(jarURLs);
+      jarFirstClasspath.addAll(classDirUrls);
+      URLClassLoader jarFirstClassLoader = new URLClassLoader(jarFirstClasspath.toArray( new URL[] {}), this.origClassLoader);
+
+      this.origClassLoader = Thread.currentThread().getContextClassLoader();
+
+      Thread.currentThread().setContextClassLoader(jarFirstClassLoader);
+      System.setProperty("java.class.path", jarURLString.toString());
+   }
+
+   protected void unmaskClasspath()
+   {
+      if(this.origClassLoader !=null)
+      {
+         Thread.currentThread().setContextClassLoader(this.origClassLoader);
+         this.origClassLoader = null;
+      }
+   }
+}

Modified: framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSConsumerTestCase.java
===================================================================
--- framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSConsumerTestCase.java	2008-06-06 19:27:32 UTC (rev 7418)
+++ framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSConsumerTestCase.java	2008-06-06 19:31:34 UTC (rev 7419)
@@ -23,27 +23,14 @@
 
 // $Id$
 
-import org.jboss.wsf.test.JBossWSTest;
-
-import java.io.File;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.lang.reflect.InvocationTargetException;
-
 /**
  * Test the WSContractConsumer API across different implementations.
  * NOTE: All tests expect to be executed below 'output/tests'.
  * 
  * @author Heiko.Braun at jboss.com
  */
-public class WSConsumerTestCase extends JBossWSTest implements WSConsumerPluginDelegate
+public class WSConsumerTestCase extends PluginBase implements WSConsumerPluginDelegate
 {
-   Object delegate = null;
-   ClassLoader origClassLoader;
 
    /**
     * Recreates a tools delegate for every test
@@ -65,19 +52,6 @@
       unmaskClasspath();
    }
 
-   private void dispatch(String methodName) throws Exception
-   {
-      try
-      {
-         delegate.getClass().getMethod(methodName).invoke(delegate);
-      }
-      catch (InvocationTargetException e)
-      {
-         e.printStackTrace();
-         throw e;
-      }
-   }
-
    /**
     * Specifies the JAX-WS and JAXB binding files to use on import operations.
     * See http://java.sun.com/webservices/docs/2.0/jaxws/customizations.html
@@ -186,51 +160,4 @@
       dispatch("testSOAP12Extension");
    }
    
-   private void maskClasspath() throws Exception
-   {
-      String classpath = System.getProperty("surefire.test.class.path");
-      List<URL> jarURLs = new LinkedList<URL>();
-      StringBuffer jarURLString = new StringBuffer();
-      List<URL> classDirUrls = new LinkedList<URL>();
-
-      if (classpath != null && !classpath.equals(""))
-      {
-         StringTokenizer st = new StringTokenizer(classpath, File.pathSeparator, false);
-         while (st.hasMoreTokens())
-         {
-            String s = st.nextToken();
-            if(s.endsWith(".jar"))  // JBWS-2175: skip target/classes and target/test-classes
-            {
-               jarURLs.add( new File(s).toURL() );
-               jarURLString.append( s ).append(File.pathSeparator);
-            }
-            else
-            {
-               classDirUrls.add( new File(s).toURL() );
-            }
-         }
-
-      }
-      
-      List<URL> jarFirstClasspath = new ArrayList<URL>();
-
-	  // Replace the ThreadContextLoader to prevent loading from target/classes and target/test-classes
-      jarFirstClasspath.addAll(jarURLs);
-      jarFirstClasspath.addAll(classDirUrls);
-      URLClassLoader jarFirstClassLoader = new URLClassLoader(jarFirstClasspath.toArray( new URL[] {}), this.origClassLoader);
-
-      this.origClassLoader = Thread.currentThread().getContextClassLoader();
-
-      Thread.currentThread().setContextClassLoader(jarFirstClassLoader);
-      System.setProperty("java.class.path", jarURLString.toString());
-   }
-
-   private void unmaskClasspath()
-   {
-      if(this.origClassLoader !=null)
-      {
-         Thread.currentThread().setContextClassLoader(this.origClassLoader);
-         this.origClassLoader = null;
-      }
-   }  
 }

Copied: framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderPlugin.java (from rev 7417, framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderPlugin.java)
===================================================================
--- framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderPlugin.java	                        (rev 0)
+++ framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderPlugin.java	2008-06-06 19:31:34 UTC (rev 7419)
@@ -0,0 +1,235 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ws.jaxws.smoke.tools;
+
+import org.jboss.wsf.common.DOMUtils;
+import org.jboss.wsf.spi.tools.WSContractProvider;
+import org.jboss.wsf.test.JBossWSTest;
+import org.w3c.dom.Element;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.PrintStream;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class WSProviderPlugin extends JBossWSTest implements WSProviderPluginDelegate
+{
+   // tools delegate
+   WSContractProvider provider;
+
+   // redirect tools message to System.out ?
+   boolean toogleMessageOut = Boolean.getBoolean(WSProviderTestCase.class.getName()+".verbose");
+
+   // relative to test execution
+   File outputDirectory;
+
+
+   public WSProviderPlugin()
+   {
+       // create a new consumer for every test case
+      provider = WSContractProvider.newInstance();
+      if(toogleMessageOut) provider.setMessageStream(System.out);
+
+      // shared output directory, relative to test execution
+      outputDirectory = createResourceFile("../test-classes");
+   }
+
+   private ClassLoader getArtefactClassLoader() throws Exception {
+      /*URLClassLoader loader = new URLClassLoader(new URL[] {
+        new URL("file:"+System.getProperty("user.dir")+"/wsprovide/java/") }
+      );
+
+      return loader;*/
+      return Thread.currentThread().getContextClassLoader();
+   }
+
+   /**
+    * Enables/Disables WSDL generation.
+    *
+    */
+   public void testGenerateWsdl() throws Exception
+   {
+      provider.setGenerateWsdl(true);
+      provide();
+
+      verifyWSDL(outputDirectory);
+   }
+
+   /**
+    * Enables/Disables Java source generation.
+    *
+    */
+   public void testGenerateSource() throws Exception
+   {
+      provider.setGenerateSource(true);
+      provide();
+
+      verifyJavaSource(outputDirectory);
+
+   }
+
+   private void verifyJavaSource(File directory)
+   {
+      File javaSource = new File(
+        directory.getAbsolutePath()+
+          "/org/jboss/test/ws/jaxws/smoke/tools/jaxws/AddResponse.java"
+        );
+
+      assertTrue("Source not generated", javaSource.exists());
+   }
+
+   /**
+    * Sets the main output directory.
+    * If the directory does not exist, it will be created.
+    */
+   public void testOutputDirectory() throws Exception
+   {
+      provide();
+      ClassLoader loader = getArtefactClassLoader();
+      Class responseWrapper = loader.loadClass("org.jboss.test.ws.jaxws.smoke.tools.jaxws.AddResponse");
+      XmlRootElement rootElement = (XmlRootElement) responseWrapper.getAnnotation(XmlRootElement.class);
+      assertNotNull("@XmlRootElement missing form response wrapper", rootElement);
+      assertEquals("Wrong namespace", rootElement.namespace(), "http://foo.bar.com/calculator");
+   }
+
+   /**
+    * Sets the resource directory. This directory will contain any generated
+    * WSDL and XSD files. If the directory does not exist, it will be created.
+    * If not specified, the output directory will be used instead.
+    *
+    */
+   public void testResourceDirectory() throws Exception
+   {
+      File directory = createResourceFile("wsprovide/resources");
+      provider.setResourceDirectory(directory);
+      provide();
+
+      verifyWSDL(directory);
+   }
+
+   private void verifyWSDL(File directory) throws Exception
+   {
+      File wsdl = new File(
+        outputDirectory.getAbsolutePath()+
+          "/CalculatorBeanService.wsdl"
+      );
+
+      assertTrue("WSDL not generated", wsdl.exists());
+      Element root = DOMUtils.parse( new FileInputStream(wsdl));
+      Element serviceElement = DOMUtils.getFirstChildElement(root, "service");
+      assertEquals(serviceElement.getAttribute("name"), "CalculatorBeanService");
+   }
+
+   /**
+    * Sets the source directory. This directory will contain any generated Java source.
+    * If the directory does not exist, it will be created. If not specified,
+    * the output directory will be used instead.
+    *
+    */
+   public void testSourceDirectory() throws Exception
+   {
+      File sourceDir = createResourceFile("wsprovide/sources");
+      provider.setSourceDirectory(sourceDir);
+      provider.setGenerateSource(true);
+      provide();
+
+      verifyJavaSource(sourceDir);
+   }
+
+   /**
+    * Sets the ClassLoader used to discover types.
+    * This defaults to the one used in instantiation.
+    *
+    */
+   public void testClassLoader() throws Exception
+   {
+      // Work around the sure jre settings
+      String javaHome = System.getProperty("java.home");
+      String jdkHome = javaHome.substring(0, javaHome.indexOf("/jre"));
+
+      String targetDir = createResourceFile("").getParent();
+      URLClassLoader loader = new URLClassLoader(
+         new URL[]
+         {
+            new URL("file:"+targetDir+"/test-libs/jaxws-classloading-service.jar"),
+            new URL("file:"+targetDir+"/test-libs/jaxws-classloading-types.jar"),
+            new URL("file:"+jdkHome+"/lib/tools.jar")
+         },
+        Thread.currentThread().getContextClassLoader()
+      );
+
+      provider.setClassLoader(loader);
+      provider.setGenerateWsdl(true);
+      provider.setOutputDirectory(outputDirectory);
+      provider.provide("org.jboss.test.ws.jaxws.smoke.tools.service.HelloWorld");
+
+      File wsdl = new File(outputDirectory.getAbsolutePath() + "/HelloWorldService.wsdl");
+
+      assertTrue("WSDL not generated", wsdl.exists());
+      Element root = DOMUtils.parse( new FileInputStream(wsdl));
+      Element serviceElement = DOMUtils.getFirstChildElement(root, "service");
+      assertEquals(serviceElement.getAttribute("name"), "HelloWorldService");
+   }
+
+   /**
+    * Sets the PrintStream to use for status feedback. The simplest example
+    * would be to use System.out.
+    *
+    */
+   public void testMessageStream() throws Exception
+   {
+
+      if(isIntegrationMetro())
+      {
+         System.out.println("FIXME [JBWS-1777] WSProvide output is not correctly redirected");
+         return;
+      }
+
+      ByteArrayOutputStream bout = new ByteArrayOutputStream();
+      PrintStream pout = new PrintStream(bout);
+
+      provider.setMessageStream(pout);
+      provide();
+
+      String messageOut = new String(bout.toByteArray());
+
+      System.out.println("-- Begin captured output --");
+      System.out.println(messageOut);
+      System.out.println("-- End captured output --");
+
+      assertTrue("Provider messages not correctly redirected",
+        messageOut.indexOf("org/jboss/test/ws/jaxws/smoke/tools/jaxws/Add.class") != -1 );
+   }
+
+   private void provide() throws Exception
+   {
+      //provider.setGenerateSource(true);
+      provider.setOutputDirectory(outputDirectory);
+      provider.provide(CalculatorBean.class);
+   }
+}

Copied: framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderPluginDelegate.java (from rev 7417, framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderPluginDelegate.java)
===================================================================
--- framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderPluginDelegate.java	                        (rev 0)
+++ framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderPluginDelegate.java	2008-06-06 19:31:34 UTC (rev 7419)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ws.jaxws.smoke.tools;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public interface WSProviderPluginDelegate
+{
+   void testGenerateWsdl() throws Exception;
+
+   void testGenerateSource() throws Exception;
+
+   void testOutputDirectory() throws Exception;
+
+   void testResourceDirectory() throws Exception;
+
+   void testSourceDirectory() throws Exception;
+
+   void testClassLoader() throws Exception;
+
+   void testMessageStream() throws Exception;
+}

Modified: framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderTestCase.java
===================================================================
--- framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderTestCase.java	2008-06-06 19:27:32 UTC (rev 7418)
+++ framework/branches/jbossws-framework-3.0.2/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderTestCase.java	2008-06-06 19:31:34 UTC (rev 7419)
@@ -21,209 +21,65 @@
  */
 package org.jboss.test.ws.jaxws.smoke.tools;
 
-import org.jboss.wsf.common.DOMUtils;
-import org.jboss.wsf.spi.tools.WSContractProvider;
-import org.jboss.wsf.test.JBossWSTest;
-import org.w3c.dom.Element;
-
-import javax.xml.bind.annotation.XmlRootElement;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.PrintStream;
-import java.net.URL;
-import java.net.URLClassLoader;
-
 /**
  * @author Heiko.Braun at jboss.com
  * @version $Revision$
  */
-public class WSProviderTestCase extends JBossWSTest
+public class WSProviderTestCase extends PluginBase implements WSProviderPluginDelegate
 {
-   // tools delegate
-   WSContractProvider provider;
-
-   // redirect tools message to System.out ? 
-   boolean toogleMessageOut = false;
-
-   // relative to test execution
-   File outputDirectory;
-
+   /**
+    * Recreates a tools delegate for every test
+    * @throws Exception
+    */
    protected void setUp() throws Exception
    {
-      super.setUp();
+   
 
-       // create a new consumer for every test case
-      provider = WSContractProvider.newInstance();
-      if(toogleMessageOut) provider.setMessageStream(System.out);
+      maskClasspath();
 
-      // shared output directory, relative to test execution
-      outputDirectory = new File("wsprovide/java");      
-   }
+      Class wspClass = Thread.currentThread().getContextClassLoader()
+        .loadClass("org.jboss.test.ws.jaxws.smoke.tools.WSProviderPlugin");
+      delegate = wspClass.newInstance();
+    }
 
-   private ClassLoader getArtefactClassLoader() throws Exception {
-      URLClassLoader loader = new URLClassLoader(new URL[] {
-        new URL("file:"+System.getProperty("user.dir")+"/wsprovide/java/") }
-      );
 
-      return loader;
+   protected void tearDown() throws Exception
+   {
+      unmaskClasspath();
    }
 
-   /**
-    * Enables/Disables WSDL generation.
-    *
-    */
    public void testGenerateWsdl() throws Exception
    {
-      provider.setGenerateWsdl(true);
-      provide();
-
-      verifyWSDL(outputDirectory);
+      dispatch("testGenerateWsdl");
    }
 
-   /**
-    * Enables/Disables Java source generation.
-    *
-    */
    public void testGenerateSource() throws Exception
    {
-      provider.setGenerateSource(true);
-      provide();
-
-      verifyJavaSource(outputDirectory);
-
+      dispatch("testGenerateSource");
    }
 
-   private void verifyJavaSource(File directory)
-   {
-      File javaSource = new File(
-        directory.getAbsolutePath()+
-          "/org/jboss/test/ws/jaxws/smoke/tools/jaxws/AddResponse.java"
-        );
-
-      assertTrue("Source not generated", javaSource.exists());
-   }
-
-   /**
-    * Sets the main output directory.
-    * If the directory does not exist, it will be created.    
-    */
    public void testOutputDirectory() throws Exception
    {
-      provide();
-      ClassLoader loader = getArtefactClassLoader();
-      Class responseWrapper = loader.loadClass("org.jboss.test.ws.jaxws.smoke.tools.jaxws.AddResponse");
-      XmlRootElement rootElement = (XmlRootElement) responseWrapper.getAnnotation(XmlRootElement.class);
-      assertNotNull("@XmlRootElement missing form response wrapper", rootElement);
-      assertEquals("Wrong namespace", rootElement.namespace(), "http://foo.bar.com/calculator");
+      dispatch("testOutputDirectory");
    }
 
-   /**
-    * Sets the resource directory. This directory will contain any generated
-    * WSDL and XSD files. If the directory does not exist, it will be created.
-    * If not specified, the output directory will be used instead.
-    *     
-    */
    public void testResourceDirectory() throws Exception
    {
-      File directory = new File("wsprovide/resources");
-      provider.setResourceDirectory(directory);
-      provide();
-
-      verifyWSDL(directory);
+      dispatch("testResourceDirectory");
    }
 
-   private void verifyWSDL(File directory) throws Exception
-   {
-      File wsdl = new File(
-        outputDirectory.getAbsolutePath()+
-          "/CalculatorBeanService.wsdl"
-      );
-
-      assertTrue("WSDL not generated", wsdl.exists());
-      Element root = DOMUtils.parse( new FileInputStream(wsdl));
-      Element serviceElement = DOMUtils.getFirstChildElement(root, "service");
-      assertEquals(serviceElement.getAttribute("name"), "CalculatorBeanService");
-   }
-
-   /**
-    * Sets the source directory. This directory will contain any generated Java source.
-    * If the directory does not exist, it will be created. If not specified,
-    * the output directory will be used instead.
-    *
-    */
    public void testSourceDirectory() throws Exception
    {
-      File sourceDir = new File("wsprovide/sources");
-      provider.setSourceDirectory(sourceDir);
-      provider.setGenerateSource(true);
-      provide();
-
-      verifyJavaSource(sourceDir);
+      dispatch("testSourceDirectory");
    }
 
-   /**
-    * Sets the ClassLoader used to discover types.
-    * This defaults to the one used in instantiation.
-    *
-    */
    public void testClassLoader() throws Exception
    {
-      URLClassLoader loader = new URLClassLoader(
-         new URL[]
-         {
-            new URL("file:"+System.getProperty("user.dir")+"/libs/jaxws-tools-classloading-service.jar"),
-            new URL("file:"+System.getProperty("user.dir")+"/libs/jaxws-tools-classloading-types.jar")
-         }
-      );
-      provider.setClassLoader(loader);
-      provider.setGenerateWsdl(true);
-      provider.setOutputDirectory(outputDirectory);
-      provider.provide("org.jboss.test.ws.jaxws.smoke.tools.service.HelloWorld");
-
-      File wsdl = new File(outputDirectory.getAbsolutePath() + "/HelloWorldService.wsdl");
-
-      assertTrue("WSDL not generated", wsdl.exists());
-      Element root = DOMUtils.parse( new FileInputStream(wsdl));
-      Element serviceElement = DOMUtils.getFirstChildElement(root, "service");
-      assertEquals(serviceElement.getAttribute("name"), "HelloWorldService");
+      dispatch("testClassLoader");
    }
 
-   /**
-    * Sets the PrintStream to use for status feedback. The simplest example
-    * would be to use System.out.
-    *
-    */
    public void testMessageStream() throws Exception
    {
-
-      if(isIntegrationMetro())
-      {
-         System.out.println("FIXME [JBWS-1777] WSProvide output is not correctly redirected");
-         return;
-      }
-
-      ByteArrayOutputStream bout = new ByteArrayOutputStream();
-      PrintStream pout = new PrintStream(bout);
-
-      provider.setMessageStream(pout);
-      provide();
-
-      String messageOut = new String(bout.toByteArray());
-      
-      System.out.println("-- Begin captured output --");
-      System.out.println(messageOut);
-      System.out.println("-- End captured output --");
-
-      assertTrue("Provider messages not correctly redirected",
-        messageOut.indexOf("org/jboss/test/ws/jaxws/smoke/tools/jaxws/Add.class") != -1 );
+      dispatch("testMessageStream");
    }
-
-   private void provide() throws Exception
-   {
-      //provider.setGenerateSource(true);
-      provider.setOutputDirectory(outputDirectory);
-      provider.provide(CalculatorBean.class);
-   }
-
 }




More information about the jbossws-commits mailing list