Author: veithen
Date: Sat Jan 14 17:23:53 2017
New Revision: 1778802
URL: http://svn.apache.org/viewvc?rev=1778802&view=rev
Log:
Merge latest changes from trunk.
Modified:
axis/axis2/java/rampart/branches/RAMPART-433/ (props changed)
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/axis2/integration/JettyServer.java
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/rahas/TestClient.java
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/rampart/KerberosDelegationService.java
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAML2TokenCertForHoKTest.java
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAML2TokenTest.java
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAML2TokenUTForBearerTest.java
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenAttributeTest.java
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenCertForHoKTest.java
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenCertForHoKV1205Test.java
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenTest.java
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForBearerTest.java
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForBearerV1205Test.java
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForHoKTest.java
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForHoKV1205Test.java
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenV1205Test.java
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/AbstractRampartTest.java
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/RampartKerberosTest.java
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/RampartTest.java
axis/axis2/java/rampart/branches/RAMPART-433/pom.xml
Propchange: axis/axis2/java/rampart/branches/RAMPART-433/
------------------------------------------------------------------------------
svn:mergeinfo = /axis/axis2/java/rampart/trunk:1778760-1778793
Modified:
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/axis2/integration/JettyServer.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/axis2/integration/JettyServer.java?rev=1778802&r1=1778801&r2=1778802&view=diff
==============================================================================
---
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/axis2/integration/JettyServer.java
(original)
+++
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/axis2/integration/JettyServer.java
Sat Jan 14 17:23:53 2017
@@ -24,6 +24,7 @@ import org.eclipse.jetty.server.ssl.SslS
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.webapp.WebAppContext;
+import org.junit.rules.ExternalResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.axis2.testutils.PortAllocator;
@@ -32,7 +33,7 @@ import org.apache.axis2.transport.http.A
/**
* Support for running an embedded Jetty server
*/
-public class JettyServer {
+public class JettyServer extends ExternalResource {
/**
* Keystore to configure for Jetty's ssl context factory: {@value}
@@ -71,57 +72,41 @@ public class JettyServer {
private static final Logger logger =
LoggerFactory.getLogger(JettyServer.class);
- private static Server server;
-
- private JettyServer() {
-
- }
-
- /**
- * Starts the embedded Jetty server using dynamic port allocation with
both http and https connectors enabled.
- *
- * @param repository The path to the Axis2 repository to use. Must not be
null or empty.
- *
- * @throws Exception
- */
- public static synchronized void start(String repository) throws Exception {
- start(repository, true, true);
- }
-
- /**
- * Starts the embedded Jetty server using dynamic port allocation.
- *
- * @param repository The path to the Axis2 repository to use. Must not be
null or empty.
- * @param enableHttp Specifies whether to enable http connector.
- * @param enableHttps Specifies whether to enable https connector.
- *
- * @throws Exception
- */
- public static synchronized void start(String repository, boolean
enableHttp, boolean enableHttps) throws Exception {
- int httpPort = enableHttp ? PortAllocator.allocatePort() : -1;
- int httpsPort = enableHttps ? PortAllocator.allocatePort() : -1;
-
- start(repository, httpPort, httpsPort);
- }
-
- /**
- * Starts the embedded Jetty server.
- *
- * @param repository The path to the Axis2 repository to use. Must not be
null or empty.
- * @param httpPort The http port to use. Set to <code>-1</code> to disable
http connector.
- * @param httpsPort The https port to use. Set to <code>-1</code> to
disable https connector.
- *
- * @throws Exception
+ private final String repository;
+ private final int httpPort;
+ private final int httpsPort;
+ private Server server;
+
+ /**
+ * Constructor.
+ *
+ * @param repository
+ * The path to the Axis2 repository to use. Must not be null or
empty.
+ * @param httpPort
+ * The http port to use. Set to <code>-1</code> to disable http
connector. Set to
+ * <code>0</code> to enable dynamic port allocation.
+ * @param httpsPort
+ * The https port to use. Set to <code>-1</code> to disable
https connector. Set to
+ * <code>0</code> to enable dynamic port allocation.
* @throws IllegalArgumentException If both ports are set to
<code>-1</code>
*/
- public static synchronized void start(String repository, int httpPort, int
httpsPort) throws Exception {
+ public JettyServer(String repository, int httpPort, int httpsPort) {
if (repository == null || repository.trim().length() == 0) {
throw new IllegalArgumentException("Axis2 repository must not be
null or empty");
}
- else if (httpPort == -1 && httpsPort == -1) {
+ if (httpPort == -1 && httpsPort == -1) {
throw new IllegalArgumentException("At least one port must be
specified.");
}
+ this.repository = repository;
+ this.httpPort = httpPort;
+ this.httpsPort = httpsPort;
+ }
+ @Override
+ protected void before() throws Throwable {
+ int httpPort = this.httpPort == 0 ? PortAllocator.allocatePort() :
this.httpPort;
+ int httpsPort = this.httpsPort == 0 ? PortAllocator.allocatePort() :
this.httpsPort;
+
server = new Server();
SelectChannelConnector connector = null;
@@ -196,15 +181,15 @@ public class JettyServer {
}
}
- /**
- * Stops the embedded Jetty server.
- *
- * @throws Exception
- */
- public static synchronized void stop() throws Exception {
+ @Override
+ protected void after() {
if (server != null) {
logger.info("Stop called");
- server.stop();
+ try {
+ server.stop();
+ } catch (Exception ex) {
+ logger.error("Failed to stop Jetty server", ex);
+ }
server = null;
}
}
@@ -213,7 +198,7 @@ public class JettyServer {
* @return Jetty's http connector port.
* @throws IllegalStateException If Jetty is not running or the http
connector cannot be found.
*/
- public static synchronized int getHttpPort() throws IllegalStateException {
+ public int getHttpPort() throws IllegalStateException {
assertStarted();
Connector[] connectors = server.getConnectors();
@@ -236,7 +221,7 @@ public class JettyServer {
* @return Jetty's ssl connector port.
* @throws IllegalStateException If Jetty is not running or the ssl
connector cannot be found.
*/
- public static synchronized int getHttpsPort() throws IllegalStateException
{
+ public int getHttpsPort() throws IllegalStateException {
assertStarted();
Connector[] connectors = server.getConnectors();
@@ -254,7 +239,7 @@ public class JettyServer {
throw new IllegalStateException("Could not find Jetty https
connector");
}
- private static void assertStarted() throws IllegalStateException {
+ private void assertStarted() throws IllegalStateException {
if (server == null) {
throw new IllegalStateException("Jetty server is not initialized");
}
Modified:
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/rahas/TestClient.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/rahas/TestClient.java?rev=1778802&r1=1778801&r2=1778802&view=diff
==============================================================================
---
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/rahas/TestClient.java
(original)
+++
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/rahas/TestClient.java
Sat Jan 14 17:23:53 2017
@@ -34,27 +34,19 @@ import org.apache.axis2.integration.Jett
import org.apache.neethi.Policy;
import org.apache.neethi.PolicyEngine;
import org.apache.rampart.RampartMessageData;
+import org.junit.Rule;
+import org.junit.Test;
-import junit.framework.TestCase;
-
-public abstract class TestClient extends TestCase {
+public abstract class TestClient {
protected int port = 5555;
- public TestClient(String name) {
- super(name);
- }
-
- protected void setUp() throws Exception {
- JettyServer.start(Constants.TESTING_PATH + getServiceRepo(), port, -1);
- }
-
- protected void tearDown() throws Exception {
- JettyServer.stop();
- }
+ @Rule
+ public final JettyServer server = new JettyServer(Constants.TESTING_PATH +
getServiceRepo(), port, -1);
/**
*/
+ @Test
public void testRequest() throws Exception {
// Get the repository location from the args
String repo = Constants.TESTING_PATH + "rahas_client_repo";
Modified:
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/rampart/KerberosDelegationService.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/rampart/KerberosDelegationService.java?rev=1778802&r1=1778801&r2=1778802&view=diff
==============================================================================
---
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/rampart/KerberosDelegationService.java
(original)
+++
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/main/java/org/apache/rampart/KerberosDelegationService.java
Sat Jan 14 17:23:53 2017
@@ -3,6 +3,7 @@ package org.apache.rampart;
import java.net.MalformedURLException;
import java.net.URL;
+import javax.servlet.http.HttpServletRequest;
import javax.xml.namespace.QName;
import org.apache.axiom.om.OMAbstractFactory;
@@ -13,7 +14,7 @@ import org.apache.axis2.AxisFault;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
-import org.apache.axis2.integration.JettyServer;
+import org.apache.axis2.context.MessageContext;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.neethi.Policy;
import org.apache.rampart.policy.model.KerberosConfig;
@@ -26,9 +27,10 @@ public class KerberosDelegationService e
public OMElement echo(OMElement elem) throws MalformedURLException,
IllegalStateException, AxisFault {
+ int port =
((HttpServletRequest)MessageContext.getCurrentMessageContext().getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST)).getLocalPort();
final String serviceName = "KerberosOverTransportKeytab";
- URL wsdlUrl = new
URL(String.format("https://localhost:%s/axis2/services/%s?wsdl",
JettyServer.getHttpsPort(), serviceName));
+ URL wsdlUrl = new
URL(String.format("https://localhost:%s/axis2/services/%s?wsdl", port,
serviceName));
ConfigurationContext configContext = ConfigurationContextFactory.
createConfigurationContextFromFileSystem("target/test-resources/rampart_client_repo",
null);
Modified:
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAML2TokenCertForHoKTest.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAML2TokenCertForHoKTest.java?rev=1778802&r1=1778801&r2=1778802&view=diff
==============================================================================
---
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAML2TokenCertForHoKTest.java
(original)
+++
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAML2TokenCertForHoKTest.java
Sat Jan 14 17:23:53 2017
@@ -22,13 +22,11 @@ import org.apache.axiom.om.OMAbstractFac
import org.apache.neethi.Policy;
import org.apache.ws.secpolicy.SP11Constants;
+import static org.junit.Assert.assertNotNull;
+
import javax.xml.namespace.QName;
public class RahasSAML2TokenCertForHoKTest extends TestClient{
- public RahasSAML2TokenCertForHoKTest(String name) {
- super(name);
- }
-
public String getServiceRepo() {
return "rahas_service_repo_1";
}
Modified:
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAML2TokenTest.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAML2TokenTest.java?rev=1778802&r1=1778801&r2=1778802&view=diff
==============================================================================
---
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAML2TokenTest.java
(original)
+++
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAML2TokenTest.java
Sat Jan 14 17:23:53 2017
@@ -22,15 +22,11 @@ import org.apache.axiom.om.OMAbstractFac
import org.apache.neethi.Policy;
import org.apache.ws.secpolicy.SP11Constants;
+import static org.junit.Assert.assertNotNull;
+
import javax.xml.namespace.QName;
-public class RahasSAML2TokenTest extends TestClient{
- /**
- * @param name
- */
- public RahasSAML2TokenTest(String name) {
- super(name);
- }
+public class RahasSAML2TokenTest extends TestClient{
public String getServiceRepo() {
return "rahas_service_repo_1";
}
Modified:
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAML2TokenUTForBearerTest.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAML2TokenUTForBearerTest.java?rev=1778802&r1=1778801&r2=1778802&view=diff
==============================================================================
---
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAML2TokenUTForBearerTest.java
(original)
+++
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAML2TokenUTForBearerTest.java
Sat Jan 14 17:23:53 2017
@@ -33,6 +33,10 @@ import org.w3c.dom.Element;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import java.io.ByteArrayInputStream;
import java.util.List;
@@ -41,11 +45,6 @@ import java.util.List;
* @author Ruchith Fernando ([email protected])
*/
public class RahasSAML2TokenUTForBearerTest extends TestClient {
-
- public RahasSAML2TokenUTForBearerTest(String name) {
- super(name);
- }
-
public OMElement getRequest() {
try {
OMElement rstElem =
TrustUtil.createRequestSecurityTokenElement(RahasConstants.VERSION_05_02);
Modified:
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenAttributeTest.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenAttributeTest.java?rev=1778802&r1=1778801&r2=1778802&view=diff
==============================================================================
---
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenAttributeTest.java
(original)
+++
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenAttributeTest.java
Sat Jan 14 17:23:53 2017
@@ -1,5 +1,7 @@
package org.apache.rahas;
+import static org.junit.Assert.assertNotNull;
+
import javax.xml.namespace.QName;
import org.apache.axiom.om.OMAbstractFactory;
@@ -9,11 +11,6 @@ import org.apache.neethi.Policy;
import org.apache.ws.secpolicy.SP11Constants;
public class RahasSAMLTokenAttributeTest extends TestClient{
-
- public RahasSAMLTokenAttributeTest(String name) {
- super(name);
- }
-
public OMElement getRequest() {
try {
OMElement rstElem =
TrustUtil.createRequestSecurityTokenElement(RahasConstants.VERSION_05_02);
Modified:
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenCertForHoKTest.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenCertForHoKTest.java?rev=1778802&r1=1778801&r2=1778802&view=diff
==============================================================================
---
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenCertForHoKTest.java
(original)
+++
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenCertForHoKTest.java
Sat Jan 14 17:23:53 2017
@@ -22,15 +22,11 @@ import org.apache.axiom.om.OMFactory;
import org.apache.neethi.Policy;
import org.apache.ws.secpolicy.SP11Constants;
-import javax.xml.namespace.QName;
+import static org.junit.Assert.assertNotNull;
+import javax.xml.namespace.QName;
public class RahasSAMLTokenCertForHoKTest extends TestClient {
-
- public RahasSAMLTokenCertForHoKTest(String name) {
- super(name);
- }
-
public String getServiceRepo() {
return "rahas_service_repo_1";
}
Modified:
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenCertForHoKV1205Test.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenCertForHoKV1205Test.java?rev=1778802&r1=1778801&r2=1778802&view=diff
==============================================================================
---
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenCertForHoKV1205Test.java
(original)
+++
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenCertForHoKV1205Test.java
Sat Jan 14 17:23:53 2017
@@ -22,15 +22,11 @@ import org.apache.axiom.om.OMFactory;
import org.apache.neethi.Policy;
import org.apache.ws.secpolicy.SP12Constants;
+import static org.junit.Assert.assertNotNull;
+
import javax.xml.namespace.QName;
public class RahasSAMLTokenCertForHoKV1205Test extends TestClient {
-
-
- public RahasSAMLTokenCertForHoKV1205Test(String name) {
- super(name);
- }
-
public OMElement getRequest() {
try {
OMElement rstElem =
Modified:
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenTest.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenTest.java?rev=1778802&r1=1778801&r2=1778802&view=diff
==============================================================================
---
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenTest.java
(original)
+++
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenTest.java
Sat Jan 14 17:23:53 2017
@@ -22,18 +22,11 @@ import org.apache.axiom.om.OMFactory;
import org.apache.neethi.Policy;
import org.apache.ws.secpolicy.SP11Constants;
+import static org.junit.Assert.assertNotNull;
+
import javax.xml.namespace.QName;
public class RahasSAMLTokenTest extends TestClient {
-
-
- /**
- * @param name
- */
- public RahasSAMLTokenTest(String name) {
- super(name);
- }
-
public String getServiceRepo() {
return "rahas_service_repo_1";
}
Modified:
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForBearerTest.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForBearerTest.java?rev=1778802&r1=1778801&r2=1778802&view=diff
==============================================================================
---
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForBearerTest.java
(original)
+++
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForBearerTest.java
Sat Jan 14 17:23:53 2017
@@ -34,6 +34,10 @@ import org.w3c.dom.Element;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import java.io.ByteArrayInputStream;
import java.util.List;
@@ -42,11 +46,6 @@ import java.util.List;
* @author Ruchith Fernando ([email protected])
*/
public class RahasSAMLTokenUTForBearerTest extends TestClient {
-
- public RahasSAMLTokenUTForBearerTest(String name) {
- super(name);
- }
-
public OMElement getRequest() {
try {
OMElement rstElem =
TrustUtil.createRequestSecurityTokenElement(RahasConstants.VERSION_05_02);
Modified:
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForBearerV1205Test.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForBearerV1205Test.java?rev=1778802&r1=1778801&r2=1778802&view=diff
==============================================================================
---
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForBearerV1205Test.java
(original)
+++
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForBearerV1205Test.java
Sat Jan 14 17:23:53 2017
@@ -22,17 +22,11 @@ import org.apache.axiom.om.OMFactory;
import org.apache.neethi.Policy;
import org.apache.ws.secpolicy.SP12Constants;
+import static org.junit.Assert.assertNotNull;
+
import javax.xml.namespace.QName;
public class RahasSAMLTokenUTForBearerV1205Test extends TestClient {
-
- /**
- * @param name
- */
- public RahasSAMLTokenUTForBearerV1205Test(String name) {
- super(name);
- }
-
public OMElement getRequest() {
try {
OMElement rstElem =
TrustUtil.createRequestSecurityTokenElement(RahasConstants.VERSION_05_12);
Modified:
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForHoKTest.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForHoKTest.java?rev=1778802&r1=1778801&r2=1778802&view=diff
==============================================================================
---
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForHoKTest.java
(original)
+++
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForHoKTest.java
Sat Jan 14 17:23:53 2017
@@ -22,14 +22,11 @@ import org.apache.axiom.om.OMFactory;
import org.apache.neethi.Policy;
import org.apache.ws.secpolicy.SP11Constants;
+import static org.junit.Assert.assertNotNull;
+
import javax.xml.namespace.QName;
public class RahasSAMLTokenUTForHoKTest extends TestClient {
-
- public RahasSAMLTokenUTForHoKTest(String name) {
- super(name);
- }
-
public OMElement getRequest() {
try {
OMElement rstElem =
TrustUtil.createRequestSecurityTokenElement(RahasConstants.VERSION_05_02);
Modified:
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForHoKV1205Test.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForHoKV1205Test.java?rev=1778802&r1=1778801&r2=1778802&view=diff
==============================================================================
---
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForHoKV1205Test.java
(original)
+++
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenUTForHoKV1205Test.java
Sat Jan 14 17:23:53 2017
@@ -16,6 +16,8 @@
package org.apache.rahas;
+import static org.junit.Assert.assertNotNull;
+
import javax.xml.namespace.QName;
import org.apache.axiom.om.OMAbstractFactory;
@@ -30,13 +32,6 @@ public class RahasSAMLTokenUTForHoKV1205
byte[] clientEntr;
- /**
- * @param name
- */
- public RahasSAMLTokenUTForHoKV1205Test(String name) {
- super(name);
- }
-
public OMElement getRequest() {
try {
OMElement rstElem =
TrustUtil.createRequestSecurityTokenElement(RahasConstants.VERSION_05_12);
Modified:
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenV1205Test.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenV1205Test.java?rev=1778802&r1=1778801&r2=1778802&view=diff
==============================================================================
---
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenV1205Test.java
(original)
+++
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rahas/RahasSAMLTokenV1205Test.java
Sat Jan 14 17:23:53 2017
@@ -22,20 +22,14 @@ import org.apache.axiom.om.OMFactory;
import org.apache.neethi.Policy;
import org.apache.ws.secpolicy.SP12Constants;
+import static org.junit.Assert.assertNotNull;
+
import javax.xml.namespace.QName;
/**
* RahasSAMLTokenTest with the WS-SX namespaces
*/
public class RahasSAMLTokenV1205Test extends TestClient {
-
- /**
- * @param name
- */
- public RahasSAMLTokenV1205Test(String name) {
- super(name);
- }
-
public OMElement getRequest() {
try {
OMElement rstElem =
TrustUtil.createRequestSecurityTokenElement(RahasConstants.VERSION_05_12);
Modified:
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/AbstractRampartTest.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/AbstractRampartTest.java?rev=1778802&r1=1778801&r2=1778802&view=diff
==============================================================================
---
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/AbstractRampartTest.java
(original)
+++
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/AbstractRampartTest.java
Sat Jan 14 17:23:53 2017
@@ -23,8 +23,6 @@ import java.net.URL;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
-import junit.framework.TestCase;
-
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
@@ -37,12 +35,15 @@ import org.apache.axis2.integration.Jett
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.neethi.Policy;
import org.apache.neethi.PolicyEngine;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
/**
* Base test class for integration tests that require Axis2 web application
running in a web container.
* The class uses Axis2 web application deployed via {@link JettyServer}.
*/
-public abstract class AbstractRampartTest extends TestCase {
+public abstract class AbstractRampartTest {
/**
* Default client connection timeout in milliseconds: {@value}
@@ -54,6 +55,11 @@ public abstract class AbstractRampartTes
protected static final String RAMPART_SERVICE_REPO_PATH =
"target/test-resources/rampart_service_repo";
protected static ResourceBundle resources;
+
+ @Rule
+ public final JettyServer server = new JettyServer(
+ RAMPART_SERVICE_REPO_PATH, isEnableHttp() ? 0 : -1,
isEnableHttps() ? 0 : -1);
+
protected String trustStore;
protected String trustStorePassword;
protected String trustStoreType;
@@ -65,19 +71,9 @@ public abstract class AbstractRampartTes
throw new RuntimeException(e.getMessage());
}
}
-
- public AbstractRampartTest() {
-
- }
- public AbstractRampartTest(String name) {
- super(name);
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
trustStore = System.getProperty("javax.net.ssl.trustStore");
System.setProperty("javax.net.ssl.trustStore", CLIENT_KEYSTORE);
@@ -86,54 +82,31 @@ public abstract class AbstractRampartTes
trustStoreType = System.getProperty("javax.net.ssl.trustStoreType");
System.setProperty("javax.net.ssl.trustStoreType", "JKS");
-
- JettyServer.start(RAMPART_SERVICE_REPO_PATH, isEnableHttp(),
isEnableHttps());
}
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- try {
- JettyServer.stop();
+ @After
+ public void tearDown() throws Exception {
+ if (trustStore != null) {
+ System.setProperty("javax.net.ssl.trustStore", trustStore);
}
- finally {
- if (trustStore != null) {
- System.setProperty("javax.net.ssl.trustStore", trustStore);
- }
- else {
- System.clearProperty("javax.net.ssl.trustStore");
- }
-
- if (trustStorePassword != null) {
- System.setProperty("javax.net.ssl.trustStorePassword",
trustStorePassword);
- }
- else {
- System.clearProperty("javax.net.ssl.trustStorePassword");
- }
-
- if (trustStoreType != null) {
- System.setProperty("javax.net.ssl.trustStoreType",
trustStoreType);
- }
- else {
- System.clearProperty("javax.net.ssl.trustStoreType");
- }
+ else {
+ System.clearProperty("javax.net.ssl.trustStore");
+ }
+
+ if (trustStorePassword != null) {
+ System.setProperty("javax.net.ssl.trustStorePassword",
trustStorePassword);
+ }
+ else {
+ System.clearProperty("javax.net.ssl.trustStorePassword");
+ }
+
+ if (trustStoreType != null) {
+ System.setProperty("javax.net.ssl.trustStoreType", trustStoreType);
+ }
+ else {
+ System.clearProperty("javax.net.ssl.trustStoreType");
}
- }
-
- /**
- * @return Jetty http port, see {@link JettyServer#getHttpPort()}
- */
- protected int getHttpPort() {
- return JettyServer.getHttpPort();
- }
-
- /**
- * @return Jetty https port, see {@link JettyServer#getHttpsPort()}
- */
- protected int getHttpsPort() {
- return JettyServer.getHttpsPort();
}
protected ServiceClient getServiceClientInstance() throws AxisFault {
Modified:
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/RampartKerberosTest.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/RampartKerberosTest.java?rev=1778802&r1=1778801&r2=1778802&view=diff
==============================================================================
---
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/RampartKerberosTest.java
(original)
+++
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/RampartKerberosTest.java
Sat Jan 14 17:23:53 2017
@@ -17,6 +17,9 @@ import org.apache.rampart.policy.model.K
import org.apache.rampart.policy.model.RampartConfig;
import org.apache.rampart.util.KerberosServer;
import org.custommonkey.xmlunit.XMLAssert;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.xml.sax.SAXException;
/**
@@ -69,9 +72,10 @@ public class RampartKerberosTest extends
*/
protected String krb5Conf;
+ @Test
public void testKerberosOverTransportKeytab() throws XMLStreamException,
SAXException, IOException {
final String serviceName = "KerberosOverTransportKeytab";
- URL serviceUrl = new
URL(String.format("https://localhost:%s/axis2/services/%s?wsdl",
getHttpsPort(), serviceName));
+ URL serviceUrl = new
URL(String.format("https://localhost:%s/axis2/services/%s?wsdl",
server.getHttpsPort(), serviceName));
ServiceClient serviceClient = getServiceClientInstance(serviceUrl);
@@ -95,9 +99,10 @@ public class RampartKerberosTest extends
XMLAssert.assertXMLEqual(echoElement.toStringWithConsume(),
result.toStringWithConsume());
}
+ @Test
public void testKerberosOverTransportPWCB() throws XMLStreamException,
SAXException, IOException {
final String serviceName = "KerberosOverTransportPWCB";
- URL serviceUrl = new
URL(String.format("https://localhost:%s/axis2/services/%s?wsdl",
getHttpsPort(), serviceName));
+ URL serviceUrl = new
URL(String.format("https://localhost:%s/axis2/services/%s?wsdl",
server.getHttpsPort(), serviceName));
ServiceClient serviceClient = getServiceClientInstance(serviceUrl);
@@ -123,10 +128,10 @@ public class RampartKerberosTest extends
XMLAssert.assertXMLEqual(echoElement.toStringWithConsume(),
result.toStringWithConsume());
}
-
+ @Test
public void testKerberosDelegation() throws XMLStreamException,
SAXException, IOException {
final String serviceName = "KerberosDelegation";
- URL serviceUrl = new
URL(String.format("https://localhost:%s/axis2/services/%s?wsdl",
getHttpsPort(), serviceName));
+ URL serviceUrl = new
URL(String.format("https://localhost:%s/axis2/services/%s?wsdl",
server.getHttpsPort(), serviceName));
ServiceClient serviceClient = getServiceClientInstance(serviceUrl);
@@ -151,13 +156,8 @@ public class RampartKerberosTest extends
XMLAssert.assertXMLEqual(echoElement.toStringWithConsume(),
result.toStringWithConsume());
}
- /* (non-Javadoc)
- * @see org.apache.rampart.AbstractRampartTest#setUp()
- */
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
+ @Before
+ public void setUpKerberos() throws Exception {
System.setProperty("sun.security.krb5.debug", "true");
System.setProperty("sun.security.jgss.debug", "true");
@@ -176,13 +176,8 @@ public class RampartKerberosTest extends
System.setProperty(JAAS_CONF_SYS_PROP, KERBEROS_JAAS_CONF);
}
- /* (non-Javadoc)
- * @see org.apache.rampart.AbstractRampartTest#tearDown()
- */
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
-
+ @After
+ public void tearDownKerberos() throws Exception {
KerberosServer.stopKerberosServer();
if (jaasConf != null) {
Modified:
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/RampartTest.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/RampartTest.java?rev=1778802&r1=1778801&r2=1778802&view=diff
==============================================================================
---
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/RampartTest.java
(original)
+++
axis/axis2/java/rampart/branches/RAMPART-433/modules/rampart-integration/src/test/java/org/apache/rampart/RampartTest.java
Sat Jan 14 17:23:53 2017
@@ -16,12 +16,11 @@
package org.apache.rampart;
-import static org.apache.axis2.integration.JettyServer.getHttpPort;
-import static org.apache.axis2.integration.JettyServer.getHttpsPort;
import static org.apache.axis2.integration.JettyServer.CLIENT_KEYSTORE;
import static org.apache.axis2.integration.JettyServer.KEYSTORE_PASSWORD;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
-import junit.framework.TestCase;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
@@ -39,14 +38,22 @@ import org.apache.axis2.context.ServiceC
import org.apache.axis2.integration.JettyServer;
import org.apache.neethi.Policy;
import org.apache.neethi.PolicyEngine;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
-public class RampartTest extends TestCase {
+public class RampartTest {
private static ResourceBundle resources;
+
+ @Rule
+ public final JettyServer server = new JettyServer(Constants.TESTING_PATH +
"rampart_service_repo", 0, 0);
+
private String trustStore;
private String trustStorePassword;
private String trustStoreType;
@@ -59,11 +66,8 @@ public class RampartTest extends TestCas
}
}
- public RampartTest(String name) {
- super(name);
- }
-
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
trustStore = System.getProperty("javax.net.ssl.trustStore");
System.setProperty("javax.net.ssl.trustStore", CLIENT_KEYSTORE);
@@ -72,36 +76,30 @@ public class RampartTest extends TestCas
trustStoreType = System.getProperty("javax.net.ssl.trustStoreType");
System.setProperty("javax.net.ssl.trustStoreType", "JKS");
-
- JettyServer.start(Constants.TESTING_PATH + "rampart_service_repo");
}
- protected void tearDown() throws Exception {
- try {
- JettyServer.stop();
+ @After
+ public void tearDown() throws Exception {
+ if (trustStore != null) {
+ System.setProperty("javax.net.ssl.trustStore", trustStore);
}
- finally {
- if (trustStore != null) {
- System.setProperty("javax.net.ssl.trustStore", trustStore);
- }
- else {
- System.clearProperty("javax.net.ssl.trustStore");
- }
-
- if (trustStorePassword != null) {
- System.setProperty("javax.net.ssl.trustStorePassword",
trustStorePassword);
- }
- else {
- System.clearProperty("javax.net.ssl.trustStorePassword");
- }
-
- if (trustStoreType != null) {
- System.setProperty("javax.net.ssl.trustStoreType",
trustStoreType);
- }
- else {
- System.clearProperty("javax.net.ssl.trustStoreType");
- }
+ else {
+ System.clearProperty("javax.net.ssl.trustStore");
+ }
+
+ if (trustStorePassword != null) {
+ System.setProperty("javax.net.ssl.trustStorePassword",
trustStorePassword);
+ }
+ else {
+ System.clearProperty("javax.net.ssl.trustStorePassword");
+ }
+
+ if (trustStoreType != null) {
+ System.setProperty("javax.net.ssl.trustStoreType", trustStoreType);
+ }
+ else {
+ System.clearProperty("javax.net.ssl.trustStoreType");
}
}
@@ -121,6 +119,7 @@ public class RampartTest extends TestCas
}
+ @Test
public void testWithPolicy() {
try {
@@ -149,7 +148,7 @@ public class RampartTest extends TestCas
if( i == 13 ) {
options.setTo(new EndpointReference("https://localhost:" +
- getHttpsPort() +
+ server.getHttpsPort() +
"/axis2/services/SecureService" + i));
//Username token created with user/pass from options
options.setUserName("alice");
@@ -157,7 +156,7 @@ public class RampartTest extends TestCas
}
else {
options.setTo(new EndpointReference("http://localhost:" +
- getHttpPort() +
+ server.getHttpPort() +
"/axis2/services/SecureService" + i));
}
@@ -225,7 +224,7 @@ public class RampartTest extends TestCas
if (i == 13) {
options.setTo(new EndpointReference("https://localhost:" +
- getHttpsPort() +
+ server.getHttpsPort() +
"/axis2/services/SecureService" + i));
//Username token created with user/pass from options
options.setUserName("alice");
@@ -233,7 +232,7 @@ public class RampartTest extends TestCas
}
else {
options.setTo(new EndpointReference("http://localhost:" +
- getHttpPort() +
+ server.getHttpPort() +
"/axis2/services/SecureService" + i));
}
System.out.println("Testing WS-Sec: negative scenario " + i);
@@ -259,10 +258,10 @@ public class RampartTest extends TestCas
Options options = new Options();
if (i == 3 || i == 6) {
- options.setTo(new EndpointReference("https://localhost:" +
getHttpsPort() + "/axis2/services/SecureServiceSC" + i));
+ options.setTo(new EndpointReference("https://localhost:" +
server.getHttpsPort() + "/axis2/services/SecureServiceSC" + i));
}
else {
- options.setTo(new EndpointReference("http://localhost:" +
getHttpPort() + "/axis2/services/SecureServiceSC" + i));
+ options.setTo(new EndpointReference("http://localhost:" +
server.getHttpPort() + "/axis2/services/SecureServiceSC" + i));
}
System.out.println("Testing WS-SecConv: custom scenario " + i);
Modified: axis/axis2/java/rampart/branches/RAMPART-433/pom.xml
URL:
http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-433/pom.xml?rev=1778802&r1=1778801&r2=1778802&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-433/pom.xml (original)
+++ axis/axis2/java/rampart/branches/RAMPART-433/pom.xml Sat Jan 14 17:23:53
2017
@@ -547,7 +547,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>3.8.2</version>
+ <version>4.12</version>
</dependency>
<dependency>
<groupId>xmlunit</groupId>
@@ -616,7 +616,7 @@
<axis2.version>1.8.0-SNAPSHOT</axis2.version>
<axiom.version>1.3.0-SNAPSHOT</axiom.version>
- <wss4j.version>1.6.17</wss4j.version>
+ <wss4j.version>1.6.19</wss4j.version>
<opensaml.version>2.5.1-1</opensaml.version>
<bcprov.jdk15.version>1.49</bcprov.jdk15.version>