use of com.sun.appserv.management.config.ResourceRefConfig in project Payara by payara.
the class ConnectorResourceConfigTest method createProgeny.
protected final AMXConfig createProgeny(final String name, final Map<String, String> options) {
final String poolName = ConnectorConnectionPoolConfigTest.ensureDefaultInstance(getDomainConfig()).getName();
assert (getDomainConfig().getResourcesConfig().getConnectorResourceConfigMap().get(name) == null) : "A resource already exists with name: " + name;
final Set<ResourceRefConfig> resourceRefs = getQueryMgr().queryJ2EETypeNameSet(XTypes.RESOURCE_REF_CONFIG, name);
ConnectorResourceConfig config = null;
final Set<ObjectName> resourceRefObjectNames = Util.toObjectNames(resourceRefs);
if (resourceRefs.size() != 0) {
assert (false);
warning("A DANGLING resource ref already exists with name: " + name + ", {" + CollectionUtil.toString(resourceRefObjectNames) + "} (SKIPPING TEST)");
} else {
config = getDomainConfig().getResourcesConfig().createConnectorResourceConfig(name, poolName, options);
final Set<ResourceRefConfig> refs = getQueryMgr().queryJ2EETypeNameSet(XTypes.RESOURCE_REF_CONFIG, name);
if (resourceRefs.size() != 0) {
final ResourceRefConfig ref = refs.iterator().next();
warning("A resource ref within " + Util.getObjectName(ref.getContainer()) + " was automatically created when creating the ConnectorResourceConfig ");
}
}
addReference(config);
return (config);
}
use of com.sun.appserv.management.config.ResourceRefConfig in project Payara by payara.
the class DanglingRefsTest method _testDanglingResourceRefConfigs.
private void _testDanglingResourceRefConfigs() throws ClassNotFoundException {
final DomainConfig domainConfig = getDomainConfig();
final Set<ResourceConfig> resourcesSet = getQueryMgr().queryInterfaceSet(ResourceConfig.class.getName(), null);
final Set<ResourceRefConfig> refs = RefHelper.findAllResourceRefConfigs(getQueryMgr());
final Map<String, ResourceConfig> resourcesMap = Util.createNameMap(resourcesSet);
for (final ResourceRefConfig ref : refs) {
final String name = ref.getName();
final ResourceConfig resourceConfig = resourcesMap.get(name);
if (resourceConfig == null) {
String msg = "Resource reference '" + Util.getObjectName(ref) + "' refers to a non-existent resource";
boolean removedOK = false;
try {
final ResourceRefConfigCR container = (ResourceRefConfigCR) ref.getContainer();
container.removeResourceRefConfig(name);
removedOK = true;
} catch (Exception e) {
msg = msg + ", and trying to remove it throws an Exception " + "(remove it manually from domain.xml)" + ", see bug #6298512";
}
if (!removedOK) {
warning(msg);
}
} else {
// printVerbose( "ResourceRefConfig '" + name + "' is OK" );
}
}
}
use of com.sun.appserv.management.config.ResourceRefConfig 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.ResourceRefConfig 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;
}
}
Aggregations