/** * set the container's logging level */ public void setLoggingLevel(String loggingLevel) { this.loggingLevel = loggingLevel; LocalConfiguration config = getConfiguration(); config.setProperty(GeneralPropertySet.LOGGING, loggingLevel); container.setConfiguration(config); }
int containerRmiPort = portSupplier.getAsInt(); int tomcatAjpPort = portSupplier.getAsInt(); config.setProperty(ServletPropertySet.PORT, Integer.toString(servletPort)); config.setProperty(GeneralPropertySet.RMI_PORT, Integer.toString(containerRmiPort)); config.setProperty(TomcatPropertySet.AJP_PORT, Integer.toString(tomcatAjpPort)); config.setProperty(GeneralPropertySet.PORT_OFFSET, "0"); int jvmJmxPort = portSupplier.getAsInt(); String jvmArgs = "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=" + jvmJmxPort; " --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED"; config.setProperty(GeneralPropertySet.START_JVMARGS, jvmArgs); container.setConfiguration(config);
ConfigurationType.STANDALONE, this.containerConfigHome.getAbsolutePath()); configuration.setProperty(GeneralPropertySet.LOGGING, loggingLevel); configuration.setProperty(GeneralPropertySet.JVMARGS, "-Djava.security.egd=file:/dev/./urandom");
private void setPropertyIfSupported(String propertyKey, String propertyValue, LocalConfiguration configuration, String containerType) { if (configuration.getCapability().supportsProperty(propertyKey)) { configuration.setProperty(propertyKey, propertyValue); } else { System.out.println("Container " + containerId + "(" + containerType + ") does not support setting of the '" + propertyKey + "' property"); } }
/** * Creates rmi port token for jndi.properties. * @return rmiPort token. */ private ReplaceTokens.Token createRmiPortToken() { if (getPropertyValue(GeneralPropertySet.RMI_PORT) == null) { configuration.setProperty(GeneralPropertySet.RMI_PORT, "2999"); } String rmiPort = getPropertyValue(GeneralPropertySet.RMI_PORT); ReplaceTokens.Token tokenRmiPort = new ReplaceTokens.Token(); tokenRmiPort.setKey(GeneralPropertySet.RMI_PORT); tokenRmiPort.setValue(rmiPort); return tokenRmiPort; }
/** * Creates rmi port token for jndi.properties. * @return rmiPort token. */ private ReplaceTokens.Token createRmiPortToken() { if (getPropertyValue(GeneralPropertySet.RMI_PORT) == null) { configuration.setProperty(GeneralPropertySet.RMI_PORT, "2999"); } String rmiPort = getPropertyValue(GeneralPropertySet.RMI_PORT); ReplaceTokens.Token tokenRmiPort = new ReplaceTokens.Token(); tokenRmiPort.setKey(GeneralPropertySet.RMI_PORT); tokenRmiPort.setValue(rmiPort); return tokenRmiPort; }
/** * {@inheritDoc}. CARGO-1255: Remove the JVM arguments from the asadmin, else debugging and * potentially many other functions do work. */ @Override protected void startInternal() throws Exception { synchronized (this.getConfiguration()) { String jvmArguments = this.getConfiguration().getPropertyValue(GeneralPropertySet.JVMARGS); try { this.getConfiguration().getProperties().remove(GeneralPropertySet.JVMARGS); super.startInternal(); } finally { if (jvmArguments != null) { this.getConfiguration().setProperty(GeneralPropertySet.JVMARGS, jvmArguments); } } } }
/** * {@inheritDoc}. CARGO-1255: Remove the JVM arguments from the asadmin, else debugging and * potentially many other functions do work. */ @Override protected void stopInternal() throws Exception { synchronized (this.getConfiguration()) { String jvmArguments = this.getConfiguration().getPropertyValue(GeneralPropertySet.JVMARGS); try { this.getConfiguration().getProperties().remove(GeneralPropertySet.JVMARGS); super.stopInternal(); } finally { if (jvmArguments != null) { this.getConfiguration().setProperty(GeneralPropertySet.JVMARGS, jvmArguments); } } } }
/** * {@inheritDoc}. CARGO-1255: Remove the JVM arguments from the asadmin, else debugging and * potentially many other functions do work. */ @Override protected void stopInternal() throws Exception { synchronized (this.getConfiguration()) { String jvmArguments = this.getConfiguration().getPropertyValue(GeneralPropertySet.JVMARGS); try { this.getConfiguration().getProperties().remove(GeneralPropertySet.JVMARGS); super.stopInternal(); } finally { if (jvmArguments != null) { this.getConfiguration().setProperty(GeneralPropertySet.JVMARGS, jvmArguments); } } } }
/** * {@inheritDoc} */ @Override protected void setUp() throws Exception { super.setUp(); // WildFly needs to be run with full profile and configured JMS journal if (getTestData().containerId.equals("wildfly9x")) { getLocalContainer().getConfiguration().setProperty("cargo.jboss.configuration", "standalone-full"); getLocalContainer().getConfiguration().setProperty( "cargo.wildfly.script.cli.embedded.journal", "target/test-classes/wildfly/wildfly9/jms-journal.cli"); } else if (getTestData().containerId.startsWith("wildfly1")) { getLocalContainer().getConfiguration().setProperty("cargo.jboss.configuration", "standalone-full"); getLocalContainer().getConfiguration().setProperty( "cargo.wildfly.script.cli.embedded.journal", "target/test-classes/wildfly/wildfly10/jms-journal.cli"); } }
/** * Test the runtime arguments. * @throws Exception If anything goes wrong. */ public void testRuntimeArgs() throws Exception { AbstractInstalledLocalContainerStub container = new AbstractInstalledLocalContainerStub(configuration); container.getConfiguration().setProperty(GeneralPropertySet.RUNTIME_ARGS, "hello -world"); container.startInternal(); JvmLauncher java = container.getJava(); assertTrue("Expected runtime arguments not contained in the java commandline.", java.getCommandLine().contains("hello -world")); }
/** * Test the JVM arguments. * @throws Exception If anything goes wrong. */ public void testJvmArgs() throws Exception { AbstractInstalledLocalContainerStub container = new AbstractInstalledLocalContainerStub(configuration); container.getConfiguration().setProperty(GeneralPropertySet.JVMARGS, "-Dx.y=z\n\r\t\t-Du.v=w"); container.startInternal(); JvmLauncher java = container.getJava(); String commandLine = java.getCommandLine(); checkString(commandLine, "-Dx.y=z "); checkString(commandLine, "-Du.v=w"); assertFalse("check new lines", commandLine.contains("\n")); assertFalse("check new lines", commandLine.contains("\r")); assertFalse("check tabs", commandLine.contains("\t")); }
/** * Configure datasource via property and retrieve the configuration file. * @param fixture Datasource fixture. * @return Configuration file for <code>fixture</code>. * @throws Exception If anything goes wrong. */ protected String configureDataSourceViaPropertyAndRetrieveConfigurationFile( DataSourceFixture fixture) throws Exception { configuration.setProperty(DatasourcePropertySet.DATASOURCE, fixture .buildDataSourcePropertyString()); ((AbstractStandaloneLocalConfigurationWithXMLConfigurationBuilder) configuration) .parsePropertiesForPendingConfiguration(); ((DataSourceSupport) configuration).configureDataSources(container); return configuration.getFileHandler().readTextFile( getDataSourceConfigurationFile(fixture), "UTF-8"); }
/** * Configure resource via property and retrieve the configuration file. * @param fixture Resource fixture. * @return Configuration file for <code>fixture</code>. * @throws Exception If anything goes wrong. */ protected String configureResourceViaPropertyAndRetrieveConfigurationFile( ResourceFixture fixture) throws Exception { configuration.setProperty(ResourcePropertySet.RESOURCE, fixture .buildResourcePropertyString()); ((AbstractStandaloneLocalConfigurationWithXMLConfigurationBuilder) configuration) .parsePropertiesForPendingConfiguration(); ((ResourceSupport) configuration).configureResources(container); return configuration.getFileHandler().readTextFile(getResourceConfigurationFile(fixture), "UTF-8"); }
/** * Test memory arguments override. * @throws Exception If anything goes wrong. */ public void testXmxMemoryArgumentOverride() throws Exception { AbstractInstalledLocalContainerStub container = new AbstractInstalledLocalContainerStub(configuration); container.getConfiguration().setProperty(GeneralPropertySet.JVMARGS, "-Xmx256m"); container.startInternal(); JvmLauncher java = container.getJava(); String commandLine = java.getCommandLine(); checkString(commandLine, "-Xms128m"); checkString(commandLine, "-Xmx256m"); }
/** * Test memory arguments override. * @throws Exception If anything goes wrong. */ public void testXmsMemoryArgumentOverride() throws Exception { AbstractInstalledLocalContainerStub container = new AbstractInstalledLocalContainerStub(configuration); container.getConfiguration().setProperty(GeneralPropertySet.JVMARGS, "-Xms256m"); container.startInternal(); JvmLauncher java = container.getJava(); String commandLine = java.getCommandLine(); checkString(commandLine, "-Xms256m"); checkString(commandLine, "-Xmx512m"); }
/** * Test resource configuration with two resources. * @throws Exception If anything goes wrong. */ @Override public void testConfigureCreatesTwoResourcesViaProperties() throws Exception { ResourceFixture resourceFixture1 = ConfigurationFixtureFactory.createXADataSourceAsResource(); configuration.setProperty(ResourcePropertySet.RESOURCE + ".1", resourceFixture1 .buildResourcePropertyString()); ResourceFixture resourceFixture2 = ConfigurationFixtureFactory.createConnectionPoolDataSourceAsResource(); String configuration = configureResourceViaPropertyAndRetrieveConfigurationFile(resourceFixture2); configurationChecker .checkConfigurationForXADataSourceConfiguredResourceMatchesResourceFixture( configuration, resourceFixture1); configurationChecker .checkConfigurationForXADataSourceConfiguredResourceMatchesResourceFixture( configuration, resourceFixture2); } }
/** * Test memory arguments override. * @throws Exception If anything goes wrong. */ public void testXXPermSizeMemoryArgumentOverride() throws Exception { AbstractInstalledLocalContainerStub container = new AbstractInstalledLocalContainerStub(configuration); container.getConfiguration().setProperty(GeneralPropertySet.JVMARGS, "-XX:PermSize=256m"); container.startInternal(); JvmLauncher java = container.getJava(); String commandLine = java.getCommandLine(); checkString(commandLine, "-Xms128m"); checkString(commandLine, "-Xmx512m"); checkString(commandLine, "-XX:PermSize=256m"); }
/** * Test memory arguments override. * @throws Exception If anything goes wrong. */ public void testXXMaxPermSizeMemoryArgumentOverride() throws Exception { AbstractInstalledLocalContainerStub container = new AbstractInstalledLocalContainerStub(configuration); container.getConfiguration() .setProperty(GeneralPropertySet.JVMARGS, "-XX:MaxPermSize=256m"); container.startInternal(); JvmLauncher java = container.getJava(); String commandLine = java.getCommandLine(); checkString(commandLine, "-Xms128m"); checkString(commandLine, "-Xmx512m"); checkString(commandLine, "-XX:MaxPermSize=256m"); }
/** * Test memory arguments override. * @throws Exception If anything goes wrong. */ public void testAllMemoryArgumentOverride() throws Exception { AbstractInstalledLocalContainerStub container = new AbstractInstalledLocalContainerStub(configuration); container.getConfiguration().setProperty(GeneralPropertySet.JVMARGS, "-Xms256m -Xmx256m -XX:PermSize=256m -XX:MaxPermSize=256m"); container.startInternal(); JvmLauncher java = container.getJava(); String commandLine = java.getCommandLine(); checkString(commandLine, "-Xms256m"); checkString(commandLine, "-Xmx256m"); checkString(commandLine, "-XX:PermSize=256m"); checkString(commandLine, "-XX:MaxPermSize=256m"); }