use of com.sun.appserv.management.config.StandaloneServerConfig in project Payara by payara.
the class MailResourceConfigTest method ensureDefaultInstance.
/**
* synchronized because multiple instances are created, and we've chosen to remove/add
* this resource multiple times for some specific tests.
*/
public static synchronized MailResourceConfig ensureDefaultInstance(final DomainConfig dc) {
MailResourceConfig result = dc.getResourcesConfig().getMailResourceConfigMap().get(getDefaultInstanceName());
if (result == null) {
result = createInstance(dc, getDefaultInstanceName(), MAIL_RESOURCE_HOST, MAIL_RESOURCE_USER, MAIL_RESOURCE_FROM, OPTIONS);
assert !AttributeResolverHelper.resolveBoolean(result, "Enabled");
final StandaloneServerConfig serverConfig = dc.getServersConfig().getStandaloneServerConfigMap().get("server");
final Map<String, String> options = new HashMap<String, String>();
options.put(ResourceConfigKeys.ENABLED_KEY, "false");
final ResourceRefConfig ref = serverConfig.createResourceRefConfig(result.getName(), options);
assert !AttributeResolverHelper.resolveBoolean(ref, "Enabled");
RefHelper.removeAllRefsTo(result, false);
}
return result;
}
use of com.sun.appserv.management.config.StandaloneServerConfig in project Payara by payara.
the class ReferencesTest method testCreateAndRemoveResourceRefStandaloneServer.
public void testCreateAndRemoveResourceRefStandaloneServer() throws Exception {
if (!checkNotOffline("testCreateRemove")) {
return;
}
final Map<String, AppserverConnectionSource> nodeAgents = getNodeAgents();
if (nodeAgents.keySet().size() == 0) {
warning("testCreateAndRemoveResourceRefStandaloneServer: no Node Agents--SKIPPING TEST");
return;
}
final String nodeAgentName = nodeAgents.keySet().iterator().next();
final ConfigSetup setup = new ConfigSetup(getDomainRoot());
ensureMailResourceConfig();
final String serverName = "testCreateAndRemoveResourceRefStandaloneServer";
final String configName = serverName + "-config";
final ConfigConfig config = setup.createConfig(configName);
try {
final int basePort = 34770;
final StandaloneServerConfig server = setup.createServer(serverName, basePort, nodeAgentName, configName);
try {
final ResourceRefConfig ref = server.createResourceRefConfig(MAIL_RESOURCE_NAME);
assert (ref != null);
server.removeResourceRefConfig(ref.getName());
} catch (Exception e) {
setup.removeServer(serverName);
throw e;
} finally {
removeMailResourceConfig();
}
} catch (Exception e) {
setup.removeConfig(configName);
throw e;
}
}
use of com.sun.appserv.management.config.StandaloneServerConfig in project Payara by payara.
the class StandaloneServerConfigTest method _testCreateStandaloneServerConfig.
private void _testCreateStandaloneServerConfig(final String serverNameSuffix, final int basePort) {
final ConfigSetup setup = new ConfigSetup(getDomainRoot());
final Map<String, NodeAgentConfig> nodeAgentConfigs = getDomainConfig().getNodeAgentsConfig().getNodeAgentConfigMap();
if (nodeAgentConfigs.keySet().size() == 0) {
warning("testCreateStandaloneServerConfig: No node agents available, skipping test.");
} else {
// create a server for each node agent
for (final String nodeAgentName : nodeAgentConfigs.keySet()) {
final String serverName = nodeAgentName + serverNameSuffix;
final String configName = serverName + "-config";
// in case a previous failed run left them around
setup.removeServer(serverName);
setup.removeConfig(configName);
final ConfigConfig config = setup.createConfig(configName);
assert (configName.equals(config.getName()));
// sanity check
final Map<String, Object> attrs = Util.getExtra(config).getAllAttributes();
try {
final StandaloneServerConfig server = setup.createServer(serverName, basePort, nodeAgentName, config.getName());
// it worked, get rid of it
setup.removeServer(server.getName());
} catch (Throwable t) {
assert false : ExceptionUtil.toString(t);
} finally {
try {
setup.removeConfig(config.getName());
} catch (Exception ee) {
// we wanted to get rid of it...oh well.
}
}
}
}
}
use of com.sun.appserv.management.config.StandaloneServerConfig in project Payara by payara.
the class ReferencesTest method testCreateRefToMissingTarget.
public void testCreateRefToMissingTarget() {
if (!checkNotOffline("testCreateRemove")) {
return;
}
final String MISSING_NAME = "NonExistent";
final DomainConfig domainConfig = getDomainRoot().getDomainConfig();
final StandaloneServerConfig serverConfig = domainConfig.getServersConfig().getStandaloneServerConfigMap().get("server");
try {
serverConfig.createResourceRefConfig(MISSING_NAME);
assert false;
serverConfig.createDeployedItemRefConfig(MISSING_NAME);
assert false;
} catch (Exception e) {
// good
}
}
use of com.sun.appserv.management.config.StandaloneServerConfig in project Payara by payara.
the class StandaloneServerConfigTest method ensureDefaultInstance.
/**
* We want the default instance to be available on both PE and EE
* so we have no choice but to use the DAS instance.
*/
public static StandaloneServerConfig ensureDefaultInstance(final DomainRoot domainRoot) {
final Map<String, StandaloneServerConfig> servers = domainRoot.getDomainConfig().getServersConfig().getStandaloneServerConfigMap();
StandaloneServerConfig server = servers.get(getDefaultInstanceName());
assert (server != null);
return server;
}
Aggregations