Search in sources :

Example 11 with ConfigSources

use of org.eclipse.jetty.start.config.ConfigSources 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()));
}
Also used : JettyBaseConfigSource(org.eclipse.jetty.start.config.JettyBaseConfigSource) ArrayList(java.util.ArrayList) CommandLineConfigSource(org.eclipse.jetty.start.config.CommandLineConfigSource) ConfigSources(org.eclipse.jetty.start.config.ConfigSources) JettyHomeConfigSource(org.eclipse.jetty.start.config.JettyHomeConfigSource) File(java.io.File) Test(org.junit.Test)

Aggregations

ConfigSources (org.eclipse.jetty.start.config.ConfigSources)11 JettyHomeConfigSource (org.eclipse.jetty.start.config.JettyHomeConfigSource)11 Test (org.junit.Test)10 File (java.io.File)9 Path (java.nio.file.Path)8 JettyBaseConfigSource (org.eclipse.jetty.start.config.JettyBaseConfigSource)8 ArrayList (java.util.ArrayList)6 CommandLineConfigSource (org.eclipse.jetty.start.config.CommandLineConfigSource)5 Matchers.containsString (org.hamcrest.Matchers.containsString)5 BaseHome (org.eclipse.jetty.start.BaseHome)1 Before (org.junit.Before)1