Search in sources :

Example 1 with CompositeOperationBuilder

use of org.jboss.as.controller.client.helpers.Operations.CompositeOperationBuilder in project wildfly by wildfly.

the class DefaultResponseCodeAtRootTestCase method testDefaultResponseCode.

@Test
public void testDefaultResponseCode() throws Exception {
    CompositeOperationBuilder cob = CompositeOperationBuilder.create();
    ModelNode operation = createOpNode("subsystem=undertow/server=default-server/host=default-host", "write-attribute");
    operation.get("name").set("default-response-code");
    operation.get("value").set(506);
    cob.addStep(operation);
    // if location service is removed, if no deployment == no virtual host.
    operation = createOpNode("subsystem=undertow/server=default-server/host=default-host", "remove");
    operation.get("address").add("location", "/");
    cob.addStep(operation);
    executeOperation(cob.build().getOperation());
    executeReloadAndWaitForCompletion(getModelControllerClient());
    deployer.deploy("test");
    try {
        HttpGet httpget = null;
        HttpResponse response = null;
        httpget = new HttpGet(url.toString() + URL_PATTERN + "xxx/xxxxx");
        response = this.httpclient.execute(httpget);
        Assert.assertEquals(404, response.getStatusLine().getStatusCode());
        deployer.undeploy("test");
        httpget = new HttpGet(url.toString() + URL_PATTERN);
        response = this.httpclient.execute(httpget);
        Assert.assertEquals("" + httpget, 506, response.getStatusLine().getStatusCode());
    } finally {
        cob = CompositeOperationBuilder.create();
        operation = createOpNode("subsystem=undertow/server=default-server/host=default-host", "undefine-attribute");
        operation.get("name").set("default-response-code");
        cob.addStep(operation);
        operation = createOpNode("subsystem=undertow/server=default-server/host=default-host", "add");
        operation.get("address").add("location", "/");
        operation.get("handler").set("welcome-content");
        cob.addStep(operation);
        executeOperation(cob.build().getOperation());
        executeReloadAndWaitForCompletion(getModelControllerClient());
    }
}
Also used : CompositeOperationBuilder(org.jboss.as.controller.client.helpers.Operations.CompositeOperationBuilder) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Example 2 with CompositeOperationBuilder

use of org.jboss.as.controller.client.helpers.Operations.CompositeOperationBuilder in project wildfly by wildfly.

the class SubsystemOperationsTestCase method testThreadPoolChange.

@Test
public void testThreadPoolChange() throws Exception {
    final KernelServices kernelServices = boot();
    final CompositeOperationBuilder compositeOp = CompositeOperationBuilder.create();
    // Add a new thread-pool
    final ModelNode address = createAddress("thread-pool", "test-pool");
    final ModelNode addOp = SubsystemOperations.createAddOperation(address);
    addOp.get("max-threads").set(10L);
    final ModelNode keepAlive = addOp.get("keepalive-time");
    keepAlive.get("time").set(100L);
    keepAlive.get("unit").set(TimeUnit.MILLISECONDS.toString());
    compositeOp.addStep(addOp);
    // Write the new default
    compositeOp.addStep(SubsystemOperations.createWriteAttributeOperation(createAddress(null), "default-thread-pool", "test-pool"));
    executeOperation(kernelServices, compositeOp.build());
}
Also used : CompositeOperationBuilder(org.jboss.as.controller.client.helpers.Operations.CompositeOperationBuilder) KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Example 3 with CompositeOperationBuilder

use of org.jboss.as.controller.client.helpers.Operations.CompositeOperationBuilder in project wildfly by wildfly.

the class SubsystemOperationsTestCase method testAddSubsystem.

@Test
public void testAddSubsystem() throws Exception {
    // Boot with no subsystem
    final KernelServices kernelServices = boot(null);
    final CompositeOperationBuilder operationBuilder = CompositeOperationBuilder.create();
    // Create the base subsystem address
    final ModelNode subsystemAddress = createAddress(null);
    final ModelNode subsystemAddOp = SubsystemOperations.createAddOperation(subsystemAddress);
    subsystemAddOp.get("default-job-repository").set("in-memory");
    subsystemAddOp.get("default-thread-pool").set("batch");
    operationBuilder.addStep(subsystemAddOp);
    // Add a job repository
    operationBuilder.addStep(SubsystemOperations.createAddOperation(createAddress(InMemoryJobRepositoryDefinition.NAME, "in-memory")));
    final ModelNode threadPool = SubsystemOperations.createAddOperation(createAddress("thread-pool", "batch"));
    threadPool.get("max-threads").set(10);
    final ModelNode keepAlive = threadPool.get("keepalive-time");
    keepAlive.get("time").set(100L);
    keepAlive.get("unit").set(TimeUnit.MILLISECONDS.toString());
    operationBuilder.addStep(threadPool);
    // Execute the add operation
    executeOperation(kernelServices, operationBuilder.build());
}
Also used : CompositeOperationBuilder(org.jboss.as.controller.client.helpers.Operations.CompositeOperationBuilder) KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Example 4 with CompositeOperationBuilder

use of org.jboss.as.controller.client.helpers.Operations.CompositeOperationBuilder in project wildfly by wildfly.

the class SubsystemOperationsTestCase method testJobRepositoryChange.

@Test
public void testJobRepositoryChange() throws Exception {
    final KernelServices kernelServices = boot();
    final CompositeOperationBuilder compositeOp = CompositeOperationBuilder.create();
    // Add a new thread-pool
    final ModelNode address = createAddress(InMemoryJobRepositoryDefinition.NAME, "new-job-repo");
    compositeOp.addStep(SubsystemOperations.createAddOperation(address));
    // Write the new default
    compositeOp.addStep(SubsystemOperations.createWriteAttributeOperation(createAddress(null), "default-thread-pool", "new-job-repo"));
    executeOperation(kernelServices, compositeOp.build());
}
Also used : CompositeOperationBuilder(org.jboss.as.controller.client.helpers.Operations.CompositeOperationBuilder) KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Aggregations

CompositeOperationBuilder (org.jboss.as.controller.client.helpers.Operations.CompositeOperationBuilder)4 ModelNode (org.jboss.dmr.ModelNode)4 Test (org.junit.Test)4 KernelServices (org.jboss.as.subsystem.test.KernelServices)3 HttpResponse (org.apache.http.HttpResponse)1 HttpGet (org.apache.http.client.methods.HttpGet)1