|
|
@@ -21,7 +21,7 @@ |
|
|
*/ |
|
|
package org.jboss.as.test.clustering.single.web; |
|
|
|
|
|
import static org.jboss.as.test.clustering.cluster.AbstractClusteringTestCase.DEPLOYMENT_1; |
|
|
import static org.jboss.as.test.clustering.cluster.AbstractClusteringTestCase.*; |
|
|
|
|
|
import java.io.IOException; |
|
|
import java.net.URI; |
|
|
@@ -38,7 +38,15 @@ |
|
|
import org.jboss.arquillian.container.test.api.OperateOnDeployment; |
|
|
import org.jboss.arquillian.junit.Arquillian; |
|
|
import org.jboss.arquillian.test.api.ArquillianResource; |
|
|
import org.jboss.as.arquillian.api.ServerSetup; |
|
|
import org.jboss.as.arquillian.container.ManagementClient; |
|
|
import org.jboss.as.controller.PathAddress; |
|
|
import org.jboss.as.controller.PathElement; |
|
|
import org.jboss.as.controller.descriptions.ModelDescriptionConstants; |
|
|
import org.jboss.as.controller.operations.common.Util; |
|
|
import org.jboss.as.test.http.util.TestHttpClientUtils; |
|
|
import org.jboss.as.test.shared.CLIServerSetupTask; |
|
|
import org.jboss.dmr.ModelNode; |
|
|
import org.jboss.shrinkwrap.api.Archive; |
|
|
import org.jboss.shrinkwrap.api.ShrinkWrap; |
|
|
import org.jboss.shrinkwrap.api.spec.WebArchive; |
|
|
@@ -52,21 +60,29 @@ |
|
|
* @author Paul Ferraro |
|
|
*/ |
|
|
@RunWith(Arquillian.class) |
|
|
@ServerSetup(SimpleWebTestCase.ServerSetupTask.class) |
|
|
public class SimpleWebTestCase { |
|
|
|
|
|
private static final String MODULE_NAME = SimpleWebTestCase.class.getSimpleName(); |
|
|
private static final String APPLICATION_NAME = MODULE_NAME + ".war"; |
|
|
|
|
|
@Deployment(name = DEPLOYMENT_1, testable = false) |
|
|
public static Archive<?> deployment() { |
|
|
WebArchive war = ShrinkWrap.create(WebArchive.class, MODULE_NAME + ".war"); |
|
|
WebArchive war = ShrinkWrap.create(WebArchive.class, APPLICATION_NAME); |
|
|
war.addClasses(SimpleServlet.class, Mutable.class); |
|
|
war.setWebXML(SimpleWebTestCase.class.getPackage(), "web.xml"); |
|
|
return war; |
|
|
} |
|
|
|
|
|
@Test |
|
|
@OperateOnDeployment(DEPLOYMENT_1) |
|
|
public void test(@ArquillianResource(SimpleServlet.class) URL baseURL) throws IOException, URISyntaxException { |
|
|
public void test(@ArquillianResource(SimpleServlet.class) URL baseURL, @ArquillianResource @OperateOnDeployment(DEPLOYMENT_1) ManagementClient managementClient) throws IOException, URISyntaxException { |
|
|
// Validate existence of runtime resource for deployment cache |
|
|
PathAddress address = PathAddress.pathAddress(PathElement.pathElement("subsystem", "infinispan"), PathElement.pathElement("cache-container", "web"), PathElement.pathElement("cache", APPLICATION_NAME)); |
|
|
ModelNode operation = Util.createOperation(ModelDescriptionConstants.READ_ATTRIBUTE_OPERATION, address); |
|
|
operation.get(ModelDescriptionConstants.NAME).set(new ModelNode("number-of-entries")); |
|
|
ModelNode result = managementClient.getControllerClient().execute(operation); |
|
|
Assert.assertEquals(0, result.get(ModelDescriptionConstants.RESULT).asInt()); |
|
|
|
|
|
URI uri = SimpleServlet.createURI(baseURL); |
|
|
|
|
|
@@ -90,5 +106,17 @@ public void test(@ArquillianResource(SimpleServlet.class) URL baseURL) throws IO |
|
|
HttpClientUtils.closeQuietly(response); |
|
|
} |
|
|
} |
|
|
|
|
|
result = managementClient.getControllerClient().execute(operation); |
|
|
Assert.assertNotEquals(0, result.get(ModelDescriptionConstants.RESULT).asInt()); |
|
|
} |
|
|
|
|
|
public static class ServerSetupTask extends CLIServerSetupTask { |
|
|
public ServerSetupTask() { |
|
|
this.builder.node("single") |
|
|
.setup("/subsystem=infinispan/cache-container=web/local-cache=passivation:write-attribute(name=statistics-enabled, value=true)") |
|
|
.teardown("/subsystem=infinispan/cache-container=web/local-cache=passivation:undefine-attribute(name=statistics-enabled)") |
|
|
; |
|
|
} |
|
|
} |
|
|
} |