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 2017/01/28 18:11:45 UTC
svn commit: r1780727 - in
/axis/axis2/java/rampart/trunk/modules/rampart-integration/src:
main/java/org/apache/rahas/TestClient.java
test/java/org/apache/rampart/RampartTest.java
Author: veithen
Date: Sat Jan 28 18:11:44 2017
New Revision: 1780727
URL: http://svn.apache.org/viewvc?rev=1780727&view=rev
Log:
Use the new ClientHelper class.
Modified:
axis/axis2/java/rampart/trunk/modules/rampart-integration/src/main/java/org/apache/rahas/TestClient.java
axis/axis2/java/rampart/trunk/modules/rampart-integration/src/test/java/org/apache/rampart/RampartTest.java
Modified: axis/axis2/java/rampart/trunk/modules/rampart-integration/src/main/java/org/apache/rahas/TestClient.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/trunk/modules/rampart-integration/src/main/java/org/apache/rahas/TestClient.java?rev=1780727&r1=1780726&r2=1780727&view=diff
==============================================================================
--- axis/axis2/java/rampart/trunk/modules/rampart-integration/src/main/java/org/apache/rahas/TestClient.java (original)
+++ axis/axis2/java/rampart/trunk/modules/rampart-integration/src/main/java/org/apache/rahas/TestClient.java Sat Jan 28 18:11:44 2017
@@ -28,9 +28,8 @@ import org.apache.axis2.Constants;
import org.apache.axis2.addressing.AddressingConstants;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.testutils.ClientHelper;
import org.apache.axis2.testutils.JettyServer;
import org.apache.neethi.Policy;
import org.apache.neethi.PolicyEngine;
@@ -43,40 +42,15 @@ public abstract class TestClient {
@Rule
public final JettyServer server = new JettyServer(TESTING_PATH + getServiceRepo(), false);
+ @Rule
+ public final ClientHelper clientHelper = new ClientHelper(server, TESTING_PATH + "rahas_client_repo");
+
/**
*/
@Test
public void testRequest() throws Exception {
- // Get the repository location from the args
- String repo = TESTING_PATH + "rahas_client_repo";
-
- ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repo,
- null);
- ServiceClient serviceClient = new ServiceClient(configContext, null);
- Options options = new Options();
-
- System.setProperty("javax.net.ssl.keyStorePassword", "password");
- System.setProperty("javax.net.ssl.keyStoreType", "JKS");
- System.setProperty("javax.net.ssl.trustStore", "/home/ruchith/Desktop/interop/certs/interop2.jks");
- System.setProperty("javax.net.ssl.trustStorePassword", "password");
- System.setProperty("javax.net.ssl.trustStoreType","JKS");
-
- options.setTo(server.getEndpointReference("SecureService"));
-// options.setTo(new EndpointReference("http://127.0.0.1:" + 9090 + "/axis2/services/UTSAMLHoK"));
-// options.setTo(new EndpointReference("https://www-lk.wso2.com:8443/axis2/services/UTSAMLHoK"));
-// options.setTo(new EndpointReference("https://192.18.49.133:2343/jaxws-s1-sts/sts"));
-// options.setTo(new EndpointReference("https://207.200.37.116/SxSts/Scenario_1_IssuedTokenOverTransport_UsernameOverTransport"));
-// options.setTo(new EndpointReference("http://localhost:9090/SxSts/Scenario_4_IssuedToken_MutualCertificate10"));
-
-// options.setTo(new EndpointReference("http://127.0.0.1:" + 9090 + "/axis2/services/MutualCertsSAMLHoK"));
-// options.setTo(new EndpointReference("http://www-lk.wso2.com:8888/axis2/services/MutualCertsSAMLHoK"));
-// options.setTo(new EndpointReference("https://131.107.72.15/trust/Addressing2004/UserName"));
-// options.setTo(new EndpointReference("https://131.107.72.15/trust/UserName"));
-// options.setTo(new EndpointReference("http://127.0.0.1:" + 9090 + "/trust/X509WSS10"));
-// options.setTo(new EndpointReference("https://131.107.72.15/trust/UserName"));
-// options.setTo(new EndpointReference("http://127.0.0.1:" + 9090 + "/jaxws-s4-sts/sts"));
-// options.setTo(new EndpointReference("http://127.0.0.1:9090/jaxws-s4/simple"));
-// options.setTo(new EndpointReference("http://127.0.0.1:" + 9090 + "/axis2/services/UTSAMLBearer"));
+ ServiceClient serviceClient = clientHelper.createServiceClient("SecureService");
+ Options options = serviceClient.getOptions();
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
options.setAction(this.getRequestAction());
@@ -90,8 +64,6 @@ public abstract class TestClient {
serviceClient.engageModule("addressing");
serviceClient.engageModule("rampart");
- serviceClient.setOptions(options);
-
//Blocking invocation
OMElement result = serviceClient.sendReceive(getRequest());
Modified: axis/axis2/java/rampart/trunk/modules/rampart-integration/src/test/java/org/apache/rampart/RampartTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/trunk/modules/rampart-integration/src/test/java/org/apache/rampart/RampartTest.java?rev=1780727&r1=1780726&r2=1780727&view=diff
==============================================================================
--- axis/axis2/java/rampart/trunk/modules/rampart-integration/src/test/java/org/apache/rampart/RampartTest.java (original)
+++ axis/axis2/java/rampart/trunk/modules/rampart-integration/src/test/java/org/apache/rampart/RampartTest.java Sat Jan 28 18:11:44 2017
@@ -30,9 +30,8 @@ import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.testutils.ClientHelper;
import org.apache.axis2.testutils.JettyServer;
import org.apache.neethi.Policy;
import org.apache.neethi.PolicyEngine;
@@ -50,8 +49,26 @@ public class RampartTest {
public final JettyServer server = new JettyServer(TESTING_PATH + "rampart_service_repo", false);
@Rule
+ public final ClientHelper clientHelper = new ClientHelper(server, TESTING_PATH + "rampart_client_repo") {
+ @Override
+ protected void configureServiceClient(ServiceClient serviceClient) throws Exception {
+ serviceClient.engageModule("addressing");
+ serviceClient.engageModule("rampart");
+ }
+ };
+
+ @Rule
public final JettyServer secureServer = new JettyServer(TESTING_PATH + "rampart_service_repo", true);
+ @Rule
+ public final ClientHelper secureClientHelper = new ClientHelper(secureServer, TESTING_PATH + "rampart_client_repo") {
+ @Override
+ protected void configureServiceClient(ServiceClient serviceClient) throws Exception {
+ serviceClient.engageModule("addressing");
+ serviceClient.engageModule("rampart");
+ }
+ };
+
static {
try {
resources = ResourceBundle.getBundle("org.apache.rampart.errors");
@@ -60,28 +77,9 @@ public class RampartTest {
}
}
- private ServiceClient getServiceClientInstance() throws AxisFault {
-
- String repository = TESTING_PATH + "rampart_client_repo";
-
- ConfigurationContext configContext = ConfigurationContextFactory.
- createConfigurationContextFromFileSystem(repository, null);
- ServiceClient serviceClient = new ServiceClient(configContext, null);
-
-
- serviceClient.engageModule("addressing");
- serviceClient.engageModule("rampart");
-
- return serviceClient;
-
- }
-
@Test
public void testWithPolicy() {
try {
-
- ServiceClient serviceClient = getServiceClientInstance();
-
//TODO : figure this out !!
boolean basic256Supported = false;
@@ -101,17 +99,15 @@ public class RampartTest {
// Testcase - 25 is failing, for the moment skipping it.
continue;
}
- Options options = new Options();
+
+ ServiceClient serviceClient = (i == 13 ? secureClientHelper : clientHelper).createServiceClient("SecureService" + i);
+ Options options = serviceClient.getOptions();
if( i == 13 ) {
- options.setTo(secureServer.getEndpointReference("SecureService" + i));
//Username token created with user/pass from options
options.setUserName("alice");
options.setPassword("password");
}
- else {
- options.setTo(server.getEndpointReference("SecureService" + i));
- }
System.out.println("Testing WS-Sec: custom scenario " + i);
options.setAction("urn:echo");
@@ -119,7 +115,6 @@ public class RampartTest {
ServiceContext context = serviceClient.getServiceContext();
context.setProperty(RampartMessageData.KEY_RAMPART_POLICY,
loadPolicy("/rampart/policy/" + i + ".xml"));
- serviceClient.setOptions(options);
if (i == 31) {
OMNamespace omNamespace = OMAbstractFactory.getOMFactory().createOMNamespace(
@@ -173,24 +168,21 @@ public class RampartTest {
//Skip the Basic256 tests
continue;
}
- Options options = new Options();
+
+ ServiceClient serviceClient = (i == 13 ? secureClientHelper : clientHelper).createServiceClient("SecureService" + i);
+ Options options = serviceClient.getOptions();
if (i == 13) {
- options.setTo(secureServer.getEndpointReference("SecureService" + i));
//Username token created with user/pass from options
options.setUserName("alice");
options.setPassword("password");
}
- else {
- options.setTo(server.getEndpointReference("SecureService" + i));
- }
System.out.println("Testing WS-Sec: negative scenario " + i);
options.setAction("urn:returnError");
ServiceContext context = serviceClient.getServiceContext();
context.setProperty(RampartMessageData.KEY_RAMPART_POLICY,
loadPolicy("/rampart/policy/" + i + ".xml"));
- serviceClient.setOptions(options);
try {
//Blocking invocation
@@ -204,23 +196,19 @@ public class RampartTest {
for (int i = 1; i <= 6; i++) { //<-The number of tests we have
- Options options = new Options();
-
+ ServiceClient serviceClient;
if (i == 3 || i == 6) {
- options.setTo(secureServer.getEndpointReference("SecureServiceSC" + i));
+ serviceClient = secureClientHelper.createServiceClient("SecureServiceSC" + i);
}
else {
- options.setTo(server.getEndpointReference("SecureServiceSC" + i));
+ serviceClient = clientHelper.createServiceClient("SecureServiceSC" + i);
}
+ Options options = serviceClient.getOptions();
System.out.println("Testing WS-SecConv: custom scenario " + i);
options.setAction("urn:echo");
- //Create a new service client instance for each secure conversation scenario
- serviceClient = getServiceClientInstance();
-
serviceClient.getServiceContext().setProperty(RampartMessageData.KEY_RAMPART_POLICY, loadPolicy("/rampart/policy/sc-" + i + ".xml"));
- serviceClient.setOptions(options);
//Blocking invocation
serviceClient.sendReceive(getEchoElement());