Search in sources :

Example 1 with ConfigSources

use of org.eclipse.jetty.start.config.ConfigSources in project jetty.project by eclipse.

the class ModulesTest method testLoadAllModules.

@Test
public void testLoadAllModules() 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();
    // Check versions
    assertThat("java.version.platform", args.getProperties().getString("java.version.platform"), anyOf(equalTo("8"), equalTo("9")));
    List<String> moduleNames = new ArrayList<>();
    for (Module mod : modules) {
        // skip alpn-boot in this test (as its behavior is jdk specific)
        if (mod.getName().equals("alpn-boot")) {
            continue;
        }
        moduleNames.add(mod.getName());
    }
    List<String> expected = new ArrayList<>();
    expected.add("base");
    expected.add("extra");
    expected.add("main");
    expected.add("optional");
    ConfigurationAssert.assertContainsUnordered("All Modules", expected, moduleNames);
}
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)

Example 2 with ConfigSources

use of org.eclipse.jetty.start.config.ConfigSources in project jetty.project by eclipse.

the class BaseHomeTest method testGetPaths_Both.

@Test
public void testGetPaths_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(config);
    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);
}
Also used : Path(java.nio.file.Path) JettyBaseConfigSource(org.eclipse.jetty.start.config.JettyBaseConfigSource) ArrayList(java.util.ArrayList) JettyHomeConfigSource(org.eclipse.jetty.start.config.JettyHomeConfigSource) Matchers.containsString(org.hamcrest.Matchers.containsString) File(java.io.File) ConfigSources(org.eclipse.jetty.start.config.ConfigSources) Test(org.junit.Test)

Example 3 with ConfigSources

use of org.eclipse.jetty.start.config.ConfigSources in project jetty.project by eclipse.

the class BaseHomeTest method testGetPaths_OnlyHome.

@Test
public void testGetPaths_OnlyHome() throws IOException {
    File homeDir = MavenTestingUtils.getTestResourceDir("hb.1/home");
    ConfigSources config = new ConfigSources();
    config.add(new JettyHomeConfigSource(homeDir.toPath()));
    BaseHome hb = new BaseHome(config);
    List<Path> paths = hb.getPaths("start.d/*");
    List<String> expected = new ArrayList<>();
    expected.add("${jetty.home}/start.d/jmx.ini");
    expected.add("${jetty.home}/start.d/jndi.ini");
    expected.add("${jetty.home}/start.d/jsp.ini");
    expected.add("${jetty.home}/start.d/logging.ini");
    expected.add("${jetty.home}/start.d/ssl.ini");
    FSTest.toOsSeparators(expected);
    assertPathList(hb, "Paths found", expected, paths);
}
Also used : Path(java.nio.file.Path) ArrayList(java.util.ArrayList) JettyHomeConfigSource(org.eclipse.jetty.start.config.JettyHomeConfigSource) Matchers.containsString(org.hamcrest.Matchers.containsString) File(java.io.File) ConfigSources(org.eclipse.jetty.start.config.ConfigSources) Test(org.junit.Test)

Example 4 with ConfigSources

use of org.eclipse.jetty.start.config.ConfigSources in project jetty.project by eclipse.

the class BaseHomeTest method testGetPath_OnlyHome.

@Test
public void testGetPath_OnlyHome() throws IOException {
    File homeDir = MavenTestingUtils.getTestResourceDir("hb.1/home");
    ConfigSources config = new ConfigSources();
    config.add(new JettyHomeConfigSource(homeDir.toPath()));
    BaseHome hb = new BaseHome(config);
    Path startIni = hb.getPath("start.ini");
    String ref = hb.toShortForm(startIni);
    Assert.assertThat("Reference", ref, startsWith("${jetty.home}"));
    String contents = IO.readToString(startIni.toFile());
    Assert.assertThat("Contents", contents, containsString("Home Ini"));
}
Also used : Path(java.nio.file.Path) JettyHomeConfigSource(org.eclipse.jetty.start.config.JettyHomeConfigSource) Matchers.containsString(org.hamcrest.Matchers.containsString) File(java.io.File) ConfigSources(org.eclipse.jetty.start.config.ConfigSources) Test(org.junit.Test)

Example 5 with ConfigSources

use of org.eclipse.jetty.start.config.ConfigSources in project jetty.project by eclipse.

the class MavenLocalRepoFileInitializerTest method setupBaseHome.

@Before
public void setupBaseHome() throws IOException {
    Path homeDir = testdir.getEmptyPathDir();
    ConfigSources config = new ConfigSources();
    config.add(new JettyHomeConfigSource(homeDir));
    config.add(new JettyBaseConfigSource(homeDir));
    this.baseHome = new BaseHome(config);
}
Also used : Path(java.nio.file.Path) JettyBaseConfigSource(org.eclipse.jetty.start.config.JettyBaseConfigSource) BaseHome(org.eclipse.jetty.start.BaseHome) JettyHomeConfigSource(org.eclipse.jetty.start.config.JettyHomeConfigSource) ConfigSources(org.eclipse.jetty.start.config.ConfigSources) Before(org.junit.Before)

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