/** * Setup container properties. * * @param container The container * @return The container properties list */ private String setupContainerProperties(InstalledLocalContainer container) { StringBuilder propertiesJSON = new StringBuilder(); Map<String, String> properties = container.getSystemProperties(); int i = 0; propertiesJSON.append("{"); for (Map.Entry<String, String> entry : properties.entrySet()) { if (i != 0) { propertiesJSON.append(","); } propertiesJSON.append("\"" + escapeJson(entry.getKey()) + "\":\"" + escapeJson(entry.getValue()) + "\""); i++; } propertiesJSON.append("}"); return propertiesJSON.toString(); }
Map<String, String> sysProps = installedContainer.getSystemProperties(); if (sysProps != null && !sysProps.isEmpty()) : installedContainer.getSystemProperties().entrySet())
/** * Setup container properties. * * @param container The container * @return The container properties list */ private String setupContainerProperties(InstalledLocalContainer container) { StringBuilder propertiesJSON = new StringBuilder(); Map<String, String> properties = container.getSystemProperties(); int i = 0; propertiesJSON.append("{"); for (Map.Entry<String, String> entry : properties.entrySet()) { if (i != 0) { propertiesJSON.append(","); } propertiesJSON.append("\"" + escapeJson(entry.getKey()) + "\":\"" + escapeJson(entry.getValue()) + "\""); i++; } propertiesJSON.append("}"); return propertiesJSON.toString(); }
/** * Setup a Derby datasource. * @param container Container to set on. */ private void setUpDerby(InstalledLocalContainer container) { if ("glassfish3x".equals(container.getId()) || "glassfish4x".equals(container.getId()) || "glassfish5x".equals(container.getId())) { // GlassFish 3.x, 4.x and 5.x already ship with Derby, adding the JAR twice will result // in java.lang.SecurityException: sealing violation: package org.apache.derby. return; } String jdbcdriver = System.getProperty("cargo.testdata.derby-jar"); if (jdbcdriver != null) { container.addExtraClasspath(jdbcdriver); } else { throw new CargoException( "Please set property [cargo.testdata.derby-jar] to a valid location of derby.jar"); } container.getSystemProperties().put("derby.system.home", getTestData().targetDir); container.getSystemProperties().put("derby.stream.error.logSeverityLevel", "0"); } }
if (installedLocalContainer.getSystemProperties() != null) : installedLocalContainer.getSystemProperties().entrySet())
if (installedLocalContainer.getSystemProperties() != null) : installedLocalContainer.getSystemProperties().entrySet())
/** * Test whether setting system properties is working properly. * @throws Exception If anything goes wrong. */ public void testSystemProperty() throws Exception { String random = UUID.randomUUID().toString(); // Copies the testdata artifact File artifactDir = new File(getTestData().targetDir).getParentFile(); File artifactFile = new File(artifactDir, "systemproperty.war").getAbsoluteFile(); Copy copyTask = (Copy) new AntUtils().createProject().createTask("copy"); copyTask.setTofile(artifactFile); copyTask.setFile(new File(getTestData().getTestDataFileFor("systemproperty-war"))); copyTask.execute(); Deployable war = new DefaultDeployableFactory().createDeployable(getContainer().getId(), artifactFile.getAbsolutePath(), DeployableType.WAR); getLocalContainer().getConfiguration().addDeployable(war); URL pingURL = new URL("http://localhost:" + getTestData().port + "/systemproperty/test?systemPropertyName=random"); getInstalledLocalContainer().getSystemProperties().put("random", random); getLocalContainer().start(); assertEquals(State.STARTED, getContainer().getState()); PingUtils.assertPingTrue(pingURL.getPath() + " not started", random, pingURL, getLogger()); getLocalContainer().stop(); assertEquals(State.STOPPED, getContainer().getState()); PingUtils.assertPingFalse(pingURL.getPath() + " not stopped", pingURL, getLogger()); }