use of org.eclipse.jetty.start.config.JettyBaseConfigSource in project jetty.project by eclipse.
the class ModuleTest method testLoadMain.
@Test
public void testLoadMain() throws IOException {
// Test Env
Path homeDir = MavenTestingUtils.getTestResourcePathDir("dist-home");
Path baseDir = testdir.getEmptyPathDir();
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));
config.add(new JettyBaseConfigSource(baseDir));
// Initialize
BaseHome basehome = new BaseHome(config);
File file = MavenTestingUtils.getTestResourceFile("dist-home/modules/main.mod");
Module module = new Module(basehome, file.toPath());
Assert.assertThat("Module Name", module.getName(), is("main"));
Assert.assertThat("Module Depends Size", module.getDepends().size(), is(1));
Assert.assertThat("Module Depends", module.getDepends(), containsInAnyOrder("base"));
Assert.assertThat("Module Xmls Size", module.getXmls().size(), is(1));
Assert.assertThat("Module Lib Size", module.getLibs().size(), is(2));
Assert.assertThat("Module Lib", module.getLibs(), contains("lib/main.jar", "lib/other.jar"));
}
use of org.eclipse.jetty.start.config.JettyBaseConfigSource in project jetty.project by eclipse.
the class ModulesTest method testLoadShallowModulesOnly.
/**
* Test loading of only shallow modules, not deep references.
* In other words. ${search-dir}/modules/*.mod should be the only
* valid references, but ${search-dir}/alt/foo/modules/*.mod should
* not be considered valid.
* @throws IOException on test failures
*/
@Test
public void testLoadShallowModulesOnly() throws IOException {
// Test Env
File homeDir = MavenTestingUtils.getTestResourceDir("jetty home with spaces");
// intentionally setup top level resources dir (as this would have many
// deep references)
File baseDir = MavenTestingUtils.getTestResourcesDir();
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(config);
StartArgs args = new StartArgs(basehome);
args.parse(config);
// Test Modules
Modules modules = new Modules(basehome, args);
modules.registerAll();
List<String> moduleNames = new ArrayList<>();
for (Module mod : modules) {
moduleNames.add(mod.getName());
}
List<String> expected = new ArrayList<>();
expected.add("base");
ConfigurationAssert.assertContainsUnordered("All Modules", expected, moduleNames);
}
use of org.eclipse.jetty.start.config.JettyBaseConfigSource in project jetty.project by eclipse.
the class ModulesTest method testResolve_ServerHttp.
@Test
public void testResolve_ServerHttp() throws IOException {
// Test Env
File homeDir = MavenTestingUtils.getTestResourceDir("dist-home");
File baseDir = testdir.getEmptyPathDir().toFile();
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(config);
StartArgs args = new StartArgs(basehome);
args.parse(config);
// Test Modules
Modules modules = new Modules(basehome, args);
modules.registerAll();
// Enable 2 modules
modules.enable("base", TEST_SOURCE);
modules.enable("optional", TEST_SOURCE);
// Collect active module list
List<Module> active = modules.getEnabled();
// Assert names are correct, and in the right order
List<String> expectedNames = new ArrayList<>();
expectedNames.add("optional");
expectedNames.add("base");
List<String> actualNames = new ArrayList<>();
for (Module actual : active) {
actualNames.add(actual.getName());
}
assertThat("Resolved Names: " + actualNames, actualNames, contains(expectedNames.toArray()));
// Assert Library List
List<String> expectedLibs = new ArrayList<>();
expectedLibs.add("lib/optional.jar");
expectedLibs.add("lib/base.jar");
List<String> actualLibs = normalizeLibs(active);
assertThat("Resolved Libs: " + actualLibs, actualLibs, contains(expectedLibs.toArray()));
// Assert XML List
List<String> expectedXmls = new ArrayList<>();
expectedXmls.add("etc/optional.xml");
expectedXmls.add("etc/base.xml");
List<String> actualXmls = normalizeXmls(active);
assertThat("Resolved XMLs: " + actualXmls, actualXmls, contains(expectedXmls.toArray()));
}
Aggregations