Skip to content

Commit

Permalink
[WFCORE-134] : Make sure CLIWrapper doesn't use default encoding
Browse files Browse the repository at this point in the history
Fixing issue in CLIWrapper that uses the dfault encoding instead of UTF-8
Fixing some hard coded string in tests.
  • Loading branch information
ehsavoie committed Sep 30, 2014
1 parent 8ad1abe commit 4987549
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
Expand Up @@ -22,6 +22,7 @@

package org.jboss.as.core.model.test.access;


import static org.jboss.as.controller.PathAddress.pathAddress;
import static org.jboss.as.controller.PathElement.pathElement;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ACCESS;
Expand Down Expand Up @@ -50,6 +51,7 @@
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.access.constraint.ApplicationTypeConfig;
import org.jboss.as.controller.access.rbac.StandardRole;
import org.jboss.as.controller.logging.ControllerLogger;
import org.jboss.as.controller.operations.common.Util;
import org.jboss.as.core.model.test.AbstractCoreModelTest;
import org.jboss.as.core.model.test.KernelServices;
Expand Down Expand Up @@ -195,11 +197,6 @@ protected static void assertPermitted(ModelNode operationResult) {

protected static void assertDenied(ModelNode operationResult) {
assertEquals(FAILED, operationResult.get(OUTCOME).asString());
assertTrue(operationResult.get(FAILURE_DESCRIPTION).asString().contains("Permission denied"));
}

protected static void assertNoAccess(ModelNode operationResult) {
assertEquals(FAILED, operationResult.get(OUTCOME).asString());
assertTrue(operationResult.get(FAILURE_DESCRIPTION).asString().contains("not found"));
assertTrue(operationResult.get(FAILURE_DESCRIPTION).asString().contains(ControllerLogger.ACCESS_LOGGER.permissionDenied()));
}
}
Expand Up @@ -53,6 +53,7 @@
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.access.constraint.SensitivityClassification;
import org.jboss.as.controller.access.rbac.StandardRole;
import org.jboss.as.controller.logging.ControllerLogger;
import org.jboss.as.controller.operations.common.Util;
import org.jboss.as.core.model.test.AbstractCoreModelTest;
import org.jboss.as.core.model.test.KernelServices;
Expand Down Expand Up @@ -96,8 +97,9 @@ private void testMonitorOrOperatorOrDeployer(StandardRole role) {
assertTrue(kernelServices.isSuccessfulBoot());

reconfigureSensitivity(SOCKET_CONFIG, true, true, true);
assertNoAccess(readInterface(FOO, role));
assertNoAccess(addInterface(role));
assertNoAccessInterface(readInterface(FOO, role), FOO);
String interfaceName = "test" + counter;
assertNoAccessInterface(addInterface(role), interfaceName);

reconfigureSensitivity(SOCKET_CONFIG, false, true, true);
assertDenied(readInterface(FOO, role));
Expand All @@ -119,8 +121,9 @@ public void testMaintainer() {
StandardRole role = StandardRole.MAINTAINER;

reconfigureSensitivity(SOCKET_CONFIG, true, true, true);
assertNoAccess(readInterface(FOO, role));
assertNoAccess(addInterface(role));
assertNoAccessInterface(readInterface(FOO, role), FOO);
String interfaceName = "test" + counter;
assertNoAccessInterface(addInterface(role), interfaceName);

reconfigureSensitivity(SOCKET_CONFIG, false, true, true);
assertDenied(readInterface(FOO, role));
Expand Down Expand Up @@ -250,11 +253,12 @@ protected static void assertPermitted(ModelNode operationResult) {

protected static void assertDenied(ModelNode operationResult) {
assertEquals(FAILED, operationResult.get(OUTCOME).asString());
assertTrue(operationResult.get(FAILURE_DESCRIPTION).asString().contains("Permission denied"));
assertTrue(operationResult.get(FAILURE_DESCRIPTION).asString().contains(ControllerLogger.ACCESS_LOGGER.permissionDenied()));
}

protected static void assertNoAccess(ModelNode operationResult) {
protected static void assertNoAccessInterface(ModelNode operationResult, String name) {
assertEquals(FAILED, operationResult.get(OUTCOME).asString());
assertTrue(operationResult.get(FAILURE_DESCRIPTION).asString().contains("not found"));
assertEquals(ControllerLogger.ACCESS_LOGGER.managementResourceNotFound(pathAddress(INTERFACE, name)).getMessage(),
operationResult.get(FAILURE_DESCRIPTION).asString());
}
}
Expand Up @@ -43,6 +43,7 @@
import org.jboss.as.cli.CommandContext;
import org.jboss.as.cli.CommandContextFactory;
import org.jboss.as.cli.CommandLineException;
import org.jboss.as.patching.logging.PatchLogger;
import org.jboss.as.patching.metadata.ContentModification;
import org.jboss.as.patching.metadata.Patch;
import org.jboss.as.patching.metadata.PatchBuilder;
Expand Down Expand Up @@ -277,7 +278,7 @@ public void testRollback() throws Exception {

protected void assertConflicts(CommandLineException e, String... conflicts) {
final StringBuilder buf = new StringBuilder();
buf.append("Conflicts detected: ");
buf.append(PatchLogger.ROOT_LOGGER.detectedConflicts()).append(": ");
int i = 0;
while(i < conflicts.length) {
buf.append(conflicts[i++].replace('\\', '/')); // fix paths on windows
Expand Down
Expand Up @@ -22,6 +22,7 @@
package org.jboss.as.test.integration.management.util;


import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -186,12 +187,12 @@ public String readOutput() {
* @return array of CLI output lines
*/
public CLIOpResult readAllAsOpResult() throws IOException {
final String response = readOutput();
if(response == null) {
if(consoleOut.size() <= 0) {
return new CLIOpResult();
}
final ModelNode node = ModelNode.fromString(response);
final ModelNode node = ModelNode.fromStream(new ByteArrayInputStream(consoleOut.toByteArray()));
return new CLIOpResult(node);

}

/**
Expand Down

0 comments on commit 4987549

Please sign in to comment.