use of org.jboss.as.controller.client.MessageSeverity in project wildfly-core by wildfly.
the class ModelControllerClientTestCase method testSynchronousOperationMessageHandler.
@Test
@Ignore("WFCORE-1125")
public void testSynchronousOperationMessageHandler() throws Exception {
final CountDownLatch executeLatch = new CountDownLatch(1);
MockModelController controller = new MockModelController() {
@Override
public ModelNode execute(ModelNode operation, OperationMessageHandler handler, OperationTransactionControl control, OperationAttachments attachments) {
this.operation = operation;
handler.handleReport(MessageSeverity.INFO, "Test1");
handler.handleReport(MessageSeverity.INFO, "Test2");
executeLatch.countDown();
ModelNode result = new ModelNode();
result.get("testing").set(operation.get("test"));
return result;
}
};
final ModelControllerClient client = setupTestClient(controller);
try {
ModelNode operation = new ModelNode();
operation.get("test").set("123");
final BlockingQueue<String> messages = new LinkedBlockingQueue<String>();
ModelNode result = client.execute(operation, new OperationMessageHandler() {
@Override
public void handleReport(MessageSeverity severity, String message) {
if (severity == MessageSeverity.INFO && message.startsWith("Test")) {
messages.add(message);
}
}
});
assertEquals("123", controller.getOperation().get("test").asString());
assertEquals("123", result.get("testing").asString());
assertEquals("Test1", messages.take());
assertEquals("Test2", messages.take());
} finally {
IoUtils.safeClose(client);
}
}
use of org.jboss.as.controller.client.MessageSeverity in project wildfly-core by wildfly.
the class RemoteProxyControllerProtocolTestCase method testOperationMessageHandler.
@Test
@Ignore("WFCORE-1125")
public void testOperationMessageHandler() throws Exception {
final MockModelController controller = new MockModelController() {
@Override
public ModelNode execute(ModelNode operation, OperationMessageHandler handler, ModelController.OperationTransactionControl control, OperationAttachments attachments) {
this.operation = operation;
handler.handleReport(MessageSeverity.INFO, "Test1");
handler.handleReport(MessageSeverity.INFO, "Test2");
control.operationPrepared(new OperationTransaction() {
@Override
public void rollback() {
}
@Override
public void commit() {
}
}, new ModelNode());
return new ModelNode();
}
};
final RemoteProxyController proxyController = setupProxyHandlers(controller);
ModelNode operation = new ModelNode();
operation.get("test").set("123");
final BlockingQueue<String> messages = new LinkedBlockingQueue<String>();
CommitProxyOperationControl commitControl = new CommitProxyOperationControl();
proxyController.execute(operation, new OperationMessageHandler() {
@Override
public void handleReport(MessageSeverity severity, String message) {
if (severity == MessageSeverity.INFO && message.startsWith("Test")) {
messages.add(message);
}
}
}, commitControl, null, null);
Assert.assertNotNull(commitControl.tx);
commitControl.tx.commit();
assertEquals("123", controller.getOperation().get("test").asString());
assertEquals("Test1", messages.take());
assertEquals("Test2", messages.take());
}
use of org.jboss.as.controller.client.MessageSeverity in project wildfly-core by wildfly.
the class ModelControllerClientTestCase method testCancelAsynchronousOperation.
@Test
public void testCancelAsynchronousOperation() throws Exception {
final CountDownLatch executeLatch = new CountDownLatch(1);
final CountDownLatch interrupted = new CountDownLatch(1);
MockModelController controller = new MockModelController() {
@Override
public ModelNode execute(ModelNode operation, OperationMessageHandler handler, OperationTransactionControl control, OperationAttachments attachments) {
this.operation = operation;
executeLatch.countDown();
try {
log.debug("Waiting for interrupt");
// Wait for this operation to be cancelled
Thread.sleep(10000000);
ModelNode result = new ModelNode();
result.get("testing").set(operation.get("test"));
return result;
} catch (InterruptedException e) {
interrupted.countDown();
throw new RuntimeException(e);
}
}
};
// Set the handler
final ModelControllerClient client = setupTestClient(controller);
try {
ModelNode operation = new ModelNode();
operation.get("test").set("123");
operation.get("operation").set("fake");
final BlockingQueue<String> messages = new LinkedBlockingQueue<String>();
AsyncFuture<ModelNode> resultFuture = client.executeAsync(operation, new OperationMessageHandler() {
@Override
public void handleReport(MessageSeverity severity, String message) {
if (severity == MessageSeverity.INFO && message.startsWith("Test")) {
messages.add(message);
}
}
});
executeLatch.await();
resultFuture.cancel(false);
interrupted.await();
} finally {
IoUtils.safeClose(client);
}
}
use of org.jboss.as.controller.client.MessageSeverity in project wildfly-core by wildfly.
the class ModelControllerClientTestCase method testAsynchronousOperationWithMessageHandler.
@Test
@Ignore("WFCORE-1125")
public void testAsynchronousOperationWithMessageHandler() throws Exception {
final CountDownLatch executeLatch = new CountDownLatch(1);
MockModelController controller = new MockModelController() {
@Override
public ModelNode execute(ModelNode operation, OperationMessageHandler handler, OperationTransactionControl control, OperationAttachments attachments) {
this.operation = operation;
handler.handleReport(MessageSeverity.INFO, "Test1");
handler.handleReport(MessageSeverity.INFO, "Test2");
executeLatch.countDown();
ModelNode result = new ModelNode();
result.get("testing").set(operation.get("test"));
return result;
}
};
// Set the handler
final ModelControllerClient client = setupTestClient(controller);
try {
ModelNode operation = new ModelNode();
operation.get("test").set("123");
operation.get("operation").set("fake");
final BlockingQueue<String> messages = new LinkedBlockingQueue<String>();
AsyncFuture<ModelNode> resultFuture = client.executeAsync(operation, new OperationMessageHandler() {
@Override
public void handleReport(MessageSeverity severity, String message) {
if (severity == MessageSeverity.INFO && message.startsWith("Test")) {
messages.add(message);
}
}
});
ModelNode result = resultFuture.get();
assertEquals("123", controller.getOperation().get("test").asString());
assertEquals("123", result.get("testing").asString());
assertEquals("Test1", messages.take());
assertEquals("Test2", messages.take());
} finally {
IoUtils.safeClose(client);
}
}
Aggregations