use of org.jboss.as.cli.operation.impl.DefaultOperationRequestAddress in project teiid by teiid.
the class AdminFactory method createAdmin.
/**
* Creates a ServerAdmin with the specified connection properties.
* @param userName
* @param password
* @param serverURL
* @param applicationName
* @return
* @throws AdminException
*/
public Admin createAdmin(String host, int port, String userName, char[] password) throws AdminException {
if (host == null) {
// $NON-NLS-1$
host = "localhost";
}
if (port < 0) {
port = 9990;
}
try {
CallbackHandler cbh = new AuthenticationCallbackHandler(userName, password);
ModelControllerClient newClient = ModelControllerClient.Factory.create(host, port, cbh);
List<String> nodeTypes = Util.getNodeTypes(newClient, new DefaultOperationRequestAddress());
if (!nodeTypes.isEmpty()) {
// $NON-NLS-1$
boolean domainMode = nodeTypes.contains("server-group");
LOGGER.info(// $NON-NLS-1$
"Connected to " + // $NON-NLS-1$ //$NON-NLS-2$
(domainMode ? "domain controller at " : "standalone controller at ") + host + ":" + // $NON-NLS-1$
port);
return new AdminImpl(newClient);
}
LOGGER.info(AdminPlugin.Util.gs(AdminPlugin.Event.TEIID70051, host, port));
} catch (UnknownHostException e) {
throw new AdminProcessingException(AdminPlugin.Event.TEIID70000, AdminPlugin.Util.gs(AdminPlugin.Event.TEIID70000, host, e.getLocalizedMessage()));
}
return null;
}
use of org.jboss.as.cli.operation.impl.DefaultOperationRequestAddress in project eap-additional-testsuite by jboss-set.
the class AddressOnlyParsingTestCase method testRootCharInTheMiddle.
@Test
public void testRootCharInTheMiddle() throws Exception {
OperationRequestAddress prefix = new DefaultOperationRequestAddress();
prefix.toNode("a", "b");
DefaultCallbackHandler handler = new DefaultCallbackHandler(prefix);
parser.parse("/", handler);
assertTrue(handler.hasAddress());
assertFalse(handler.hasOperationName());
assertFalse(handler.hasProperties());
assertFalse(handler.endsOnAddressOperationNameSeparator());
assertFalse(handler.endsOnPropertyListStart());
assertFalse(handler.endsOnPropertySeparator());
assertFalse(handler.endsOnPropertyValueSeparator());
assertTrue(handler.endsOnNodeSeparator());
assertFalse(handler.endsOnNodeTypeNameSeparator());
assertFalse(handler.isRequestComplete());
OperationRequestAddress address = handler.getAddress();
address.isEmpty();
try {
handler.reset();
parser.parse("//", handler);
Assert.fail("Shouldn't allow root character in the middle of the path");
} catch (CommandFormatException e) {
// expected
}
try {
handler.reset();
parser.parse("./a/", handler);
Assert.fail("Shouldn't allow root character in the middle of the path");
} catch (CommandFormatException e) {
// expected
}
handler.reset();
parser.parse("./a=b/", handler);
try {
handler.reset();
parser.parse("./a=b//", handler);
Assert.fail("Shouldn't allow root character in the middle of the path");
} catch (CommandFormatException e) {
// expected
}
try {
handler.reset();
parser.parse("./a=b//a=b", handler);
Assert.fail("Shouldn't allow root character in the middle of the path");
} catch (CommandFormatException e) {
// expected
}
}
Aggregations