Skip to content

Commit

Permalink
Use the solid reload method in ReloadWSDLPublisherTestCase
Browse files Browse the repository at this point in the history
  • Loading branch information
bstansberry committed Jun 23, 2015
1 parent d9c4576 commit 37d842b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 73 deletions.
Expand Up @@ -21,21 +21,22 @@
*/ */
package org.jboss.as.test.manualmode.ws; package org.jboss.as.test.manualmode.ws;


import static org.jboss.as.test.shared.ServerReload.executeReloadAndWaitForCompletion;

import java.io.IOException; import java.io.IOException;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.Proxy; import java.net.Proxy;
import java.net.ProxySelector; import java.net.ProxySelector;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.util.List; import java.util.List;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;


import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.xml.namespace.QName; import javax.xml.namespace.QName;
import javax.xml.ws.Service; import javax.xml.ws.Service;

import org.jboss.arquillian.container.test.api.ContainerController; import org.jboss.arquillian.container.test.api.ContainerController;
import org.jboss.arquillian.container.test.api.Deployer; import org.jboss.arquillian.container.test.api.Deployer;
import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.container.test.api.Deployment;
Expand All @@ -44,24 +45,14 @@
import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.as.arquillian.container.ManagementClient; import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.as.controller.client.ModelControllerClient; import org.jboss.as.test.shared.TestSuiteEnvironment;
import org.jboss.as.controller.client.helpers.Operations;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.NAME;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.READ_ATTRIBUTE_OPERATION;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RESULT;
import org.jboss.dmr.ModelNode;
import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive; import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.as.test.shared.TestSuiteEnvironment;
import org.junit.After; import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import static org.junit.Assert.fail;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.xnio.IoUtils;


/** /**
* *
Expand Down Expand Up @@ -111,7 +102,7 @@ public void testHelloStringAfterReload() throws Exception {
Service service = Service.create(wsdlURL, serviceName); Service service = Service.create(wsdlURL, serviceName);
EndpointIface proxy = service.getPort(EndpointIface.class); EndpointIface proxy = service.getPort(EndpointIface.class);
Assert.assertEquals("Hello World!", proxy.helloString("World")); Assert.assertEquals("Hello World!", proxy.helloString("World"));
reloadServer(managementClient, 100000); executeReloadAndWaitForCompletion(managementClient.getControllerClient(), 100000);
checkWsdl(wsdlURL); checkWsdl(wsdlURL);
serviceName = new QName("http://jbossws.org/basic", "POJOService"); serviceName = new QName("http://jbossws.org/basic", "POJOService");
service = Service.create(wsdlURL, serviceName); service = Service.create(wsdlURL, serviceName);
Expand All @@ -132,53 +123,6 @@ public void stopContainer() {
} }
} }


private void reloadServer(ManagementClient managementClient, int timeout) throws Exception {
executeReload(managementClient.getControllerClient());
waitForLiveServerToReload(timeout);
}

private void executeReload(ModelControllerClient client) throws IOException {
ModelNode operation = new ModelNode();
operation.get(OP_ADDR).setEmptyList();
operation.get(OP).set("reload");
try {
Assert.assertTrue(Operations.isSuccessfulOutcome(client.execute(operation)));
} catch(IOException e) {
final Throwable cause = e.getCause();
if (!(cause instanceof ExecutionException) && !(cause instanceof CancellationException)) {
throw e;
} // else ignore, this might happen if the channel gets closed before we got the response
} finally {
client.close();
}
}

private void waitForLiveServerToReload(int timeout) throws Exception {
long start = System.currentTimeMillis();
ModelNode operation = new ModelNode();
operation.get(OP_ADDR).setEmptyList();
operation.get(OP).set(READ_ATTRIBUTE_OPERATION);
operation.get(NAME).set("server-state");
while (System.currentTimeMillis() - start < timeout) {
ModelControllerClient liveClient = ModelControllerClient.Factory.create(
TestSuiteEnvironment.getServerAddress(), TestSuiteEnvironment.getServerPort());
try {
ModelNode result = liveClient.execute(operation);
if ("running".equals(result.get(RESULT).asString())) {
return;
}
} catch (IOException e) {
} finally {
IoUtils.safeClose(liveClient);
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
}
fail("Live Server did not reload in the imparted time.");
}

private void checkWsdl(URL wsdlURL) throws IOException { private void checkWsdl(URL wsdlURL) throws IOException {
StringBuilder proxyUsed = new StringBuilder(); StringBuilder proxyUsed = new StringBuilder();
try { try {
Expand Down
Expand Up @@ -22,24 +22,24 @@


package org.jboss.as.test.shared; package org.jboss.as.test.shared;


import org.jboss.as.controller.client.ModelControllerClient;
import org.jboss.as.controller.client.helpers.ClientConstants;
import org.jboss.dmr.ModelNode;
import org.junit.Assert;
import org.xnio.IoUtils;

import java.io.IOException;
import java.net.UnknownHostException;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;

import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.NAME; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.NAME;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.READ_ATTRIBUTE_OPERATION; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.READ_ATTRIBUTE_OPERATION;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RESULT; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RESULT;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;


import java.io.IOException;
import java.net.UnknownHostException;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;

import org.jboss.as.controller.client.ModelControllerClient;
import org.jboss.as.controller.client.helpers.ClientConstants;
import org.jboss.dmr.ModelNode;
import org.junit.Assert;
import org.xnio.IoUtils;

/** /**
* @author Stuart Douglas * @author Stuart Douglas
*/ */
Expand All @@ -48,8 +48,12 @@ public class ServerReload {
public static final int TIMEOUT = 100000; public static final int TIMEOUT = 100000;


public static void executeReloadAndWaitForCompletion(ModelControllerClient client) { public static void executeReloadAndWaitForCompletion(ModelControllerClient client) {
executeReloadAndWaitForCompletion(client, TIMEOUT);
}

public static void executeReloadAndWaitForCompletion(ModelControllerClient client, int timeout) {
executeReload(client); executeReload(client);
waitForLiveServerToReload(TIMEOUT); waitForLiveServerToReload(timeout);
} }


private static void executeReload(ModelControllerClient client) { private static void executeReload(ModelControllerClient client) {
Expand Down

0 comments on commit 37d842b

Please sign in to comment.