You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2015/12/24 17:43:37 UTC
svn commit: r1721640 - in /axis/axis2/java/rampart/trunk: ./
modules/rampart-integration/ modules/rampart-samples/
modules/rampart-samples/policy/
modules/rampart-samples/policy/sample08/src/org/apache/rampart/samples/policy/sample08/
modules/rampart-s...
Author: veithen
Date: Thu Dec 24 16:43:37 2015
New Revision: 1721640
URL: http://svn.apache.org/viewvc?rev=1721640&view=rev
Log:
Add code to automatically execute the samples as integration tests.
Added:
axis/axis2/java/rampart/trunk/modules/rampart-samples/src/
axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/
axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/
axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/
axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/
axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/
axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/
axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/
axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/Controller.java (with props)
axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/Logger.java (with props)
axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/Sample.java (with props)
axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/SampleTest.java (with props)
axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/ServerRunner.java (with props)
axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/ServerWatcher.java (with props)
Modified:
axis/axis2/java/rampart/trunk/modules/rampart-integration/pom.xml
axis/axis2/java/rampart/trunk/modules/rampart-samples/policy/build.xml
axis/axis2/java/rampart/trunk/modules/rampart-samples/policy/sample08/src/org/apache/rampart/samples/policy/sample08/Client.java
axis/axis2/java/rampart/trunk/modules/rampart-samples/pom.xml
axis/axis2/java/rampart/trunk/pom.xml
Modified: axis/axis2/java/rampart/trunk/modules/rampart-integration/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/trunk/modules/rampart-integration/pom.xml?rev=1721640&r1=1721639&r2=1721640&view=diff
==============================================================================
--- axis/axis2/java/rampart/trunk/modules/rampart-integration/pom.xml (original)
+++ axis/axis2/java/rampart/trunk/modules/rampart-integration/pom.xml Thu Dec 24 16:43:37 2015
@@ -564,7 +564,6 @@
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>addressing</artifactId>
- <version>${axis2.version}</version>
<type>mar</type>
</dependency>
<dependency>
Modified: axis/axis2/java/rampart/trunk/modules/rampart-samples/policy/build.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/trunk/modules/rampart-samples/policy/build.xml?rev=1721640&r1=1721639&r2=1721640&view=diff
==============================================================================
--- axis/axis2/java/rampart/trunk/modules/rampart-samples/policy/build.xml (original)
+++ axis/axis2/java/rampart/trunk/modules/rampart-samples/policy/build.xml Thu Dec 24 16:43:37 2015
@@ -18,12 +18,13 @@
<project basedir="." default="clean">
- <property name="service.repos.dir" value="build/service_repositories"/>
- <property name="client.repos.dir" value="build/client_repositories"/>
- <property name="temp.dir" value="build/temp"/>
+ <property name="build.dir" value="build"/>
+ <property name="service.repos.dir" value="${build.dir}/service_repositories"/>
+ <property name="client.repos.dir" value="${build.dir}/client_repositories"/>
+ <property name="temp.dir" value="${build.dir}/temp"/>
<property name="keys.dir" value="../keys"/>
- <property name="temp.client.dir" value="build/temp_client"/>
- <property name="endorsed.dir" value="build/endorsed"/>
+ <property name="temp.client.dir" value="${build.dir}/temp_client"/>
+ <property name="endorsed.dir" value="${build.dir}/endorsed"/>
<property name="client.port" value="8080"/>
<property name="server.port" value="8080"/>
@@ -133,7 +134,7 @@
<target name="clean">
- <delete dir="build" />
+ <delete dir="${build.dir}" />
</target>
<!-- Macro to create a service repo for a given sample -->
@@ -283,7 +284,7 @@
<!-- Run client -->
- <java classname="org.apache.rampart.samples.policy.sample@{sample.number}.Client" fork="true">
+ <java classname="org.apache.rampart.samples.policy.sample@{sample.number}.Client" fork="true" failonerror="true">
<arg value="${sample.services.url}/sample@{sample.number}"/>
<arg value="${client.repos.dir}/sample@{sample.number}"/>
<arg value="sample@{sample.number}/policy.xml"/>
Modified: axis/axis2/java/rampart/trunk/modules/rampart-samples/policy/sample08/src/org/apache/rampart/samples/policy/sample08/Client.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/trunk/modules/rampart-samples/policy/sample08/src/org/apache/rampart/samples/policy/sample08/Client.java?rev=1721640&r1=1721639&r2=1721640&view=diff
==============================================================================
--- axis/axis2/java/rampart/trunk/modules/rampart-samples/policy/sample08/src/org/apache/rampart/samples/policy/sample08/Client.java (original)
+++ axis/axis2/java/rampart/trunk/modules/rampart-samples/policy/sample08/src/org/apache/rampart/samples/policy/sample08/Client.java Thu Dec 24 16:43:37 2015
@@ -31,6 +31,8 @@ import org.apache.rahas.client.STSClient
import org.apache.ws.secpolicy.SP11Constants;
import org.opensaml.common.xml.SAMLConstants;
+import java.net.URL;
+
import javax.xml.namespace.QName;
public class Client {
@@ -49,7 +51,7 @@ public class Client {
String action = TrustUtil.getActionValue(RahasConstants.VERSION_05_02, RahasConstants.RST_ACTION_ISSUE);
stsClient.setAction(action);
- Token responseToken = stsClient.requestSecurityToken(loadPolicy("sample08/policy.xml"), "http://localhost:8080/axis2/services/STS", loadPolicy("sample08/sts_policy.xml"), null);
+ Token responseToken = stsClient.requestSecurityToken(loadPolicy("sample08/policy.xml"), new URL(new URL(args[0]), "/axis2/services/STS").toString(), loadPolicy("sample08/sts_policy.xml"), null);
System.out.println("\n############################# Requested SAML 2.0 Token ###################################\n");
System.out.println(responseToken.getToken().toString());
Modified: axis/axis2/java/rampart/trunk/modules/rampart-samples/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/trunk/modules/rampart-samples/pom.xml?rev=1721640&r1=1721639&r2=1721640&view=diff
==============================================================================
--- axis/axis2/java/rampart/trunk/modules/rampart-samples/pom.xml (original)
+++ axis/axis2/java/rampart/trunk/modules/rampart-samples/pom.xml Thu Dec 24 16:43:37 2015
@@ -37,45 +37,30 @@
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-repo-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>create-test-repository</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.directory}/axis2/repository</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
</plugin>
<plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
+ <artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
- <phase>generate-sources</phase>
+ <id>copy-dependencies</id>
+ <phase>generate-test-resources</phase>
<goals>
- <goal>add-source</goal>
+ <goal>copy-dependencies</goal>
</goals>
<configuration>
- <sources>
- <source>basic/sample01/src</source>
- <source>basic/sample02/src</source>
- <source>basic/sample03/src</source>
- <source>basic/sample04/src</source>
- <source>basic/sample05/src</source>
- <source>basic/sample06/src</source>
- <source>basic/sample07/src</source>
- <source>basic/sample08/src</source>
- <source>basic/sample09/src</source>
- <source>basic/sample10/src</source>
- <source>basic/sample11/src</source>
- <source>policy/sample01/src</source>
- <source>policy/sample02/src</source>
- <source>policy/sample03/src</source>
- <source>policy/sample04/src</source>
- <source>policy/sample05/src</source>
- <source>policy/sample06/src</source>
- <source>policy/sample07/src</source>
- <source>policy/sample08/src</source>
- <source>policy/sample-tomcat/src</source>
- </sources>
+ <outputDirectory>${project.build.directory}/axis2/lib</outputDirectory>
</configuration>
</execution>
</executions>
@@ -91,27 +76,82 @@
<dependencies>
<dependency>
- <groupId>org.apache.rampart</groupId>
- <artifactId>rampart-policy</artifactId>
- <version>${project.version}</version>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.rampart</groupId>
- <artifactId>rampart-trust</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.rampart</groupId>
- <artifactId>rampart-core</artifactId>
- <version>${project.version}</version>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.9.6</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.sun</groupId>
+ <artifactId>tools</artifactId>
+ <version>1.7.0</version>
+ <scope>system</scope>
+ <systemPath>${java.home}/../lib/tools.jar</systemPath>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>addressing</artifactId>
+ <type>mar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rampart</artifactId>
+ <version>${project.version}</version>
+ <type>mar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rahas</artifactId>
+ <version>${project.version}</version>
+ <type>mar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-transport-http</artifactId>
+ <version>${axis2.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-transport-local</artifactId>
+ <version>${axis2.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-adb</artifactId>
+ <version>${axis2.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-testutils</artifactId>
+ <version>${axis2.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rampart-core</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
</dependency>
</dependencies>
</project>
Added: axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/Controller.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/Controller.java?rev=1721640&view=auto
==============================================================================
--- axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/Controller.java (added)
+++ axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/Controller.java Thu Dec 24 16:43:37 2015
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.rampart.samples.runner;
+
+import org.apache.axis2.testutils.PortAllocator;
+import org.apache.tools.ant.Project;
+
+final class Controller {
+ private final Sample sample;
+ private boolean serverReady;
+ private boolean serverStopped;
+ private boolean serverStopDetected;
+
+ Controller(Sample sample) {
+ this.sample = sample;
+ }
+
+ void execute() throws InterruptedException {
+ int port = PortAllocator.allocatePort();
+ Logger logger = new Logger();
+ logger.setErrorPrintStream(System.err);
+ logger.setOutputPrintStream(System.out);
+ logger.setMessageOutputLevel(Project.MSG_INFO);
+ ServerWatcher serverWatcher = new ServerWatcher(this, port);
+ new Thread(serverWatcher).start();
+ try {
+ Thread serverRunnerThread = new Thread(new ServerRunner(this, sample, logger, port));
+ serverRunnerThread.start();
+ try {
+ synchronized (this) {
+ if (!serverStopped && !serverReady) {
+ wait();
+ } else if (serverStopped) {
+ return;
+ }
+ }
+ sample.runClient(logger, port);
+ } finally {
+ logger.shutdown();
+ serverRunnerThread.interrupt();
+ synchronized (this) {
+ while (!serverStopDetected) {
+ wait();
+ }
+ }
+ }
+ } finally {
+ serverWatcher.stop();
+ }
+ }
+
+ synchronized void serverStopped() {
+ serverStopped = true;
+ notifyAll();
+ }
+
+ synchronized void serverReady() {
+ serverReady = true;
+ notifyAll();
+ }
+
+ synchronized void serverStopDetected() {
+ serverStopDetected = true;
+ notifyAll();
+ }
+}
Propchange: axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/Controller.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/Logger.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/Logger.java?rev=1721640&view=auto
==============================================================================
--- axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/Logger.java (added)
+++ axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/Logger.java Thu Dec 24 16:43:37 2015
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.rampart.samples.runner;
+
+import java.io.PrintStream;
+
+import org.apache.tools.ant.DefaultLogger;
+
+final class Logger extends DefaultLogger {
+ private boolean shutdown;
+
+ @Override
+ protected synchronized void printMessage(String message, PrintStream stream, int priority) {
+ if (!shutdown) {
+ super.printMessage(message, stream, priority);
+ }
+ }
+
+ void shutdown() {
+ this.shutdown = true;
+ }
+}
Propchange: axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/Logger.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/Sample.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/Sample.java?rev=1721640&view=auto
==============================================================================
--- axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/Sample.java (added)
+++ axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/Sample.java Thu Dec 24 16:43:37 2015
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.rampart.samples.runner;
+
+import java.io.File;
+
+import org.apache.tools.ant.BuildLogger;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.ProjectHelper;
+
+final class Sample {
+ private final File buildFile;
+ private final String sampleId;
+
+ Sample(File buildFile, String sampleId) {
+ this.buildFile = buildFile;
+ this.sampleId = sampleId;
+ }
+
+ private void run(BuildLogger logger, int port, String target) {
+ Project project = new Project();
+ File targetDir = new File("target");
+ project.setUserProperty("env.AXIS2_HOME", new File(targetDir, "axis2").getAbsolutePath());
+ project.setUserProperty("build.dir", new File(targetDir, "build").getAbsolutePath());
+ project.setUserProperty("client.port", String.valueOf(port));
+ project.setUserProperty("server.port", String.valueOf(port));
+ ProjectHelper.configureProject(project, buildFile);
+ project.addBuildListener(logger);
+ project.executeTarget(target);
+ }
+
+ void runServer(BuildLogger logger, int port) {
+ run(logger, port, "service." + sampleId);
+ }
+
+ void runClient(BuildLogger logger, int port) {
+ run(logger, port, "client." + sampleId);
+ }
+}
Propchange: axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/Sample.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/SampleTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/SampleTest.java?rev=1721640&view=auto
==============================================================================
--- axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/SampleTest.java (added)
+++ axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/SampleTest.java Thu Dec 24 16:43:37 2015
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.rampart.samples.runner;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class SampleTest extends TestCase {
+ private final Sample sample;
+
+ public SampleTest(String group, String id) {
+ super(group + "/" + id);
+ this.sample = new Sample(new File(group + "/build.xml"), id);
+ }
+
+ @Override
+ protected void runTest() throws Throwable {
+ new Controller(sample).execute();
+ }
+
+ public static TestSuite suite() {
+ TestSuite suite = new TestSuite();
+ suite.addTest(new SampleTest("policy", "01"));
+ suite.addTest(new SampleTest("policy", "02"));
+ suite.addTest(new SampleTest("policy", "03"));
+ suite.addTest(new SampleTest("policy", "04"));
+ // TODO: these are failing
+// suite.addTest(new SampleTest("policy", "05"));
+// suite.addTest(new SampleTest("policy", "06"));
+// suite.addTest(new SampleTest("policy", "07"));
+ suite.addTest(new SampleTest("policy", "08"));
+ return suite;
+ }
+}
Propchange: axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/SampleTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/ServerRunner.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/ServerRunner.java?rev=1721640&view=auto
==============================================================================
--- axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/ServerRunner.java (added)
+++ axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/ServerRunner.java Thu Dec 24 16:43:37 2015
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.rampart.samples.runner;
+
+import org.apache.tools.ant.BuildLogger;
+
+final class ServerRunner implements Runnable {
+ private final Controller controller;
+ private final Sample sample;
+ private final BuildLogger logger;
+ private final int port;
+
+ ServerRunner(Controller controller, Sample sample, BuildLogger logger, int port) {
+ this.controller = controller;
+ this.sample = sample;
+ this.logger = logger;
+ this.port = port;
+ }
+
+ public void run() {
+ try {
+ sample.runServer(logger, port);
+ } finally {
+ controller.serverStopped();
+ }
+ }
+}
Propchange: axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/ServerRunner.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/ServerWatcher.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/ServerWatcher.java?rev=1721640&view=auto
==============================================================================
--- axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/ServerWatcher.java (added)
+++ axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/ServerWatcher.java Thu Dec 24 16:43:37 2015
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.rampart.samples.runner;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.ConnectException;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+final class ServerWatcher implements Runnable {
+ private final Controller controller;
+ private final URL url;
+ private boolean serverWasReady;
+ private boolean stopped;
+
+ ServerWatcher(Controller controller, int port) {
+ this.controller = controller;
+ try {
+ url = new URL("http", "localhost", port, "/axis2/services/");
+ } catch (MalformedURLException ex) {
+ throw new Error("Unexpected exception", ex);
+ }
+ }
+
+ public synchronized void run() {
+ while (true) {
+ if (stopped) {
+ return;
+ }
+ try {
+ HttpURLConnection connection = (HttpURLConnection)url.openConnection();
+ int responseCode = connection.getResponseCode();
+ InputStream in = connection.getInputStream();
+ try {
+ byte[] buffer = new byte[1024];
+ while (in.read(buffer) != -1) {
+ // Just loop;
+ }
+ } finally {
+ in.close();
+ }
+ if (responseCode == 200) {
+ if (!serverWasReady) {
+ serverWasReady = true;
+ controller.serverReady();
+ }
+ }
+ } catch (ConnectException ex) {
+ if (serverWasReady) {
+ controller.serverStopDetected();
+ return;
+ }
+ } catch (IOException ex) {
+ // Just continue trying
+ }
+ try {
+ wait(100);
+ } catch (InterruptedException ex) {
+ return;
+ }
+ }
+ }
+
+ public synchronized void stop() {
+ stopped = true;
+ notifyAll();
+ }
+}
Propchange: axis/axis2/java/rampart/trunk/modules/rampart-samples/src/test/java/org/apache/rampart/samples/runner/ServerWatcher.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: axis/axis2/java/rampart/trunk/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/trunk/pom.xml?rev=1721640&r1=1721639&r2=1721640&view=diff
==============================================================================
--- axis/axis2/java/rampart/trunk/pom.xml (original)
+++ axis/axis2/java/rampart/trunk/pom.xml Thu Dec 24 16:43:37 2015
@@ -441,6 +441,12 @@
<version>${axis2.version}</version>
<classifier>impl</classifier>
</dependency>
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>addressing</artifactId>
+ <version>${axis2.version}</version>
+ <type>mar</type>
+ </dependency>
<!-- Since Rampart depends on DOOM, but axiom-dom is not a transitive
dependency, we need to manage the Axiom version. -->