[jbossws-commits] JBossWS SVN: r14238 - framework/branches/jbossws-framework-2.0.1.GA_CP/src/test/java/org/jboss/test/ws/jaxws/smoke/tools.
jbossws-commits at lists.jboss.org
jbossws-commits at lists.jboss.org
Wed May 4 03:35:12 EDT 2011
Author: bmaxwell
Date: 2011-05-04 03:35:11 -0400 (Wed, 04 May 2011)
New Revision: 14238
Added:
framework/branches/jbossws-framework-2.0.1.GA_CP/src/test/java/org/jboss/test/ws/jaxws/smoke/tools/PluginBase.java
framework/branches/jbossws-framework-2.0.1.GA_CP/src/test/java/org/jboss/test/ws/jaxws/smoke/tools/StackConfigurable.java
framework/branches/jbossws-framework-2.0.1.GA_CP/src/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderPluginDelegate.java
Modified:
framework/branches/jbossws-framework-2.0.1.GA_CP/src/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderPlugin.java
framework/branches/jbossws-framework-2.0.1.GA_CP/src/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderTestCase.java
Log:
[JBPAPP-6253] backporting additional classes to make testcase compile
Added: framework/branches/jbossws-framework-2.0.1.GA_CP/src/test/java/org/jboss/test/ws/jaxws/smoke/tools/PluginBase.java
===================================================================
--- framework/branches/jbossws-framework-2.0.1.GA_CP/src/test/java/org/jboss/test/ws/jaxws/smoke/tools/PluginBase.java (rev 0)
+++ framework/branches/jbossws-framework-2.0.1.GA_CP/src/test/java/org/jboss/test/ws/jaxws/smoke/tools/PluginBase.java 2011-05-04 07:35:11 UTC (rev 14238)
@@ -0,0 +1,154 @@
+/*
+ * 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.Arrays;
+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 abstract class PluginBase extends JBossWSTest
+{
+ protected Object delegate = null;
+ protected ClassLoader origClassLoader;
+ protected String oldCPProp;
+ protected boolean integrationNative = false;
+ protected boolean integrationMetro = false;
+ protected boolean integrationCXF = false;
+
+ protected void dispatch(String methodName) throws Exception
+ {
+ try
+ {
+ delegate.getClass().getMethod(methodName).invoke(delegate);
+ }
+ catch (InvocationTargetException e)
+ {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ protected void setDelegate(Class<?> clazz) throws Exception
+ {
+ delegate = clazz.newInstance();
+ List<String> list = new LinkedList<String>();
+ for (Class<?> c : clazz.getInterfaces())
+ {
+ list.add(c.getName());
+ }
+ if (list.contains(StackConfigurable.class.getName()))
+ {
+ clazz.getMethod("setIntegrationNative", boolean.class).invoke(delegate, integrationNative);
+ clazz.getMethod("setIntegrationMetro", boolean.class).invoke(delegate, integrationMetro);
+ clazz.getMethod("setIntegrationCXF", boolean.class).invoke(delegate, integrationCXF);
+ }
+ }
+
+ protected void setupClasspath() throws Exception
+ {
+ if (!(integrationCXF || integrationMetro || integrationNative))
+ {
+ //the integration stack is not set yet, doing it before mangling with the classpath
+ readIntegrationStack();
+ }
+ String classpath = System.getProperty("surefire.test.class.path");
+ if (classpath == null) //no maven surefire classpath hacks required
+ return;
+ 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
+ {
+ if( filtered(s) )
+ continue;
+ 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);
+ this.oldCPProp = System.getProperty("java.class.path");
+ System.setProperty("java.class.path", jarURLString.toString());
+ }
+
+ protected abstract boolean filtered(String jarName);
+
+ protected void restoreClasspath()
+ {
+ if(this.origClassLoader !=null)
+ {
+ Thread.currentThread().setContextClassLoader(this.origClassLoader);
+ this.origClassLoader = null;
+ System.setProperty("java.class.path", oldCPProp);
+ }
+ }
+
+ protected void readIntegrationStack()
+ {
+ this.integrationNative = isIntegrationNative();
+ this.integrationMetro = isIntegrationMetro();
+ this.integrationCXF = isIntegrationCXF();
+ }
+
+ // JBPAPP-6253 - Implement support for SOAP12 protocol in wsprovide - in JBossWS 2.x - CXF / Metro stacks don't exist
+ private boolean isIntegrationMetro()
+ {
+ return false;
+ }
+ private boolean isIntegrationCXF()
+ {
+ return false;
+ }
+}
Added: framework/branches/jbossws-framework-2.0.1.GA_CP/src/test/java/org/jboss/test/ws/jaxws/smoke/tools/StackConfigurable.java
===================================================================
--- framework/branches/jbossws-framework-2.0.1.GA_CP/src/test/java/org/jboss/test/ws/jaxws/smoke/tools/StackConfigurable.java (rev 0)
+++ framework/branches/jbossws-framework-2.0.1.GA_CP/src/test/java/org/jboss/test/ws/jaxws/smoke/tools/StackConfigurable.java 2011-05-04 07:35:11 UTC (rev 14238)
@@ -0,0 +1,31 @@
+/*
+ * 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;
+
+public interface StackConfigurable
+{
+ public void setIntegrationNative(boolean integrationNative);
+
+ public void setIntegrationMetro(boolean integrationMetro);
+
+ public void setIntegrationCXF(boolean integrationCXF);
+}
Modified: framework/branches/jbossws-framework-2.0.1.GA_CP/src/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderPlugin.java
===================================================================
--- framework/branches/jbossws-framework-2.0.1.GA_CP/src/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderPlugin.java 2011-05-04 07:03:29 UTC (rev 14237)
+++ framework/branches/jbossws-framework-2.0.1.GA_CP/src/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderPlugin.java 2011-05-04 07:35:11 UTC (rev 14238)
@@ -126,6 +126,7 @@
+ "jaxws" + FS + "GetKeysResponse.java");
assertTrue("Source not generated", javaSource.exists());
String contents;
+
if (isIntegrationCXF())
{
System.out.println("FIXME: [JBWS-2507] Support generics in wrapper classes");
@@ -295,6 +296,7 @@
public void testMessageStream() throws Exception
{
+
if(isIntegrationMetro())
{
System.out.println("FIXME: [JBWS-1777] WSProvide output is not correctly redirected");
@@ -306,6 +308,7 @@
return;
}
+
ByteArrayOutputStream bout = new ByteArrayOutputStream();
PrintStream pout = new PrintStream(bout);
@@ -332,6 +335,36 @@
provider.setOutputDirectory(outputDirectory);
//JBWS-2479: using different beans because the whole smoke tools test is supposed to be run for every stack
//and we can't afford excluding it for Metro just because of JBWS-2479
- provider.provide(!isIntegrationMetro() ? CalculatorBean.class : CalculatorBeanNoAdapter.class);
+
+ // JBPAPP-6253 - Metro doesn't exist in JBossWS 2.x
+ //provider.provide(!isIntegrationMetro() ? CalculatorBean.class : CalculatorBeanNoAdapter.class);
+ provider.provide(CalculatorBean.class);
}
+
+ // JBPAPP-6253 - Implement support for SOAP12 protocol in wsprovide - in JBossWS 2.x - CXF / Metro stacks don't exist
+ private boolean isIntegrationCXF()
+ {
+ return false;
+ }
+
+ private boolean isIntegrationMetro()
+ {
+ return false;
+ }
+
+ private static final String SYSPROP_TEST_RESOURCES_DIRECTORY = "test.resources.directory";
+ private static String testResourcesDir;
+ public File createResourceFile(String filename)
+ {
+ File resDir = new File(getTestResourcesDir());
+ File file = new File(resDir.getAbsolutePath() + File.separator + filename);
+ return file;
+ }
+ public static String getTestResourcesDir()
+ {
+ if (testResourcesDir == null)
+ testResourcesDir = System.getProperty(SYSPROP_TEST_RESOURCES_DIRECTORY);
+
+ return testResourcesDir;
+ }
}
Added: framework/branches/jbossws-framework-2.0.1.GA_CP/src/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderPluginDelegate.java
===================================================================
--- framework/branches/jbossws-framework-2.0.1.GA_CP/src/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderPluginDelegate.java (rev 0)
+++ framework/branches/jbossws-framework-2.0.1.GA_CP/src/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderPluginDelegate.java 2011-05-04 07:35:11 UTC (rev 14238)
@@ -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-2.0.1.GA_CP/src/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderTestCase.java
===================================================================
--- framework/branches/jbossws-framework-2.0.1.GA_CP/src/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderTestCase.java 2011-05-04 07:03:29 UTC (rev 14237)
+++ framework/branches/jbossws-framework-2.0.1.GA_CP/src/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderTestCase.java 2011-05-04 07:35:11 UTC (rev 14238)
@@ -38,7 +38,7 @@
* @author Heiko.Braun at jboss.com
* @version $Revision$
*/
-public class WSProviderTestCase extends JBossWSTest
+public class WSProviderTestCase extends PluginBase
{
// tools delegate
WSContractProvider provider;
@@ -214,4 +214,17 @@
provider.provide(CalculatorBean.class);
}
+ /**
+ * Filter sun jaxws implementation because it clashes
+ * with the native one (ServiceLoader...)
+ * @param jarName
+ * @return
+ */
+ protected boolean filtered(String jarName)
+ {
+ return (isIntegrationNative() &&
+ (jarName.indexOf("jaxws-rt")!=-1 || jarName.indexOf("jaxws-tools")!=-1)
+ );
+ }
+
}
More information about the jbossws-commits
mailing list