Author: alessio.soldano(a)jboss.com
Date: 2013-05-16 06:29:30 -0400 (Thu, 16 May 2013)
New Revision: 17587
Added:
stack/cxf/trunk/modules/testsuite/test-utils/
stack/cxf/trunk/modules/testsuite/test-utils/pom.xml
stack/cxf/trunk/modules/testsuite/test-utils/src/
stack/cxf/trunk/modules/testsuite/test-utils/src/main/
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/jboss/
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/jboss/wsf/
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/jboss/wsf/test/
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/jboss/wsf/test/AppclientHelper.java
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/jboss/wsf/test/CallbackHandler.java
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/jboss/wsf/test/CleanupOperation.java
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/jboss/wsf/test/JBossWSTest.java
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/jboss/wsf/test/JBossWSTestHelper.java
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/jboss/wsf/test/JBossWSTestSetup.java
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/jboss/wsf/test/XOPTestSupport.java
stack/cxf/trunk/modules/testsuite/test-utils/src/main/resources/
stack/cxf/trunk/modules/testsuite/test-utils/src/test/
stack/cxf/trunk/modules/testsuite/test-utils/src/test/etc/
stack/cxf/trunk/modules/testsuite/test-utils/src/test/etc/tst.policy
stack/cxf/trunk/modules/testsuite/test-utils/src/test/java/
stack/cxf/trunk/modules/testsuite/test-utils/src/test/resources/
Modified:
stack/cxf/trunk/modules/dist/pom.xml
stack/cxf/trunk/modules/dist/src/main/scripts/assembly-bin-dist.xml
stack/cxf/trunk/modules/dist/src/main/scripts/assembly-deploy-artifacts.xml
stack/cxf/trunk/modules/dist/src/main/scripts/assembly-src-dist.xml
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/pom.xml
stack/cxf/trunk/modules/testsuite/cxf-tests/pom.xml
stack/cxf/trunk/modules/testsuite/pom.xml
stack/cxf/trunk/modules/testsuite/shared-tests/pom.xml
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/ant-import/build-testsuite.xml
stack/cxf/trunk/pom.xml
Log:
[JBWS-3636] Removing dependency on jbossws-shared-testsuite, adding test util classes to a
testsuite submodule
Modified: stack/cxf/trunk/modules/dist/pom.xml
===================================================================
--- stack/cxf/trunk/modules/dist/pom.xml 2013-05-16 04:33:11 UTC (rev 17586)
+++ stack/cxf/trunk/modules/dist/pom.xml 2013-05-16 10:29:30 UTC (rev 17587)
@@ -84,19 +84,6 @@
<artifactId>jbossws-native-services</artifactId>
</dependency>
- <!--test-suite-->
- <dependency>
- <groupId>org.jboss.ws</groupId>
- <artifactId>jbossws-shared-testsuite</artifactId>
- <type>zip</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.ws</groupId>
- <artifactId>jbossws-shared-testsuite</artifactId>
- <scope>test</scope>
- </dependency>
-
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
Modified: stack/cxf/trunk/modules/dist/src/main/scripts/assembly-bin-dist.xml
===================================================================
--- stack/cxf/trunk/modules/dist/src/main/scripts/assembly-bin-dist.xml 2013-05-16
04:33:11 UTC (rev 17586)
+++ stack/cxf/trunk/modules/dist/src/main/scripts/assembly-bin-dist.xml 2013-05-16
10:29:30 UTC (rev 17587)
@@ -87,6 +87,34 @@
<include>resources/jaxws/samples/**</include>
</includes>
</fileSet>
+ <!-- Test utils -->
+ <fileSet>
+ <directory>../testsuite/test-utils/src/main</directory>
+ <outputDirectory>jbossws-cxf-bin-dist/tests</outputDirectory>
+ <includes>
+ <include>java/org/jboss/wsf/test/**</include>
+ </includes>
+ </fileSet>
+ <!-- Stack agnostic tests -->
+ <fileSet>
+ <directory>../testsuite/shared-tests/src/test</directory>
+ <outputDirectory>jbossws-cxf-bin-dist/tests</outputDirectory>
+ <includes>
+ <include>ant-import/**</include>
+ <include>java/org/jboss/test/helper/**</include>
+ <include>java/org/jboss/test/ws/jaxrpc/samples/**</include>
+ <include>java/org/jboss/test/ws/jaxws/samples/**</include>
+ <include>java/org/jboss/test/ws/jaxws/smoke/**</include>
+ <include>java/org/jboss/test/ws/appclient/**</include>
+ <include>java/org/jboss/test/ws/management/**</include>
+ <include>java/org/jboss/test/ws/saaj/**</include>
+ <include>resources/jaxrpc/samples/**</include>
+ <include>resources/jaxws/samples/**</include>
+ <include>resources/jaxws/smoke/**</include>
+ <include>resources/management/**</include>
+ <include>resources/saaj/**</include>
+ </includes>
+ </fileSet>
<!-- Appclient patches -->
<fileSet>
<directory>../testsuite/src/test/resources/</directory>
@@ -100,34 +128,4 @@
</includes>
</fileSet>
</fileSets>
-
- <dependencySets>
- <dependencySet>
- <outputDirectory>jbossws-cxf-bin-dist/tests</outputDirectory>
- <useStrictFiltering>true</useStrictFiltering>
- <unpack>true</unpack>
- <scope>test</scope>
- <includes>
- <include>*:jbossws-shared-testsuite:zip</include>
- </includes>
- <unpackOptions>
- <includes>
- <include>ant-import/**</include>
- <include>java/org/jboss/test/helper/**</include>
- <include>java/org/jboss/test/ws/jaxrpc/samples/**</include>
- <include>java/org/jboss/test/ws/jaxws/samples/**</include>
- <include>java/org/jboss/test/ws/jaxws/smoke/**</include>
- <include>java/org/jboss/test/ws/appclient/**</include>
- <include>java/org/jboss/test/ws/management/**</include>
- <include>java/org/jboss/test/ws/saaj/**</include>
- <include>resources/jaxrpc/samples/**</include>
- <include>resources/jaxws/samples/**</include>
- <include>resources/jaxws/smoke/**</include>
- <include>resources/management/**</include>
- <include>resources/saaj/**</include>
- </includes>
- </unpackOptions>
- <useProjectArtifact>false</useProjectArtifact>
- </dependencySet>
- </dependencySets>
</assembly>
Modified: stack/cxf/trunk/modules/dist/src/main/scripts/assembly-deploy-artifacts.xml
===================================================================
--- stack/cxf/trunk/modules/dist/src/main/scripts/assembly-deploy-artifacts.xml 2013-05-16
04:33:11 UTC (rev 17586)
+++ stack/cxf/trunk/modules/dist/src/main/scripts/assembly-deploy-artifacts.xml 2013-05-16
10:29:30 UTC (rev 17587)
@@ -136,17 +136,6 @@
<useProjectArtifact>false</useProjectArtifact>
</dependencySet>
- <dependencySet>
- <outputDirectory>deploy-artifacts/lib</outputDirectory>
- <unpack>false</unpack>
- <includes>
- <include>org.jboss.ws:jbossws-shared-testsuite:jar</include>
- </includes>
-
<outputFileNameMapping>${artifact.artifactId}.${artifact.extension}</outputFileNameMapping>
- <scope>test</scope>
- <useProjectArtifact>false</useProjectArtifact>
- </dependencySet>
-
<dependencySet>
<outputDirectory>deploy-artifacts/lib</outputDirectory>
<unpack>false</unpack>
Modified: stack/cxf/trunk/modules/dist/src/main/scripts/assembly-src-dist.xml
===================================================================
--- stack/cxf/trunk/modules/dist/src/main/scripts/assembly-src-dist.xml 2013-05-16
04:33:11 UTC (rev 17586)
+++ stack/cxf/trunk/modules/dist/src/main/scripts/assembly-src-dist.xml 2013-05-16
10:29:30 UTC (rev 17587)
@@ -21,19 +21,9 @@
<outputDirectory>jbossws-cxf-src-dist/modules/</outputDirectory>
<excludes>
<exclude>**/target/**</exclude>
- <exclude>**/shared-tests/**</exclude>
</excludes>
</fileSet>
<fileSet>
- <directory>../testsuite/shared-tests</directory>
-
<outputDirectory>jbossws-cxf-src-dist/modules/testsuite/shared-tests</outputDirectory>
- <includes>
- <include>src/test/etc/</include>
- <include>scripts/</include>
- <include>pom.xml</include>
- </includes>
- </fileSet>
- <fileSet>
<directory>../../</directory>
<outputDirectory>jbossws-cxf-src-dist/</outputDirectory>
<includes>
@@ -45,21 +35,4 @@
</fileSet>
</fileSets>
- <dependencySets>
- <dependencySet>
-
<outputDirectory>jbossws-cxf-src-dist/modules/testsuite/shared-tests/src/test</outputDirectory>
- <useStrictFiltering>true</useStrictFiltering>
- <scope>test</scope>
- <unpack>true</unpack>
- <includes>
- <include>*:jbossws-shared-testsuite:zip</include>
- </includes>
- <unpackOptions>
- <includes>
- <include>**/*</include>
- </includes>
- </unpackOptions>
- <useProjectArtifact>false</useProjectArtifact>
- </dependencySet>
- </dependencySets>
</assembly>
Modified: stack/cxf/trunk/modules/testsuite/cxf-spring-tests/pom.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-spring-tests/pom.xml 2013-05-16 04:33:11 UTC
(rev 17586)
+++ stack/cxf/trunk/modules/testsuite/cxf-spring-tests/pom.xml 2013-05-16 10:29:30 UTC
(rev 17587)
@@ -17,6 +17,12 @@
<dependencies>
<dependency>
<groupId>org.jboss.ws.cxf</groupId>
+ <artifactId>jbossws-cxf-test-utils</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.ws.cxf</groupId>
<artifactId>jbossws-cxf-server</artifactId>
<version>${project.version}</version>
</dependency>
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/pom.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/pom.xml 2013-05-16 04:33:11 UTC (rev
17586)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/pom.xml 2013-05-16 10:29:30 UTC (rev
17587)
@@ -26,6 +26,12 @@
<dependencies>
<dependency>
<groupId>org.jboss.ws.cxf</groupId>
+ <artifactId>jbossws-cxf-test-utils</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.ws.cxf</groupId>
<artifactId>jbossws-cxf-server</artifactId>
<version>${project.version}</version>
</dependency>
Modified: stack/cxf/trunk/modules/testsuite/pom.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/pom.xml 2013-05-16 04:33:11 UTC (rev 17586)
+++ stack/cxf/trunk/modules/testsuite/pom.xml 2013-05-16 10:29:30 UTC (rev 17587)
@@ -34,6 +34,7 @@
<!-- Modules -->
<modules>
+ <module>test-utils</module>
<module>cxf-tests</module>
<module>shared-tests</module>
</modules>
@@ -49,10 +50,6 @@
<artifactId>jbossws-common-tools</artifactId>
</dependency>
<dependency>
- <groupId>org.jboss.ws</groupId>
- <artifactId>jbossws-shared-testsuite</artifactId>
- </dependency>
- <dependency>
<groupId>gnu-getopt</groupId>
<artifactId>getopt</artifactId>
<version>${gnu.getopt.version}</version>
Modified: stack/cxf/trunk/modules/testsuite/shared-tests/pom.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/shared-tests/pom.xml 2013-05-16 04:33:11 UTC (rev
17586)
+++ stack/cxf/trunk/modules/testsuite/shared-tests/pom.xml 2013-05-16 10:29:30 UTC (rev
17587)
@@ -17,6 +17,12 @@
<!-- Dependencies -->
<dependencies>
<dependency>
+ <groupId>org.jboss.ws.cxf</groupId>
+ <artifactId>jbossws-cxf-test-utils</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
Modified:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/ant-import/build-testsuite.xml
===================================================================
---
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/ant-import/build-testsuite.xml 2013-05-16
04:33:11 UTC (rev 17586)
+++
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/ant-import/build-testsuite.xml 2013-05-16
10:29:30 UTC (rev 17587)
@@ -178,7 +178,6 @@
<path id="integration.target.client.classpath">
<!-- included from thirdparty local dir as it's not installed on AS - START
-->
<pathelement
location="${thirdparty.dir}/jbossws-${jbossws.integration.target}-tests-integration.jar"/>
- <pathelement
location="${thirdparty.dir}/jbossws-shared-testsuite.jar"/>
<!-- included from thirdparty local dir as it's not installed on AS - END
-->
<pathelement location="${jboss.home}/jboss-modules.jar"/>
<fileset dir="${jboss.home}/modules/org/jboss/logging/main/">
@@ -342,7 +341,6 @@
<path id="integration.target.client.classpath">
<!-- included from thirdparty local dir as it's not installed on AS - START
-->
<pathelement
location="${thirdparty.dir}/jbossws-${jbossws.integration.target}-tests-integration.jar"/>
- <pathelement
location="${thirdparty.dir}/jbossws-shared-testsuite.jar"/>
<!-- included from thirdparty local dir as it's not installed on AS - END
-->
<pathelement location="${jboss.home}/jboss-modules.jar"/>
<fileset
dir="${jboss.home}/modules/system/layers/base/org/jboss/logging/main/">
@@ -506,7 +504,6 @@
<path id="integration.target.client.classpath">
<!-- included from thirdparty local dir as it's not installed on AS - START
-->
<pathelement
location="${thirdparty.dir}/jbossws-${jbossws.integration.target}-tests-integration.jar"/>
- <pathelement
location="${thirdparty.dir}/jbossws-shared-testsuite.jar"/>
<!-- included from thirdparty local dir as it's not installed on AS - END
-->
<pathelement location="${jboss.home}/jboss-modules.jar"/>
<fileset
dir="${jboss.home}/modules/system/layers/base/org/jboss/logging/main/">
Property changes on: stack/cxf/trunk/modules/testsuite/test-utils
___________________________________________________________________
Added: svn:ignore
+ target
.classpath
.project
.settings
Added: stack/cxf/trunk/modules/testsuite/test-utils/pom.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/test-utils/pom.xml (rev 0)
+++ stack/cxf/trunk/modules/testsuite/test-utils/pom.xml 2013-05-16 10:29:30 UTC (rev
17587)
@@ -0,0 +1,35 @@
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <name>JBoss Web Services - Stack CXF Test utils</name>
+ <artifactId>jbossws-cxf-test-utils</artifactId>
+ <packaging>jar</packaging>
+
+ <!-- Parent -->
+ <parent>
+ <groupId>org.jboss.ws.cxf</groupId>
+ <artifactId>jbossws-cxf-testsuite</artifactId>
+ <version>4.2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.ws</groupId>
+ <artifactId>jbossws-common</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+</project>
Added:
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/jboss/wsf/test/AppclientHelper.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/jboss/wsf/test/AppclientHelper.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/jboss/wsf/test/AppclientHelper.java 2013-05-16
10:29:30 UTC (rev 17587)
@@ -0,0 +1,278 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat, Inc., 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.wsf.test;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.jboss.ws.common.concurrent.CopyJob;
+import org.jboss.ws.common.io.TeeOutputStream;
+
+/**
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+final class AppclientHelper
+{
+
+ private static final String JBOSS_HOME = System.getProperty("jboss.home");
+ private static final String FS = System.getProperty("file.separator"); //
'/' on unix, '\' on windows
+ private static final String PS = System.getProperty("path.separator"); //
':' on unix, ';' on windows
+ private static final String EXT = ":".equals(PS) ? ".sh" :
".bat";
+ private static final String appclientScript = JBOSS_HOME + FS + "bin" + FS +
"appclient" + EXT;
+ private static final Semaphore s = new Semaphore(1, true); //one appclient only can be
running at the same time ATM
+ private static Map<String, AppclientProcess> appclients = new HashMap<String,
AppclientProcess>(1);
+ private static ExecutorService executors =
Executors.newCachedThreadPool(AppclientDaemonFactory.INSTANCE);
+ private static String appclientOutputDir;
+
+ private static class AppclientProcess {
+ public Process process;
+ public CopyJob outTask;
+ public CopyJob errTask;
+ public OutputStream output;
+ public OutputStream log;
+ }
+
+ private AppclientHelper()
+ {
+ // forbidden instantiation
+ }
+
+ static Process deployAppclient(final String archive, final OutputStream appclientOS,
final String... appclientArgs) throws Exception
+ {
+ final AppclientProcess ap = newAppclientProcess(archive, appclientOS,
appclientArgs);
+ final String appclientEarName = getAppclientEarName(archive);
+ final String appclientFullName = getAppclientFullName(archive);
+ final String patternToMatch = "Deployed \"" + appclientEarName +
"\"";
+ final String errorMessage = "Cannot deploy " + appclientFullName + "
to appclient";
+ awaitOutput(ap.output, patternToMatch, errorMessage);
+ appclients.put(archive, ap);
+ return ap.process;
+ }
+
+ static void undeployAppclient(final String archive, boolean awaitShutdown) throws
Exception
+ {
+ final AppclientProcess ap = appclients.remove(archive);
+ try
+ {
+ if (awaitShutdown)
+ {
+ shutdownAppclient(archive, ap.output);
+ }
+ }
+ finally
+ {
+ s.release();
+ //NPE checks to avoid hiding other exceptional conditions that led to premature
undeploy..
+ if (ap != null) {
+ if (ap.output != null) {
+ ap.outTask.kill();
+ }
+ if (ap.errTask != null) {
+ ap.errTask.kill();
+ }
+ if (ap.process != null) {
+ ap.process.destroy();
+ }
+ if (ap.log != null) {
+ ap.log.close();
+ }
+ }
+ }
+ }
+
+ private static AppclientProcess newAppclientProcess(final String archive, final
OutputStream appclientOS, final String... appclientArgs) throws Exception
+ {
+ s.acquire();
+ try {
+ final String killFileName = getKillFileName(archive);
+ final String appclientFullName = getAppclientFullName(archive);
+ final String appclientShortName = getAppclientShortName(archive);
+ final AppclientProcess ap = new AppclientProcess();
+ ap.output = new ByteArrayOutputStream();
+ final List<String> args = new LinkedList<String>();
+ args.add(appclientScript);
+ args.add("--appclient-config=appclient-ws.xml");
+ args.add(appclientFullName);
+ if (appclientOS == null)
+ {
+ args.add(killFileName);
+ }
+ else
+ {
+ // propagate appclient args
+ for (final String appclientArg : appclientArgs)
+ {
+ args.add(appclientArg);
+ }
+ }
+
+ ap.log = new FileOutputStream(new File(getAppclientOutputDir(),
appclientShortName + ".log-" + System.currentTimeMillis()));
+ final OutputStream logOutputStreams = (appclientOS == null) ? ap.log : new
TeeOutputStream(ap.log, appclientOS);
+ printLogTrailer(logOutputStreams, appclientFullName);
+
+ final ProcessBuilder pb = new ProcessBuilder().command(args);
+ // always propagate IPv6 related properties
+ final StringBuilder javaOptsValue = new StringBuilder();
+
javaOptsValue.append("-Djboss.bind.address=").append(undoIPv6Brackets(System.getProperty("jboss.bind.address",
"localhost"))).append(" ");
+
javaOptsValue.append("-Djava.net.preferIPv4Stack=").append(System.getProperty("java.net.preferIPv4Stack",
"true")).append(" ");
+
javaOptsValue.append("-Djava.net.preferIPv6Addresses=").append(System.getProperty("java.net.preferIPv6Addresses",
"false")).append(" ");
+ pb.environment().put("JAVA_OPTS", javaOptsValue.toString());
+ ap.process = pb.start();
+ // appclient out
+ ap.outTask = new CopyJob(ap.process.getInputStream(), new
TeeOutputStream(ap.output, logOutputStreams));
+ // appclient err
+ ap.errTask = new CopyJob(ap.process.getErrorStream(), ap.log);
+ // unfortunately the following threads are needed because of Windows behavior
+ executors.submit(ap.outTask);
+ executors.submit(ap.errTask);
+ return ap;
+ } catch (Exception e) {
+ s.release();
+ throw e;
+ }
+ }
+
+ private static void printLogTrailer(OutputStream logOutputStreams, String
appclientFullName) {
+ final PrintWriter pw = new PrintWriter(logOutputStreams);
+ pw.write("Starting appclient process: " + appclientFullName +
"...\n");
+ pw.flush();
+ }
+
+ private static String undoIPv6Brackets(final String s)
+ {
+ return s.startsWith("[") ? s.substring(1, s.length() - 1) : s;
+ }
+
+ private static void shutdownAppclient(final String archive, final OutputStream os)
throws IOException, InterruptedException
+ {
+ final File killFile = new File(getKillFileName(archive));
+ killFile.createNewFile();
+ final String appclientFullName = getAppclientFullName(archive);
+ final String patternToMatch = "stopped in";
+ final String errorMessage = "Cannot undeploy " + appclientFullName +
" from appclient";
+ try
+ {
+ awaitOutput(os, patternToMatch, errorMessage);
+ }
+ finally
+ {
+ if (!killFile.delete())
+ {
+ killFile.deleteOnExit();
+ }
+ }
+ }
+
+ private static void awaitOutput(final OutputStream os, final String patternToMatch,
final String errorMessage) throws InterruptedException {
+ int countOfAttempts = 0;
+ final int maxCountOfAttempts = 120; // max wait time: 2 minutes
+ while (!os.toString().contains(patternToMatch))
+ {
+ Thread.sleep(1000);
+ if (countOfAttempts++ == maxCountOfAttempts)
+ {
+ throw new RuntimeException(errorMessage);
+ }
+ }
+ }
+
+ private static String getKillFileName(final String archive)
+ {
+ final int sharpIndex = archive.indexOf('#');
+ return JBOSS_HOME + FS + "bin" + FS + archive.substring(sharpIndex + 1) +
".kill";
+ }
+
+ private static String getAppclientOutputDir()
+ {
+ if (appclientOutputDir == null)
+ {
+ appclientOutputDir = System.getProperty("appclient.output.dir");
+ if (appclientOutputDir == null)
+ {
+ throw new IllegalStateException("System property appclient.output.dir
not configured");
+ }
+ final File appclientOutputDirectory = new File(appclientOutputDir);
+ if (!appclientOutputDirectory.exists())
+ {
+ if (!appclientOutputDirectory.mkdirs())
+ {
+ throw new IllegalStateException("Unable to create directory " +
appclientOutputDir);
+ }
+ }
+ }
+ return appclientOutputDir;
+ }
+
+ private static String getAppclientFullName(final String archive)
+ {
+ final int sharpIndex = archive.indexOf('#');
+ final String earName = archive.substring(0, sharpIndex);
+ return JBossWSTestHelper.getArchiveFile(earName).getParent() + FS + archive;
+ }
+
+ private static String getAppclientShortName(final String archive)
+ {
+ final int sharpIndex = archive.indexOf('#');
+ return archive.substring(sharpIndex + 1);
+ }
+
+ private static String getAppclientEarName(final String archive)
+ {
+ final int sharpIndex = archive.indexOf('#');
+ return archive.substring(0, sharpIndex);
+ }
+
+ // [JBPAPP-10027] appclient threads are always daemons (to don't block JVM
shutdown)
+ private static class AppclientDaemonFactory implements ThreadFactory {
+ static final AppclientDaemonFactory INSTANCE = new AppclientDaemonFactory();
+ final ThreadGroup group;
+ final AtomicInteger threadNumber = new AtomicInteger(1);
+ final String namePrefix;
+
+ AppclientDaemonFactory() {
+ group = Thread.currentThread().getThreadGroup();
+ namePrefix = "appclient-output-processing-daemon-";
+ }
+
+ public Thread newThread(final Runnable r) {
+ final Thread t = new Thread(group, r, namePrefix +
threadNumber.getAndIncrement());
+ t.setDaemon(true);
+ t.setPriority(Thread.NORM_PRIORITY);
+ return t;
+ }
+ }
+
+}
Added:
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/jboss/wsf/test/CallbackHandler.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/jboss/wsf/test/CallbackHandler.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/jboss/wsf/test/CallbackHandler.java 2013-05-16
10:29:30 UTC (rev 17587)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2012 Red Hat Inc. and/or its affiliates and other contributors
+ * as indicated by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.wsf.test;
+
+import java.io.IOException;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.sasl.RealmCallback;
+
+/**
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+public final class CallbackHandler implements
javax.security.auth.callback.CallbackHandler
+{
+ @Override
+ public void handle(final Callback[] callbacks) throws IOException,
UnsupportedCallbackException
+ {
+ for (final Callback current : callbacks)
+ {
+ if(current instanceof NameCallback)
+ {
+ ((NameCallback) current).setName("$local");
+ }
+ else if (current instanceof RealmCallback)
+ {
+ ((RealmCallback) current).setText(((RealmCallback)
current).getDefaultText());
+ }
+ }
+ }
+}
+
Added:
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/jboss/wsf/test/CleanupOperation.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/jboss/wsf/test/CleanupOperation.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/jboss/wsf/test/CleanupOperation.java 2013-05-16
10:29:30 UTC (rev 17587)
@@ -0,0 +1,27 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, 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.wsf.test;
+
+public interface CleanupOperation
+{
+ void cleanUp();
+}
Added:
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/jboss/wsf/test/JBossWSTest.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/jboss/wsf/test/JBossWSTest.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/jboss/wsf/test/JBossWSTest.java 2013-05-16
10:29:30 UTC (rev 17587)
@@ -0,0 +1,455 @@
+/*
+ * 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.wsf.test;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+import javax.management.MBeanServerConnection;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import junit.framework.TestCase;
+
+import org.jboss.logging.Logger;
+import org.jboss.ws.common.DOMWriter;
+import org.jboss.ws.common.concurrent.CopyJob;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Base class for JBossWS test cases.
+ *
+ * @author <a href="mailto:tdiesler@redhat.com">Thomas Diesler</a>
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:alessio.soldano@jboss.com">Alessio
Soldano</a>
+ */
+public abstract class JBossWSTest extends TestCase
+{
+ protected static Logger log = Logger.getLogger(JBossWSTest.class.getName());
+
+ public JBossWSTest()
+ {
+ }
+
+ public JBossWSTest(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Execute <b>command</b> in separate process.
+ * @param command command to execute
+ * @throws IOException if I/O error occurs
+ */
+ public static void executeCommand(String command) throws IOException
+ {
+ executeCommand(command, null, null, null);
+ }
+
+ /**
+ * Execute <b>command</b> in separate process. If process will fail,
display custom <b>message</b> in assertion.
+ * @param command command to execute
+ * @param message message to display if assertion fails
+ * @throws IOException if I/O error occurs
+ */
+ public static void executeCommand(String command, String message) throws IOException
+ {
+ executeCommand(command, null, message, null);
+ }
+
+ /**
+ * Execute <b>command</b> in separate process, copy process input to
<b>os</b>.
+ * @param command command to execute
+ * @param os output stream to copy process input to. If null,
<b>System.out</b> will be used
+ * @throws IOException if I/O error occurs
+ */
+ public static void executeCommand(String command, OutputStream os) throws IOException
+ {
+ executeCommand(command, os, null, null);
+ }
+
+ /**
+ * Execute <b>command</b> in separate process, copy process input to
<b>os</b>. If process will fail, display custom <b>message</b> in
assertion.
+ * @param command command to execute
+ * @param os output stream to copy process input to. If null,
<b>System.out</b> will be used
+ * @param message message to display if assertion fails
+ * @throws IOException if I/O error occurs
+ */
+ public static void executeCommand(String command, OutputStream os, String message)
throws IOException
+ {
+ executeCommand(command, os, message, null);
+ }
+
+ /**
+ * Execute <b>command</b> in separate process, copy process input to
<b>os</b>. If process will fail, display custom <b>message</b> in
assertion.
+ * @param command command to execute
+ * @param os output stream to copy process input to. If null,
<b>System.out</b> will be used
+ * @param message message to display if assertion fails
+ * @param env environment
+ * @throws IOException if I/O error occurs
+ */
+ public static void executeCommand(String command, OutputStream os, String message,
Map<String, String> env) throws IOException
+ {
+ if (command == null)
+ throw new NullPointerException( "Command cannot be null" );
+
+ log.info("Executing command: " + command);
+
+ StringTokenizer st = new StringTokenizer(command, " \t\r");
+ List<String> tokenizedCommand = new LinkedList<String>();
+ while (st.hasMoreTokens())
+ {
+ // PRECONDITION: command doesn't contain whitespaces in the paths
+ tokenizedCommand.add(st.nextToken());
+ }
+
+ try
+ {
+ executeCommand(tokenizedCommand, os, message, env);
+ }
+ catch (IOException e)
+ {
+ log.warn("Make sure there are no whitespaces in command paths", e);
+ throw e;
+ }
+ }
+
+ /**
+ * Execute <b>command</b> in separate process, copy process input to
<b>os</b>. If process will fail, display custom <b>message</b> in
assertion.
+ * @param command command to execute
+ * @param os output stream to copy process input to. If null,
<b>System.out</b> will be used
+ * @param message message to display if assertion fails
+ * @param env environment
+ * @throws IOException if I/O error occurs
+ */
+ private static void executeCommand(List<String> command, OutputStream os, String
message, Map<String, String> env) throws IOException
+ {
+ ProcessBuilder pb = new ProcessBuilder(command);
+ if (env != null)
+ {
+ for (String variable : env.keySet())
+ {
+ pb.environment().put(variable, env.get(variable));
+ }
+ }
+ Process p = pb.start();
+ CopyJob inputStreamJob = new CopyJob(p.getInputStream(), os == null ? System.out :
os);
+ CopyJob errorStreamJob = new CopyJob(p.getErrorStream(), System.err);
+ // unfortunately the following threads are needed because of Windows behavior
+ System.out.println("Process input stream:");
+ System.err.println("Process error stream:");
+ Thread inputJob = new Thread(inputStreamJob);
+ Thread outputJob = new Thread(errorStreamJob);
+ try
+ {
+ inputJob.start();
+ inputJob.join(5000);
+ outputJob.start();
+ outputJob.join(5000);
+ int statusCode = p.waitFor();
+ String fallbackMessage = "Process did exit with status " + statusCode;
+ assertTrue(message != null ? message : fallbackMessage, statusCode == 0);
+ }
+ catch (InterruptedException ie)
+ {
+ ie.printStackTrace(System.err);
+ }
+ finally
+ {
+ inputStreamJob.kill();
+ errorStreamJob.kill();
+ p.destroy();
+ }
+ }
+
+ public static MBeanServerConnection getServer() throws NamingException
+ {
+ return JBossWSTestHelper.getServer();
+ }
+
+ public static boolean isTargetJBoss7()
+ {
+ return JBossWSTestHelper.isTargetJBoss7();
+ }
+
+ public static boolean isTargetJBoss71()
+ {
+ return JBossWSTestHelper.isTargetJBoss71();
+ }
+
+ public static boolean isTargetJBoss72()
+ {
+ return JBossWSTestHelper.isTargetJBoss72();
+ }
+
+ public static boolean isIntegrationNative()
+ {
+ return JBossWSTestHelper.isIntegrationNative();
+ }
+
+ public static boolean isIntegrationCXF()
+ {
+ return JBossWSTestHelper.isIntegrationCXF();
+ }
+
+ public static void deploy(String archive) throws Exception
+ {
+ JBossWSTestHelper.deploy(archive);
+ }
+
+ public static void undeploy(String archive) throws Exception
+ {
+ JBossWSTestHelper.undeploy(archive);
+ }
+
+ public static String getServerHost()
+ {
+ return JBossWSTestHelper.getServerHost();
+ }
+
+ public static File getArchiveFile(String archive)
+ {
+ return JBossWSTestHelper.getArchiveFile(archive);
+ }
+
+ public static URL getArchiveURL(String archive) throws MalformedURLException
+ {
+ return JBossWSTestHelper.getArchiveURL(archive);
+ }
+
+ public static File getResourceFile(String resource)
+ {
+ return JBossWSTestHelper.getResourceFile(resource);
+ }
+
+ public static URL getResourceURL(String resource) throws MalformedURLException
+ {
+ return JBossWSTestHelper.getResourceURL(resource);
+ }
+
+ public static File createResourceFile(String filename)
+ {
+ File resDir = new File(JBossWSTestHelper.getTestResourcesDir());
+ return new File(resDir.getAbsolutePath() + File.separator + filename);
+ }
+
+ public static File createResourceFile(File parent, String filename)
+ {
+ return new File(parent, filename);
+ }
+
+ private static Hashtable<String, String> getEnvironment(final String
resourceName) throws IOException {
+ final Hashtable<String, String> env = new Hashtable<String,
String>();
+ final InputStream is =
JBossWSTest.class.getClassLoader().getResourceAsStream(resourceName);
+ if (is != null) {
+ final Properties props = new Properties();
+ props.load(is);
+ Entry<Object, Object> entry;
+ final Iterator<Entry<Object, Object>> entries =
props.entrySet().iterator();
+ while (entries.hasNext()) {
+ entry = entries.next();
+ env.put((String)entry.getKey(), (String)entry.getValue());
+ }
+ }
+ return env;
+ }
+
+ /** Gets the appclient remote env context.
+ * Every test calling this method have to ensure InitialContext.close()
+ * method is called at end of test to clean up all associated caches.
+ */
+ public static InitialContext getAppclientInitialContext() throws NamingException,
IOException
+ {
+ final Hashtable<String, String> env =
getEnvironment("appclient.jndi.properties");
+ return new InitialContext(env);
+ }
+
+ /** Get the server remote env context
+ * Every test calling this method have to ensure InitialContext.close()
+ * method is called at end of test to clean up all associated caches.
+ */
+ public static InitialContext getServerInitialContext() throws NamingException,
IOException
+ {
+ final Hashtable<String, String> env =
getEnvironment("server.jndi.properties");
+ return new InitialContext(env);
+ }
+
+ public static void assertEquals(Element expElement, Element wasElement, boolean
ignoreWhitespace)
+ {
+ normalizeWhitespace(expElement, ignoreWhitespace);
+ normalizeWhitespace(wasElement, ignoreWhitespace);
+ String expStr = DOMWriter.printNode(expElement, false);
+ String wasStr = DOMWriter.printNode(wasElement, false);
+ if (expStr.equals(wasStr) == false)
+ {
+ System.out.println("\nExp: " + expStr + "\nWas: " +
wasStr);
+ }
+ assertEquals(expStr, wasStr);
+ }
+
+ public static void assertEquals(Element expElement, Element wasElement)
+ {
+ assertEquals(expElement, wasElement, false);
+ }
+
+ public static void assertEquals(Object exp, Object was)
+ {
+ if (exp instanceof Object[] && was instanceof Object[])
+ assertEqualsArray((Object[])exp, (Object[])was);
+ else if (exp instanceof byte[] && was instanceof byte[])
+ assertEqualsArray((byte[])exp, (byte[])was);
+ else if (exp instanceof boolean[] && was instanceof boolean[])
+ assertEqualsArray((boolean[])exp, (boolean[])was);
+ else if (exp instanceof short[] && was instanceof short[])
+ assertEqualsArray((short[])exp, (short[])was);
+ else if (exp instanceof int[] && was instanceof int[])
+ assertEqualsArray((int[])exp, (int[])was);
+ else if (exp instanceof long[] && was instanceof long[])
+ assertEqualsArray((long[])exp, (long[])was);
+ else if (exp instanceof float[] && was instanceof float[])
+ assertEqualsArray((float[])exp, (float[])was);
+ else if (exp instanceof double[] && was instanceof double[])
+ assertEqualsArray((double[])exp, (double[])was);
+ else
+ TestCase.assertEquals(exp, was);
+ }
+
+ private static void assertEqualsArray(Object[] exp, Object[] was)
+ {
+ if (exp == null && was == null)
+ return;
+
+ if (exp != null && was != null)
+ {
+ if (exp.length != was.length)
+ {
+ fail("Expected <" + exp.length + "> array items, but was
<" + was.length + ">");
+ }
+ else
+ {
+ for (int i = 0; i < exp.length; i++)
+ {
+
+ Object compExp = exp[i];
+ Object compWas = was[i];
+ assertEquals(compExp, compWas);
+ }
+ }
+ }
+ else if (exp == null)
+ {
+ fail("Expected a null array, but was: " + Arrays.asList(was));
+ }
+ else if (was == null)
+ {
+ fail("Expected " + Arrays.asList(exp) + ", but was: null");
+ }
+ }
+
+ private static void assertEqualsArray(byte[] exp, byte[] was)
+ {
+ assertTrue("Arrays don't match", Arrays.equals(exp, was));
+ }
+
+ private static void assertEqualsArray(boolean[] exp, boolean[] was)
+ {
+ assertTrue("Arrays don't match", Arrays.equals(exp, was));
+ }
+
+ private static void assertEqualsArray(short[] exp, short[] was)
+ {
+ assertTrue("Arrays don't match", Arrays.equals(exp, was));
+ }
+
+ private static void assertEqualsArray(int[] exp, int[] was)
+ {
+ assertTrue("Arrays don't match", Arrays.equals(exp, was));
+ }
+
+ private static void assertEqualsArray(long[] exp, long[] was)
+ {
+ assertTrue("Arrays don't match", Arrays.equals(exp, was));
+ }
+
+ private static void assertEqualsArray(float[] exp, float[] was)
+ {
+ assertTrue("Arrays don't match", Arrays.equals(exp, was));
+ }
+
+ private static void assertEqualsArray(double[] exp, double[] was)
+ {
+ assertTrue("Arrays don't match", Arrays.equals(exp, was));
+ }
+
+ /** Removes whitespace text nodes if they have an element sibling.
+ */
+ private static void normalizeWhitespace(Element element, boolean ignoreWhitespace)
+ {
+ boolean hasChildElement = false;
+ ArrayList<Node> toDetach = new ArrayList<Node>();
+
+ NodeList childNodes = element.getChildNodes();
+ for (int i = 0; i < childNodes.getLength(); i++)
+ {
+ Node node = childNodes.item(i);
+ if (node.getNodeType() == Node.TEXT_NODE)
+ {
+ String nodeValue = node.getNodeValue();
+ if (nodeValue.trim().length() == 0)
+ toDetach.add(node);
+ }
+ if (node.getNodeType() == Node.ELEMENT_NODE)
+ {
+ normalizeWhitespace((Element)node, ignoreWhitespace);
+ hasChildElement = true;
+ }
+ }
+
+ // remove whitespace nodes
+ if (hasChildElement || ignoreWhitespace)
+ {
+ Iterator<Node> it = toDetach.iterator();
+ while (it.hasNext())
+ {
+ Node whiteSpaceNode = it.next();
+ element.removeChild(whiteSpaceNode);
+ }
+ }
+ }
+
+}
Added:
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/jboss/wsf/test/JBossWSTestHelper.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/jboss/wsf/test/JBossWSTestHelper.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/jboss/wsf/test/JBossWSTestHelper.java 2013-05-16
10:29:30 UTC (rev 17587)
@@ -0,0 +1,377 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, 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.wsf.test;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.Inet6Address;
+import java.net.InetAddress;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.UnknownHostException;
+import java.util.Map;
+
+import javax.management.MBeanServerConnection;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
+import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+import javax.xml.ws.Service;
+import javax.xml.ws.Service.Mode;
+import javax.xml.ws.soap.SOAPBinding;
+
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.deployer.Deployer;
+
+/**
+ * A JBossWS test helper that deals with test deployment/undeployment, etc.
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @author ropalka(a)redhat.com
+ * @author alessio.soldano(a)jboss.com
+ */
+public class JBossWSTestHelper
+{
+ private static final String SYSPROP_JBOSSWS_INTEGRATION_TARGET =
"jbossws.integration.target";
+ private static final String SYSPROP_JBOSS_BIND_ADDRESS =
"jboss.bind.address";
+ 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 TEST_USERNAME = "test.username";
+ private static final String TEST_PASSWORD = "test.password";
+ private static final boolean DEPLOY_PROCESS_ENABLED =
!Boolean.getBoolean("disable.test.archive.deployment");
+ private static Deployer DEPLOYER;
+
+ private static MBeanServerConnection server;
+ private static String integrationTarget;
+ private static String implInfo;
+ private static String testArchiveDir;
+ private static String testResourcesDir;
+
+ private static synchronized Deployer getDeployer()
+ {
+ //lazy loading of deployer
+ if (DEPLOYER == null)
+ {
+ SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+ DEPLOYER = spiProvider.getSPI(Deployer.class);
+ }
+ return DEPLOYER;
+ }
+
+ /** Deploy the given archive to the server
+ */
+ public static void deploy(final String archive) throws Exception
+ {
+ if (DEPLOY_PROCESS_ENABLED)
+ {
+ URL archiveURL = getArchiveFile(archive).toURI().toURL();
+ getDeployer().deploy(archiveURL);
+ }
+ }
+
+ /** Undeploy the given archive from the server
+ */
+ public static void undeploy(final String archive) throws Exception
+ {
+ if (DEPLOY_PROCESS_ENABLED)
+ {
+ URL archiveURL = getArchiveFile(archive).toURI().toURL();
+ getDeployer().undeploy(archiveURL);
+ }
+ }
+
+ /** Deploy the given archive to the appclient.
+ * Archive name is always in form archive.ear#appclient.jar
+ */
+ public static Process deployAppclient(final String archive, final OutputStream
appclientOS, final String... appclientArgs) throws Exception
+ {
+ if (DEPLOY_PROCESS_ENABLED)
+ {
+ return AppclientHelper.deployAppclient(archive, appclientOS, appclientArgs);
+ }
+ return null;
+ }
+
+ /** Undeploy the given archive from the appclient
+ * Archive name is always in form archive.ear#appclient.jar
+ */
+ public static void undeployAppclient(final String archive, boolean awaitShutdown)
throws Exception
+ {
+ if (DEPLOY_PROCESS_ENABLED)
+ {
+ AppclientHelper.undeployAppclient(archive, awaitShutdown);
+ }
+ }
+
+ public static boolean isTargetJBoss7()
+ {
+ String target = getIntegrationTarget();
+ return target.startsWith("jboss7");
+ }
+
+ public static boolean isTargetJBoss71()
+ {
+ String target = getIntegrationTarget();
+ return target.startsWith("jboss71");
+ }
+
+ public static boolean isTargetJBoss72()
+ {
+ String target = getIntegrationTarget();
+ return target.startsWith("jboss72");
+ }
+
+ @Deprecated
+ public static boolean isTargetJBoss8()
+ {
+ return isTargetJBoss8();
+ }
+
+ public static boolean isTargetWildFly8()
+ {
+ String target = getIntegrationTarget();
+ return target.startsWith("wildfly8");
+ }
+
+ @Deprecated
+ public static boolean isTargetJBoss80()
+ {
+ return isTargetWildFly80();
+ }
+
+ public static boolean isTargetWildFly80()
+ {
+ String target = getIntegrationTarget();
+ return target.startsWith("wildfly80");
+ }
+
+ public static boolean isIntegrationNative()
+ {
+ String vendor = getImplementationInfo();
+ return vendor.toLowerCase().indexOf("jboss") != -1;
+ }
+
+ public static boolean isIntegrationCXF()
+ {
+ String vendor = getImplementationInfo();
+ return vendor.toLowerCase().indexOf("apache") != -1;
+ }
+
+ private static String getImplementationInfo()
+ {
+ if (implInfo == null)
+ {
+ Object obj = getImplementationObject();
+ implInfo = obj.getClass().getPackage().getName();
+ }
+ return implInfo;
+ }
+
+ private static Object getImplementationObject()
+ {
+ Service service = Service.create(new QName("dummyService"));
+ Object obj = service.getHandlerResolver();
+ if (obj == null)
+ {
+ service.addPort(new QName("dummyPort"),
SOAPBinding.SOAP11HTTP_BINDING, "http://dummy-address");
+ obj = service.createDispatch(new QName("dummyPort"), Source.class,
Mode.PAYLOAD);
+ }
+ return obj;
+ }
+
+ /**
+ * Get the JBoss server host from system property "jboss.bind.address"
+ * This defaults to "localhost"
+ */
+ public static String getServerHost()
+ {
+ final String host = System.getProperty(SYSPROP_JBOSS_BIND_ADDRESS,
"localhost");
+ return toIPv6URLFormat(host);
+ }
+
+ private static String toIPv6URLFormat(final String host)
+ {
+ try
+ {
+ if (host.startsWith(":"))
+ {
+ throw new IllegalArgumentException("JBossWS test suite requires IPv6
addresses to be wrapped with [] brackets. Expected format is: [" + host +
"]");
+ }
+ if (host.startsWith("["))
+ {
+ if (System.getProperty("java.net.preferIPv4Stack") == null)
+ {
+ throw new IllegalStateException("always provide
java.net.preferIPv4Stack JVM property when using IPv6 address format");
+ }
+ if (System.getProperty("java.net.preferIPv6Addresses") == null)
+ {
+ throw new IllegalStateException("always provide
java.net.preferIPv6Addresses JVM property when using IPv6 address format");
+ }
+ }
+ final boolean isIPv6Address = InetAddress.getByName(host) instanceof
Inet6Address;
+ final boolean isIPv6Formatted = isIPv6Address &&
host.startsWith("[");
+ return isIPv6Address && !isIPv6Formatted ? "[" + host +
"]" : host;
+ }
+ catch (final UnknownHostException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static MBeanServerConnection getServer()
+ {
+ if (server == null)
+ {
+ String integrationTarget = getIntegrationTarget();
+ if (integrationTarget.startsWith("jboss7") ||
integrationTarget.startsWith("wildfly8") ||
integrationTarget.startsWith("jboss8"))
+ {
+ server = getAS7ServerConnection(integrationTarget);
+ }
+ else
+ {
+ throw new IllegalStateException("Unsupported target container: " +
integrationTarget);
+ }
+ }
+ return server;
+ }
+
+ private static MBeanServerConnection getAS7ServerConnection(String integrationTarget)
+ {
+ String host = getServerHost();
+ String urlString = System.getProperty("jmx.service.url",
"service:jmx:remoting-jmx://" + host + ":" + 9999);
+ try {
+ JMXServiceURL serviceURL = new JMXServiceURL(urlString);
+ return JMXConnectorFactory.connect(serviceURL,
null).getMBeanServerConnection();
+ } catch (IOException ex) {
+ throw new IllegalStateException("Cannot obtain MBeanServerConnection to:
" + urlString, ex);
+ }
+ }
+
+ public static String getIntegrationTarget()
+ {
+ if (integrationTarget == null)
+ {
+ integrationTarget = System.getProperty(SYSPROP_JBOSSWS_INTEGRATION_TARGET);
+
+ if (integrationTarget == null)
+ throw new IllegalStateException("Cannot obtain system property: " +
SYSPROP_JBOSSWS_INTEGRATION_TARGET);
+ }
+
+ return integrationTarget;
+ }
+
+ /** Try to discover the URL for the deployment archive */
+ public static URL getArchiveURL(String archive) throws MalformedURLException
+ {
+ return getArchiveFile(archive).toURI().toURL();
+ }
+
+ /** Try to discover the File for the deployment archive */
+ public static File getArchiveFile(String archive)
+ {
+ File file = new File(archive);
+ if (file.exists())
+ return file;
+
+ file = new File(getTestArchiveDir() + "/" + archive);
+ 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);
+ }
+
+ /** Try to discover the URL for the test resource */
+ public static URL getResourceURL(String resource) throws MalformedURLException
+ {
+ return getResourceFile(resource).toURI().toURL();
+ }
+
+ /** Try to discover the File for the test resource */
+ public static File getResourceFile(String resource)
+ {
+ File file = new File(resource);
+ if (file.exists())
+ return file;
+
+ file = new File(getTestResourcesDir() + "/" + resource);
+ if (file.exists())
+ return file;
+
+ String notSet = (getTestResourcesDir() == null ? " System property '"
+ SYSPROP_TEST_RESOURCES_DIRECTORY + "' not set." : "");
+ throw new IllegalArgumentException("Cannot obtain '" +
getTestResourcesDir() + "/" + resource + "'." + notSet);
+ }
+
+ public static String getTestArchiveDir()
+ {
+ if (testArchiveDir == null)
+ testArchiveDir = System.getProperty(SYSPROP_TEST_ARCHIVE_DIRECTORY);
+
+ return testArchiveDir;
+ }
+
+ public static String getTestResourcesDir()
+ {
+ if (testResourcesDir == null)
+ testResourcesDir = System.getProperty(SYSPROP_TEST_RESOURCES_DIRECTORY);
+
+ return testResourcesDir;
+ }
+
+ public static String getTestUsername() {
+ String prop = System.getProperty(TEST_USERNAME);
+ if (prop == null || "".equals(prop) || ("${" + TEST_USERNAME +
"}").equals(prop)) {
+ prop = "kermit";
+ }
+ return prop;
+ }
+
+ public static String getTestPassword() {
+ String prop = System.getProperty(TEST_PASSWORD);
+ if (prop == null || "".equals(prop) || ("${" + TEST_PASSWORD +
"}").equals(prop)) {
+ prop = "thefrog";
+ }
+ return prop;
+ }
+
+ public static void addSecurityDomain(String name, Map<String,String>
authenticationOptions) throws Exception
+ {
+ getDeployer().addSecurityDomain(name, authenticationOptions);
+ }
+
+ public static void removeSecurityDomain(String name) throws Exception
+ {
+ getDeployer().removeSecurityDomain(name);
+ }
+
+ public static void addHttpsConnector(Map<String, String> options) throws
Exception
+ {
+ getDeployer().addHttpsConnector(options);
+ }
+
+ public static void removeHttpsConnector() throws Exception
+ {
+ getDeployer().removeHttpsConnector();
+ }
+}
Added:
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/jboss/wsf/test/JBossWSTestSetup.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/jboss/wsf/test/JBossWSTestSetup.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/jboss/wsf/test/JBossWSTestSetup.java 2013-05-16
10:29:30 UTC (rev 17587)
@@ -0,0 +1,344 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, 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.wsf.test;
+
+import java.io.File;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import javax.management.MBeanServerConnection;
+import javax.naming.NamingException;
+import javax.security.sasl.SaslException;
+
+import junit.extensions.TestSetup;
+import junit.framework.Protectable;
+import junit.framework.Test;
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
+
+import org.jboss.logging.Logger;
+
+/**
+ * A test setup that deploys/undeploys archives
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @author alessio.soldano(a)jboss.com
+ * @since 14-Oct-2004
+ */
+public class JBossWSTestSetup extends TestSetup
+{
+ // provide logging
+ private static Logger log = Logger.getLogger(JBossWSTestSetup.class);
+
+ private static final String JBOSSWS_SEC_DOMAIN = "JBossWS";
+
+ private String[] archives = new String[0];
+ private OutputStream appclientOutputStream;
+ private String appclientArg;
+ private ClassLoader originalClassLoader;
+ private Map<String, Map<String, String>> securityDomains;
+ private boolean defaultSecurityDomainRequirement = false;
+ private Map<String, String> httpsConnOptions;
+ private CleanupOperation cleanupOp;
+
+ public JBossWSTestSetup(Class<?> testClass, String archiveList)
+ {
+ super(new TestSuite(testClass));
+ getArchiveArray(archiveList);
+ }
+
+ public JBossWSTestSetup(Class<?> testClass, String archiveList, CleanupOperation
cleanupOp)
+ {
+ this(testClass, archiveList);
+ this.cleanupOp = cleanupOp;
+ }
+
+ public JBossWSTestSetup(Class<?> testClass, String archiveList, OutputStream
appclientOutputStream)
+ {
+ super(new TestSuite(testClass));
+ getArchiveArray(archiveList);
+ this.appclientOutputStream = appclientOutputStream;
+ }
+
+ public JBossWSTestSetup(Class<?> testClass, String archiveList, boolean
requiresDefaultSecurityDomain)
+ {
+ this(testClass, archiveList);
+ setDefaultSecurityDomainRequirement(requiresDefaultSecurityDomain);
+ }
+
+ public JBossWSTestSetup(Class<?> testClass, String archiveList, boolean
requiresDefaultSecurityDomain, CleanupOperation cleanupOp)
+ {
+ this(testClass, archiveList, requiresDefaultSecurityDomain);
+ this.cleanupOp = cleanupOp;
+ }
+
+ public JBossWSTestSetup(Test test, String archiveList)
+ {
+ super(test);
+ getArchiveArray(archiveList);
+ }
+
+ public JBossWSTestSetup(Test test, String archiveList, CleanupOperation cleanupOp)
+ {
+ this(test, archiveList);
+ this.cleanupOp = cleanupOp;
+ }
+
+ public JBossWSTestSetup(Test test, String archiveList, boolean
requiresDefaultSecurityDomain)
+ {
+ this(test, archiveList);
+ setDefaultSecurityDomainRequirement(requiresDefaultSecurityDomain);
+ }
+
+ public JBossWSTestSetup(Test test)
+ {
+ super(test);
+ }
+
+ /**
+ * Override junit.extensions.TestSetup:run(TestResult result) to call cleanup
operation
+ * before tearing down the whole test setup. Required for allowing tests to perform
+ * final cleanup of static references.
+ */
+ @Override
+ public void run(final TestResult result)
+ {
+ Protectable p = new Protectable()
+ {
+ public void protect() throws Exception
+ {
+ setUp();
+ basicRun(result);
+ if (cleanupOp != null) {
+ cleanupOp.cleanUp();
+ }
+ tearDown();
+ }
+ };
+ result.runProtected(this, p);
+ }
+
+ public File getArchiveFile(String archive)
+ {
+ return JBossWSTestHelper.getArchiveFile(archive);
+ }
+
+ public URL getArchiveURL(String archive) throws MalformedURLException
+ {
+ return JBossWSTestHelper.getArchiveFile(archive).toURI().toURL();
+ }
+
+ public File getResourceFile(String resource)
+ {
+ return JBossWSTestHelper.getResourceFile(resource);
+ }
+
+ public URL getResourceURL(String resource) throws MalformedURLException
+ {
+ return JBossWSTestHelper.getResourceFile(resource).toURI().toURL();
+ }
+
+ private void getArchiveArray(String archiveList)
+ {
+ if (archiveList != null)
+ {
+ StringTokenizer st = new StringTokenizer(archiveList, ", ");
+ archives = new String[st.countTokens()];
+
+ for (int i = 0; i < archives.length; i++)
+ archives[i] = st.nextToken();
+ }
+ }
+
+ protected void setUp() throws Exception
+ {
+ // verify integration target
+ String integrationTarget = JBossWSTestHelper.getIntegrationTarget();
+ log.debug("Integration target: " + integrationTarget);
+
+ if (securityDomains != null && !securityDomains.isEmpty())
+ {
+ for (String key : securityDomains.keySet())
+ {
+ JBossWSTestHelper.addSecurityDomain(key, securityDomains.get(key));
+ }
+ }
+ if (defaultSecurityDomainRequirement)
+ {
+ String usersPropFile =
System.getProperty("org.jboss.ws.testsuite.securityDomain.users.propfile");
+ String rolesPropFile =
System.getProperty("org.jboss.ws.testsuite.securityDomain.roles.propfile");
+ Map<String, String> authenticationOptions = new HashMap<String,
String>();
+ if (usersPropFile != null) {
+ authenticationOptions.put("usersProperties", usersPropFile);
+ }
+ if (rolesPropFile != null) {
+ authenticationOptions.put("rolesProperties", rolesPropFile);
+ }
+ authenticationOptions.put("unauthenticatedIdentity",
"anonymous");
+ try {
+ JBossWSTestHelper.addSecurityDomain(JBOSSWS_SEC_DOMAIN,
authenticationOptions);
+ } catch (Exception e) {
+ //be lenient here, the default jbossws security domain might be there because
of
+ //a previously prematurely interrupted testsuite run, so go ahead with that,
it
+ //will removed and re-installed at next test requiring it in any case
+ e.printStackTrace();
+ log.warn("Could not add default security domain!", e);
+ }
+ }
+ if (httpsConnOptions != null) {
+ JBossWSTestHelper.addHttpsConnector(httpsConnOptions);
+ }
+
+ List<URL> clientJars = new ArrayList<URL>();
+ for (int i = 0; i < archives.length; i++)
+ {
+ String archive = archives[i];
+ if (archive.endsWith("-appclient.jar"))
+ {
+ URL archiveURL = getArchiveURL(archive.substring(archive.indexOf('#')
+ 1));
+ clientJars.add(archiveURL);
+ JBossWSTestHelper.deployAppclient(archive, appclientOutputStream,
appclientArg);
+ }
+ else if (archive.endsWith("-client.jar"))
+ {
+ URL archiveURL = getArchiveURL(archive);
+ clientJars.add(archiveURL);
+ }
+ else
+ {
+ performDeploy(archive);
+ }
+ }
+
+ ClassLoader parent = Thread.currentThread().getContextClassLoader();
+ originalClassLoader = parent;
+ // add client jars to the class loader
+ if (!clientJars.isEmpty())
+ {
+ URL[] urls = new URL[clientJars.size()];
+ for (int i = 0; i < clientJars.size(); i++)
+ {
+ urls[i] = clientJars.get(i);
+ }
+ URLClassLoader cl = new URLClassLoader(urls, parent);
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ }
+
+ private static void performDeploy(String archive) throws Exception
+ {
+ try
+ {
+ JBossWSTestHelper.deploy(archive);
+ }
+ catch (Throwable ex)
+ {
+ ex.printStackTrace();
+ Throwable cause = ex.getCause();
+ boolean foundSecurityCause = false;
+ while (!foundSecurityCause && cause != null && cause != ex) {
+ foundSecurityCause = cause instanceof SaslException;
+ ex = cause;
+ cause = cause.getCause();
+ }
+ if (foundSecurityCause) {
+ System.out.println("\n** Please make sure you properly setup
authentication credentials to the application server management console **\n\n" +
+ "In order for running the JBossWS testsuite against a protected
application server (username/password different from 'admin' /
'admin'),\n" +
+ "use '-Djbossws.deployer.authentication.username=username
-Djbossws.deployer.authentication.password=password'\n");
+ }
+ JBossWSTestHelper.undeploy(archive);
+ }
+ }
+
+ protected void tearDown() throws Exception
+ {
+ try
+ {
+ for (int i = 0; i < archives.length; i++)
+ {
+ String archive = archives[archives.length - i - 1];
+ if (archive.endsWith("-appclient.jar"))
+ {
+ JBossWSTestHelper.undeployAppclient(archive, true);
+ }
+ else if (!archive.endsWith("-client.jar"))
+ {
+ JBossWSTestHelper.undeploy(archive);
+ }
+ }
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(originalClassLoader);
+
+ if (securityDomains != null && !securityDomains.isEmpty())
+ {
+ for (String key : securityDomains.keySet())
+ {
+ JBossWSTestHelper.removeSecurityDomain(key);
+ }
+ }
+ if (defaultSecurityDomainRequirement)
+ {
+ JBossWSTestHelper.removeSecurityDomain(JBOSSWS_SEC_DOMAIN);
+ }
+ if (httpsConnOptions != null)
+ {
+ JBossWSTestHelper.removeHttpsConnector();
+ }
+ }
+ }
+
+ protected ClassLoader getOriginalClassLoader()
+ {
+ return originalClassLoader;
+ }
+
+ public MBeanServerConnection getServer() throws NamingException
+ {
+ return JBossWSTestHelper.getServer();
+ }
+
+ public void addSecurityDomainRequirement(String securityDomainName, Map<String,
String> authenticationOptions)
+ {
+ if (securityDomains == null) {
+ securityDomains = new HashMap<String, Map<String,String>>();
+ }
+ securityDomains.put(securityDomainName, authenticationOptions);
+ }
+
+ public void setDefaultSecurityDomainRequirement(boolean
defaultSecurityDomainRequirement)
+ {
+ this.defaultSecurityDomainRequirement = defaultSecurityDomainRequirement;
+ }
+
+ public void setHttpsConnectorRequirement(Map<String, String> options) {
+ httpsConnOptions = options;
+ }
+}
Added:
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/jboss/wsf/test/XOPTestSupport.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/jboss/wsf/test/XOPTestSupport.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/test-utils/src/main/java/org/jboss/wsf/test/XOPTestSupport.java 2013-05-16
10:29:30 UTC (rev 17587)
@@ -0,0 +1,95 @@
+/*
+ * 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.wsf.test;
+
+import java.awt.Image;
+import java.awt.Toolkit;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.activation.DataHandler;
+import javax.xml.transform.stream.StreamSource;
+
+import org.jboss.ws.common.IOUtils;
+
+/**
+ * @author Heiko Braun <heiko.braun(a)jboss.com>
+ * @since 22-Sep-2006
+ */
+public class XOPTestSupport
+{
+
+ public static byte[] getBytesFromFile(File file) throws IOException
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ IOUtils.copyStream(baos, new FileInputStream(file));
+ return baos.toByteArray();
+ }
+
+ public static Image createTestImage(File imgFile)
+ {
+ Image image = null;
+ try
+ {
+ URL url = imgFile.toURI().toURL();
+
+ image = null;
+ try
+ {
+ image = Toolkit.getDefaultToolkit().createImage(url);
+ }
+ catch (Throwable th)
+ {
+ //log.warn("Cannot create Image: " + th);
+ }
+ }
+ catch (MalformedURLException e)
+ {
+ throw new RuntimeException(e);
+ }
+
+ return image;
+ }
+
+ public static StreamSource createTestSource()
+ {
+ return new StreamSource(new
ByteArrayInputStream("<some><nestedXml/></some>".getBytes()));
+ }
+
+ public static DataHandler createDataHandler(File imgFile)
+ {
+ try
+ {
+ URL url = imgFile.toURI().toURL();
+ return new DataHandler(url);
+ }
+ catch (MalformedURLException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+}
Added: stack/cxf/trunk/modules/testsuite/test-utils/src/test/etc/tst.policy
===================================================================
--- stack/cxf/trunk/modules/testsuite/test-utils/src/test/etc/tst.policy
(rev 0)
+++ stack/cxf/trunk/modules/testsuite/test-utils/src/test/etc/tst.policy 2013-05-16
10:29:30 UTC (rev 17587)
@@ -0,0 +1,3 @@
+grant {
+ permission java.security.AllPermission;
+};
Modified: stack/cxf/trunk/pom.xml
===================================================================
--- stack/cxf/trunk/pom.xml 2013-05-16 04:33:11 UTC (rev 17586)
+++ stack/cxf/trunk/pom.xml 2013-05-16 10:29:30 UTC (rev 17587)
@@ -63,7 +63,6 @@
<jbossws.spi.version>2.2.0-SNAPSHOT</jbossws.spi.version>
<jbossws.common.version>2.2.0-SNAPSHOT</jbossws.common.version>
<jbossws.common.tools.version>1.2.0-SNAPSHOT</jbossws.common.tools.version>
-
<jbossws.shared.testsuite.version>4.2.0-SNAPSHOT</jbossws.shared.testsuite.version>
<jbossws.jboss712.version>4.2.0-SNAPSHOT</jbossws.jboss712.version>
<jbossws.jboss713.version>4.2.0-SNAPSHOT</jbossws.jboss713.version>
<jbossws.jboss720.version>4.2.0-SNAPSHOT</jbossws.jboss720.version>
@@ -137,19 +136,6 @@
</dependency>
<dependency>
<groupId>org.jboss.ws</groupId>
- <artifactId>jbossws-shared-testsuite</artifactId>
- <version>${jbossws.shared.testsuite.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.ws</groupId>
- <artifactId>jbossws-shared-testsuite</artifactId>
- <version>${jbossws.shared.testsuite.version}</version>
- <type>zip</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.ws</groupId>
<artifactId>jbossws-jboss712-server-integration</artifactId>
<version>${jbossws.jboss712.version}</version>
</dependency>