Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Erdfelt2014-04-10 23:45:11 +0000
committerJoakim Erdfelt2014-04-10 23:45:11 +0000
commiteff78efe3cb65a495e013ba7ebf0ac7e083c2cc6 (patch)
treebf488c9c39c4a2f131b2dadfc4b1aea5380b7a15 /jetty-start/src/test
parent4f49bb958411be4c75173714e1e4549632061410 (diff)
downloadorg.eclipse.jetty.project-eff78efe3cb65a495e013ba7ebf0ac7e083c2cc6.tar.gz
org.eclipse.jetty.project-eff78efe3cb65a495e013ba7ebf0ac7e083c2cc6.tar.xz
org.eclipse.jetty.project-eff78efe3cb65a495e013ba7ebf0ac7e083c2cc6.zip
432321 - jetty-start / Allow defining extra start directories for common configurations
+ Integration of ConfigSources with rest of startup.
Diffstat (limited to 'jetty-start/src/test')
-rw-r--r--jetty-start/src/test/java/org/eclipse/jetty/start/BaseHomeTest.java59
-rw-r--r--jetty-start/src/test/java/org/eclipse/jetty/start/ConfigurationAssert.java7
-rw-r--r--jetty-start/src/test/java/org/eclipse/jetty/start/ExtraStartTest.java74
-rw-r--r--jetty-start/src/test/java/org/eclipse/jetty/start/ModuleGraphWriterTest.java37
-rw-r--r--jetty-start/src/test/java/org/eclipse/jetty/start/ModuleTest.java2
-rw-r--r--jetty-start/src/test/java/org/eclipse/jetty/start/ModulesTest.java104
6 files changed, 188 insertions, 95 deletions
diff --git a/jetty-start/src/test/java/org/eclipse/jetty/start/BaseHomeTest.java b/jetty-start/src/test/java/org/eclipse/jetty/start/BaseHomeTest.java
index 5514abd66a..368668bfd9 100644
--- a/jetty-start/src/test/java/org/eclipse/jetty/start/BaseHomeTest.java
+++ b/jetty-start/src/test/java/org/eclipse/jetty/start/BaseHomeTest.java
@@ -26,6 +26,9 @@ import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.jetty.start.config.ConfigSources;
+import org.eclipse.jetty.start.config.JettyBaseConfigSource;
+import org.eclipse.jetty.start.config.JettyHomeConfigSource;
import org.eclipse.jetty.toolchain.test.IO;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.junit.Assert;
@@ -92,18 +95,22 @@ public class BaseHomeTest
}
@Test
- public void testGetFile_OnlyHome() throws IOException
+ public void testGetPath_OnlyHome() throws IOException
{
File homeDir = MavenTestingUtils.getTestResourceDir("hb.1/home");
File baseDir = null;
+
+ ConfigSources config = new ConfigSources();
+ config.add(new JettyHomeConfigSource(homeDir.toPath()));
BaseHome hb = new BaseHome(homeDir,baseDir);
- File startIni = hb.getFile("start.ini");
+ hb.initialize(config);
+ Path startIni = hb.getPath("start.ini");
String ref = hb.toShortForm(startIni);
Assert.assertThat("Reference",ref,startsWith("${jetty.home}"));
- String contents = IO.readToString(startIni);
+ String contents = IO.readToString(startIni.toFile());
Assert.assertThat("Contents",contents,containsString("Home Ini"));
}
@@ -113,7 +120,11 @@ public class BaseHomeTest
File homeDir = MavenTestingUtils.getTestResourceDir("hb.1/home");
File baseDir = null;
+ ConfigSources config = new ConfigSources();
+ config.add(new JettyHomeConfigSource(homeDir.toPath()));
+
BaseHome hb = new BaseHome(homeDir,baseDir);
+ hb.initialize(config);
List<Path> paths = hb.getPaths("start.d/*");
List<String> expected = new ArrayList<>();
@@ -133,7 +144,11 @@ public class BaseHomeTest
File homeDir = MavenTestingUtils.getTestResourceDir("hb.1/home");
File baseDir = null;
+ ConfigSources config = new ConfigSources();
+ config.add(new JettyHomeConfigSource(homeDir.toPath()));
+
BaseHome hb = new BaseHome(homeDir,baseDir);
+ hb.initialize(config);
List<Path> paths = hb.getPaths("start.d/*.ini");
List<String> expected = new ArrayList<>();
@@ -153,34 +168,15 @@ public class BaseHomeTest
File homeDir = MavenTestingUtils.getTestResourceDir("hb.1/home");
File baseDir = MavenTestingUtils.getTestResourceDir("hb.1/base");
- BaseHome hb = new BaseHome(homeDir,baseDir);
- List<Path> paths = hb.getPaths("start.d/*.ini");
-
- List<String> expected = new ArrayList<>();
- expected.add("${jetty.base}/start.d/jmx.ini");
- expected.add("${jetty.home}/start.d/jndi.ini");
- expected.add("${jetty.home}/start.d/jsp.ini");
- expected.add("${jetty.base}/start.d/logging.ini");
- expected.add("${jetty.home}/start.d/ssl.ini");
- expected.add("${jetty.base}/start.d/myapp.ini");
- FSTest.toOsSeparators(expected);
-
- assertPathList(hb,"Paths found",expected,paths);
- }
-
- @Test
- public void testGetPaths_More() throws IOException
- {
- File homeDir = MavenTestingUtils.getTestResourceDir("hb.1/home");
- File baseDir = MavenTestingUtils.getTestResourceDir("hb.1/base");
- File moreDir = MavenTestingUtils.getTestResourceDir("extra-start-dirs/more-startd");
+ ConfigSources config = new ConfigSources();
+ config.add(new JettyBaseConfigSource(baseDir.toPath()));
+ config.add(new JettyHomeConfigSource(homeDir.toPath()));
BaseHome hb = new BaseHome(homeDir,baseDir);
- hb.addExtraStart("more",moreDir);
+ hb.initialize(config);
List<Path> paths = hb.getPaths("start.d/*.ini");
List<String> expected = new ArrayList<>();
- expected.add("${more}/start.d/more.ini");
expected.add("${jetty.base}/start.d/jmx.ini");
expected.add("${jetty.home}/start.d/jndi.ini");
expected.add("${jetty.home}/start.d/jsp.ini");
@@ -201,18 +197,23 @@ public class BaseHomeTest
}
@Test
- public void testGetFile_Both() throws IOException
+ public void testGetPath_Both() throws IOException
{
File homeDir = MavenTestingUtils.getTestResourceDir("hb.1/home");
File baseDir = MavenTestingUtils.getTestResourceDir("hb.1/base");
+ ConfigSources config = new ConfigSources();
+ config.add(new JettyBaseConfigSource(baseDir.toPath()));
+ config.add(new JettyHomeConfigSource(homeDir.toPath()));
+
BaseHome hb = new BaseHome(homeDir,baseDir);
- File startIni = hb.getFile("start.ini");
+ hb.initialize(config);
+ Path startIni = hb.getPath("start.ini");
String ref = hb.toShortForm(startIni);
Assert.assertThat("Reference",ref,startsWith("${jetty.base}"));
- String contents = IO.readToString(startIni);
+ String contents = IO.readToString(startIni.toFile());
Assert.assertThat("Contents",contents,containsString("Base Ini"));
}
}
diff --git a/jetty-start/src/test/java/org/eclipse/jetty/start/ConfigurationAssert.java b/jetty-start/src/test/java/org/eclipse/jetty/start/ConfigurationAssert.java
index 5ad4a23817..dcd9baf221 100644
--- a/jetty-start/src/test/java/org/eclipse/jetty/start/ConfigurationAssert.java
+++ b/jetty-start/src/test/java/org/eclipse/jetty/start/ConfigurationAssert.java
@@ -25,6 +25,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
@@ -64,7 +65,7 @@ public class ConfigurationAssert
}
}
List<String> actualXmls = new ArrayList<>();
- for (File xml : args.getXmlFiles())
+ for (Path xml : args.getXmlFiles())
{
actualXmls.add(shorten(baseHome,xml,testResourcesDir));
}
@@ -82,7 +83,7 @@ public class ConfigurationAssert
List<String> actualLibs = new ArrayList<>();
for (File path : args.getClasspath())
{
- actualLibs.add(shorten(baseHome,path,testResourcesDir));
+ actualLibs.add(shorten(baseHome,path.toPath(),testResourcesDir));
}
assertContainsUnordered("Libs",expectedLibs,actualLibs);
@@ -147,7 +148,7 @@ public class ConfigurationAssert
assertContainsUnordered("Files/Dirs",expectedFiles,actualFiles);
}
- private static String shorten(BaseHome baseHome, File path, File testResourcesDir)
+ private static String shorten(BaseHome baseHome, Path path, File testResourcesDir)
{
String value = baseHome.toShortForm(path);
if (value.startsWith(testResourcesDir.getAbsolutePath()))
diff --git a/jetty-start/src/test/java/org/eclipse/jetty/start/ExtraStartTest.java b/jetty-start/src/test/java/org/eclipse/jetty/start/ExtraStartTest.java
index c217e53d02..f22c37b3fd 100644
--- a/jetty-start/src/test/java/org/eclipse/jetty/start/ExtraStartTest.java
+++ b/jetty-start/src/test/java/org/eclipse/jetty/start/ExtraStartTest.java
@@ -25,6 +25,9 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.jetty.start.Props.Prop;
+import org.eclipse.jetty.start.config.ConfigSource;
+import org.eclipse.jetty.start.config.ConfigSources;
+import org.eclipse.jetty.start.config.DirConfigSource;
import org.eclipse.jetty.toolchain.test.FS;
import org.eclipse.jetty.toolchain.test.TestingDir;
import org.junit.Assert;
@@ -40,14 +43,15 @@ public class ExtraStartTest
public void assertSearchOrder(List<String> expectedSearchOrder)
{
+ ConfigSources sources = main.getBaseHome().getConfigSources();
List<String> actualOrder = new ArrayList<>();
- actualOrder.add("${jetty.base}");
- List<String> startRefs = args.getExtraStartRefs();
- if (startRefs.size() > 0)
+ for (ConfigSource source : sources)
{
- actualOrder.addAll(startRefs);
+ if (source instanceof DirConfigSource)
+ {
+ actualOrder.add(source.getId());
+ }
}
- actualOrder.add("${jetty.home}");
ConfigurationAssert.assertOrdered("Search Order",expectedSearchOrder,actualOrder);
}
@@ -92,7 +96,7 @@ public class ExtraStartTest
FS.ensureEmpty(base);
TestEnv.makeFile(base,"start.ini", //
"jetty.host=127.0.0.1");
-
+
// Simple command line - no reference to extra-start-dirs
MainResult result = runMain(base,home);
@@ -125,7 +129,7 @@ public class ExtraStartTest
// Simple command line reference to extra-start-dir
MainResult result = runMain(base,home,
- // direct reference via path
+ // direct reference via path
"--extra-start-dir=" + common.getAbsolutePath());
List<String> expectedSearchOrder = new ArrayList<>();
@@ -158,9 +162,9 @@ public class ExtraStartTest
"jetty.host=127.0.0.1");
// Simple command line reference to extra-start-dir via property (also on command line)
- MainResult result = runMain(base,home,
- // property
- "my.common=" + common.getAbsolutePath(),
+ MainResult result = runMain(base,home,
+ // property
+ "my.common=" + common.getAbsolutePath(),
// reference via property
"--extra-start-dir=${my.common}");
@@ -185,9 +189,9 @@ public class ExtraStartTest
// Create opt
File opt = testdir.getFile("opt");
FS.ensureEmpty(opt);
-
+
// Create common
- File common = new File(opt, "common");
+ File common = new File(opt,"common");
FS.ensureEmpty(common);
TestEnv.makeFile(common,"start.ini","jetty.port=8080");
@@ -196,13 +200,13 @@ public class ExtraStartTest
FS.ensureEmpty(base);
TestEnv.makeFile(base,"start.ini", //
"jetty.host=127.0.0.1");
-
+
String dirRef = "${my.opt}" + File.separator + "common";
// Simple command line reference to extra-start-dir via property (also on command line)
- MainResult result = runMain(base,home,
- // property to 'opt' dir
- "my.opt=" + opt.getAbsolutePath(),
+ MainResult result = runMain(base,home,
+ // property to 'opt' dir
+ "my.opt=" + opt.getAbsolutePath(),
// reference via property prefix
"--extra-start-dir=" + dirRef);
@@ -219,7 +223,7 @@ public class ExtraStartTest
@Test
public void testCommandLine_1Extra_FromCompoundProp() throws Exception
{
- // Create home
+ // Create home
File home = testdir.getFile("home");
FS.ensureEmpty(home);
TestEnv.copyTestDir("usecases/home",home);
@@ -227,9 +231,9 @@ public class ExtraStartTest
// Create opt
File opt = testdir.getFile("opt");
FS.ensureEmpty(opt);
-
+
// Create common
- File common = new File(opt, "common");
+ File common = new File(opt,"common");
FS.ensureEmpty(common);
TestEnv.makeFile(common,"start.ini","jetty.port=8080");
@@ -238,12 +242,12 @@ public class ExtraStartTest
FS.ensureEmpty(base);
TestEnv.makeFile(base,"start.ini", //
"jetty.host=127.0.0.1");
-
+
String dirRef = "${my.opt}" + File.separator + "${my.dir}";
-
+
// Simple command line reference to extra-start-dir via property (also on command line)
- MainResult result = runMain(base,home,
- // property to 'opt' dir
+ MainResult result = runMain(base,home,
+ // property to 'opt' dir
"my.opt=" + opt.getAbsolutePath(),
// property to commmon dir name
"my.dir=common",
@@ -327,7 +331,7 @@ public class ExtraStartTest
result.assertProperty("jetty.host","127.0.0.1");
result.assertProperty("jetty.port","8080"); // from 'common'
}
-
+
@Test
public void testRefCommonRefCorp() throws Exception
{
@@ -368,7 +372,7 @@ public class ExtraStartTest
result.assertProperty("jetty.host","127.0.0.1");
result.assertProperty("jetty.port","8080"); // from 'common'
}
-
+
@Test
public void testRefCommonRefCorp_FromSimpleProps() throws Exception
{
@@ -396,7 +400,7 @@ public class ExtraStartTest
FS.ensureEmpty(base);
TestEnv.makeFile(base,"start.ini", //
"jetty.host=127.0.0.1",//
- "my.common="+common.getAbsolutePath(), //
+ "my.common=" + common.getAbsolutePath(), //
"--extra-start-dir=${my.common}");
MainResult result = runMain(base,home);
@@ -411,7 +415,7 @@ public class ExtraStartTest
result.assertProperty("jetty.host","127.0.0.1");
result.assertProperty("jetty.port","8080"); // from 'common'
}
-
+
@Test
public void testRefCommonRefCorp_CmdLineRef() throws Exception
{
@@ -448,7 +452,7 @@ public class ExtraStartTest
"--extra-start-dir=" + common.getAbsolutePath());
MainResult result = runMain(base,home,
- // command line provided extra-start-dir ref
+ // command line provided extra-start-dir ref
"--extra-start-dir=" + devops.getAbsolutePath());
List<String> expectedSearchOrder = new ArrayList<>();
@@ -462,7 +466,7 @@ public class ExtraStartTest
result.assertProperty("jetty.host","127.0.0.1");
result.assertProperty("jetty.port","2222"); // from 'devops'
}
-
+
@Test
public void testRefCommonRefCorp_CmdLineProp() throws Exception
{
@@ -492,7 +496,7 @@ public class ExtraStartTest
"--extra-start-dir=" + common.getAbsolutePath());
MainResult result = runMain(base,home,
- // command line property should override all others
+ // command line property should override all others
"jetty.port=7070");
List<String> expectedSearchOrder = new ArrayList<>();
@@ -505,7 +509,7 @@ public class ExtraStartTest
result.assertProperty("jetty.host","127.0.0.1");
result.assertProperty("jetty.port","7070"); // from command line
}
-
+
@Test
public void testBadDoubleRef() throws Exception
{
@@ -521,15 +525,15 @@ public class ExtraStartTest
// Create corp
File corp = testdir.getFile("corp");
FS.ensureEmpty(corp);
- TestEnv.makeFile(corp,"start.ini",
- // standard property
+ TestEnv.makeFile(corp,"start.ini",
+ // standard property
"jetty.port=9090",
// INTENTIONAL BAD Reference (duplicate)
"--extra-start-dir=" + common.getAbsolutePath());
// Populate common
- TestEnv.makeFile(common,"start.ini",
- // standard property
+ TestEnv.makeFile(common,"start.ini",
+ // standard property
"jetty.port=8080",
// reference to corp
"--extra-start-dir=" + corp.getAbsolutePath());
diff --git a/jetty-start/src/test/java/org/eclipse/jetty/start/ModuleGraphWriterTest.java b/jetty-start/src/test/java/org/eclipse/jetty/start/ModuleGraphWriterTest.java
index 92ad50363a..c4aeb53c28 100644
--- a/jetty-start/src/test/java/org/eclipse/jetty/start/ModuleGraphWriterTest.java
+++ b/jetty-start/src/test/java/org/eclipse/jetty/start/ModuleGraphWriterTest.java
@@ -18,13 +18,16 @@
package org.eclipse.jetty.start;
-import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.*;
import java.io.File;
import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
+import java.nio.file.Path;
+import org.eclipse.jetty.start.config.CommandLineConfigSource;
+import org.eclipse.jetty.start.config.ConfigSources;
+import org.eclipse.jetty.start.config.JettyBaseConfigSource;
+import org.eclipse.jetty.start.config.JettyHomeConfigSource;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.toolchain.test.TestingDir;
import org.junit.Assert;
@@ -33,30 +36,40 @@ import org.junit.Test;
public class ModuleGraphWriterTest
{
- @SuppressWarnings("unused")
- private final static List<String> TEST_SOURCE = Collections.singletonList("<test>");
-
- private StartArgs DEFAULT_ARGS = new StartArgs(new String[]{"jetty.version=TEST"}).parseCommandLine();
-
@Rule
public TestingDir testdir = new TestingDir();
@Test
public void testGenerate_NothingEnabled() throws IOException
{
+ // Test Env
File homeDir = MavenTestingUtils.getTestResourceDir("usecases/home");
File baseDir = testdir.getEmptyDir();
- BaseHome basehome = new BaseHome(homeDir,baseDir);
+ String cmdLine[] = new String[] {"jetty.version=TEST"};
+
+ // Configuration
+ CommandLineConfigSource cmdLineSource = new CommandLineConfigSource(cmdLine);
+ ConfigSources config = new ConfigSources();
+ config.add(cmdLineSource);
+ config.add(new JettyHomeConfigSource(homeDir.toPath()));
+ config.add(new JettyBaseConfigSource(baseDir.toPath()));
+
+ // Initialize
+ BaseHome basehome = new BaseHome();
+ basehome.initialize(config);
+
+ StartArgs args = new StartArgs();
+ args.parse(config);
Modules modules = new Modules();
- modules.registerAll(basehome, DEFAULT_ARGS);
+ modules.registerAll(basehome, args);
modules.buildGraph();
- File outputFile = new File(baseDir,"graph.dot");
+ Path outputFile = basehome.getBasePath("graph.dot");
ModuleGraphWriter writer = new ModuleGraphWriter();
writer.write(modules,outputFile);
- Assert.assertThat("Output File Exists",outputFile.exists(),is(true));
+ Assert.assertThat("Output File Exists",FS.exists(outputFile),is(true));
}
}
diff --git a/jetty-start/src/test/java/org/eclipse/jetty/start/ModuleTest.java b/jetty-start/src/test/java/org/eclipse/jetty/start/ModuleTest.java
index 31b2e4d299..c49ee3a106 100644
--- a/jetty-start/src/test/java/org/eclipse/jetty/start/ModuleTest.java
+++ b/jetty-start/src/test/java/org/eclipse/jetty/start/ModuleTest.java
@@ -34,7 +34,7 @@ public class ModuleTest
private Module loadTestHomeModule(String moduleFileName) throws IOException
{
File file = MavenTestingUtils.getTestResourceFile("usecases/home/modules/" + moduleFileName);
- return new Module(new BaseHome(),file);
+ return new Module(new BaseHome(),file.toPath());
}
@Test
diff --git a/jetty-start/src/test/java/org/eclipse/jetty/start/ModulesTest.java b/jetty-start/src/test/java/org/eclipse/jetty/start/ModulesTest.java
index 6ce160cd9d..744a3bdc66 100644
--- a/jetty-start/src/test/java/org/eclipse/jetty/start/ModulesTest.java
+++ b/jetty-start/src/test/java/org/eclipse/jetty/start/ModulesTest.java
@@ -27,23 +27,48 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import org.eclipse.jetty.start.config.CommandLineConfigSource;
+import org.eclipse.jetty.start.config.ConfigSources;
+import org.eclipse.jetty.start.config.JettyBaseConfigSource;
+import org.eclipse.jetty.start.config.JettyHomeConfigSource;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
+import org.eclipse.jetty.toolchain.test.TestingDir;
import org.junit.Assert;
+import org.junit.Rule;
import org.junit.Test;
public class ModulesTest
{
private final static List<String> TEST_SOURCE = Collections.singletonList("<test>");
- private StartArgs DEFAULT_ARGS = new StartArgs(new String[] { "jetty.version=TEST" }).parseCommandLine();
+
+ @Rule
+ public TestingDir testdir = new TestingDir();
@Test
public void testLoadAllModules() throws IOException
{
+ // Test Env
File homeDir = MavenTestingUtils.getTestResourceDir("usecases/home");
- BaseHome basehome = new BaseHome(homeDir,homeDir);
-
+ File baseDir = testdir.getEmptyDir();
+ String cmdLine[] = new String[] {"jetty.version=TEST"};
+
+ // Configuration
+ CommandLineConfigSource cmdLineSource = new CommandLineConfigSource(cmdLine);
+ ConfigSources config = new ConfigSources();
+ config.add(cmdLineSource);
+ config.add(new JettyHomeConfigSource(homeDir.toPath()));
+ config.add(new JettyBaseConfigSource(baseDir.toPath()));
+
+ // Initialize
+ BaseHome basehome = new BaseHome();
+ basehome.initialize(config);
+
+ StartArgs args = new StartArgs();
+ args.parse(config);
+
+ // Test Modules
Modules modules = new Modules();
- modules.registerAll(basehome,DEFAULT_ARGS);
+ modules.registerAll(basehome,args);
List<String> moduleNames = new ArrayList<>();
for (Module mod : modules)
@@ -66,11 +91,28 @@ public class ModulesTest
@Test
public void testEnableRegexSimple() throws IOException
{
+ // Test Env
File homeDir = MavenTestingUtils.getTestResourceDir("usecases/home");
- BaseHome basehome = new BaseHome(homeDir,homeDir);
-
+ File baseDir = testdir.getEmptyDir();
+ String cmdLine[] = new String[] {"jetty.version=TEST"};
+
+ // Configuration
+ CommandLineConfigSource cmdLineSource = new CommandLineConfigSource(cmdLine);
+ ConfigSources config = new ConfigSources();
+ config.add(cmdLineSource);
+ config.add(new JettyHomeConfigSource(homeDir.toPath()));
+ config.add(new JettyBaseConfigSource(baseDir.toPath()));
+
+ // Initialize
+ BaseHome basehome = new BaseHome();
+ basehome.initialize(config);
+
+ StartArgs args = new StartArgs();
+ args.parse(config);
+
+ // Test Modules
Modules modules = new Modules();
- modules.registerAll(basehome,DEFAULT_ARGS);
+ modules.registerAll(basehome,args);
modules.enable("[sj]{1}.*",TEST_SOURCE);
String expected[] = { "jmx", "stats", "spdy", "security", "jndi", "jsp", "servlet", "jaas", "server" };
@@ -81,12 +123,28 @@ public class ModulesTest
@Test
public void testResolve_ServerHttp() throws IOException
{
+ // Test Env
File homeDir = MavenTestingUtils.getTestResourceDir("usecases/home");
- BaseHome basehome = new BaseHome(homeDir,homeDir);
-
- // Register modules
+ File baseDir = testdir.getEmptyDir();
+ String cmdLine[] = new String[] {"jetty.version=TEST"};
+
+ // Configuration
+ CommandLineConfigSource cmdLineSource = new CommandLineConfigSource(cmdLine);
+ ConfigSources config = new ConfigSources();
+ config.add(cmdLineSource);
+ config.add(new JettyHomeConfigSource(homeDir.toPath()));
+ config.add(new JettyBaseConfigSource(baseDir.toPath()));
+
+ // Initialize
+ BaseHome basehome = new BaseHome();
+ basehome.initialize(config);
+
+ StartArgs args = new StartArgs();
+ args.parse(config);
+
+ // Test Modules
Modules modules = new Modules();
- modules.registerAll(basehome,DEFAULT_ARGS);
+ modules.registerAll(basehome,args);
modules.buildGraph();
// Enable 2 modules
@@ -137,12 +195,28 @@ public class ModulesTest
@Test
public void testResolve_WebSocket() throws IOException
{
+ // Test Env
File homeDir = MavenTestingUtils.getTestResourceDir("usecases/home");
- BaseHome basehome = new BaseHome(homeDir,homeDir);
-
- // Register modules
+ File baseDir = testdir.getEmptyDir();
+ String cmdLine[] = new String[] {"jetty.version=TEST"};
+
+ // Configuration
+ CommandLineConfigSource cmdLineSource = new CommandLineConfigSource(cmdLine);
+ ConfigSources config = new ConfigSources();
+ config.add(cmdLineSource);
+ config.add(new JettyHomeConfigSource(homeDir.toPath()));
+ config.add(new JettyBaseConfigSource(baseDir.toPath()));
+
+ // Initialize
+ BaseHome basehome = new BaseHome();
+ basehome.initialize(config);
+
+ StartArgs args = new StartArgs();
+ args.parse(config);
+
+ // Test Modules
Modules modules = new Modules();
- modules.registerAll(basehome,DEFAULT_ARGS);
+ modules.registerAll(basehome,args);
modules.buildGraph();
// modules.dump();

Back to the top