Issue #18 - jvm argument names are no longer used when re-configuring setup.env; renamed variables that referenced jettyPort.

Former-commit-id: 2386dd5890 [formerly 1c18ec39ea8a1bf1867ee96d6a33a9c595951d1f]
Former-commit-id: 94b327d00f
This commit is contained in:
Bryan Kowal 2012-04-09 13:15:50 -05:00
parent f49aadd9c8
commit 898487c15c
3 changed files with 68 additions and 39 deletions

View file

@ -19,7 +19,7 @@ import org.apache.commons.configuration.XMLConfiguration;
* <databasePort>int</databasePort> * <databasePort>int</databasePort>
* <edexHttpPort>int</edexHttpPort> * <edexHttpPort>int</edexHttpPort>
* <jmsPort>int</jmsPort> * <jmsPort>int</jmsPort>
* <jettyPort>int</jettyPort> * <webPort>int</webPort>
* <confidentialPort></confidentialPort> * <confidentialPort></confidentialPort>
* </Wes2BridgeCase> * </Wes2BridgeCase>
*/ */
@ -32,7 +32,7 @@ public class Wes2BridgeConfiguration
private int databasePort = -1; private int databasePort = -1;
private int edexHttpPort = -1; private int edexHttpPort = -1;
private int jmsPort = -1; private int jmsPort = -1;
private int jettyPort = -1; private int webPort = -1;
private int confidentialPort = -1; private int confidentialPort = -1;
/** /**
@ -47,7 +47,7 @@ public class Wes2BridgeConfiguration
this.databasePort = -1; this.databasePort = -1;
this.edexHttpPort = -1; this.edexHttpPort = -1;
this.jmsPort = -1; this.jmsPort = -1;
this.jettyPort = -1; this.webPort = -1;
this.confidentialPort = -1; this.confidentialPort = -1;
} }
@ -80,8 +80,8 @@ public class Wes2BridgeConfiguration
xmlConfiguration.getInt("edexHttpPort"); xmlConfiguration.getInt("edexHttpPort");
this.jmsPort = this.jmsPort =
xmlConfiguration.getInt("jmsPort"); xmlConfiguration.getInt("jmsPort");
this.jettyPort = this.webPort =
xmlConfiguration.getInt("jettyPort"); xmlConfiguration.getInt("webPort");
this.confidentialPort = this.confidentialPort =
xmlConfiguration.getInt("confidentialPort"); xmlConfiguration.getInt("confidentialPort");
} }
@ -136,14 +136,14 @@ public class Wes2BridgeConfiguration
this.jmsPort = jmsPort; this.jmsPort = jmsPort;
} }
public int getJettyPort() public int getWebPort()
{ {
return jettyPort; return webPort;
} }
public void setJettyPort(int jettyPort) public void setWebPort(int webPort)
{ {
this.jettyPort = jettyPort; this.webPort = webPort;
} }
public int getConfidentialPort() public int getConfidentialPort()

View file

@ -18,8 +18,8 @@ public class ConfigurationUtility
private static final String FIELD_DBPORT = "-databasePort"; private static final String FIELD_DBPORT = "-databasePort";
private static final String FIELD_HTTPPORT = "-httpPort"; private static final String FIELD_HTTPPORT = "-httpPort";
private static final String FIELD_JMSPORT = "-jmsPort"; private static final String FIELD_JMSPORT = "-jmsPort";
private static final String FIELD_JETTYPORT = private static final String FIELD_WEBPORT =
"-jettyPort"; "-webPort";
private static final String FIELD_CONFPORT = private static final String FIELD_CONFPORT =
"-confidentialPort"; "-confidentialPort";
@ -67,9 +67,9 @@ public class ConfigurationUtility
{ {
System.out.print(configuration.getJmsPort()); System.out.print(configuration.getJmsPort());
} }
else if (field.equals(FIELD_JETTYPORT)) else if (field.equals(FIELD_WEBPORT))
{ {
System.out.println(configuration.getJettyPort()); System.out.println(configuration.getWebPort());
} }
else if (field.equals(FIELD_CONFPORT)) else if (field.equals(FIELD_CONFPORT))
{ {

View file

@ -200,41 +200,52 @@ public class Wes2BridgeManager
BufferedWriter bw = BufferedWriter bw =
new BufferedWriter(new FileWriter(destFile)); new BufferedWriter(new FileWriter(destFile));
final String line1 = "wrapper.java.additional.5="; /*
final String line2 = "wrapper.java.additional.23="; * We want to replace at least one of the jmx jvm arguments
final String line3 = "wrapper.java.additional.24="; * with the wes2bridge.instance argument.
final String line4 = "wrapper.java.additional.25="; */
final String line5 = "wrapper.java.additional.42="; boolean wes2BridgeInstanceAdded = false;
final String line6 = "wrapper.java.additional.43=";
/*
* Disable JMX Remote and add a new wes2bridge.instance
* JVM argument so that it will be possible to determine
* which edex instance belongs to which test case.
*/
/*
* This may apply to multiple jvm arguments including:
* 1) -Dcom.sun.management.jmxremote.port
* 2) -Dcom.sun.management.jmxremote.authenticate
* 3) -Dcom.sun.management.jmxremote.ssl
*/
final String line1 = "-Dcom.sun.management.jmxremote";
/* Set the web port; used by uengine spring. */
final String line2 = "-Dweb.port";
/* Set the confidential port; used by uengine spring. */
final String line3 = "-Dconfidential.port";
String line = ""; String line = "";
while ((line = br.readLine()) != null) while ((line = br.readLine()) != null)
{ {
if (line.startsWith(line1)) if (line.contains(line1))
{ {
line = line1; line = this.getJVMArgumentName(line);
if (wes2BridgeInstanceAdded == false)
{
line += "-Dwes2bridge.instance=" +
this.configuration.getTestCaseName();
wes2BridgeInstanceAdded = true;
}
} }
else if (line.startsWith(line2)) else if (line.contains(line2))
{ {
line = line2 + "-Dwes2bridge.instance=" + line = this.getJVMArgumentName(line);
this.configuration.getTestCaseName(); line += line2 + "=" +
this.configuration.getWebPort();
} }
else if (line.startsWith(line3)) else if (line.contains(line3))
{ {
line = line3; line = this.getJVMArgumentName(line);
} line += line3 + "=" +
else if (line.startsWith(line4))
{
line = line4;
}
else if (line.startsWith(line5))
{
line = line5 + "-Dweb.port=" +
this.configuration.getJettyPort();
}
else if (line.startsWith(line6))
{
line = line6 + "-Dconfidential.port=" +
this.configuration.getConfidentialPort(); this.configuration.getConfidentialPort();
} }
@ -244,6 +255,24 @@ public class Wes2BridgeManager
bw.close(); bw.close();
} }
private String getJVMArgumentName(String jvmArgument)
{
if (jvmArgument == null)
{
System.out.println("ERROR: Invalid wrapper.conf file.");
System.exit(-1);
}
String[] splitJVMArg = jvmArgument.split("=");
if (splitJVMArg.length <= 0)
{
System.out.println("ERROR: Invalid wrapper.conf file.");
System.exit(-1);
}
return splitJVMArg[0] + "=";
}
private void updateEdexCamel(String edexDirectory) private void updateEdexCamel(String edexDirectory)
throws FileNotFoundException, IOException throws FileNotFoundException, IOException
{ {