Re-enabling PropertyPassingTest
This commit is contained in:
parent
e17cee533a
commit
bddeb8cb77
|
@ -24,7 +24,7 @@ import java.util.List;
|
|||
|
||||
public class CommandLineBuilder
|
||||
{
|
||||
private static File findExecutable(File root, String path)
|
||||
public static File findExecutable(File root, String path)
|
||||
{
|
||||
String npath = path.replace('/',File.separatorChar);
|
||||
File exe = new File(root,npath);
|
||||
|
@ -35,7 +35,7 @@ public class CommandLineBuilder
|
|||
return exe;
|
||||
}
|
||||
|
||||
private static String findJavaBin()
|
||||
public static String findJavaBin()
|
||||
{
|
||||
File javaHome = new File(System.getProperty("java.home"));
|
||||
if (!javaHome.exists())
|
||||
|
|
|
@ -18,6 +18,10 @@
|
|||
|
||||
package org.eclipse.jetty.start;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Properties;
|
||||
|
||||
|
@ -25,6 +29,7 @@ public class PropertyDump
|
|||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// As System Properties
|
||||
Properties props = System.getProperties();
|
||||
Enumeration<?> names = props.propertyNames();
|
||||
while (names.hasMoreElements())
|
||||
|
@ -36,6 +41,35 @@ public class PropertyDump
|
|||
System.out.printf("%s=%s%n",name,props.getProperty(name));
|
||||
}
|
||||
}
|
||||
|
||||
// As File Argument
|
||||
for (String arg : args)
|
||||
{
|
||||
if (arg.endsWith(".properties"))
|
||||
{
|
||||
Properties aprops = new Properties();
|
||||
File propFile = new File(arg);
|
||||
System.out.printf("[load file %s]%n",propFile.getName());
|
||||
try (FileReader reader = new FileReader(propFile))
|
||||
{
|
||||
aprops.load(reader);
|
||||
Enumeration<?> anames = aprops.propertyNames();
|
||||
while (anames.hasMoreElements())
|
||||
{
|
||||
String name = (String)anames.nextElement();
|
||||
if (name.startsWith("test."))
|
||||
{
|
||||
System.out.printf("%s=%s%n",name,aprops.getProperty(name));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,14 +32,11 @@ import java.util.List;
|
|||
|
||||
import org.eclipse.jetty.toolchain.test.IO;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.toolchain.test.OS;
|
||||
import org.eclipse.jetty.toolchain.test.TestingDir;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
@Ignore
|
||||
public class PropertyPassingTest
|
||||
{
|
||||
private static class ConsoleCapture implements Runnable
|
||||
|
@ -95,18 +92,17 @@ public class PropertyPassingTest
|
|||
@Test
|
||||
public void testAsJvmArg() throws IOException, InterruptedException
|
||||
{
|
||||
File testCfg = MavenTestingUtils.getTestResourceFile("property-dump-start.config");
|
||||
File bogusXml = MavenTestingUtils.getTestResourceFile("bogus.xml");
|
||||
|
||||
// Setup command line
|
||||
List<String> commands = new ArrayList<>();
|
||||
commands.add(getJavaBin());
|
||||
commands.add("-Dmain.class=" + PropertyDump.class.getName());
|
||||
commands.add("-cp");
|
||||
commands.add(getClassPath());
|
||||
// addDebug(commands);
|
||||
commands.add("-Dtest.foo=bar"); // TESTING THIS
|
||||
commands.add(getStartJarBin());
|
||||
commands.add("--config=" + testCfg.getAbsolutePath());
|
||||
commands.add(bogusXml.getAbsolutePath());
|
||||
|
||||
// Run command, collect output
|
||||
|
@ -117,21 +113,19 @@ public class PropertyPassingTest
|
|||
}
|
||||
|
||||
@Test
|
||||
@Ignore("not working yet")
|
||||
public void testAsCommandLineArg() throws IOException, InterruptedException
|
||||
{
|
||||
File testCfg = MavenTestingUtils.getTestResourceFile("property-dump-start.config");
|
||||
File bogusXml = MavenTestingUtils.getTestResourceFile("bogus.xml");
|
||||
|
||||
// Setup command line
|
||||
List<String> commands = new ArrayList<>();
|
||||
commands.add(getJavaBin());
|
||||
commands.add("-Dmain.class=" + PropertyDump.class.getName());
|
||||
commands.add("-cp");
|
||||
commands.add(getClassPath());
|
||||
// addDebug(commands);
|
||||
commands.add(getStartJarBin());
|
||||
commands.add("test.foo=bar"); // TESTING THIS
|
||||
commands.add("--config=" + testCfg.getAbsolutePath());
|
||||
commands.add(bogusXml.getAbsolutePath());
|
||||
|
||||
// Run command, collect output
|
||||
|
@ -144,18 +138,17 @@ public class PropertyPassingTest
|
|||
@Test
|
||||
public void testAsDashDCommandLineArg() throws IOException, InterruptedException
|
||||
{
|
||||
File testCfg = MavenTestingUtils.getTestResourceFile("property-dump-start.config");
|
||||
File bogusXml = MavenTestingUtils.getTestResourceFile("bogus.xml");
|
||||
|
||||
// Setup command line
|
||||
List<String> commands = new ArrayList<>();
|
||||
commands.add(getJavaBin());
|
||||
commands.add("-Dmain.class=" + PropertyDump.class.getName());
|
||||
commands.add("-cp");
|
||||
commands.add(getClassPath());
|
||||
// addDebug(commands);
|
||||
commands.add(getStartJarBin());
|
||||
commands.add("-Dtest.foo=bar"); // TESTING THIS
|
||||
commands.add("--config=" + testCfg.getAbsolutePath());
|
||||
commands.add(bogusXml.getAbsolutePath());
|
||||
|
||||
// Run command, collect output
|
||||
|
@ -199,7 +192,8 @@ public class PropertyPassingTest
|
|||
ConsoleCapture stdErrPump = new ConsoleCapture("STDERR",pid.getErrorStream()).start();
|
||||
|
||||
int exitCode = pid.waitFor();
|
||||
if(exitCode != 0) {
|
||||
if (exitCode != 0)
|
||||
{
|
||||
System.out.printf("STDERR: [" + stdErrPump.getConsoleOutput() + "]%n");
|
||||
System.out.printf("STDOUT: [" + stdOutPump.getConsoleOutput() + "]%n");
|
||||
Assert.assertThat("Exit code",exitCode,is(0));
|
||||
|
@ -214,35 +208,6 @@ public class PropertyPassingTest
|
|||
|
||||
private String getJavaBin()
|
||||
{
|
||||
File javaHome = new File(System.getProperty("java.home"));
|
||||
if (!javaHome.exists())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
File javabin = findExecutable(javaHome,"bin/java");
|
||||
if (javabin != null)
|
||||
{
|
||||
return javabin.getAbsolutePath();
|
||||
}
|
||||
|
||||
javabin = findExecutable(javaHome,"bin/java.exe");
|
||||
if (javabin != null)
|
||||
{
|
||||
return javabin.getAbsolutePath();
|
||||
}
|
||||
|
||||
return "java";
|
||||
}
|
||||
|
||||
private File findExecutable(File root, String path)
|
||||
{
|
||||
String npath = OS.separators(path);
|
||||
File exe = new File(root,npath);
|
||||
if (!exe.exists())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return exe;
|
||||
return CommandLineBuilder.findJavaBin();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
|
||||
org.eclipse.jetty.start.PropertyDump.class
|
||||
|
||||
[*]
|
||||
$(basedir)/src/test/resources
|
||||
|
||||
[default]
|
||||
$(basedir)/src/test/resources
|
Loading…
Reference in New Issue