Merge pull request #6702 from eclipse/jetty-9.4.x-start-test-cleanup
Cleaning up jetty-start Usecase testing.
This commit is contained in:
commit
d4f1ac8c7f
|
@ -1,272 +0,0 @@
|
||||||
//
|
|
||||||
// ========================================================================
|
|
||||||
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
// All rights reserved. This program and the accompanying materials
|
|
||||||
// are made available under the terms of the Eclipse Public License v1.0
|
|
||||||
// and Apache License v2.0 which accompanies this distribution.
|
|
||||||
//
|
|
||||||
// The Eclipse Public License is available at
|
|
||||||
// http://www.eclipse.org/legal/epl-v10.html
|
|
||||||
//
|
|
||||||
// The Apache License v2.0 is available at
|
|
||||||
// http://www.opensource.org/licenses/apache2.0.php
|
|
||||||
//
|
|
||||||
// You may elect to redistribute this code under either of these licenses.
|
|
||||||
// ========================================================================
|
|
||||||
//
|
|
||||||
|
|
||||||
package org.eclipse.jetty.start;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import org.eclipse.jetty.start.Props.Prop;
|
|
||||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
|
||||||
import org.eclipse.jetty.toolchain.test.PathAssert;
|
|
||||||
import org.hamcrest.Matchers;
|
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.greaterThan;
|
|
||||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
||||||
|
|
||||||
public class ConfigurationAssert
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Given a provided StartArgs, assert that the configuration it has determined is valid based on values in a assert text file.
|
|
||||||
*
|
|
||||||
* @param baseHome the BaseHome used. Access it via {@link Main#getBaseHome()}
|
|
||||||
* @param args the StartArgs that has been processed via {@link Main#processCommandLine(String[])}
|
|
||||||
* @param filename the filename of the assertion values
|
|
||||||
* @throws FileNotFoundException if unable to find the configuration
|
|
||||||
* @throws IOException if unable to process the configuration
|
|
||||||
*/
|
|
||||||
public static void assertConfiguration(BaseHome baseHome, StartArgs args, String filename) throws FileNotFoundException, IOException
|
|
||||||
{
|
|
||||||
assertConfiguration(baseHome, args, null, MavenTestingUtils.getTestResourceFile(filename));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a provided StartArgs, assert that the configuration it has determined is valid based on values in a assert text file.
|
|
||||||
*
|
|
||||||
* @param baseHome the BaseHome used. Access it via {@link Main#getBaseHome()}
|
|
||||||
* @param args the StartArgs that has been processed via {@link Main#processCommandLine(String[])}
|
|
||||||
* @param output the captured output that you want to assert against
|
|
||||||
* @param filename the filename of the assertion values
|
|
||||||
* @throws FileNotFoundException if unable to find the configuration
|
|
||||||
* @throws IOException if unable to process the configuration
|
|
||||||
*/
|
|
||||||
public static void assertConfiguration(BaseHome baseHome, StartArgs args, String output, String filename) throws FileNotFoundException, IOException
|
|
||||||
{
|
|
||||||
assertConfiguration(baseHome, args, output, MavenTestingUtils.getTestResourceFile(filename));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a provided StartArgs, assert that the configuration it has determined is valid based on values in a assert text file.
|
|
||||||
*
|
|
||||||
* @param baseHome the BaseHome used. Access it via {@link Main#getBaseHome()}
|
|
||||||
* @param args the StartArgs that has been processed via {@link Main#processCommandLine(String[])}
|
|
||||||
* @param file the file of the assertion values
|
|
||||||
* @throws FileNotFoundException if unable to find the configuration
|
|
||||||
* @throws IOException if unable to process the configuration
|
|
||||||
*/
|
|
||||||
public static void assertConfiguration(BaseHome baseHome, StartArgs args, String output, File file) throws FileNotFoundException, IOException
|
|
||||||
{
|
|
||||||
if (output != null)
|
|
||||||
{
|
|
||||||
System.err.println(output);
|
|
||||||
}
|
|
||||||
Path testResourcesDir = MavenTestingUtils.getTestResourcesDir().toPath().toRealPath();
|
|
||||||
TextFile textFile = new TextFile(file.toPath());
|
|
||||||
|
|
||||||
// Validate XMLs (order is important)
|
|
||||||
List<String> expectedXmls = new ArrayList<>();
|
|
||||||
for (String line : textFile)
|
|
||||||
{
|
|
||||||
if (line.startsWith("XML|"))
|
|
||||||
{
|
|
||||||
expectedXmls.add(FS.separators(getValue(line)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List<String> actualXmls = new ArrayList<>();
|
|
||||||
for (Path xml : args.getXmlFiles())
|
|
||||||
{
|
|
||||||
actualXmls.add(shorten(baseHome, xml, testResourcesDir));
|
|
||||||
}
|
|
||||||
assertOrdered("XML Resolution Order", expectedXmls, actualXmls);
|
|
||||||
|
|
||||||
// Validate LIBs (order is not important)
|
|
||||||
List<String> expectedLibs = new ArrayList<>();
|
|
||||||
for (String line : textFile)
|
|
||||||
{
|
|
||||||
if (line.startsWith("LIB|"))
|
|
||||||
{
|
|
||||||
expectedLibs.add(FS.separators(getValue(line)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List<String> actualLibs = new ArrayList<>();
|
|
||||||
for (File path : args.getClasspath())
|
|
||||||
{
|
|
||||||
actualLibs.add(shorten(baseHome, path.toPath(), testResourcesDir));
|
|
||||||
}
|
|
||||||
assertContainsUnordered("Libs", expectedLibs, actualLibs);
|
|
||||||
|
|
||||||
// Validate PROPERTIES (order is not important)
|
|
||||||
Set<String> expectedProperties = new HashSet<>();
|
|
||||||
for (String line : textFile)
|
|
||||||
{
|
|
||||||
if (line.startsWith("PROP|") || line.startsWith("SYS|"))
|
|
||||||
{
|
|
||||||
expectedProperties.add(getValue(line));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List<String> actualProperties = new ArrayList<>();
|
|
||||||
for (Prop prop : args.getProperties())
|
|
||||||
{
|
|
||||||
String name = prop.key;
|
|
||||||
if ("jetty.home".equals(name) ||
|
|
||||||
"jetty.base".equals(name) ||
|
|
||||||
"jetty.home.uri".equals(name) ||
|
|
||||||
"jetty.base.uri".equals(name) ||
|
|
||||||
"user.dir".equals(name) ||
|
|
||||||
prop.source.equals(Props.ORIGIN_SYSPROP) ||
|
|
||||||
name.startsWith("runtime.feature.") ||
|
|
||||||
name.startsWith("java."))
|
|
||||||
{
|
|
||||||
// strip these out from assertion, to make assertions easier.
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
actualProperties.add(prop.key + "=" + args.getProperties().expand(prop.value));
|
|
||||||
}
|
|
||||||
assertContainsUnordered("Properties", expectedProperties, actualProperties);
|
|
||||||
|
|
||||||
// Validate PROPERTIES (order is not important)
|
|
||||||
for (String line : textFile)
|
|
||||||
{
|
|
||||||
if (line.startsWith("SYS|"))
|
|
||||||
{
|
|
||||||
String[] expected = getValue(line).split("=", 2);
|
|
||||||
String actual = System.getProperty(expected[0]);
|
|
||||||
assertThat("System property " + expected[0], actual, Matchers.equalTo(expected[1]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate Downloads
|
|
||||||
List<String> expectedDownloads = new ArrayList<>();
|
|
||||||
for (String line : textFile)
|
|
||||||
{
|
|
||||||
if (line.startsWith("DOWNLOAD|"))
|
|
||||||
{
|
|
||||||
expectedDownloads.add(getValue(line));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List<String> actualDownloads = new ArrayList<>();
|
|
||||||
for (FileArg darg : args.getFiles())
|
|
||||||
{
|
|
||||||
if (darg.uri != null)
|
|
||||||
{
|
|
||||||
actualDownloads.add(String.format("%s|%s", darg.uri, darg.location));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assertContainsUnordered("Downloads", expectedDownloads, actualDownloads);
|
|
||||||
|
|
||||||
// File / Path Existence Checks
|
|
||||||
streamOf(textFile, "EXISTS").forEach(f ->
|
|
||||||
{
|
|
||||||
Path path = baseHome.getPath(f);
|
|
||||||
if (f.endsWith("/"))
|
|
||||||
{
|
|
||||||
PathAssert.assertDirExists("Required Directory", path);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PathAssert.assertFileExists("Required File", path);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Output Validation
|
|
||||||
streamOf(textFile, "OUTPUT").forEach(regex ->
|
|
||||||
{
|
|
||||||
Pattern pat = Pattern.compile(regex);
|
|
||||||
Matcher mat = pat.matcher(output);
|
|
||||||
assertTrue(mat.find(), "Output [\n" + output + "]\nContains Regex Match: " + pat.pattern());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String shorten(BaseHome baseHome, Path path, Path testResourcesDir)
|
|
||||||
{
|
|
||||||
String value = baseHome.toShortForm(path);
|
|
||||||
if (value.startsWith("${"))
|
|
||||||
{
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (path.startsWith(testResourcesDir))
|
|
||||||
{
|
|
||||||
int len = testResourcesDir.toString().length();
|
|
||||||
value = "${maven-test-resources}" + value.substring(len);
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void assertContainsUnordered(String msg, Collection<String> expectedSet, Collection<String> actualSet)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
assertEquals(expectedSet.size(), actualSet.size(), msg);
|
|
||||||
if (!expectedSet.isEmpty())
|
|
||||||
assertThat(msg, actualSet, Matchers.containsInAnyOrder(expectedSet.toArray()));
|
|
||||||
}
|
|
||||||
catch (AssertionError e)
|
|
||||||
{
|
|
||||||
System.err.println("Expected: " + expectedSet.stream().sorted().collect(Collectors.toList()));
|
|
||||||
System.err.println("Actual : " + actualSet.stream().sorted().collect(Collectors.toList()));
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("Duplicates")
|
|
||||||
public static void assertOrdered(String msg, List<String> expectedList, List<String> actualList)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
assertEquals(expectedList.size(), actualList.size(), msg);
|
|
||||||
if (!expectedList.isEmpty())
|
|
||||||
assertThat(msg, actualList, Matchers.contains(expectedList.toArray()));
|
|
||||||
}
|
|
||||||
catch (AssertionError e)
|
|
||||||
{
|
|
||||||
System.err.println("Expected: " + expectedList);
|
|
||||||
System.err.println("Actual : " + actualList);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Stream<String> streamOf(TextFile textFile, String key)
|
|
||||||
{
|
|
||||||
return textFile.stream()
|
|
||||||
.filter(s -> s.startsWith(key + "|")).map(f -> getValue(f));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getValue(String arg)
|
|
||||||
{
|
|
||||||
int idx = arg.indexOf('|');
|
|
||||||
assertThat("Expecting '|' sign in [" + arg + "]", idx, greaterThanOrEqualTo(0));
|
|
||||||
String value = arg.substring(idx + 1).trim();
|
|
||||||
assertThat("Expecting Value after '|' in [" + arg + "]", value.length(), greaterThan(0));
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -34,6 +34,7 @@ import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.contains;
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
import static org.hamcrest.Matchers.notNullValue;
|
import static org.hamcrest.Matchers.notNullValue;
|
||||||
|
@ -58,7 +59,7 @@ public class IncludeJettyDirTest
|
||||||
actualOrder.add(source.getId());
|
actualOrder.add(source.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ConfigurationAssert.assertOrdered("Search Order", expectedSearchOrder, actualOrder);
|
assertThat("Search Order", actualOrder, contains(expectedSearchOrder.toArray()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void assertProperty(String key, String expectedValue)
|
public void assertProperty(String key, String expectedValue)
|
||||||
|
|
|
@ -19,12 +19,10 @@
|
||||||
package org.eclipse.jetty.start;
|
package org.eclipse.jetty.start;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.jetty.toolchain.test.IO;
|
|
||||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
|
@ -33,8 +31,6 @@ import org.junit.jupiter.api.Test;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
import static org.hamcrest.Matchers.not;
|
|
||||||
import static org.hamcrest.Matchers.startsWith;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
public class MainTest
|
public class MainTest
|
||||||
|
@ -46,42 +42,6 @@ public class MainTest
|
||||||
System.setProperty("jetty.base", "");
|
System.setProperty("jetty.base", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testBasicProcessing() throws Exception
|
|
||||||
{
|
|
||||||
List<String> cmdLineArgs = new ArrayList<>();
|
|
||||||
Path testJettyHome = MavenTestingUtils.getTestResourceDir("dist-home").toPath().toRealPath();
|
|
||||||
cmdLineArgs.add("user.dir=" + testJettyHome);
|
|
||||||
cmdLineArgs.add("jetty.home=" + testJettyHome);
|
|
||||||
// cmdLineArgs.add("jetty.http.port=9090");
|
|
||||||
|
|
||||||
Main main = new Main();
|
|
||||||
StartArgs args = main.processCommandLine(cmdLineArgs.toArray(new String[0]));
|
|
||||||
BaseHome baseHome = main.getBaseHome();
|
|
||||||
// System.err.println(args);
|
|
||||||
|
|
||||||
ConfigurationAssert.assertConfiguration(baseHome, args, "assert-home.txt");
|
|
||||||
|
|
||||||
// System.err.println("StartArgs.props:");
|
|
||||||
// args.getProperties().forEach(p->System.err.println(p));
|
|
||||||
// System.err.println("BaseHome.props:");
|
|
||||||
// baseHome.getConfigSources().getProps().forEach(p->System.err.println(p));
|
|
||||||
|
|
||||||
Props props = args.getProperties();
|
|
||||||
|
|
||||||
assertThat("Props(jetty.home)", props.getString("jetty.home"), is(baseHome.getHome()));
|
|
||||||
assertThat("Props(jetty.home)", props.getString("jetty.home"), is(not(startsWith("file:"))));
|
|
||||||
assertThat("Props(jetty.home.uri)", props.getString("jetty.home.uri") + "/", is(baseHome.getHomePath().toUri().toString()));
|
|
||||||
assertThat("Props(jetty.base)", props.getString("jetty.base"), is(baseHome.getBase()));
|
|
||||||
assertThat("Props(jetty.base)", props.getString("jetty.base"), is(not(startsWith("file:"))));
|
|
||||||
assertThat("Props(jetty.base.uri)", props.getString("jetty.base.uri") + "/", is(baseHome.getBasePath().toUri().toString()));
|
|
||||||
|
|
||||||
assertThat("System.getProperty(jetty.home)", System.getProperty("jetty.home"), is(baseHome.getHome()));
|
|
||||||
assertThat("System.getProperty(jetty.home)", System.getProperty("jetty.home"), is(not(startsWith("file:"))));
|
|
||||||
assertThat("System.getProperty(jetty.base)", System.getProperty("jetty.base"), is(baseHome.getBase()));
|
|
||||||
assertThat("System.getProperty(jetty.base)", System.getProperty("jetty.base"), is(not(startsWith("file:"))));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStopProcessing() throws Exception
|
public void testStopProcessing() throws Exception
|
||||||
{
|
{
|
||||||
|
@ -125,46 +85,6 @@ public class MainTest
|
||||||
main.usage(false);
|
main.usage(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testWithCommandLine() throws Exception
|
|
||||||
{
|
|
||||||
List<String> cmdLineArgs = new ArrayList<>();
|
|
||||||
|
|
||||||
Path homePath = MavenTestingUtils.getTestResourceDir("dist-home").toPath().toRealPath();
|
|
||||||
cmdLineArgs.add("jetty.home=" + homePath);
|
|
||||||
cmdLineArgs.add("user.dir=" + homePath);
|
|
||||||
|
|
||||||
// JVM args
|
|
||||||
cmdLineArgs.add("--exec");
|
|
||||||
cmdLineArgs.add("-Xms1024m");
|
|
||||||
cmdLineArgs.add("-Xmx1024m");
|
|
||||||
|
|
||||||
// Arbitrary Libs
|
|
||||||
Path extraJar = MavenTestingUtils.getTestResourceFile("extra-libs/example.jar").toPath().toRealPath();
|
|
||||||
Path extraDir = MavenTestingUtils.getTestResourceDir("extra-resources").toPath().toRealPath();
|
|
||||||
|
|
||||||
assertThat("Extra Jar exists: " + extraJar, Files.exists(extraJar), is(true));
|
|
||||||
assertThat("Extra Dir exists: " + extraDir, Files.exists(extraDir), is(true));
|
|
||||||
|
|
||||||
String lib = "--lib=" + extraJar + File.pathSeparator + extraDir;
|
|
||||||
cmdLineArgs.add(lib);
|
|
||||||
|
|
||||||
// Arbitrary XMLs
|
|
||||||
cmdLineArgs.add("config.xml");
|
|
||||||
cmdLineArgs.add("config-foo.xml");
|
|
||||||
cmdLineArgs.add("config-bar.xml");
|
|
||||||
|
|
||||||
Main main = new Main();
|
|
||||||
|
|
||||||
StartArgs args = main.processCommandLine(cmdLineArgs.toArray(new String[0]));
|
|
||||||
BaseHome baseHome = main.getBaseHome();
|
|
||||||
|
|
||||||
assertThat("jetty.home", baseHome.getHome(), is(homePath.toString()));
|
|
||||||
assertThat("jetty.base", baseHome.getBase(), is(homePath.toString()));
|
|
||||||
|
|
||||||
ConfigurationAssert.assertConfiguration(baseHome, args, "assert-home-with-jvm.txt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testJvmArgExpansion() throws Exception
|
public void testJvmArgExpansion() throws Exception
|
||||||
{
|
{
|
||||||
|
@ -195,54 +115,4 @@ public class MainTest
|
||||||
);
|
);
|
||||||
assertThat(commandLine, containsString(expectedExpansion));
|
assertThat(commandLine, containsString(expectedExpansion));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testWithModules() throws Exception
|
|
||||||
{
|
|
||||||
List<String> cmdLineArgs = new ArrayList<>();
|
|
||||||
|
|
||||||
Path homePath = MavenTestingUtils.getTestResourceDir("dist-home").toPath().toRealPath();
|
|
||||||
cmdLineArgs.add("jetty.home=" + homePath);
|
|
||||||
cmdLineArgs.add("user.dir=" + homePath);
|
|
||||||
cmdLineArgs.add("java.version=1.8.0_31");
|
|
||||||
|
|
||||||
// Modules
|
|
||||||
cmdLineArgs.add("--module=optional,extra");
|
|
||||||
|
|
||||||
Main main = new Main();
|
|
||||||
|
|
||||||
StartArgs args = main.processCommandLine(cmdLineArgs.toArray(new String[0]));
|
|
||||||
BaseHome baseHome = main.getBaseHome();
|
|
||||||
|
|
||||||
assertThat("jetty.home", baseHome.getHome(), is(homePath.toString()));
|
|
||||||
assertThat("jetty.base", baseHome.getBase(), is(homePath.toString()));
|
|
||||||
|
|
||||||
ConfigurationAssert.assertConfiguration(baseHome, args, "assert-home-with-module.txt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testJettyHomeWithSpaces() throws Exception
|
|
||||||
{
|
|
||||||
Path distPath = MavenTestingUtils.getTestResourceDir("dist-home").toPath().toRealPath();
|
|
||||||
Path homePath = MavenTestingUtils.getTargetTestingPath().resolve("dist home with spaces");
|
|
||||||
if (!Files.exists(homePath))
|
|
||||||
{
|
|
||||||
IO.copy(distPath.toFile(), homePath.toFile());
|
|
||||||
Files.createFile(homePath.resolve("lib/a library.jar"));
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> cmdLineArgs = new ArrayList<>();
|
|
||||||
cmdLineArgs.add("user.dir=" + homePath);
|
|
||||||
cmdLineArgs.add("jetty.home=" + homePath);
|
|
||||||
cmdLineArgs.add("--lib=lib/a library.jar");
|
|
||||||
|
|
||||||
Main main = new Main();
|
|
||||||
StartArgs args = main.processCommandLine(cmdLineArgs.toArray(new String[0]));
|
|
||||||
BaseHome baseHome = main.getBaseHome();
|
|
||||||
|
|
||||||
assertThat("jetty.home", baseHome.getHome(), is(homePath.toString()));
|
|
||||||
assertThat("jetty.base", baseHome.getBase(), is(homePath.toString()));
|
|
||||||
|
|
||||||
ConfigurationAssert.assertConfiguration(baseHome, args, "assert-home-with-spaces.txt");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.contains;
|
import static org.hamcrest.Matchers.contains;
|
||||||
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
import static org.hamcrest.Matchers.nullValue;
|
import static org.hamcrest.Matchers.nullValue;
|
||||||
|
@ -92,7 +93,7 @@ public class ModulesTest
|
||||||
expected.add("main");
|
expected.add("main");
|
||||||
expected.add("optional");
|
expected.add("optional");
|
||||||
|
|
||||||
ConfigurationAssert.assertContainsUnordered("All Modules", expected, moduleNames);
|
assertThat("All Modules", moduleNames, containsInAnyOrder(expected.toArray()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -139,7 +140,7 @@ public class ModulesTest
|
||||||
List<String> expected = new ArrayList<>();
|
List<String> expected = new ArrayList<>();
|
||||||
expected.add("base");
|
expected.add("base");
|
||||||
|
|
||||||
ConfigurationAssert.assertContainsUnordered("All Modules", expected, moduleNames);
|
assertThat("All Modules", moduleNames, containsInAnyOrder(expected.toArray()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,87 +0,0 @@
|
||||||
//
|
|
||||||
// ========================================================================
|
|
||||||
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
// All rights reserved. This program and the accompanying materials
|
|
||||||
// are made available under the terms of the Eclipse Public License v1.0
|
|
||||||
// and Apache License v2.0 which accompanies this distribution.
|
|
||||||
//
|
|
||||||
// The Eclipse Public License is available at
|
|
||||||
// http://www.eclipse.org/legal/epl-v10.html
|
|
||||||
//
|
|
||||||
// The Apache License v2.0 is available at
|
|
||||||
// http://www.opensource.org/licenses/apache2.0.php
|
|
||||||
//
|
|
||||||
// You may elect to redistribute this code under either of these licenses.
|
|
||||||
// ========================================================================
|
|
||||||
//
|
|
||||||
|
|
||||||
package org.eclipse.jetty.start;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import org.eclipse.jetty.start.util.RebuildTestResources;
|
|
||||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
|
||||||
import org.junit.jupiter.api.Disabled;
|
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
|
||||||
import org.junit.jupiter.params.provider.Arguments;
|
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.containsString;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test bad configuration scenarios.
|
|
||||||
*/
|
|
||||||
public class TestBadUseCases
|
|
||||||
{
|
|
||||||
public static Stream<Arguments> getCases()
|
|
||||||
{
|
|
||||||
List<Object[]> ret = new ArrayList<>();
|
|
||||||
|
|
||||||
ret.add(new Object[]{
|
|
||||||
"http2",
|
|
||||||
"Invalid Java version",
|
|
||||||
new String[]{"java.version=0.0.0_0"}
|
|
||||||
});
|
|
||||||
|
|
||||||
ret.add(new Object[]{
|
|
||||||
"versioned-modules-too-new",
|
|
||||||
"Module [http3] specifies jetty version [10.0] which is newer than this version of jetty [" + RebuildTestResources.JETTY_VERSION + "]",
|
|
||||||
null
|
|
||||||
});
|
|
||||||
|
|
||||||
return ret.stream().map(Arguments::of);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO unsure how this failure should be handled
|
|
||||||
@Disabled
|
|
||||||
@ParameterizedTest
|
|
||||||
@MethodSource("getCases")
|
|
||||||
public void testBadConfig(String caseName, String expectedErrorMessage, String[] commandLineArgs) throws Exception
|
|
||||||
{
|
|
||||||
File homeDir = MavenTestingUtils.getTestResourceDir("dist-home");
|
|
||||||
File baseDir = MavenTestingUtils.getTestResourceDir("usecases/" + caseName);
|
|
||||||
|
|
||||||
Main main = new Main();
|
|
||||||
List<String> cmdLine = new ArrayList<>();
|
|
||||||
cmdLine.add("jetty.home=" + homeDir.getAbsolutePath());
|
|
||||||
cmdLine.add("jetty.base=" + baseDir.getAbsolutePath());
|
|
||||||
// cmdLine.add("--debug");
|
|
||||||
|
|
||||||
if (commandLineArgs != null)
|
|
||||||
{
|
|
||||||
for (String arg : commandLineArgs)
|
|
||||||
{
|
|
||||||
cmdLine.add(arg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
UsageException x = assertThrows(UsageException.class, () -> main.processCommandLine(cmdLine));
|
|
||||||
assertThat(x.getMessage(), containsString(expectedErrorMessage));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,158 +0,0 @@
|
||||||
//
|
|
||||||
// ========================================================================
|
|
||||||
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
// All rights reserved. This program and the accompanying materials
|
|
||||||
// are made available under the terms of the Eclipse Public License v1.0
|
|
||||||
// and Apache License v2.0 which accompanies this distribution.
|
|
||||||
//
|
|
||||||
// The Eclipse Public License is available at
|
|
||||||
// http://www.eclipse.org/legal/epl-v10.html
|
|
||||||
//
|
|
||||||
// The Apache License v2.0 is available at
|
|
||||||
// http://www.opensource.org/licenses/apache2.0.php
|
|
||||||
//
|
|
||||||
// You may elect to redistribute this code under either of these licenses.
|
|
||||||
// ========================================================================
|
|
||||||
//
|
|
||||||
|
|
||||||
package org.eclipse.jetty.start;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.PrintStream;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
|
||||||
import org.hamcrest.Matchers;
|
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
|
||||||
import org.junit.jupiter.params.provider.Arguments;
|
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
|
||||||
|
|
||||||
import static java.util.stream.Collectors.toList;
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Various Home + Base use cases
|
|
||||||
*/
|
|
||||||
public class TestUseCases
|
|
||||||
{
|
|
||||||
public static Stream<Arguments> getCases()
|
|
||||||
{
|
|
||||||
File usecases = MavenTestingUtils.getTestResourceDir("usecases/");
|
|
||||||
File[] cases = usecases.listFiles((dir, name) -> name.endsWith(".assert.txt"));
|
|
||||||
Arrays.sort(cases);
|
|
||||||
|
|
||||||
List<Arguments> ret = new ArrayList<>();
|
|
||||||
for (File assertTxt : cases)
|
|
||||||
{
|
|
||||||
String caseName = assertTxt.getName().replace(".assert.txt", "");
|
|
||||||
ret.add(Arguments.of(caseName));
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret.stream();
|
|
||||||
}
|
|
||||||
|
|
||||||
@ParameterizedTest
|
|
||||||
@MethodSource("getCases")
|
|
||||||
public void testUseCase(String caseName) throws Exception
|
|
||||||
{
|
|
||||||
String baseName = caseName.replaceFirst("\\..*$", "");
|
|
||||||
File assertFile = MavenTestingUtils.getTestResourceFile("usecases/" + caseName + ".assert.txt");
|
|
||||||
|
|
||||||
Path homeDir = MavenTestingUtils.getTestResourceDir("dist-home").toPath().toRealPath();
|
|
||||||
|
|
||||||
Path baseSrcDir = MavenTestingUtils.getTestResourceDir("usecases/" + baseName).toPath().toRealPath();
|
|
||||||
Path baseDir = MavenTestingUtils.getTargetTestingPath(caseName);
|
|
||||||
org.eclipse.jetty.toolchain.test.FS.ensureEmpty(baseDir);
|
|
||||||
org.eclipse.jetty.toolchain.test.IO.copyDir(baseSrcDir.toFile(), baseDir.toFile());
|
|
||||||
|
|
||||||
System.setProperty("jetty.home", homeDir.toString());
|
|
||||||
System.setProperty("jetty.base", baseDir.toString());
|
|
||||||
|
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
||||||
PrintStream originalStream = StartLog.setStream(new PrintStream(out));
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// If there is a "{caseName}.prepare.txt" then use those
|
|
||||||
// lines as if you are calling start.jar once to setup
|
|
||||||
// the base directory.
|
|
||||||
List<String> prepareArgs = lines(caseName + ".prepare.txt");
|
|
||||||
if (!prepareArgs.isEmpty())
|
|
||||||
{
|
|
||||||
Main main = new Main();
|
|
||||||
List<String> cmdLine = new ArrayList<>();
|
|
||||||
cmdLine.add("--testing-mode");
|
|
||||||
cmdLine.addAll(prepareArgs);
|
|
||||||
|
|
||||||
main.start(main.processCommandLine(cmdLine));
|
|
||||||
}
|
|
||||||
|
|
||||||
Main main = new Main();
|
|
||||||
List<String> cmdLine = new ArrayList<>();
|
|
||||||
// cmdLine.add("--debug");
|
|
||||||
|
|
||||||
// If there is a "{caseName}.cmdline.txt" then these
|
|
||||||
// entries are extra command line argument to use for
|
|
||||||
// the actual testcase
|
|
||||||
cmdLine.addAll(lines(caseName + ".cmdline.txt"));
|
|
||||||
StartArgs args = main.processCommandLine(cmdLine);
|
|
||||||
args.getAllModules().checkEnabledModules();
|
|
||||||
BaseHome baseHome = main.getBaseHome();
|
|
||||||
|
|
||||||
StartLog.setStream(originalStream);
|
|
||||||
String output = out.toString(StandardCharsets.UTF_8.name());
|
|
||||||
ConfigurationAssert.assertConfiguration(baseHome, args, output, assertFile);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
List<String> exceptions = lines(assertFile).stream().filter(s -> s.startsWith("EX|")).collect(toList());
|
|
||||||
if (exceptions.isEmpty())
|
|
||||||
throw e;
|
|
||||||
for (String ex : exceptions)
|
|
||||||
{
|
|
||||||
ex = ex.substring(3);
|
|
||||||
assertThat(e.toString(), Matchers.containsString(ex));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
StartLog.setStream(originalStream);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<String> lines(String filename) throws IOException
|
|
||||||
{
|
|
||||||
return lines(MavenTestingUtils.getTestResourcesPath().resolve("usecases" + File.separator + filename).toFile());
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<String> lines(File file) throws IOException
|
|
||||||
{
|
|
||||||
if (!file.exists() || !file.canRead())
|
|
||||||
return Collections.emptyList();
|
|
||||||
List<String> ret = new ArrayList<>();
|
|
||||||
try (FileReader reader = new FileReader(file);
|
|
||||||
BufferedReader buf = new BufferedReader(reader))
|
|
||||||
{
|
|
||||||
String line;
|
|
||||||
while ((line = buf.readLine()) != null)
|
|
||||||
{
|
|
||||||
line = line.trim();
|
|
||||||
if (line.length() > 0)
|
|
||||||
{
|
|
||||||
ret.add(line);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -25,7 +25,6 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.jetty.start.ConfigurationAssert;
|
|
||||||
import org.eclipse.jetty.start.Props.Prop;
|
import org.eclipse.jetty.start.Props.Prop;
|
||||||
import org.eclipse.jetty.start.TestEnv;
|
import org.eclipse.jetty.start.TestEnv;
|
||||||
import org.eclipse.jetty.start.UsageException;
|
import org.eclipse.jetty.start.UsageException;
|
||||||
|
@ -36,6 +35,7 @@ import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.contains;
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
import static org.hamcrest.Matchers.notNullValue;
|
import static org.hamcrest.Matchers.notNullValue;
|
||||||
|
@ -54,7 +54,7 @@ public class ConfigSourcesTest
|
||||||
actualList.add(source.getId());
|
actualList.add(source.getId());
|
||||||
}
|
}
|
||||||
List<String> expectedList = Arrays.asList(expectedOrder);
|
List<String> expectedList = Arrays.asList(expectedOrder);
|
||||||
ConfigurationAssert.assertOrdered("ConfigSources.id order", expectedList, actualList);
|
assertThat("ConfigSources.id order", actualList, contains(expectedList.toArray()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertDirOrder(ConfigSources sources, Path... expectedDirOrder) throws IOException
|
private void assertDirOrder(ConfigSources sources, Path... expectedDirOrder) throws IOException
|
||||||
|
@ -72,7 +72,7 @@ public class ConfigSourcesTest
|
||||||
{
|
{
|
||||||
expectedList.add(path.toRealPath().toString());
|
expectedList.add(path.toRealPath().toString());
|
||||||
}
|
}
|
||||||
ConfigurationAssert.assertOrdered("ConfigSources.dir order", expectedList, actualList);
|
assertThat("ConfigSources.dir order", actualList, contains(expectedList.toArray()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertProperty(ConfigSources sources, String key, String expectedValue)
|
private void assertProperty(ConfigSources sources, String key, String expectedValue)
|
||||||
|
@ -124,7 +124,7 @@ public class ConfigSourcesTest
|
||||||
FS.ensureEmpty(base);
|
FS.ensureEmpty(base);
|
||||||
TestEnv.makeFile(base, "start.ini",
|
TestEnv.makeFile(base, "start.ini",
|
||||||
"jetty.http.host=127.0.0.1",
|
"jetty.http.host=127.0.0.1",
|
||||||
"--include-jetty-dir=" + common.toString());
|
"--include-jetty-dir=" + common);
|
||||||
|
|
||||||
ConfigSources sources = new ConfigSources();
|
ConfigSources sources = new ConfigSources();
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ public class ConfigSourcesTest
|
||||||
|
|
||||||
String[] cmdLine = new String[]{
|
String[] cmdLine = new String[]{
|
||||||
// property
|
// property
|
||||||
"my.common=" + common.toString(),
|
"my.common=" + common,
|
||||||
// reference via property
|
// reference via property
|
||||||
"--include-jetty-dir=${my.common}"
|
"--include-jetty-dir=${my.common}"
|
||||||
};
|
};
|
||||||
|
@ -208,7 +208,7 @@ public class ConfigSourcesTest
|
||||||
// Simple command line reference to include-jetty-dir via property (also on command line)
|
// Simple command line reference to include-jetty-dir via property (also on command line)
|
||||||
String[] cmdLine = new String[]{
|
String[] cmdLine = new String[]{
|
||||||
// property to 'opt' dir
|
// property to 'opt' dir
|
||||||
"my.opt=" + opt.toString(),
|
"my.opt=" + opt,
|
||||||
// reference via property prefix
|
// reference via property prefix
|
||||||
"--include-jetty-dir=" + dirRef
|
"--include-jetty-dir=" + dirRef
|
||||||
};
|
};
|
||||||
|
@ -256,8 +256,8 @@ public class ConfigSourcesTest
|
||||||
|
|
||||||
String[] cmdLine = new String[]{
|
String[] cmdLine = new String[]{
|
||||||
// property to 'opt' dir
|
// property to 'opt' dir
|
||||||
"my.opt=" + opt.toString(),
|
"my.opt=" + opt,
|
||||||
// property to commmon dir name
|
// property to common dir name
|
||||||
"my.dir=common",
|
"my.dir=common",
|
||||||
// reference via property prefix
|
// reference via property prefix
|
||||||
"--include-jetty-dir=" + dirRef
|
"--include-jetty-dir=" + dirRef
|
||||||
|
@ -293,7 +293,7 @@ public class ConfigSourcesTest
|
||||||
FS.ensureEmpty(base);
|
FS.ensureEmpty(base);
|
||||||
TestEnv.makeFile(base, "start.ini",
|
TestEnv.makeFile(base, "start.ini",
|
||||||
"jetty.http.host=127.0.0.1",
|
"jetty.http.host=127.0.0.1",
|
||||||
"--include-jetty-dir=" + common.toString());
|
"--include-jetty-dir=" + common);
|
||||||
|
|
||||||
ConfigSources sources = new ConfigSources();
|
ConfigSources sources = new ConfigSources();
|
||||||
|
|
||||||
|
@ -332,7 +332,7 @@ public class ConfigSourcesTest
|
||||||
FS.ensureEmpty(base);
|
FS.ensureEmpty(base);
|
||||||
TestEnv.makeFile(base, "start.ini",
|
TestEnv.makeFile(base, "start.ini",
|
||||||
"jetty.http.host=127.0.0.1",
|
"jetty.http.host=127.0.0.1",
|
||||||
"--include-jetty-dir=" + common.toString(),
|
"--include-jetty-dir=" + common,
|
||||||
"--include-jetty-dir=" + corp.toString());
|
"--include-jetty-dir=" + corp.toString());
|
||||||
|
|
||||||
ConfigSources sources = new ConfigSources();
|
ConfigSources sources = new ConfigSources();
|
||||||
|
@ -371,7 +371,7 @@ public class ConfigSourcesTest
|
||||||
Path common = testdir.getPathFile("common");
|
Path common = testdir.getPathFile("common");
|
||||||
FS.ensureEmpty(common);
|
FS.ensureEmpty(common);
|
||||||
TestEnv.makeFile(common, "start.ini",
|
TestEnv.makeFile(common, "start.ini",
|
||||||
"--include-jetty-dir=" + corp.toString(),
|
"--include-jetty-dir=" + corp,
|
||||||
"jetty.http.port=8080");
|
"jetty.http.port=8080");
|
||||||
|
|
||||||
// Create base
|
// Create base
|
||||||
|
@ -379,7 +379,7 @@ public class ConfigSourcesTest
|
||||||
FS.ensureEmpty(base);
|
FS.ensureEmpty(base);
|
||||||
TestEnv.makeFile(base, "start.ini",
|
TestEnv.makeFile(base, "start.ini",
|
||||||
"jetty.http.host=127.0.0.1",
|
"jetty.http.host=127.0.0.1",
|
||||||
"--include-jetty-dir=" + common.toString());
|
"--include-jetty-dir=" + common);
|
||||||
|
|
||||||
ConfigSources sources = new ConfigSources();
|
ConfigSources sources = new ConfigSources();
|
||||||
|
|
||||||
|
@ -417,7 +417,7 @@ public class ConfigSourcesTest
|
||||||
Path common = testdir.getPathFile("common");
|
Path common = testdir.getPathFile("common");
|
||||||
FS.ensureEmpty(common);
|
FS.ensureEmpty(common);
|
||||||
TestEnv.makeFile(common, "start.ini",
|
TestEnv.makeFile(common, "start.ini",
|
||||||
"my.corp=" + corp.toString(),
|
"my.corp=" + corp,
|
||||||
"--include-jetty-dir=${my.corp}",
|
"--include-jetty-dir=${my.corp}",
|
||||||
"jetty.http.port=8080");
|
"jetty.http.port=8080");
|
||||||
|
|
||||||
|
@ -426,7 +426,7 @@ public class ConfigSourcesTest
|
||||||
FS.ensureEmpty(base);
|
FS.ensureEmpty(base);
|
||||||
TestEnv.makeFile(base, "start.ini",
|
TestEnv.makeFile(base, "start.ini",
|
||||||
"jetty.http.host=127.0.0.1",
|
"jetty.http.host=127.0.0.1",
|
||||||
"my.common=" + common.toString(),
|
"my.common=" + common,
|
||||||
"--include-jetty-dir=${my.common}");
|
"--include-jetty-dir=${my.common}");
|
||||||
|
|
||||||
ConfigSources sources = new ConfigSources();
|
ConfigSources sources = new ConfigSources();
|
||||||
|
@ -473,7 +473,7 @@ public class ConfigSourcesTest
|
||||||
Path common = testdir.getPathFile("common");
|
Path common = testdir.getPathFile("common");
|
||||||
FS.ensureEmpty(common);
|
FS.ensureEmpty(common);
|
||||||
TestEnv.makeFile(common, "start.ini",
|
TestEnv.makeFile(common, "start.ini",
|
||||||
"--include-jetty-dir=" + corp.toString(),
|
"--include-jetty-dir=" + corp,
|
||||||
"jetty.http.port=8080");
|
"jetty.http.port=8080");
|
||||||
|
|
||||||
// Create base
|
// Create base
|
||||||
|
@ -481,13 +481,13 @@ public class ConfigSourcesTest
|
||||||
FS.ensureEmpty(base);
|
FS.ensureEmpty(base);
|
||||||
TestEnv.makeFile(base, "start.ini",
|
TestEnv.makeFile(base, "start.ini",
|
||||||
"jetty.http.host=127.0.0.1",
|
"jetty.http.host=127.0.0.1",
|
||||||
"--include-jetty-dir=" + common.toString());
|
"--include-jetty-dir=" + common);
|
||||||
|
|
||||||
ConfigSources sources = new ConfigSources();
|
ConfigSources sources = new ConfigSources();
|
||||||
|
|
||||||
String[] cmdLine = new String[]{
|
String[] cmdLine = new String[]{
|
||||||
// command line provided include-jetty-dir ref
|
// command line provided include-jetty-dir ref
|
||||||
"--include-jetty-dir=" + devops.toString()
|
"--include-jetty-dir=" + devops
|
||||||
};
|
};
|
||||||
sources.add(new CommandLineConfigSource(cmdLine));
|
sources.add(new CommandLineConfigSource(cmdLine));
|
||||||
sources.add(new JettyHomeConfigSource(home));
|
sources.add(new JettyHomeConfigSource(home));
|
||||||
|
@ -524,7 +524,7 @@ public class ConfigSourcesTest
|
||||||
Path common = testdir.getPathFile("common");
|
Path common = testdir.getPathFile("common");
|
||||||
FS.ensureEmpty(common);
|
FS.ensureEmpty(common);
|
||||||
TestEnv.makeFile(common, "start.ini",
|
TestEnv.makeFile(common, "start.ini",
|
||||||
"--include-jetty-dir=" + corp.toString(),
|
"--include-jetty-dir=" + corp,
|
||||||
"jetty.http.port=8080");
|
"jetty.http.port=8080");
|
||||||
|
|
||||||
// Create base
|
// Create base
|
||||||
|
@ -532,7 +532,7 @@ public class ConfigSourcesTest
|
||||||
FS.ensureEmpty(base);
|
FS.ensureEmpty(base);
|
||||||
TestEnv.makeFile(base, "start.ini",
|
TestEnv.makeFile(base, "start.ini",
|
||||||
"jetty.http.host=127.0.0.1",
|
"jetty.http.host=127.0.0.1",
|
||||||
"--include-jetty-dir=" + common.toString());
|
"--include-jetty-dir=" + common);
|
||||||
|
|
||||||
ConfigSources sources = new ConfigSources();
|
ConfigSources sources = new ConfigSources();
|
||||||
|
|
||||||
|
@ -581,14 +581,14 @@ public class ConfigSourcesTest
|
||||||
// standard property
|
// standard property
|
||||||
"jetty.http.port=8080",
|
"jetty.http.port=8080",
|
||||||
// reference to corp
|
// reference to corp
|
||||||
"--include-jetty-dir=" + corp.toString());
|
"--include-jetty-dir=" + corp);
|
||||||
|
|
||||||
// Create base
|
// Create base
|
||||||
Path base = testdir.getPathFile("base");
|
Path base = testdir.getPathFile("base");
|
||||||
FS.ensureEmpty(base);
|
FS.ensureEmpty(base);
|
||||||
TestEnv.makeFile(base, "start.ini",
|
TestEnv.makeFile(base, "start.ini",
|
||||||
"jetty.http.host=127.0.0.1",
|
"jetty.http.host=127.0.0.1",
|
||||||
"--include-jetty-dir=" + common.toString());
|
"--include-jetty-dir=" + common);
|
||||||
|
|
||||||
ConfigSources sources = new ConfigSources();
|
ConfigSources sources = new ConfigSources();
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,265 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// All rights reserved. This program and the accompanying materials
|
||||||
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
|
//
|
||||||
|
// The Eclipse Public License is available at
|
||||||
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
//
|
||||||
|
// The Apache License v2.0 is available at
|
||||||
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
|
//
|
||||||
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
|
// ========================================================================
|
||||||
|
//
|
||||||
|
|
||||||
|
package org.eclipse.jetty.start.usecases;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintStream;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Spliterator;
|
||||||
|
import java.util.Spliterators;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.StreamSupport;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.start.BaseHome;
|
||||||
|
import org.eclipse.jetty.start.Main;
|
||||||
|
import org.eclipse.jetty.start.Props;
|
||||||
|
import org.eclipse.jetty.start.StartArgs;
|
||||||
|
import org.eclipse.jetty.start.StartLog;
|
||||||
|
import org.eclipse.jetty.toolchain.test.FS;
|
||||||
|
import org.eclipse.jetty.toolchain.test.jupiter.WorkDir;
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
public abstract class AbstractUseCase
|
||||||
|
{
|
||||||
|
public WorkDir workDir;
|
||||||
|
|
||||||
|
protected Path homeDir;
|
||||||
|
protected Path baseDir;
|
||||||
|
|
||||||
|
@AfterEach
|
||||||
|
public void clearSystemProperties()
|
||||||
|
{
|
||||||
|
System.setProperty("jetty.home", "");
|
||||||
|
System.setProperty("jetty.base", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
public void setupTest() throws IOException
|
||||||
|
{
|
||||||
|
Path testdir = workDir.getEmptyPathDir();
|
||||||
|
|
||||||
|
// Create empty base directory for testcase to use
|
||||||
|
baseDir = testdir.resolve("test-base");
|
||||||
|
FS.ensureDirExists(baseDir);
|
||||||
|
|
||||||
|
// Create baseline jetty-home directory
|
||||||
|
homeDir = testdir.resolve("dist-home");
|
||||||
|
FS.ensureDirExists(homeDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setupStandardHomeDir() throws IOException
|
||||||
|
{
|
||||||
|
Path etc = homeDir.resolve("etc");
|
||||||
|
FS.ensureDirExists(etc);
|
||||||
|
FS.touch(etc.resolve("base.xml"));
|
||||||
|
FS.touch(etc.resolve("config.xml"));
|
||||||
|
FS.touch(etc.resolve("config-bar.xml"));
|
||||||
|
FS.touch(etc.resolve("config-foo.xml"));
|
||||||
|
FS.touch(etc.resolve("extra.xml"));
|
||||||
|
FS.touch(etc.resolve("main.xml"));
|
||||||
|
FS.touch(etc.resolve("optional.xml"));
|
||||||
|
|
||||||
|
Path lib = homeDir.resolve("lib");
|
||||||
|
FS.ensureDirExists(lib);
|
||||||
|
FS.touch(lib.resolve("base.jar"));
|
||||||
|
FS.touch(lib.resolve("main.jar"));
|
||||||
|
FS.touch(lib.resolve("optional.jar"));
|
||||||
|
FS.touch(lib.resolve("other.jar"));
|
||||||
|
Path libExtra = lib.resolve("extra");
|
||||||
|
FS.ensureDirExists(libExtra);
|
||||||
|
FS.touch(libExtra.resolve("extra0.jar"));
|
||||||
|
FS.touch(libExtra.resolve("extra1.jar"));
|
||||||
|
|
||||||
|
Path modules = homeDir.resolve("modules");
|
||||||
|
FS.ensureDirExists(modules);
|
||||||
|
|
||||||
|
Files.write(modules.resolve("base.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[optional]",
|
||||||
|
"optional",
|
||||||
|
"[lib]",
|
||||||
|
"lib/base.jar",
|
||||||
|
"[xml]",
|
||||||
|
"etc/base.xml"),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(modules.resolve("extra.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[depend]",
|
||||||
|
"main",
|
||||||
|
"[lib]",
|
||||||
|
"lib/extra/*.jar",
|
||||||
|
"[xml]",
|
||||||
|
"etc/extra.xml",
|
||||||
|
"[ini]",
|
||||||
|
"extra.prop=value0"),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(modules.resolve("main.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[depend]",
|
||||||
|
"base",
|
||||||
|
"[optional]",
|
||||||
|
"optional",
|
||||||
|
"[lib]",
|
||||||
|
"lib/main.jar",
|
||||||
|
"lib/other.jar",
|
||||||
|
"[xml]",
|
||||||
|
"etc/main.xml",
|
||||||
|
"[files]",
|
||||||
|
"maindir/",
|
||||||
|
"[ini]",
|
||||||
|
"main.prop=value0",
|
||||||
|
"[ini-template]",
|
||||||
|
"main.prop=valueT"),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(modules.resolve("optional.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[lib]",
|
||||||
|
"lib/optional.jar",
|
||||||
|
"[xml]",
|
||||||
|
"etc/optional.xml",
|
||||||
|
"[ini]",
|
||||||
|
"optional.prop=value0"),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ExecResults
|
||||||
|
{
|
||||||
|
public Exception exception;
|
||||||
|
public BaseHome baseHome;
|
||||||
|
public StartArgs startArgs;
|
||||||
|
public String output;
|
||||||
|
|
||||||
|
public List<String> getXmls()
|
||||||
|
{
|
||||||
|
return startArgs.getXmlFiles().stream()
|
||||||
|
.map(p -> baseHome.toShortForm(p))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getLibs()
|
||||||
|
{
|
||||||
|
return StreamSupport.stream(
|
||||||
|
Spliterators.spliteratorUnknownSize(startArgs.getClasspath().iterator(), Spliterator.ORDERED), false)
|
||||||
|
.map(f -> baseHome.toShortForm(f))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getProperties()
|
||||||
|
{
|
||||||
|
Props props = startArgs.getProperties();
|
||||||
|
|
||||||
|
Predicate<Props.Prop> propPredicate = (p) ->
|
||||||
|
{
|
||||||
|
String name = p.key;
|
||||||
|
return !("jetty.home".equals(name) ||
|
||||||
|
"jetty.base".equals(name) ||
|
||||||
|
"jetty.home.uri".equals(name) ||
|
||||||
|
"jetty.base.uri".equals(name) ||
|
||||||
|
"user.dir".equals(name) ||
|
||||||
|
p.source.equals(Props.ORIGIN_SYSPROP) ||
|
||||||
|
name.startsWith("runtime.feature.") ||
|
||||||
|
name.startsWith("java."));
|
||||||
|
};
|
||||||
|
|
||||||
|
return StreamSupport.stream(
|
||||||
|
Spliterators.spliteratorUnknownSize(props.iterator(), Spliterator.ORDERED), false)
|
||||||
|
.filter(propPredicate)
|
||||||
|
.map((prop) -> prop.key + "=" + props.expand(prop.value))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getDownloads()
|
||||||
|
{
|
||||||
|
return startArgs.getFiles().stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.filter(farg -> farg.uri != null)
|
||||||
|
.map(farg -> String.format("%s|%s", farg.uri, farg.location))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ExecResults exec(List<String> cmdline, boolean start)
|
||||||
|
{
|
||||||
|
List<String> execArgs = new ArrayList<>();
|
||||||
|
|
||||||
|
if (cmdline.stream().noneMatch((line -> line.startsWith("jetty.home="))))
|
||||||
|
{
|
||||||
|
execArgs.add("jetty.home=" + homeDir.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmdline.stream().noneMatch((line -> line.startsWith("jetty.base="))))
|
||||||
|
{
|
||||||
|
execArgs.add("jetty.base=" + baseDir.toString());
|
||||||
|
}
|
||||||
|
execArgs.add("--testing-mode");
|
||||||
|
// execArgs.add("--debug");
|
||||||
|
execArgs.addAll(cmdline);
|
||||||
|
|
||||||
|
ExecResults execResults = new ExecResults();
|
||||||
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
|
PrintStream originalStream = StartLog.setStream(new PrintStream(out));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Main main = new Main();
|
||||||
|
|
||||||
|
execResults.startArgs = main.processCommandLine(execArgs);
|
||||||
|
if (start)
|
||||||
|
{
|
||||||
|
main.start(execResults.startArgs);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
execResults.startArgs.getAllModules().checkEnabledModules();
|
||||||
|
}
|
||||||
|
execResults.baseHome = main.getBaseHome();
|
||||||
|
|
||||||
|
StartLog.setStream(originalStream);
|
||||||
|
execResults.output = out.toString(StandardCharsets.UTF_8.name());
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
execResults.exception = e;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
StartLog.setStream(originalStream);
|
||||||
|
}
|
||||||
|
return execResults;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void assertOutputContainsRegex(String output, String regexPattern)
|
||||||
|
{
|
||||||
|
Pattern pat = Pattern.compile(regexPattern);
|
||||||
|
Matcher mat = pat.matcher(output);
|
||||||
|
assertTrue(mat.find(), "Output [\n" + output + "]\nContains Regex Match: " + pat.pattern());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,93 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// All rights reserved. This program and the accompanying materials
|
||||||
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
|
//
|
||||||
|
// The Eclipse Public License is available at
|
||||||
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
//
|
||||||
|
// The Apache License v2.0 is available at
|
||||||
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
|
//
|
||||||
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
|
// ========================================================================
|
||||||
|
//
|
||||||
|
|
||||||
|
package org.eclipse.jetty.start.usecases;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.toolchain.test.FS;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.contains;
|
||||||
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
|
|
||||||
|
public class AgentPropertiesTest extends AbstractUseCase
|
||||||
|
{
|
||||||
|
@Test
|
||||||
|
public void testAgentPropertiesTest() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
FS.ensureDirExists(baseDir.resolve("lib"));
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules"));
|
||||||
|
FS.touch(baseDir.resolve("lib/agent-jdk-1.5.jar"));
|
||||||
|
FS.touch(baseDir.resolve("lib/agent-jdk-1.6.jar"));
|
||||||
|
FS.touch(baseDir.resolve("lib/agent-jdk-1.7.jar"));
|
||||||
|
FS.touch(baseDir.resolve("lib/agent-jdk-1.8.jar"));
|
||||||
|
Files.write(baseDir.resolve("modules/agent.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[depend]",
|
||||||
|
"main",
|
||||||
|
"[lib]",
|
||||||
|
"lib/agent-jdk-${java.vm.specification.version}.jar"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("start.ini"),
|
||||||
|
Collections.singletonList(
|
||||||
|
"--module=main,agent"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Collections.singletonList(
|
||||||
|
"java.vm.specification.version=1.7"
|
||||||
|
);
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Validate Resulting XMLs
|
||||||
|
List<String> expectedXmls = Arrays.asList(
|
||||||
|
"${jetty.home}/etc/base.xml",
|
||||||
|
"${jetty.home}/etc/main.xml"
|
||||||
|
);
|
||||||
|
List<String> actualXmls = results.getXmls();
|
||||||
|
assertThat("XML Resolution Order", actualXmls, contains(expectedXmls.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting LIBs
|
||||||
|
List<String> expectedLibs = Arrays.asList(
|
||||||
|
"${jetty.home}/lib/base.jar",
|
||||||
|
"${jetty.home}/lib/main.jar",
|
||||||
|
"${jetty.home}/lib/other.jar",
|
||||||
|
"${jetty.base}/lib/agent-jdk-1.7.jar"
|
||||||
|
);
|
||||||
|
List<String> actualLibs = results.getLibs();
|
||||||
|
assertThat("Libs", actualLibs, containsInAnyOrder(expectedLibs.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting Properties
|
||||||
|
Set<String> expectedProperties = new HashSet<>();
|
||||||
|
expectedProperties.add("main.prop=value0");
|
||||||
|
List<String> actualProperties = results.getProperties();
|
||||||
|
assertThat("Properties", actualProperties, containsInAnyOrder(expectedProperties.toArray()));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,452 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// All rights reserved. This program and the accompanying materials
|
||||||
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
|
//
|
||||||
|
// The Eclipse Public License is available at
|
||||||
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
//
|
||||||
|
// The Apache License v2.0 is available at
|
||||||
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
|
//
|
||||||
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
|
// ========================================================================
|
||||||
|
//
|
||||||
|
|
||||||
|
package org.eclipse.jetty.start.usecases;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.toolchain.test.FS;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.contains;
|
||||||
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
|
import static org.hamcrest.Matchers.containsString;
|
||||||
|
|
||||||
|
public class AlternatesTest extends AbstractUseCase
|
||||||
|
{
|
||||||
|
@Test
|
||||||
|
public void testAlternate0Test() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
FS.ensureDirExists(baseDir.resolve("etc"));
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules"));
|
||||||
|
FS.touch(baseDir.resolve("etc/d.xml"));
|
||||||
|
FS.touch(baseDir.resolve("etc/ndb.xml"));
|
||||||
|
Files.write(baseDir.resolve("modules/alternate.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[provides]",
|
||||||
|
"default",
|
||||||
|
"[ini]",
|
||||||
|
"default.option=alternate"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/default.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[xml]",
|
||||||
|
"etc/d.xml",
|
||||||
|
"[ini]",
|
||||||
|
"default.option=default"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/noDftOptionA.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[provides]",
|
||||||
|
"noDft",
|
||||||
|
"[optional]",
|
||||||
|
"default",
|
||||||
|
"[ini]",
|
||||||
|
"noDft.option=A"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/noDftOptionB.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[provides]",
|
||||||
|
"noDft",
|
||||||
|
"[depend]",
|
||||||
|
"default",
|
||||||
|
"[xml]",
|
||||||
|
"etc/ndb.xml",
|
||||||
|
"[ini]",
|
||||||
|
"noDft.option=B"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("start.ini"),
|
||||||
|
Collections.singletonList(
|
||||||
|
"--module=main"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Collections.singletonList(
|
||||||
|
"--module=noDftOptionA"
|
||||||
|
);
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Validate Resulting XMLs
|
||||||
|
List<String> expectedXmls = Arrays.asList(
|
||||||
|
"${jetty.home}/etc/base.xml",
|
||||||
|
"${jetty.home}/etc/main.xml"
|
||||||
|
);
|
||||||
|
List<String> actualXmls = results.getXmls();
|
||||||
|
assertThat("XML Resolution Order", actualXmls, contains(expectedXmls.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting LIBs
|
||||||
|
List<String> expectedLibs = Arrays.asList(
|
||||||
|
"${jetty.home}/lib/base.jar",
|
||||||
|
"${jetty.home}/lib/main.jar",
|
||||||
|
"${jetty.home}/lib/other.jar"
|
||||||
|
);
|
||||||
|
List<String> actualLibs = results.getLibs();
|
||||||
|
assertThat("Libs", actualLibs, containsInAnyOrder(expectedLibs.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting Properties
|
||||||
|
Set<String> expectedProperties = new HashSet<>();
|
||||||
|
expectedProperties.add("main.prop=value0");
|
||||||
|
expectedProperties.add("noDft.option=A");
|
||||||
|
List<String> actualProperties = results.getProperties();
|
||||||
|
assertThat("Properties", actualProperties, containsInAnyOrder(expectedProperties.toArray()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAlternate1Test() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
FS.ensureDirExists(baseDir.resolve("etc"));
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules"));
|
||||||
|
FS.touch(baseDir.resolve("etc/d.xml"));
|
||||||
|
FS.touch(baseDir.resolve("etc/ndb.xml"));
|
||||||
|
Files.write(baseDir.resolve("modules/alternate.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[provides]",
|
||||||
|
"default",
|
||||||
|
"[ini]",
|
||||||
|
"default.option=alternate"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/default.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[xml]",
|
||||||
|
"etc/d.xml",
|
||||||
|
"[ini]",
|
||||||
|
"default.option=default"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/noDftOptionA.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[provides]",
|
||||||
|
"noDft",
|
||||||
|
"[optional]",
|
||||||
|
"default",
|
||||||
|
"[ini]",
|
||||||
|
"noDft.option=A"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/noDftOptionB.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[provides]",
|
||||||
|
"noDft",
|
||||||
|
"[depend]",
|
||||||
|
"default",
|
||||||
|
"[xml]",
|
||||||
|
"etc/ndb.xml",
|
||||||
|
"[ini]",
|
||||||
|
"noDft.option=B"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("start.ini"),
|
||||||
|
Collections.singletonList(
|
||||||
|
"--module=main"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Collections.singletonList(
|
||||||
|
"--module=noDftOptionB"
|
||||||
|
);
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Validate Resulting XMLs
|
||||||
|
List<String> expectedXmls = Arrays.asList(
|
||||||
|
"${jetty.home}/etc/base.xml",
|
||||||
|
"${jetty.home}/etc/main.xml",
|
||||||
|
"${jetty.base}/etc/d.xml",
|
||||||
|
"${jetty.base}/etc/ndb.xml"
|
||||||
|
);
|
||||||
|
List<String> actualXmls = results.getXmls();
|
||||||
|
assertThat("XML Resolution Order", actualXmls, contains(expectedXmls.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting LIBs
|
||||||
|
List<String> expectedLibs = Arrays.asList(
|
||||||
|
"${jetty.home}/lib/base.jar",
|
||||||
|
"${jetty.home}/lib/main.jar",
|
||||||
|
"${jetty.home}/lib/other.jar"
|
||||||
|
);
|
||||||
|
List<String> actualLibs = results.getLibs();
|
||||||
|
assertThat("Libs", actualLibs, containsInAnyOrder(expectedLibs.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting Properties
|
||||||
|
Set<String> expectedProperties = new HashSet<>();
|
||||||
|
expectedProperties.add("main.prop=value0");
|
||||||
|
expectedProperties.add("default.option=default");
|
||||||
|
expectedProperties.add("noDft.option=B");
|
||||||
|
List<String> actualProperties = results.getProperties();
|
||||||
|
assertThat("Properties", actualProperties, containsInAnyOrder(expectedProperties.toArray()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAlternate2Test() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
FS.ensureDirExists(baseDir.resolve("etc"));
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules"));
|
||||||
|
FS.touch(baseDir.resolve("etc/d.xml"));
|
||||||
|
FS.touch(baseDir.resolve("etc/ndb.xml"));
|
||||||
|
Files.write(baseDir.resolve("modules/alternate.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[provides]",
|
||||||
|
"default",
|
||||||
|
"[ini]",
|
||||||
|
"default.option=alternate"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/default.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[xml]",
|
||||||
|
"etc/d.xml",
|
||||||
|
"[ini]",
|
||||||
|
"default.option=default"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/noDftOptionA.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[provides]",
|
||||||
|
"noDft",
|
||||||
|
"[optional]",
|
||||||
|
"default",
|
||||||
|
"[ini]",
|
||||||
|
"noDft.option=A"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/noDftOptionB.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[provides]",
|
||||||
|
"noDft",
|
||||||
|
"[depend]",
|
||||||
|
"default",
|
||||||
|
"[xml]",
|
||||||
|
"etc/ndb.xml",
|
||||||
|
"[ini]",
|
||||||
|
"noDft.option=B"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("start.ini"),
|
||||||
|
Collections.singletonList(
|
||||||
|
"--module=main"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Collections.singletonList(
|
||||||
|
"--module=alternate,noDftOptionB"
|
||||||
|
);
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Validate Resulting XMLs
|
||||||
|
List<String> expectedXmls = Arrays.asList(
|
||||||
|
"${jetty.home}/etc/base.xml",
|
||||||
|
"${jetty.home}/etc/main.xml",
|
||||||
|
"${jetty.base}/etc/ndb.xml"
|
||||||
|
);
|
||||||
|
List<String> actualXmls = results.getXmls();
|
||||||
|
assertThat("XML Resolution Order", actualXmls, contains(expectedXmls.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting LIBs
|
||||||
|
List<String> expectedLibs = Arrays.asList(
|
||||||
|
"${jetty.home}/lib/base.jar",
|
||||||
|
"${jetty.home}/lib/main.jar",
|
||||||
|
"${jetty.home}/lib/other.jar"
|
||||||
|
);
|
||||||
|
List<String> actualLibs = results.getLibs();
|
||||||
|
assertThat("Libs", actualLibs, containsInAnyOrder(expectedLibs.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting Properties
|
||||||
|
Set<String> expectedProperties = new HashSet<>();
|
||||||
|
expectedProperties.add("main.prop=value0");
|
||||||
|
expectedProperties.add("default.option=alternate");
|
||||||
|
expectedProperties.add("noDft.option=B");
|
||||||
|
List<String> actualProperties = results.getProperties();
|
||||||
|
assertThat("Properties", actualProperties, containsInAnyOrder(expectedProperties.toArray()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAlternate3Test() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
FS.ensureDirExists(baseDir.resolve("etc"));
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules"));
|
||||||
|
FS.touch(baseDir.resolve("etc/d.xml"));
|
||||||
|
FS.touch(baseDir.resolve("etc/ndb.xml"));
|
||||||
|
Files.write(baseDir.resolve("modules/alternate.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[provides]",
|
||||||
|
"default",
|
||||||
|
"[ini]",
|
||||||
|
"default.option=alternate"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/default.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[xml]",
|
||||||
|
"etc/d.xml",
|
||||||
|
"[ini]",
|
||||||
|
"default.option=default"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/noDftOptionA.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[provides]",
|
||||||
|
"noDft",
|
||||||
|
"[optional]",
|
||||||
|
"default",
|
||||||
|
"[ini]",
|
||||||
|
"noDft.option=A"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/noDftOptionB.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[provides]",
|
||||||
|
"noDft",
|
||||||
|
"[depend]",
|
||||||
|
"default",
|
||||||
|
"[xml]",
|
||||||
|
"etc/ndb.xml",
|
||||||
|
"[ini]",
|
||||||
|
"noDft.option=B"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("start.ini"),
|
||||||
|
Collections.singletonList(
|
||||||
|
"--module=main"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Collections.singletonList(
|
||||||
|
"--module=alternate,default"
|
||||||
|
);
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Check Exceptions
|
||||||
|
assertThat(results.exception.toString(), containsString("UsageException"));
|
||||||
|
assertThat(results.exception.toString(), containsString("default, which is already provided by alternate"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAlternate4Test() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
FS.ensureDirExists(baseDir.resolve("etc"));
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules"));
|
||||||
|
FS.touch(baseDir.resolve("etc/d.xml"));
|
||||||
|
FS.touch(baseDir.resolve("etc/ndb.xml"));
|
||||||
|
Files.write(baseDir.resolve("modules/alternate.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[provides]",
|
||||||
|
"default",
|
||||||
|
"[ini]",
|
||||||
|
"default.option=alternate"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/default.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[xml]",
|
||||||
|
"etc/d.xml",
|
||||||
|
"[ini]",
|
||||||
|
"default.option=default"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/noDftOptionA.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[provides]",
|
||||||
|
"noDft",
|
||||||
|
"[optional]",
|
||||||
|
"default",
|
||||||
|
"[ini]",
|
||||||
|
"noDft.option=A"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/noDftOptionB.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[provides]",
|
||||||
|
"noDft",
|
||||||
|
"[depend]",
|
||||||
|
"default",
|
||||||
|
"[xml]",
|
||||||
|
"etc/ndb.xml",
|
||||||
|
"[ini]",
|
||||||
|
"noDft.option=B"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("start.ini"),
|
||||||
|
Collections.singletonList(
|
||||||
|
"--module=main"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// === Prepare Jetty Base using Main
|
||||||
|
List<String> prepareArgs = Arrays.asList(
|
||||||
|
"--testing-mode",
|
||||||
|
"--add-to-start=noDftOptionB"
|
||||||
|
);
|
||||||
|
exec(prepareArgs, true);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Collections.singletonList(
|
||||||
|
"--module=alternate"
|
||||||
|
);
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Validate Resulting XMLs
|
||||||
|
List<String> expectedXmls = Arrays.asList(
|
||||||
|
"${jetty.home}/etc/base.xml",
|
||||||
|
"${jetty.home}/etc/main.xml",
|
||||||
|
"${jetty.base}/etc/ndb.xml"
|
||||||
|
);
|
||||||
|
List<String> actualXmls = results.getXmls();
|
||||||
|
assertThat("XML Resolution Order", actualXmls, contains(expectedXmls.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting LIBs
|
||||||
|
List<String> expectedLibs = Arrays.asList(
|
||||||
|
"${jetty.home}/lib/base.jar",
|
||||||
|
"${jetty.home}/lib/main.jar",
|
||||||
|
"${jetty.home}/lib/other.jar"
|
||||||
|
);
|
||||||
|
List<String> actualLibs = results.getLibs();
|
||||||
|
assertThat("Libs", actualLibs, containsInAnyOrder(expectedLibs.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting Properties
|
||||||
|
Set<String> expectedProperties = new HashSet<>();
|
||||||
|
expectedProperties.add("main.prop=value0");
|
||||||
|
expectedProperties.add("default.option=alternate");
|
||||||
|
expectedProperties.add("noDft.option=B");
|
||||||
|
List<String> actualProperties = results.getProperties();
|
||||||
|
assertThat("Properties", actualProperties, containsInAnyOrder(expectedProperties.toArray()));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,90 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// All rights reserved. This program and the accompanying materials
|
||||||
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
|
//
|
||||||
|
// The Eclipse Public License is available at
|
||||||
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
//
|
||||||
|
// The Apache License v2.0 is available at
|
||||||
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
|
//
|
||||||
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
|
// ========================================================================
|
||||||
|
//
|
||||||
|
|
||||||
|
package org.eclipse.jetty.start.usecases;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.toolchain.test.PathAssert;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.contains;
|
||||||
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
|
|
||||||
|
public class BarebonesAddToStartTest extends AbstractUseCase
|
||||||
|
{
|
||||||
|
@Test
|
||||||
|
public void testBarebonesAddToStartTest() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
Files.write(baseDir.resolve("start.ini"),
|
||||||
|
Collections.singletonList(
|
||||||
|
"--module=main"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// === Prepare Jetty Base using Main
|
||||||
|
List<String> prepareArgs = Arrays.asList(
|
||||||
|
"--testing-mode",
|
||||||
|
"--add-to-start=optional"
|
||||||
|
);
|
||||||
|
exec(prepareArgs, true);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Collections.emptyList();
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Validate Resulting XMLs
|
||||||
|
List<String> expectedXmls = Arrays.asList(
|
||||||
|
"${jetty.home}/etc/optional.xml",
|
||||||
|
"${jetty.home}/etc/base.xml",
|
||||||
|
"${jetty.home}/etc/main.xml"
|
||||||
|
);
|
||||||
|
List<String> actualXmls = results.getXmls();
|
||||||
|
assertThat("XML Resolution Order", actualXmls, contains(expectedXmls.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting LIBs
|
||||||
|
List<String> expectedLibs = Arrays.asList(
|
||||||
|
"${jetty.home}/lib/base.jar",
|
||||||
|
"${jetty.home}/lib/main.jar",
|
||||||
|
"${jetty.home}/lib/other.jar",
|
||||||
|
"${jetty.home}/lib/optional.jar"
|
||||||
|
);
|
||||||
|
List<String> actualLibs = results.getLibs();
|
||||||
|
assertThat("Libs", actualLibs, containsInAnyOrder(expectedLibs.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting Properties
|
||||||
|
Set<String> expectedProperties = new HashSet<>();
|
||||||
|
expectedProperties.add("main.prop=value0");
|
||||||
|
expectedProperties.add("optional.prop=value0");
|
||||||
|
List<String> actualProperties = results.getProperties();
|
||||||
|
assertThat("Properties", actualProperties, containsInAnyOrder(expectedProperties.toArray()));
|
||||||
|
|
||||||
|
// === Validate Specific Jetty Base Files/Dirs Exist
|
||||||
|
PathAssert.assertDirExists("Required Directory: maindir/", results.baseHome.getPath("maindir/"));
|
||||||
|
PathAssert.assertFileExists("Required File: start.ini", results.baseHome.getPath("start.ini"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,92 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// All rights reserved. This program and the accompanying materials
|
||||||
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
|
//
|
||||||
|
// The Eclipse Public License is available at
|
||||||
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
//
|
||||||
|
// The Apache License v2.0 is available at
|
||||||
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
|
//
|
||||||
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
|
// ========================================================================
|
||||||
|
//
|
||||||
|
|
||||||
|
package org.eclipse.jetty.start.usecases;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.toolchain.test.PathAssert;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.contains;
|
||||||
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
|
|
||||||
|
public class BarebonesAddToStartdTest extends AbstractUseCase
|
||||||
|
{
|
||||||
|
@Test
|
||||||
|
public void testBarebonesAddToStartdTest() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
Files.write(baseDir.resolve("start.ini"),
|
||||||
|
Collections.singletonList(
|
||||||
|
"--module=main"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// === Prepare Jetty Base using Main
|
||||||
|
List<String> prepareArgs = Arrays.asList(
|
||||||
|
"--testing-mode",
|
||||||
|
"--create-startd",
|
||||||
|
"--add-to-start=optional"
|
||||||
|
);
|
||||||
|
exec(prepareArgs, true);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Collections.emptyList();
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Validate Resulting XMLs
|
||||||
|
List<String> expectedXmls = Arrays.asList(
|
||||||
|
"${jetty.home}/etc/optional.xml",
|
||||||
|
"${jetty.home}/etc/base.xml",
|
||||||
|
"${jetty.home}/etc/main.xml"
|
||||||
|
);
|
||||||
|
List<String> actualXmls = results.getXmls();
|
||||||
|
assertThat("XML Resolution Order", actualXmls, contains(expectedXmls.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting LIBs
|
||||||
|
List<String> expectedLibs = Arrays.asList(
|
||||||
|
"${jetty.home}/lib/base.jar",
|
||||||
|
"${jetty.home}/lib/main.jar",
|
||||||
|
"${jetty.home}/lib/other.jar",
|
||||||
|
"${jetty.home}/lib/optional.jar"
|
||||||
|
);
|
||||||
|
List<String> actualLibs = results.getLibs();
|
||||||
|
assertThat("Libs", actualLibs, containsInAnyOrder(expectedLibs.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting Properties
|
||||||
|
Set<String> expectedProperties = new HashSet<>();
|
||||||
|
expectedProperties.add("main.prop=value0");
|
||||||
|
expectedProperties.add("optional.prop=value0");
|
||||||
|
List<String> actualProperties = results.getProperties();
|
||||||
|
assertThat("Properties", actualProperties, containsInAnyOrder(expectedProperties.toArray()));
|
||||||
|
|
||||||
|
// === Validate Specific Jetty Base Files/Dirs Exist
|
||||||
|
PathAssert.assertDirExists("Required Directory: maindir/", results.baseHome.getPath("maindir/"));
|
||||||
|
PathAssert.assertFileExists("Required File: start.d/start.ini", results.baseHome.getPath("start.d/start.ini"));
|
||||||
|
PathAssert.assertFileExists("Required File: start.d/optional.ini", results.baseHome.getPath("start.d/optional.ini"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// All rights reserved. This program and the accompanying materials
|
||||||
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
|
//
|
||||||
|
// The Eclipse Public License is available at
|
||||||
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
//
|
||||||
|
// The Apache License v2.0 is available at
|
||||||
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
|
//
|
||||||
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
|
// ========================================================================
|
||||||
|
//
|
||||||
|
|
||||||
|
package org.eclipse.jetty.start.usecases;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.containsString;
|
||||||
|
|
||||||
|
public class BarebonesAddUnknownTest extends AbstractUseCase
|
||||||
|
{
|
||||||
|
@Test
|
||||||
|
public void testBarebonesAddUnknownTest() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
Files.write(baseDir.resolve("start.ini"),
|
||||||
|
Collections.singletonList(
|
||||||
|
"--module=main"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// === Prepare Jetty Base using Main
|
||||||
|
List<String> prepareArgs = Arrays.asList(
|
||||||
|
"--testing-mode",
|
||||||
|
"--create-startd",
|
||||||
|
"--add-to-start=unknown"
|
||||||
|
);
|
||||||
|
ExecResults prepareResults = exec(prepareArgs, true);
|
||||||
|
|
||||||
|
// === Check Exceptions
|
||||||
|
assertThat(prepareResults.exception.toString(), containsString("UsageException"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,90 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// All rights reserved. This program and the accompanying materials
|
||||||
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
|
//
|
||||||
|
// The Eclipse Public License is available at
|
||||||
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
//
|
||||||
|
// The Apache License v2.0 is available at
|
||||||
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
|
//
|
||||||
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
|
// ========================================================================
|
||||||
|
//
|
||||||
|
|
||||||
|
package org.eclipse.jetty.start.usecases;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.toolchain.test.PathAssert;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.contains;
|
||||||
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
|
|
||||||
|
public class BarebonesAlreadyEnabledTest extends AbstractUseCase
|
||||||
|
{
|
||||||
|
@Test
|
||||||
|
public void testBarebonesAlreadyEnabledTest() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
Files.write(baseDir.resolve("start.ini"),
|
||||||
|
Collections.singletonList(
|
||||||
|
"--module=main"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// === Prepare Jetty Base using Main
|
||||||
|
List<String> prepareArgs = Arrays.asList(
|
||||||
|
"--testing-mode",
|
||||||
|
"--add-to-start=main"
|
||||||
|
);
|
||||||
|
ExecResults prepareResults = exec(prepareArgs, true);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Collections.emptyList();
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Validate Resulting XMLs
|
||||||
|
List<String> expectedXmls = Arrays.asList(
|
||||||
|
"${jetty.home}/etc/base.xml",
|
||||||
|
"${jetty.home}/etc/main.xml"
|
||||||
|
);
|
||||||
|
List<String> actualXmls = results.getXmls();
|
||||||
|
assertThat("XML Resolution Order", actualXmls, contains(expectedXmls.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting LIBs
|
||||||
|
List<String> expectedLibs = Arrays.asList(
|
||||||
|
"${jetty.home}/lib/base.jar",
|
||||||
|
"${jetty.home}/lib/main.jar",
|
||||||
|
"${jetty.home}/lib/other.jar"
|
||||||
|
);
|
||||||
|
List<String> actualLibs = results.getLibs();
|
||||||
|
assertThat("Libs", actualLibs, containsInAnyOrder(expectedLibs.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting Properties
|
||||||
|
Set<String> expectedProperties = new HashSet<>();
|
||||||
|
expectedProperties.add("main.prop=value0");
|
||||||
|
List<String> actualProperties = results.getProperties();
|
||||||
|
assertThat("Properties", actualProperties, containsInAnyOrder(expectedProperties.toArray()));
|
||||||
|
|
||||||
|
// === Validate Specific Jetty Base Files/Dirs Exist
|
||||||
|
PathAssert.assertDirExists("Required Directory: maindir/", results.baseHome.getPath("maindir/"));
|
||||||
|
PathAssert.assertFileExists("Required File: start.ini", results.baseHome.getPath("start.ini"));
|
||||||
|
|
||||||
|
// === Validate Specific Lines Exist in Output
|
||||||
|
assertOutputContainsRegex(prepareResults.output, "INFO : main already enabled by \\[\\$\\{jetty.base}[\\\\/]start.ini\\]");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,75 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// All rights reserved. This program and the accompanying materials
|
||||||
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
|
//
|
||||||
|
// The Eclipse Public License is available at
|
||||||
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
//
|
||||||
|
// The Apache License v2.0 is available at
|
||||||
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
|
//
|
||||||
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
|
// ========================================================================
|
||||||
|
//
|
||||||
|
|
||||||
|
package org.eclipse.jetty.start.usecases;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.contains;
|
||||||
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
|
|
||||||
|
public class BarebonesTest extends AbstractUseCase
|
||||||
|
{
|
||||||
|
@Test
|
||||||
|
public void testBarebonesTest() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
Files.write(baseDir.resolve("start.ini"),
|
||||||
|
Arrays.asList(
|
||||||
|
"--module=main"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Collections.emptyList();
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Validate Resulting XMLs
|
||||||
|
List<String> expectedXmls = Arrays.asList(
|
||||||
|
"${jetty.home}/etc/base.xml",
|
||||||
|
"${jetty.home}/etc/main.xml"
|
||||||
|
);
|
||||||
|
List<String> actualXmls = results.getXmls();
|
||||||
|
assertThat("XML Resolution Order", actualXmls, contains(expectedXmls.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting LIBs
|
||||||
|
List<String> expectedLibs = Arrays.asList(
|
||||||
|
"${jetty.home}/lib/base.jar",
|
||||||
|
"${jetty.home}/lib/main.jar",
|
||||||
|
"${jetty.home}/lib/other.jar"
|
||||||
|
);
|
||||||
|
List<String> actualLibs = results.getLibs();
|
||||||
|
assertThat("Libs", actualLibs, containsInAnyOrder(expectedLibs.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting Properties
|
||||||
|
Set<String> expectedProperties = new HashSet<>();
|
||||||
|
expectedProperties.add("main.prop=value0");
|
||||||
|
List<String> actualProperties = results.getProperties();
|
||||||
|
assertThat("Properties", actualProperties, containsInAnyOrder(expectedProperties.toArray()));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,97 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// All rights reserved. This program and the accompanying materials
|
||||||
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
|
//
|
||||||
|
// The Eclipse Public License is available at
|
||||||
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
//
|
||||||
|
// The Apache License v2.0 is available at
|
||||||
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
|
//
|
||||||
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
|
// ========================================================================
|
||||||
|
//
|
||||||
|
|
||||||
|
package org.eclipse.jetty.start.usecases;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.toolchain.test.FS;
|
||||||
|
import org.eclipse.jetty.toolchain.test.PathAssert;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
|
|
||||||
|
public class BasehomeWithfilesTest extends AbstractUseCase
|
||||||
|
{
|
||||||
|
@Test
|
||||||
|
public void testBasehomeWithfilesTest() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules"));
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules/withfiles"));
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules/withfiles/four"));
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules/withfiles/four/sub"));
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules/withfiles/four/sub/dir"));
|
||||||
|
|
||||||
|
Files.write(baseDir.resolve("modules/withfiles.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[files]",
|
||||||
|
"basehome:modules/withfiles/test.txt|one/renamed.txt",
|
||||||
|
"basehome:modules/withfiles/test.txt|two/",
|
||||||
|
"three/",
|
||||||
|
"basehome:modules/withfiles/test.txt|three",
|
||||||
|
"basehome:modules/withfiles",
|
||||||
|
"basehome:modules/withfiles/four/|five/",
|
||||||
|
"six/",
|
||||||
|
"basehome:modules/withfiles/four/sub|six"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
FS.touch(baseDir.resolve("modules/withfiles/four/sub/dir/test.txt"));
|
||||||
|
FS.touch(baseDir.resolve("modules/withfiles/four/test.txt"));
|
||||||
|
FS.touch(baseDir.resolve("modules/withfiles/test.txt"));
|
||||||
|
|
||||||
|
// === Prepare Jetty Base using Main
|
||||||
|
List<String> prepareArgs = Arrays.asList(
|
||||||
|
"--testing-mode",
|
||||||
|
"--create-startd",
|
||||||
|
"--add-to-start=withfiles"
|
||||||
|
);
|
||||||
|
exec(prepareArgs, true);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Collections.emptyList();
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Validate Downloaded Files
|
||||||
|
List<String> expectedDownloads = Arrays.asList(
|
||||||
|
"basehome:modules/withfiles/test.txt|one/renamed.txt",
|
||||||
|
"basehome:modules/withfiles/test.txt|two/",
|
||||||
|
"basehome:modules/withfiles/test.txt|three",
|
||||||
|
"basehome:modules/withfiles|null",
|
||||||
|
"basehome:modules/withfiles/four/|five/",
|
||||||
|
"basehome:modules/withfiles/four/sub|six"
|
||||||
|
);
|
||||||
|
List<String> actualDownloads = results.getDownloads();
|
||||||
|
assertThat("Downloads", actualDownloads, containsInAnyOrder(expectedDownloads.toArray()));
|
||||||
|
|
||||||
|
// === Validate Specific Jetty Base Files/Dirs Exist
|
||||||
|
PathAssert.assertFileExists("Required File: test.txt", results.baseHome.getPath("test.txt"));
|
||||||
|
PathAssert.assertFileExists("Required File: one/renamed.txt", results.baseHome.getPath("one/renamed.txt"));
|
||||||
|
PathAssert.assertFileExists("Required File: two/test.txt", results.baseHome.getPath("two/test.txt"));
|
||||||
|
PathAssert.assertFileExists("Required File: three/test.txt", results.baseHome.getPath("three/test.txt"));
|
||||||
|
PathAssert.assertFileExists("Required File: four/sub/dir/test.txt", results.baseHome.getPath("four/sub/dir/test.txt"));
|
||||||
|
PathAssert.assertFileExists("Required File: five/sub/dir/test.txt", results.baseHome.getPath("five/sub/dir/test.txt"));
|
||||||
|
PathAssert.assertFileExists("Required File: six/sub/dir/test.txt", results.baseHome.getPath("six/sub/dir/test.txt"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,108 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// All rights reserved. This program and the accompanying materials
|
||||||
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
|
//
|
||||||
|
// The Eclipse Public License is available at
|
||||||
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
//
|
||||||
|
// The Apache License v2.0 is available at
|
||||||
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
|
//
|
||||||
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
|
// ========================================================================
|
||||||
|
//
|
||||||
|
|
||||||
|
package org.eclipse.jetty.start.usecases;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.contains;
|
||||||
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
|
public class BasicPropertiesTest extends AbstractUseCase
|
||||||
|
{
|
||||||
|
@Test
|
||||||
|
public void testBasicPropertiesTest() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
Files.write(baseDir.resolve("start.ini"),
|
||||||
|
Arrays.asList(
|
||||||
|
"--module=main",
|
||||||
|
"jetty.http.port=${port}"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Arrays.asList(
|
||||||
|
"other=value",
|
||||||
|
"port=9090",
|
||||||
|
"add+=beginning",
|
||||||
|
"add+=middle",
|
||||||
|
"add+=end",
|
||||||
|
"list+=,one",
|
||||||
|
"list+=,two",
|
||||||
|
"list+=,three",
|
||||||
|
"name?=value",
|
||||||
|
"name?=enoughAlready",
|
||||||
|
"name0=/",
|
||||||
|
"name1=${name0}foo",
|
||||||
|
"name2=${name1}/bar",
|
||||||
|
"-DSYSTEM=${name}",
|
||||||
|
"-DSYSTEM?=IGNORED",
|
||||||
|
"-DPRESET?=${SYSTEM}"
|
||||||
|
);
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Validate Resulting XMLs
|
||||||
|
List<String> expectedXmls = Arrays.asList(
|
||||||
|
"${jetty.home}/etc/base.xml",
|
||||||
|
"${jetty.home}/etc/main.xml"
|
||||||
|
);
|
||||||
|
List<String> actualXmls = results.getXmls();
|
||||||
|
assertThat("XML Resolution Order", actualXmls, contains(expectedXmls.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting LIBs
|
||||||
|
List<String> expectedLibs = Arrays.asList(
|
||||||
|
"${jetty.home}/lib/base.jar",
|
||||||
|
"${jetty.home}/lib/main.jar",
|
||||||
|
"${jetty.home}/lib/other.jar"
|
||||||
|
);
|
||||||
|
List<String> actualLibs = results.getLibs();
|
||||||
|
assertThat("Libs", actualLibs, containsInAnyOrder(expectedLibs.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting Properties
|
||||||
|
Set<String> expectedProperties = new HashSet<>();
|
||||||
|
expectedProperties.add("main.prop=value0");
|
||||||
|
expectedProperties.add("port=9090");
|
||||||
|
expectedProperties.add("other=value");
|
||||||
|
expectedProperties.add("jetty.http.port=9090");
|
||||||
|
expectedProperties.add("add=beginningmiddleend");
|
||||||
|
expectedProperties.add("list=one,two,three");
|
||||||
|
expectedProperties.add("name=value");
|
||||||
|
expectedProperties.add("name0=/");
|
||||||
|
expectedProperties.add("name1=/foo");
|
||||||
|
expectedProperties.add("name2=/foo/bar");
|
||||||
|
expectedProperties.add("SYSTEM=value");
|
||||||
|
expectedProperties.add("PRESET=value");
|
||||||
|
List<String> actualProperties = results.getProperties();
|
||||||
|
assertThat("Properties", actualProperties, containsInAnyOrder(expectedProperties.toArray()));
|
||||||
|
|
||||||
|
// === Validate System Properties
|
||||||
|
assertThat("System Property [SYSTEM]", System.getProperty("SYSTEM"), equalTo("value"));
|
||||||
|
assertThat("System Property [PRESET]", System.getProperty("PRESET"), equalTo("value"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,300 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// All rights reserved. This program and the accompanying materials
|
||||||
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
|
//
|
||||||
|
// The Eclipse Public License is available at
|
||||||
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
//
|
||||||
|
// The Apache License v2.0 is available at
|
||||||
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
|
//
|
||||||
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
|
// ========================================================================
|
||||||
|
//
|
||||||
|
|
||||||
|
package org.eclipse.jetty.start.usecases;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.start.Props;
|
||||||
|
import org.eclipse.jetty.toolchain.test.FS;
|
||||||
|
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||||
|
import org.eclipse.jetty.toolchain.test.PathAssert;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.contains;
|
||||||
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
|
import static org.hamcrest.Matchers.not;
|
||||||
|
import static org.hamcrest.Matchers.startsWith;
|
||||||
|
|
||||||
|
public class BasicTest extends AbstractUseCase
|
||||||
|
{
|
||||||
|
private void setupDistHome() throws IOException
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
Files.write(homeDir.resolve("start.ini"),
|
||||||
|
Collections.singletonList(
|
||||||
|
"--module=main"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBasicProcessing() throws Exception
|
||||||
|
{
|
||||||
|
setupDistHome();
|
||||||
|
|
||||||
|
Files.write(baseDir.resolve("start.ini"),
|
||||||
|
Collections.singletonList(
|
||||||
|
"--module=main"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = new ArrayList<>();
|
||||||
|
runArgs.add("--create-files");
|
||||||
|
ExecResults results = exec(runArgs, true);
|
||||||
|
|
||||||
|
// === Validate Resulting XMLs
|
||||||
|
List<String> expectedXmls = Arrays.asList(
|
||||||
|
"${jetty.home}/etc/base.xml",
|
||||||
|
"${jetty.home}/etc/main.xml"
|
||||||
|
);
|
||||||
|
List<String> actualXmls = results.getXmls();
|
||||||
|
assertThat("XML Resolution Order", actualXmls, contains(expectedXmls.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting LIBs
|
||||||
|
List<String> expectedLibs = Arrays.asList(
|
||||||
|
"${jetty.home}/lib/base.jar",
|
||||||
|
"${jetty.home}/lib/main.jar",
|
||||||
|
"${jetty.home}/lib/other.jar"
|
||||||
|
);
|
||||||
|
List<String> actualLibs = results.getLibs();
|
||||||
|
assertThat("Libs", actualLibs, containsInAnyOrder(expectedLibs.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting Properties
|
||||||
|
Set<String> expectedProperties = new HashSet<>();
|
||||||
|
expectedProperties.add("main.prop=value0");
|
||||||
|
List<String> actualProperties = results.getProperties();
|
||||||
|
assertThat("Properties", actualProperties, containsInAnyOrder(expectedProperties.toArray()));
|
||||||
|
|
||||||
|
// === Validate Specific Jetty Base Files/Dirs Exist
|
||||||
|
PathAssert.assertDirExists("Required Directory: maindir/", results.baseHome.getPath("maindir/"));
|
||||||
|
|
||||||
|
// === Validate home/base property uri values
|
||||||
|
Props props = results.startArgs.getProperties();
|
||||||
|
|
||||||
|
assertThat("Props(jetty.home)", props.getString("jetty.home"), is(results.baseHome.getHome()));
|
||||||
|
assertThat("Props(jetty.home)", props.getString("jetty.home"), is(not(startsWith("file:"))));
|
||||||
|
assertThat("Props(jetty.home.uri)", props.getString("jetty.home.uri") + "/", is(results.baseHome.getHomePath().toUri().toString()));
|
||||||
|
assertThat("Props(jetty.base)", props.getString("jetty.base"), is(results.baseHome.getBase()));
|
||||||
|
assertThat("Props(jetty.base)", props.getString("jetty.base"), is(not(startsWith("file:"))));
|
||||||
|
assertThat("Props(jetty.base.uri)", props.getString("jetty.base.uri") + "/", is(results.baseHome.getBasePath().toUri().toString()));
|
||||||
|
|
||||||
|
assertThat("System.getProperty(jetty.home)", System.getProperty("jetty.home"), is(results.baseHome.getHome()));
|
||||||
|
assertThat("System.getProperty(jetty.home)", System.getProperty("jetty.home"), is(not(startsWith("file:"))));
|
||||||
|
assertThat("System.getProperty(jetty.base)", System.getProperty("jetty.base"), is(results.baseHome.getBase()));
|
||||||
|
assertThat("System.getProperty(jetty.base)", System.getProperty("jetty.base"), is(not(startsWith("file:"))));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWithCommandLine() throws Exception
|
||||||
|
{
|
||||||
|
setupDistHome();
|
||||||
|
|
||||||
|
Files.write(baseDir.resolve("start.ini"),
|
||||||
|
Collections.singletonList(
|
||||||
|
"--module=main"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = new ArrayList<>();
|
||||||
|
runArgs.add("--create-files");
|
||||||
|
|
||||||
|
// JVM args
|
||||||
|
runArgs.add("--exec");
|
||||||
|
runArgs.add("-Xms1g");
|
||||||
|
runArgs.add("-Xmx1g");
|
||||||
|
|
||||||
|
// Arbitrary Libs
|
||||||
|
Path extraJar = MavenTestingUtils.getTestResourceFile("extra-libs/example.jar").toPath().toRealPath();
|
||||||
|
Path extraDir = MavenTestingUtils.getTestResourceDir("extra-resources").toPath().toRealPath();
|
||||||
|
|
||||||
|
assertThat("Extra Jar exists: " + extraJar, Files.exists(extraJar), is(true));
|
||||||
|
assertThat("Extra Dir exists: " + extraDir, Files.exists(extraDir), is(true));
|
||||||
|
|
||||||
|
String lib = "--lib=" + extraJar + File.pathSeparator + extraDir;
|
||||||
|
runArgs.add(lib);
|
||||||
|
|
||||||
|
// Arbitrary XMLs
|
||||||
|
runArgs.add("config.xml");
|
||||||
|
runArgs.add("config-foo.xml");
|
||||||
|
runArgs.add("config-bar.xml");
|
||||||
|
|
||||||
|
ExecResults results = exec(runArgs, true);
|
||||||
|
|
||||||
|
// === Validate Resulting XMLs
|
||||||
|
List<String> expectedXmls = Arrays.asList(
|
||||||
|
"${jetty.home}/etc/base.xml",
|
||||||
|
"${jetty.home}/etc/main.xml",
|
||||||
|
"${jetty.home}/etc/config.xml",
|
||||||
|
"${jetty.home}/etc/config-foo.xml",
|
||||||
|
"${jetty.home}/etc/config-bar.xml"
|
||||||
|
);
|
||||||
|
List<String> actualXmls = results.getXmls();
|
||||||
|
assertThat("XML Resolution Order", actualXmls, contains(expectedXmls.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting LIBs
|
||||||
|
List<String> expectedLibs = Arrays.asList(
|
||||||
|
extraJar.toString(),
|
||||||
|
extraDir.toString(),
|
||||||
|
"${jetty.home}/lib/base.jar",
|
||||||
|
"${jetty.home}/lib/main.jar",
|
||||||
|
"${jetty.home}/lib/other.jar"
|
||||||
|
);
|
||||||
|
List<String> actualLibs = results.getLibs();
|
||||||
|
assertThat("Libs", actualLibs, containsInAnyOrder(expectedLibs.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting Properties
|
||||||
|
Set<String> expectedProperties = new HashSet<>();
|
||||||
|
expectedProperties.add("main.prop=value0");
|
||||||
|
List<String> actualProperties = results.getProperties();
|
||||||
|
assertThat("Properties", actualProperties, containsInAnyOrder(expectedProperties.toArray()));
|
||||||
|
|
||||||
|
// === Validate Specific Jetty Base Files/Dirs Exist
|
||||||
|
PathAssert.assertDirExists("Required Directory: maindir/", results.baseHome.getPath("maindir/"));
|
||||||
|
|
||||||
|
// === Validate JVM args
|
||||||
|
List<String> expectedJvmArgs = Arrays.asList(
|
||||||
|
"-Xms1g",
|
||||||
|
"-Xmx1g"
|
||||||
|
);
|
||||||
|
List<String> actualJvmArgs = results.startArgs.getJvmArgs();
|
||||||
|
assertThat("JVM Args", actualJvmArgs, contains(expectedJvmArgs.toArray()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWithModulesFromCommandLine() throws Exception
|
||||||
|
{
|
||||||
|
setupDistHome();
|
||||||
|
|
||||||
|
Files.write(baseDir.resolve("start.ini"),
|
||||||
|
Collections.singletonList(
|
||||||
|
"--module=main"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = new ArrayList<>();
|
||||||
|
runArgs.add("--create-files");
|
||||||
|
runArgs.add("java.version=1.8.0_31");
|
||||||
|
|
||||||
|
// Modules
|
||||||
|
runArgs.add("--module=optional,extra");
|
||||||
|
|
||||||
|
ExecResults results = exec(runArgs, true);
|
||||||
|
|
||||||
|
// === Validate Resulting XMLs
|
||||||
|
List<String> expectedXmls = Arrays.asList(
|
||||||
|
"${jetty.home}/etc/optional.xml",
|
||||||
|
"${jetty.home}/etc/base.xml",
|
||||||
|
"${jetty.home}/etc/main.xml",
|
||||||
|
"${jetty.home}/etc/extra.xml"
|
||||||
|
);
|
||||||
|
List<String> actualXmls = results.getXmls();
|
||||||
|
assertThat("XML Resolution Order", actualXmls, contains(expectedXmls.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting LIBs
|
||||||
|
List<String> expectedLibs = Arrays.asList(
|
||||||
|
"${jetty.home}/lib/optional.jar",
|
||||||
|
"${jetty.home}/lib/base.jar",
|
||||||
|
"${jetty.home}/lib/main.jar",
|
||||||
|
"${jetty.home}/lib/other.jar",
|
||||||
|
"${jetty.home}/lib/extra/extra0.jar",
|
||||||
|
"${jetty.home}/lib/extra/extra1.jar"
|
||||||
|
);
|
||||||
|
List<String> actualLibs = results.getLibs();
|
||||||
|
assertThat("Libs", actualLibs, containsInAnyOrder(expectedLibs.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting Properties
|
||||||
|
Set<String> expectedProperties = new HashSet<>();
|
||||||
|
expectedProperties.add("extra.prop=value0");
|
||||||
|
expectedProperties.add("main.prop=value0");
|
||||||
|
expectedProperties.add("optional.prop=value0");
|
||||||
|
List<String> actualProperties = results.getProperties();
|
||||||
|
assertThat("Properties", actualProperties, containsInAnyOrder(expectedProperties.toArray()));
|
||||||
|
|
||||||
|
// === Validate Specific Jetty Base Files/Dirs Exist
|
||||||
|
PathAssert.assertDirExists("Required Directory: maindir/", results.baseHome.getPath("maindir/"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testHomeWithSpaces() throws Exception
|
||||||
|
{
|
||||||
|
homeDir = workDir.getPath().resolve("jetty home with spaces");
|
||||||
|
FS.ensureDirExists(homeDir);
|
||||||
|
|
||||||
|
setupDistHome();
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = new ArrayList<>();
|
||||||
|
runArgs.add("--module=main");
|
||||||
|
ExecResults results = exec(runArgs, true);
|
||||||
|
|
||||||
|
// === Validate Resulting XMLs
|
||||||
|
List<String> expectedXmls = Arrays.asList(
|
||||||
|
"${jetty.home}/etc/base.xml",
|
||||||
|
"${jetty.home}/etc/main.xml"
|
||||||
|
);
|
||||||
|
List<String> actualXmls = results.getXmls();
|
||||||
|
assertThat("XML Resolution Order", actualXmls, contains(expectedXmls.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting LIBs
|
||||||
|
List<String> expectedLibs = Arrays.asList(
|
||||||
|
"${jetty.home}/lib/base.jar",
|
||||||
|
"${jetty.home}/lib/main.jar",
|
||||||
|
"${jetty.home}/lib/other.jar"
|
||||||
|
);
|
||||||
|
List<String> actualLibs = results.getLibs();
|
||||||
|
assertThat("Libs", actualLibs, containsInAnyOrder(expectedLibs.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting Properties
|
||||||
|
Set<String> expectedProperties = new HashSet<>();
|
||||||
|
expectedProperties.add("main.prop=value0");
|
||||||
|
List<String> actualProperties = results.getProperties();
|
||||||
|
assertThat("Properties", actualProperties, containsInAnyOrder(expectedProperties.toArray()));
|
||||||
|
|
||||||
|
// === Validate home/base property uri values
|
||||||
|
Props props = results.startArgs.getProperties();
|
||||||
|
|
||||||
|
assertThat("Props(jetty.home)", props.getString("jetty.home"), is(results.baseHome.getHome()));
|
||||||
|
assertThat("Props(jetty.home)", props.getString("jetty.home"), is(not(startsWith("file:"))));
|
||||||
|
assertThat("Props(jetty.home.uri)", props.getString("jetty.home.uri") + "/", is(results.baseHome.getHomePath().toUri().toString()));
|
||||||
|
assertThat("Props(jetty.base)", props.getString("jetty.base"), is(results.baseHome.getBase()));
|
||||||
|
assertThat("Props(jetty.base)", props.getString("jetty.base"), is(not(startsWith("file:"))));
|
||||||
|
assertThat("Props(jetty.base.uri)", props.getString("jetty.base.uri") + "/", is(results.baseHome.getBasePath().toUri().toString()));
|
||||||
|
|
||||||
|
assertThat("System.getProperty(jetty.home)", System.getProperty("jetty.home"), is(results.baseHome.getHome()));
|
||||||
|
assertThat("System.getProperty(jetty.home)", System.getProperty("jetty.home"), is(not(startsWith("file:"))));
|
||||||
|
assertThat("System.getProperty(jetty.base)", System.getProperty("jetty.base"), is(results.baseHome.getBase()));
|
||||||
|
assertThat("System.getProperty(jetty.base)", System.getProperty("jetty.base"), is(not(startsWith("file:"))));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,102 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// All rights reserved. This program and the accompanying materials
|
||||||
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
|
//
|
||||||
|
// The Eclipse Public License is available at
|
||||||
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
//
|
||||||
|
// The Apache License v2.0 is available at
|
||||||
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
|
//
|
||||||
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
|
// ========================================================================
|
||||||
|
//
|
||||||
|
|
||||||
|
package org.eclipse.jetty.start.usecases;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.toolchain.test.FS;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.contains;
|
||||||
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
|
|
||||||
|
public class DatabaseTest extends AbstractUseCase
|
||||||
|
{
|
||||||
|
@Test
|
||||||
|
public void testDatabaseTest() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
FS.ensureDirExists(baseDir.resolve("etc"));
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules"));
|
||||||
|
FS.ensureDirExists(baseDir.resolve("lib"));
|
||||||
|
FS.ensureDirExists(baseDir.resolve("lib/db"));
|
||||||
|
Files.write(baseDir.resolve("etc/db.xml"),
|
||||||
|
Collections.singletonList(
|
||||||
|
"<!-- build up org.eclipse.jetty.plus.jndi.Resource here -->"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
FS.touch(baseDir.resolve("lib/db/bonecp.jar"));
|
||||||
|
FS.touch(baseDir.resolve("lib/db/mysql-driver.jar"));
|
||||||
|
Files.write(baseDir.resolve("modules/db.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[lib]",
|
||||||
|
"lib/db/*.jar",
|
||||||
|
"[xml]",
|
||||||
|
"etc/db.xml"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("start.ini"),
|
||||||
|
Arrays.asList(
|
||||||
|
"--module=main,db",
|
||||||
|
"mysql.user=frank",
|
||||||
|
"mysql.pass=secret"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Collections.emptyList();
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Validate Resulting XMLs
|
||||||
|
List<String> expectedXmls = Arrays.asList(
|
||||||
|
"${jetty.home}/etc/base.xml",
|
||||||
|
"${jetty.home}/etc/main.xml",
|
||||||
|
"${jetty.base}/etc/db.xml"
|
||||||
|
);
|
||||||
|
List<String> actualXmls = results.getXmls();
|
||||||
|
assertThat("XML Resolution Order", actualXmls, contains(expectedXmls.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting LIBs
|
||||||
|
List<String> expectedLibs = Arrays.asList(
|
||||||
|
"${jetty.home}/lib/base.jar",
|
||||||
|
"${jetty.home}/lib/main.jar",
|
||||||
|
"${jetty.home}/lib/other.jar",
|
||||||
|
"${jetty.base}/lib/db/bonecp.jar",
|
||||||
|
"${jetty.base}/lib/db/mysql-driver.jar"
|
||||||
|
);
|
||||||
|
List<String> actualLibs = results.getLibs();
|
||||||
|
assertThat("Libs", actualLibs, containsInAnyOrder(expectedLibs.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting Properties
|
||||||
|
Set<String> expectedProperties = new HashSet<>();
|
||||||
|
expectedProperties.add("main.prop=value0");
|
||||||
|
expectedProperties.add("mysql.user=frank");
|
||||||
|
expectedProperties.add("mysql.pass=secret");
|
||||||
|
List<String> actualProperties = results.getProperties();
|
||||||
|
assertThat("Properties", actualProperties, containsInAnyOrder(expectedProperties.toArray()));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,165 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// All rights reserved. This program and the accompanying materials
|
||||||
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
|
//
|
||||||
|
// The Eclipse Public License is available at
|
||||||
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
//
|
||||||
|
// The Apache License v2.0 is available at
|
||||||
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
|
//
|
||||||
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
|
// ========================================================================
|
||||||
|
//
|
||||||
|
|
||||||
|
package org.eclipse.jetty.start.usecases;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.toolchain.test.FS;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.contains;
|
||||||
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
|
|
||||||
|
public class DynamicDependTest extends AbstractUseCase
|
||||||
|
{
|
||||||
|
@Test
|
||||||
|
public void testDynamic0Test() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules/impl"));
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules"));
|
||||||
|
Files.write(baseDir.resolve("modules/dynamic.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[depend]",
|
||||||
|
"main",
|
||||||
|
"impl/dynamic-${java.version}"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/impl/dynamic-1.7.0_31.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[ini]",
|
||||||
|
"dynamic=1.7.0_31-from-mod"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/impl/dynamic-1.8.0_05.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[ini]",
|
||||||
|
"dynamic=1.8.0_05_from_mod"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("start.ini"),
|
||||||
|
Collections.singletonList(
|
||||||
|
"--module=main"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Arrays.asList(
|
||||||
|
"java.version=1.7.0_31",
|
||||||
|
"--module=dynamic"
|
||||||
|
);
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Validate Resulting XMLs
|
||||||
|
List<String> expectedXmls = Arrays.asList(
|
||||||
|
"${jetty.home}/etc/base.xml",
|
||||||
|
"${jetty.home}/etc/main.xml"
|
||||||
|
);
|
||||||
|
List<String> actualXmls = results.getXmls();
|
||||||
|
assertThat("XML Resolution Order", actualXmls, contains(expectedXmls.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting LIBs
|
||||||
|
List<String> expectedLibs = Arrays.asList(
|
||||||
|
"${jetty.home}/lib/base.jar",
|
||||||
|
"${jetty.home}/lib/main.jar",
|
||||||
|
"${jetty.home}/lib/other.jar"
|
||||||
|
);
|
||||||
|
List<String> actualLibs = results.getLibs();
|
||||||
|
assertThat("Libs", actualLibs, containsInAnyOrder(expectedLibs.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting Properties
|
||||||
|
Set<String> expectedProperties = new HashSet<>();
|
||||||
|
expectedProperties.add("main.prop=value0");
|
||||||
|
expectedProperties.add("dynamic=1.7.0_31-from-mod");
|
||||||
|
List<String> actualProperties = results.getProperties();
|
||||||
|
assertThat("Properties", actualProperties, containsInAnyOrder(expectedProperties.toArray()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDynamic1Test() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules/impl"));
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules"));
|
||||||
|
Files.write(baseDir.resolve("modules/dynamic.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[depend]",
|
||||||
|
"main",
|
||||||
|
"impl/dynamic-${java.version}"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/impl/dynamic-1.7.0_31.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[ini]",
|
||||||
|
"dynamic=1.7.0_31-from-mod"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/impl/dynamic-1.8.0_05.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[ini]",
|
||||||
|
"dynamic=1.8.0_05_from_mod"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("start.ini"),
|
||||||
|
Collections.singletonList(
|
||||||
|
"--module=main"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Arrays.asList(
|
||||||
|
"java.version=1.8.0_05",
|
||||||
|
"--module=dynamic"
|
||||||
|
);
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Validate Resulting XMLs
|
||||||
|
List<String> expectedXmls = Arrays.asList(
|
||||||
|
"${jetty.home}/etc/base.xml",
|
||||||
|
"${jetty.home}/etc/main.xml"
|
||||||
|
);
|
||||||
|
List<String> actualXmls = results.getXmls();
|
||||||
|
assertThat("XML Resolution Order", actualXmls, contains(expectedXmls.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting LIBs
|
||||||
|
List<String> expectedLibs = Arrays.asList(
|
||||||
|
"${jetty.home}/lib/base.jar",
|
||||||
|
"${jetty.home}/lib/main.jar",
|
||||||
|
"${jetty.home}/lib/other.jar"
|
||||||
|
);
|
||||||
|
List<String> actualLibs = results.getLibs();
|
||||||
|
assertThat("Libs", actualLibs, containsInAnyOrder(expectedLibs.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting Properties
|
||||||
|
Set<String> expectedProperties = new HashSet<>();
|
||||||
|
expectedProperties.add("main.prop=value0");
|
||||||
|
expectedProperties.add("dynamic=1.8.0_05_from_mod");
|
||||||
|
List<String> actualProperties = results.getProperties();
|
||||||
|
assertThat("Properties", actualProperties, containsInAnyOrder(expectedProperties.toArray()));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,95 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// All rights reserved. This program and the accompanying materials
|
||||||
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
|
//
|
||||||
|
// The Eclipse Public License is available at
|
||||||
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
//
|
||||||
|
// The Apache License v2.0 is available at
|
||||||
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
|
//
|
||||||
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
|
// ========================================================================
|
||||||
|
//
|
||||||
|
|
||||||
|
package org.eclipse.jetty.start.usecases;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.toolchain.test.FS;
|
||||||
|
import org.eclipse.jetty.toolchain.test.PathAssert;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.contains;
|
||||||
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
|
|
||||||
|
public class EmptyAddToStartCreateStartdTest extends AbstractUseCase
|
||||||
|
{
|
||||||
|
@Test
|
||||||
|
public void testEmptyAddToStartCreateStartdTest() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
FS.touch(baseDir.resolve("unrelated.txt"));
|
||||||
|
|
||||||
|
// === Prepare Jetty Base using Main
|
||||||
|
List<String> prepareArgs = Arrays.asList(
|
||||||
|
"--testing-mode",
|
||||||
|
"--add-to-start=extra",
|
||||||
|
"--create-startd",
|
||||||
|
"--add-to-start=optional"
|
||||||
|
);
|
||||||
|
ExecResults prepareResults = exec(prepareArgs, true);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Collections.emptyList();
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Validate Resulting XMLs
|
||||||
|
List<String> expectedXmls = Arrays.asList(
|
||||||
|
"${jetty.home}/etc/optional.xml",
|
||||||
|
"${jetty.home}/etc/base.xml",
|
||||||
|
"${jetty.home}/etc/main.xml",
|
||||||
|
"${jetty.home}/etc/extra.xml"
|
||||||
|
);
|
||||||
|
List<String> actualXmls = results.getXmls();
|
||||||
|
assertThat("XML Resolution Order", actualXmls, contains(expectedXmls.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting LIBs
|
||||||
|
List<String> expectedLibs = Arrays.asList(
|
||||||
|
"${jetty.home}/lib/optional.jar",
|
||||||
|
"${jetty.home}/lib/base.jar",
|
||||||
|
"${jetty.home}/lib/main.jar",
|
||||||
|
"${jetty.home}/lib/other.jar",
|
||||||
|
"${jetty.home}/lib/extra/extra0.jar",
|
||||||
|
"${jetty.home}/lib/extra/extra1.jar"
|
||||||
|
);
|
||||||
|
List<String> actualLibs = results.getLibs();
|
||||||
|
assertThat("Libs", actualLibs, containsInAnyOrder(expectedLibs.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting Properties
|
||||||
|
Set<String> expectedProperties = new HashSet<>();
|
||||||
|
expectedProperties.add("extra.prop=value0");
|
||||||
|
expectedProperties.add("main.prop=value0");
|
||||||
|
expectedProperties.add("optional.prop=value0");
|
||||||
|
List<String> actualProperties = results.getProperties();
|
||||||
|
assertThat("Properties", actualProperties, containsInAnyOrder(expectedProperties.toArray()));
|
||||||
|
|
||||||
|
// === Validate Specific Jetty Base Files/Dirs Exist
|
||||||
|
PathAssert.assertDirExists("Required Directory: maindir/", results.baseHome.getPath("maindir/"));
|
||||||
|
PathAssert.assertFileExists("Required File: start.d/extra.ini", results.baseHome.getPath("start.d/extra.ini"));
|
||||||
|
PathAssert.assertFileExists("Required File: start.d/optional.ini", results.baseHome.getPath("start.d/optional.ini"));
|
||||||
|
|
||||||
|
// === Validate Specific Lines Exist in Output
|
||||||
|
assertOutputContainsRegex(prepareResults.output, "MKDIR : \\$\\{jetty.base\\}[\\\\/]maindir");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,89 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// All rights reserved. This program and the accompanying materials
|
||||||
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
|
//
|
||||||
|
// The Eclipse Public License is available at
|
||||||
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
//
|
||||||
|
// The Apache License v2.0 is available at
|
||||||
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
|
//
|
||||||
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
|
// ========================================================================
|
||||||
|
//
|
||||||
|
|
||||||
|
package org.eclipse.jetty.start.usecases;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.toolchain.test.FS;
|
||||||
|
import org.eclipse.jetty.toolchain.test.PathAssert;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.contains;
|
||||||
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
|
|
||||||
|
public class EmptyAddToStartTest extends AbstractUseCase
|
||||||
|
{
|
||||||
|
@Test
|
||||||
|
public void testEmptyAddToStartTest() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
FS.touch(baseDir.resolve("unrelated.txt"));
|
||||||
|
|
||||||
|
// === Prepare Jetty Base using Main
|
||||||
|
List<String> prepareArgs = Arrays.asList(
|
||||||
|
"--testing-mode",
|
||||||
|
"--add-to-start=extra,optional"
|
||||||
|
);
|
||||||
|
exec(prepareArgs, true);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Collections.emptyList();
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Validate Resulting XMLs
|
||||||
|
List<String> expectedXmls = Arrays.asList(
|
||||||
|
"${jetty.home}/etc/optional.xml",
|
||||||
|
"${jetty.home}/etc/base.xml",
|
||||||
|
"${jetty.home}/etc/main.xml",
|
||||||
|
"${jetty.home}/etc/extra.xml"
|
||||||
|
);
|
||||||
|
List<String> actualXmls = results.getXmls();
|
||||||
|
assertThat("XML Resolution Order", actualXmls, contains(expectedXmls.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting LIBs
|
||||||
|
List<String> expectedLibs = Arrays.asList(
|
||||||
|
"${jetty.home}/lib/optional.jar",
|
||||||
|
"${jetty.home}/lib/base.jar",
|
||||||
|
"${jetty.home}/lib/main.jar",
|
||||||
|
"${jetty.home}/lib/other.jar",
|
||||||
|
"${jetty.home}/lib/extra/extra0.jar",
|
||||||
|
"${jetty.home}/lib/extra/extra1.jar"
|
||||||
|
);
|
||||||
|
List<String> actualLibs = results.getLibs();
|
||||||
|
assertThat("Libs", actualLibs, containsInAnyOrder(expectedLibs.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting Properties
|
||||||
|
Set<String> expectedProperties = new HashSet<>();
|
||||||
|
expectedProperties.add("extra.prop=value0");
|
||||||
|
expectedProperties.add("main.prop=value0");
|
||||||
|
expectedProperties.add("optional.prop=value0");
|
||||||
|
List<String> actualProperties = results.getProperties();
|
||||||
|
assertThat("Properties", actualProperties, containsInAnyOrder(expectedProperties.toArray()));
|
||||||
|
|
||||||
|
// === Validate Specific Jetty Base Files/Dirs Exist
|
||||||
|
PathAssert.assertDirExists("Required Directory: maindir/", results.baseHome.getPath("maindir/"));
|
||||||
|
PathAssert.assertFileExists("Required File: start.ini", results.baseHome.getPath("start.ini"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,92 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// All rights reserved. This program and the accompanying materials
|
||||||
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
|
//
|
||||||
|
// The Eclipse Public License is available at
|
||||||
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
//
|
||||||
|
// The Apache License v2.0 is available at
|
||||||
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
|
//
|
||||||
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
|
// ========================================================================
|
||||||
|
//
|
||||||
|
|
||||||
|
package org.eclipse.jetty.start.usecases;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.toolchain.test.FS;
|
||||||
|
import org.eclipse.jetty.toolchain.test.PathAssert;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.contains;
|
||||||
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
|
|
||||||
|
public class EmptyCreateStartdTest extends AbstractUseCase
|
||||||
|
{
|
||||||
|
@Test
|
||||||
|
public void testEmptyCreateStartdTest() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
FS.touch(baseDir.resolve("unrelated.txt"));
|
||||||
|
|
||||||
|
// === Prepare Jetty Base using Main
|
||||||
|
List<String> prepareArgs = Arrays.asList(
|
||||||
|
"--testing-mode",
|
||||||
|
"--create-startd",
|
||||||
|
"--add-to-start=extra,optional"
|
||||||
|
);
|
||||||
|
exec(prepareArgs, true);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Collections.emptyList();
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Validate Resulting XMLs
|
||||||
|
List<String> expectedXmls = Arrays.asList(
|
||||||
|
"${jetty.home}/etc/optional.xml",
|
||||||
|
"${jetty.home}/etc/base.xml",
|
||||||
|
"${jetty.home}/etc/main.xml",
|
||||||
|
"${jetty.home}/etc/extra.xml"
|
||||||
|
);
|
||||||
|
List<String> actualXmls = results.getXmls();
|
||||||
|
assertThat("XML Resolution Order", actualXmls, contains(expectedXmls.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting LIBs
|
||||||
|
List<String> expectedLibs = Arrays.asList(
|
||||||
|
"${jetty.home}/lib/optional.jar",
|
||||||
|
"${jetty.home}/lib/base.jar",
|
||||||
|
"${jetty.home}/lib/main.jar",
|
||||||
|
"${jetty.home}/lib/other.jar",
|
||||||
|
"${jetty.home}/lib/extra/extra0.jar",
|
||||||
|
"${jetty.home}/lib/extra/extra1.jar"
|
||||||
|
);
|
||||||
|
List<String> actualLibs = results.getLibs();
|
||||||
|
assertThat("Libs", actualLibs, containsInAnyOrder(expectedLibs.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting Properties
|
||||||
|
Set<String> expectedProperties = new HashSet<>();
|
||||||
|
expectedProperties.add("extra.prop=value0");
|
||||||
|
expectedProperties.add("main.prop=value0");
|
||||||
|
expectedProperties.add("optional.prop=value0");
|
||||||
|
List<String> actualProperties = results.getProperties();
|
||||||
|
assertThat("Properties", actualProperties, containsInAnyOrder(expectedProperties.toArray()));
|
||||||
|
|
||||||
|
// === Validate Specific Jetty Base Files/Dirs Exist
|
||||||
|
PathAssert.assertDirExists("Required Directory: maindir/", results.baseHome.getPath("maindir/"));
|
||||||
|
PathAssert.assertDirExists("Required Directory: start.d/", results.baseHome.getPath("start.d/"));
|
||||||
|
PathAssert.assertFileExists("Required File: start.d/extra.ini", results.baseHome.getPath("start.d/extra.ini"));
|
||||||
|
PathAssert.assertFileExists("Required File: start.d/optional.ini", results.baseHome.getPath("start.d/optional.ini"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// All rights reserved. This program and the accompanying materials
|
||||||
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
|
//
|
||||||
|
// The Eclipse Public License is available at
|
||||||
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
//
|
||||||
|
// The Apache License v2.0 is available at
|
||||||
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
|
//
|
||||||
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
|
// ========================================================================
|
||||||
|
//
|
||||||
|
|
||||||
|
package org.eclipse.jetty.start.usecases;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.toolchain.test.FS;
|
||||||
|
import org.eclipse.jetty.toolchain.test.PathAssert;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
|
|
||||||
|
public class Files0Test extends AbstractUseCase
|
||||||
|
{
|
||||||
|
@Test
|
||||||
|
public void testFiles0Test() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules"));
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules/demo"));
|
||||||
|
Files.write(baseDir.resolve("modules/demo.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[files]",
|
||||||
|
"basehome:modules/demo/demo-config.xml|etc/demo-config.xml"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
FS.touch(baseDir.resolve("modules/demo/demo-config.xml"));
|
||||||
|
|
||||||
|
// === Prepare Jetty Base using Main
|
||||||
|
List<String> prepareArgs = Arrays.asList(
|
||||||
|
"--testing-mode",
|
||||||
|
"--create-startd",
|
||||||
|
"--add-to-start=demo"
|
||||||
|
);
|
||||||
|
ExecResults prepareResults = exec(prepareArgs, true);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Collections.emptyList();
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Validate Downloaded Files
|
||||||
|
List<String> expectedDownloads = Arrays.asList(
|
||||||
|
"basehome:modules/demo/demo-config.xml|etc/demo-config.xml"
|
||||||
|
);
|
||||||
|
List<String> actualDownloads = results.getDownloads();
|
||||||
|
assertThat("Downloads", actualDownloads, containsInAnyOrder(expectedDownloads.toArray()));
|
||||||
|
|
||||||
|
// === Validate Specific Jetty Base Files/Dirs Exist
|
||||||
|
PathAssert.assertFileExists("Required File: etc/demo-config.xml", results.baseHome.getPath("etc/demo-config.xml"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,173 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// All rights reserved. This program and the accompanying materials
|
||||||
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
|
//
|
||||||
|
// The Eclipse Public License is available at
|
||||||
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
//
|
||||||
|
// The Apache License v2.0 is available at
|
||||||
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
|
//
|
||||||
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
|
// ========================================================================
|
||||||
|
//
|
||||||
|
|
||||||
|
package org.eclipse.jetty.start.usecases;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.toolchain.test.FS;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.containsString;
|
||||||
|
|
||||||
|
public class LoopTest extends AbstractUseCase
|
||||||
|
{
|
||||||
|
@Test
|
||||||
|
public void testLoopTest() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules"));
|
||||||
|
|
||||||
|
// Create loop
|
||||||
|
// richard -> harry -> tom -> richard
|
||||||
|
|
||||||
|
Files.write(baseDir.resolve("modules/branch.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[provides]",
|
||||||
|
"branch"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/richard.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[depends]",
|
||||||
|
"harry"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/harry.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[depends]",
|
||||||
|
"tom"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/other.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[provides]",
|
||||||
|
"branch"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/root.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[depends]",
|
||||||
|
"branch"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/tom.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[depends]",
|
||||||
|
"richard"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("start.ini"),
|
||||||
|
Collections.singletonList(
|
||||||
|
"--module=root"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// === Prepare Jetty Base using Main
|
||||||
|
List<String> prepareArgs = Arrays.asList(
|
||||||
|
"--testing-mode",
|
||||||
|
"--create-startd",
|
||||||
|
"--add-to-start=tom"
|
||||||
|
);
|
||||||
|
exec(prepareArgs, true);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Collections.emptyList();
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Check Exceptions
|
||||||
|
assertThat(results.exception.toString(), containsString("CyclicException"));
|
||||||
|
assertThat(results.exception.toString(), containsString("cyclic"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDynamicLoopTest() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules/dynamic"));
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules"));
|
||||||
|
|
||||||
|
// Create loop
|
||||||
|
// richard -> dynamic/harry -> tom -> richard
|
||||||
|
|
||||||
|
Files.write(baseDir.resolve("modules/branch.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[provides]",
|
||||||
|
"branch"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/richard.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[depends]",
|
||||||
|
"dynamic/harry"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/dynamic/harry.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[depends]",
|
||||||
|
"tom"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/other.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[provides]",
|
||||||
|
"branch"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/root.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[depends]",
|
||||||
|
"branch"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/tom.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[depends]",
|
||||||
|
"richard"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("start.ini"),
|
||||||
|
Collections.singletonList(
|
||||||
|
"--module=root"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// === Prepare Jetty Base using Main
|
||||||
|
List<String> prepareArgs = Arrays.asList(
|
||||||
|
"--testing-mode",
|
||||||
|
"--create-startd",
|
||||||
|
"--add-to-start=tom"
|
||||||
|
);
|
||||||
|
exec(prepareArgs, true);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Collections.emptyList();
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Check Exceptions
|
||||||
|
assertThat(results.exception.toString(), containsString("CyclicException"));
|
||||||
|
assertThat(results.exception.toString(), containsString("cyclic"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,432 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// All rights reserved. This program and the accompanying materials
|
||||||
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
|
//
|
||||||
|
// The Eclipse Public License is available at
|
||||||
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
//
|
||||||
|
// The Apache License v2.0 is available at
|
||||||
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
|
//
|
||||||
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
|
// ========================================================================
|
||||||
|
//
|
||||||
|
|
||||||
|
package org.eclipse.jetty.start.usecases;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.toolchain.test.FS;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.contains;
|
||||||
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
|
import static org.hamcrest.Matchers.containsString;
|
||||||
|
|
||||||
|
public class OrderedTest extends AbstractUseCase
|
||||||
|
{
|
||||||
|
@Test
|
||||||
|
public void testOrdered0Test() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules"));
|
||||||
|
FS.ensureDirExists(baseDir.resolve("etc"));
|
||||||
|
FS.touch(baseDir.resolve("etc/alternateA.xml"));
|
||||||
|
FS.touch(baseDir.resolve("etc/alternateB.xml"));
|
||||||
|
FS.touch(baseDir.resolve("etc/dependent.xml"));
|
||||||
|
Files.write(baseDir.resolve("modules/alternateA.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[provides]",
|
||||||
|
"alternate",
|
||||||
|
"[xml]",
|
||||||
|
"etc/alternateA.xml"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/alternateB.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[provides]",
|
||||||
|
"alternate",
|
||||||
|
"[xml]",
|
||||||
|
"etc/alternateB.xml"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/convenience.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[depends]",
|
||||||
|
"replacement",
|
||||||
|
"something-else"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/dependent.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[depends]",
|
||||||
|
"alternate",
|
||||||
|
"[xml]",
|
||||||
|
"etc/dependent.xml"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/original.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[ini]",
|
||||||
|
"impl=original"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/replacement.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[provides]",
|
||||||
|
"original",
|
||||||
|
"[ini]",
|
||||||
|
"impl=replacement"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/something-else.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[depends]",
|
||||||
|
"original"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Collections.singletonList(
|
||||||
|
"--module=alternateA,dependent"
|
||||||
|
);
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Validate Resulting XMLs
|
||||||
|
List<String> expectedXmls = Arrays.asList(
|
||||||
|
"${jetty.base}/etc/alternateA.xml",
|
||||||
|
"${jetty.base}/etc/dependent.xml"
|
||||||
|
);
|
||||||
|
List<String> actualXmls = results.getXmls();
|
||||||
|
assertThat("XML Resolution Order", actualXmls, contains(expectedXmls.toArray()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOrdered1Test() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules"));
|
||||||
|
FS.ensureDirExists(baseDir.resolve("etc"));
|
||||||
|
FS.touch(baseDir.resolve("etc/alternateA.xml"));
|
||||||
|
FS.touch(baseDir.resolve("etc/alternateB.xml"));
|
||||||
|
FS.touch(baseDir.resolve("etc/dependent.xml"));
|
||||||
|
Files.write(baseDir.resolve("modules/alternateA.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[provides]",
|
||||||
|
"alternate",
|
||||||
|
"[xml]",
|
||||||
|
"etc/alternateA.xml"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/alternateB.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[provides]",
|
||||||
|
"alternate",
|
||||||
|
"[xml]",
|
||||||
|
"etc/alternateB.xml"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/convenience.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[depends]",
|
||||||
|
"replacement",
|
||||||
|
"something-else"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/dependent.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[depends]",
|
||||||
|
"alternate",
|
||||||
|
"[xml]",
|
||||||
|
"etc/dependent.xml"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/original.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[ini]",
|
||||||
|
"impl=original"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/replacement.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[provides]",
|
||||||
|
"original",
|
||||||
|
"[ini]",
|
||||||
|
"impl=replacement"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/something-else.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[depends]",
|
||||||
|
"original"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Collections.singletonList(
|
||||||
|
"--module=dependent,alternateA"
|
||||||
|
);
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Validate Resulting XMLs
|
||||||
|
List<String> expectedXmls = Arrays.asList(
|
||||||
|
"${jetty.base}/etc/alternateA.xml",
|
||||||
|
"${jetty.base}/etc/dependent.xml"
|
||||||
|
);
|
||||||
|
List<String> actualXmls = results.getXmls();
|
||||||
|
assertThat("XML Resolution Order", actualXmls, contains(expectedXmls.toArray()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOrdered2Test() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules"));
|
||||||
|
FS.ensureDirExists(baseDir.resolve("etc"));
|
||||||
|
FS.touch(baseDir.resolve("etc/alternateA.xml"));
|
||||||
|
FS.touch(baseDir.resolve("etc/alternateB.xml"));
|
||||||
|
FS.touch(baseDir.resolve("etc/dependent.xml"));
|
||||||
|
Files.write(baseDir.resolve("modules/alternateA.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[provides]",
|
||||||
|
"alternate",
|
||||||
|
"[xml]",
|
||||||
|
"etc/alternateA.xml"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/alternateB.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[provides]",
|
||||||
|
"alternate",
|
||||||
|
"[xml]",
|
||||||
|
"etc/alternateB.xml"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/convenience.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[depends]",
|
||||||
|
"replacement",
|
||||||
|
"something-else"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/dependent.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[depends]",
|
||||||
|
"alternate",
|
||||||
|
"[xml]",
|
||||||
|
"etc/dependent.xml"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/original.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[ini]",
|
||||||
|
"impl=original"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/replacement.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[provides]",
|
||||||
|
"original",
|
||||||
|
"[ini]",
|
||||||
|
"impl=replacement"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/something-else.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[depends]",
|
||||||
|
"original"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Collections.singletonList(
|
||||||
|
"--module=dependent"
|
||||||
|
);
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Check Exceptions
|
||||||
|
assertThat(results.exception.toString(), containsString("UsageException: Unsatisfied module dependencies"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOrderedDefaultTest() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules"));
|
||||||
|
FS.ensureDirExists(baseDir.resolve("etc"));
|
||||||
|
FS.touch(baseDir.resolve("etc/alternateA.xml"));
|
||||||
|
FS.touch(baseDir.resolve("etc/alternateB.xml"));
|
||||||
|
FS.touch(baseDir.resolve("etc/dependent.xml"));
|
||||||
|
Files.write(baseDir.resolve("modules/alternateA.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[provides]",
|
||||||
|
"alternate",
|
||||||
|
"[xml]",
|
||||||
|
"etc/alternateA.xml"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/alternateB.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[provides]",
|
||||||
|
"alternate",
|
||||||
|
"[xml]",
|
||||||
|
"etc/alternateB.xml"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/convenience.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[depends]",
|
||||||
|
"replacement",
|
||||||
|
"something-else"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/dependent.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[depends]",
|
||||||
|
"alternate",
|
||||||
|
"[xml]",
|
||||||
|
"etc/dependent.xml"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/original.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[ini]",
|
||||||
|
"impl=original"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/replacement.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[provides]",
|
||||||
|
"original",
|
||||||
|
"[ini]",
|
||||||
|
"impl=replacement"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/something-else.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[depends]",
|
||||||
|
"original"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Collections.singletonList(
|
||||||
|
"--module=main,convenience"
|
||||||
|
);
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Validate Resulting XMLs
|
||||||
|
List<String> expectedXmls = Arrays.asList(
|
||||||
|
"${jetty.home}/etc/base.xml",
|
||||||
|
"${jetty.home}/etc/main.xml"
|
||||||
|
);
|
||||||
|
List<String> actualXmls = results.getXmls();
|
||||||
|
assertThat("XML Resolution Order", actualXmls, contains(expectedXmls.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting LIBs
|
||||||
|
List<String> expectedLibs = Arrays.asList(
|
||||||
|
"${jetty.home}/lib/base.jar",
|
||||||
|
"${jetty.home}/lib/main.jar",
|
||||||
|
"${jetty.home}/lib/other.jar"
|
||||||
|
);
|
||||||
|
List<String> actualLibs = results.getLibs();
|
||||||
|
assertThat("Libs", actualLibs, containsInAnyOrder(expectedLibs.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting Properties
|
||||||
|
Set<String> expectedProperties = new HashSet<>();
|
||||||
|
expectedProperties.add("main.prop=value0");
|
||||||
|
expectedProperties.add("impl=replacement");
|
||||||
|
List<String> actualProperties = results.getProperties();
|
||||||
|
assertThat("Properties", actualProperties, containsInAnyOrder(expectedProperties.toArray()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOrderedProvided0Test() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules"));
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules/dynamic"));
|
||||||
|
FS.ensureDirExists(baseDir.resolve("etc"));
|
||||||
|
FS.touch(baseDir.resolve("etc/implA.xml"));
|
||||||
|
FS.touch(baseDir.resolve("etc/implB.xml"));
|
||||||
|
Files.write(baseDir.resolve("modules/abstractA.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[depend]",
|
||||||
|
"dynamic/${implA}",
|
||||||
|
"[ini]",
|
||||||
|
"implA=implA",
|
||||||
|
"[ini-template]",
|
||||||
|
"implA=implA"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/abstractB.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[depend]",
|
||||||
|
"dynamic/${implB}",
|
||||||
|
"[provide]",
|
||||||
|
"provided",
|
||||||
|
"[ini]",
|
||||||
|
"implB=implB",
|
||||||
|
"[ini-template]",
|
||||||
|
"implB=implB"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/dynamic/implA.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[depend]",
|
||||||
|
"provided",
|
||||||
|
"[xml]",
|
||||||
|
"etc/implA.xml"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/dynamic/implB.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[xml]",
|
||||||
|
"etc/implB.xml"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// === Prepare Jetty Base using Main
|
||||||
|
List<String> prepareArgs = Arrays.asList(
|
||||||
|
"--testing-mode",
|
||||||
|
"--create-startd",
|
||||||
|
"--add-to-start=abstractB,abstractA"
|
||||||
|
);
|
||||||
|
exec(prepareArgs, true);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Collections.emptyList();
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Validate Resulting XMLs
|
||||||
|
List<String> expectedXmls = Arrays.asList(
|
||||||
|
"${jetty.base}/etc/implB.xml",
|
||||||
|
"${jetty.base}/etc/implA.xml"
|
||||||
|
);
|
||||||
|
List<String> actualXmls = results.getXmls();
|
||||||
|
assertThat("XML Resolution Order", actualXmls, contains(expectedXmls.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting Properties
|
||||||
|
Set<String> expectedProperties = new HashSet<>();
|
||||||
|
expectedProperties.add("implA=implA");
|
||||||
|
expectedProperties.add("implB=implB");
|
||||||
|
List<String> actualProperties = results.getProperties();
|
||||||
|
assertThat("Properties", actualProperties, containsInAnyOrder(expectedProperties.toArray()));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,311 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// All rights reserved. This program and the accompanying materials
|
||||||
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
|
//
|
||||||
|
// The Eclipse Public License is available at
|
||||||
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
//
|
||||||
|
// The Apache License v2.0 is available at
|
||||||
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
|
//
|
||||||
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
|
// ========================================================================
|
||||||
|
//
|
||||||
|
|
||||||
|
package org.eclipse.jetty.start.usecases;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.toolchain.test.FS;
|
||||||
|
import org.eclipse.jetty.toolchain.test.PathAssert;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.contains;
|
||||||
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
|
|
||||||
|
public class ParameterizedTest extends AbstractUseCase
|
||||||
|
{
|
||||||
|
@Test
|
||||||
|
public void testParameterizedAddToStartTest() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
FS.ensureDirExists(baseDir.resolve("etc"));
|
||||||
|
FS.ensureDirExists(baseDir.resolve("start.d"));
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules"));
|
||||||
|
Files.write(baseDir.resolve("etc/commands.txt"),
|
||||||
|
Arrays.asList(
|
||||||
|
"name0=changed0",
|
||||||
|
"name1=changed1",
|
||||||
|
"--add-to-start=parameterized",
|
||||||
|
"# ignore this"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/parameterized.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[depend]",
|
||||||
|
"main",
|
||||||
|
"[ini]",
|
||||||
|
"name=value",
|
||||||
|
"name0?=default",
|
||||||
|
"name2?=two",
|
||||||
|
"[ini-template]",
|
||||||
|
"name0=value0",
|
||||||
|
"# name1=value1",
|
||||||
|
"# name2=too"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("start.d/tobeupdated.ini"),
|
||||||
|
Arrays.asList(
|
||||||
|
"#p=v",
|
||||||
|
"property=value",
|
||||||
|
"#comment",
|
||||||
|
"property0=value0",
|
||||||
|
"#comment",
|
||||||
|
"#property1=value1"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// === Prepare Jetty Base using Main
|
||||||
|
List<String> prepareArgs = Arrays.asList(
|
||||||
|
"--testing-mode",
|
||||||
|
"--create-startd",
|
||||||
|
"other=value",
|
||||||
|
"name=changed",
|
||||||
|
"name0=changed0",
|
||||||
|
"name1=changed1",
|
||||||
|
"--add-to-start=parameterized"
|
||||||
|
);
|
||||||
|
exec(prepareArgs, true);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Collections.emptyList();
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Validate Resulting XMLs
|
||||||
|
List<String> expectedXmls = Arrays.asList(
|
||||||
|
"${jetty.home}/etc/base.xml",
|
||||||
|
"${jetty.home}/etc/main.xml"
|
||||||
|
);
|
||||||
|
List<String> actualXmls = results.getXmls();
|
||||||
|
assertThat("XML Resolution Order", actualXmls, contains(expectedXmls.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting LIBs
|
||||||
|
List<String> expectedLibs = Arrays.asList(
|
||||||
|
"${jetty.home}/lib/base.jar",
|
||||||
|
"${jetty.home}/lib/main.jar",
|
||||||
|
"${jetty.home}/lib/other.jar"
|
||||||
|
);
|
||||||
|
List<String> actualLibs = results.getLibs();
|
||||||
|
assertThat("Libs", actualLibs, containsInAnyOrder(expectedLibs.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting Properties
|
||||||
|
Set<String> expectedProperties = new HashSet<>();
|
||||||
|
expectedProperties.add("main.prop=value0");
|
||||||
|
expectedProperties.add("name=value");
|
||||||
|
expectedProperties.add("name0=changed0");
|
||||||
|
expectedProperties.add("name1=changed1");
|
||||||
|
expectedProperties.add("name2=two");
|
||||||
|
expectedProperties.add("property=value");
|
||||||
|
expectedProperties.add("property0=value0");
|
||||||
|
List<String> actualProperties = results.getProperties();
|
||||||
|
assertThat("Properties", actualProperties, containsInAnyOrder(expectedProperties.toArray()));
|
||||||
|
|
||||||
|
// === Validate Specific Jetty Base Files/Dirs Exist
|
||||||
|
PathAssert.assertFileExists("Required File: start.d/parameterized.ini", results.baseHome.getPath("start.d/parameterized.ini"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testParameterizedCommandsTest() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
FS.ensureDirExists(baseDir.resolve("etc"));
|
||||||
|
FS.ensureDirExists(baseDir.resolve("start.d"));
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules"));
|
||||||
|
Files.write(baseDir.resolve("etc/commands.txt"),
|
||||||
|
Arrays.asList(
|
||||||
|
"name0=changed0",
|
||||||
|
"name1=changed1",
|
||||||
|
"--add-to-start=parameterized",
|
||||||
|
"# ignore this"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/parameterized.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[depend]",
|
||||||
|
"main",
|
||||||
|
"[ini]",
|
||||||
|
"name=value",
|
||||||
|
"name0?=default",
|
||||||
|
"name2?=two",
|
||||||
|
"[ini-template]",
|
||||||
|
"name0=value0",
|
||||||
|
"# name1=value1",
|
||||||
|
"# name2=too"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("start.d/tobeupdated.ini"),
|
||||||
|
Arrays.asList(
|
||||||
|
"#p=v",
|
||||||
|
"property=value",
|
||||||
|
"#comment",
|
||||||
|
"property0=value0",
|
||||||
|
"#comment",
|
||||||
|
"#property1=value1"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// === Prepare Jetty Base using Main
|
||||||
|
List<String> prepareArgs = Arrays.asList(
|
||||||
|
"--testing-mode",
|
||||||
|
"--create-startd",
|
||||||
|
"other=value",
|
||||||
|
"name=changed",
|
||||||
|
"--commands=etc/commands.txt"
|
||||||
|
);
|
||||||
|
exec(prepareArgs, true);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Collections.emptyList();
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Validate Resulting XMLs
|
||||||
|
List<String> expectedXmls = Arrays.asList(
|
||||||
|
"${jetty.home}/etc/base.xml",
|
||||||
|
"${jetty.home}/etc/main.xml"
|
||||||
|
);
|
||||||
|
List<String> actualXmls = results.getXmls();
|
||||||
|
assertThat("XML Resolution Order", actualXmls, contains(expectedXmls.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting LIBs
|
||||||
|
List<String> expectedLibs = Arrays.asList(
|
||||||
|
"${jetty.home}/lib/base.jar",
|
||||||
|
"${jetty.home}/lib/main.jar",
|
||||||
|
"${jetty.home}/lib/other.jar"
|
||||||
|
);
|
||||||
|
List<String> actualLibs = results.getLibs();
|
||||||
|
assertThat("Libs", actualLibs, containsInAnyOrder(expectedLibs.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting Properties
|
||||||
|
Set<String> expectedProperties = new HashSet<>();
|
||||||
|
expectedProperties.add("main.prop=value0");
|
||||||
|
expectedProperties.add("name=value");
|
||||||
|
expectedProperties.add("name0=changed0");
|
||||||
|
expectedProperties.add("name1=changed1");
|
||||||
|
expectedProperties.add("name2=two");
|
||||||
|
expectedProperties.add("property=value");
|
||||||
|
expectedProperties.add("property0=value0");
|
||||||
|
List<String> actualProperties = results.getProperties();
|
||||||
|
assertThat("Properties", actualProperties, containsInAnyOrder(expectedProperties.toArray()));
|
||||||
|
|
||||||
|
// === Validate Specific Jetty Base Files/Dirs Exist
|
||||||
|
PathAssert.assertFileExists("Required File: start.d/parameterized.ini", results.baseHome.getPath("start.d/parameterized.ini"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testParameterizedUpdateTest() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
FS.ensureDirExists(baseDir.resolve("etc"));
|
||||||
|
FS.ensureDirExists(baseDir.resolve("start.d"));
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules"));
|
||||||
|
Files.write(baseDir.resolve("etc/commands.txt"),
|
||||||
|
Arrays.asList(
|
||||||
|
"name0=changed0",
|
||||||
|
"name1=changed1",
|
||||||
|
"--add-to-start=parameterized",
|
||||||
|
"# ignore this"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/parameterized.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[depend]",
|
||||||
|
"main",
|
||||||
|
"[ini]",
|
||||||
|
"name=value",
|
||||||
|
"name0?=default",
|
||||||
|
"name2?=two",
|
||||||
|
"[ini-template]",
|
||||||
|
"name0=value0",
|
||||||
|
"# name1=value1",
|
||||||
|
"# name2=too"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("start.d/tobeupdated.ini"),
|
||||||
|
Arrays.asList(
|
||||||
|
"#p=v",
|
||||||
|
"property=value",
|
||||||
|
"#comment",
|
||||||
|
"property0=value0",
|
||||||
|
"#comment",
|
||||||
|
"#property1=value1"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// === Prepare Jetty Base using Main
|
||||||
|
List<String> prepareArgs = Arrays.asList(
|
||||||
|
"--testing-mode",
|
||||||
|
"--create-startd",
|
||||||
|
"other=value",
|
||||||
|
"name=changed",
|
||||||
|
"name0=changed0",
|
||||||
|
"name1=changed1",
|
||||||
|
"--add-to-start=parameterized",
|
||||||
|
"--update-ini",
|
||||||
|
"property0=changed0",
|
||||||
|
"property1=changed1",
|
||||||
|
"name0=updated0"
|
||||||
|
);
|
||||||
|
exec(prepareArgs, true);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Collections.emptyList();
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Validate Resulting XMLs
|
||||||
|
List<String> expectedXmls = Arrays.asList(
|
||||||
|
"${jetty.home}/etc/base.xml",
|
||||||
|
"${jetty.home}/etc/main.xml"
|
||||||
|
);
|
||||||
|
List<String> actualXmls = results.getXmls();
|
||||||
|
assertThat("XML Resolution Order", actualXmls, contains(expectedXmls.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting LIBs
|
||||||
|
List<String> expectedLibs = Arrays.asList(
|
||||||
|
"${jetty.home}/lib/base.jar",
|
||||||
|
"${jetty.home}/lib/main.jar",
|
||||||
|
"${jetty.home}/lib/other.jar"
|
||||||
|
);
|
||||||
|
List<String> actualLibs = results.getLibs();
|
||||||
|
assertThat("Libs", actualLibs, containsInAnyOrder(expectedLibs.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting Properties
|
||||||
|
Set<String> expectedProperties = new HashSet<>();
|
||||||
|
expectedProperties.add("main.prop=value0");
|
||||||
|
expectedProperties.add("name=value");
|
||||||
|
expectedProperties.add("name0=updated0");
|
||||||
|
expectedProperties.add("name1=changed1");
|
||||||
|
expectedProperties.add("name2=two");
|
||||||
|
expectedProperties.add("property=value");
|
||||||
|
expectedProperties.add("property0=changed0");
|
||||||
|
expectedProperties.add("property1=changed1");
|
||||||
|
List<String> actualProperties = results.getProperties();
|
||||||
|
assertThat("Properties", actualProperties, containsInAnyOrder(expectedProperties.toArray()));
|
||||||
|
|
||||||
|
// === Validate Specific Jetty Base Files/Dirs Exist
|
||||||
|
PathAssert.assertFileExists("Required File: start.d/parameterized.ini", results.baseHome.getPath("start.d/parameterized.ini"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,184 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// All rights reserved. This program and the accompanying materials
|
||||||
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
|
//
|
||||||
|
// The Eclipse Public License is available at
|
||||||
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
//
|
||||||
|
// The Apache License v2.0 is available at
|
||||||
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
|
//
|
||||||
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
|
// ========================================================================
|
||||||
|
//
|
||||||
|
|
||||||
|
package org.eclipse.jetty.start.usecases;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.toolchain.test.FS;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.contains;
|
||||||
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
|
|
||||||
|
public class TransientIniTemplateTest extends AbstractUseCase
|
||||||
|
{
|
||||||
|
@Test
|
||||||
|
public void testTransientWithoutIniTemplateTest() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
FS.ensureDirExists(baseDir.resolve("etc"));
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules"));
|
||||||
|
FS.touch(baseDir.resolve("etc/d.xml"));
|
||||||
|
FS.touch(baseDir.resolve("etc/t.xml"));
|
||||||
|
Files.write(baseDir.resolve("modules/direct.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[xml]",
|
||||||
|
"etc/d.xml",
|
||||||
|
"[depend]",
|
||||||
|
"transient",
|
||||||
|
"[ini-template]",
|
||||||
|
"direct.option=direct"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/transient.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[xml]",
|
||||||
|
"etc/t.xml",
|
||||||
|
"[optional]",
|
||||||
|
"main"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("start.ini"),
|
||||||
|
Collections.singletonList(
|
||||||
|
"--module=main"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// === Prepare Jetty Base using Main
|
||||||
|
List<String> prepareArgs = Arrays.asList(
|
||||||
|
"--testing-mode",
|
||||||
|
"--add-to-start=direct"
|
||||||
|
);
|
||||||
|
exec(prepareArgs, true);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Collections.emptyList();
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Validate Resulting XMLs
|
||||||
|
List<String> expectedXmls = Arrays.asList(
|
||||||
|
"${jetty.home}/etc/base.xml",
|
||||||
|
"${jetty.home}/etc/main.xml",
|
||||||
|
"${jetty.base}/etc/t.xml",
|
||||||
|
"${jetty.base}/etc/d.xml"
|
||||||
|
);
|
||||||
|
List<String> actualXmls = results.getXmls();
|
||||||
|
assertThat("XML Resolution Order", actualXmls, contains(expectedXmls.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting LIBs
|
||||||
|
List<String> expectedLibs = Arrays.asList(
|
||||||
|
"${jetty.home}/lib/base.jar",
|
||||||
|
"${jetty.home}/lib/main.jar",
|
||||||
|
"${jetty.home}/lib/other.jar"
|
||||||
|
);
|
||||||
|
List<String> actualLibs = results.getLibs();
|
||||||
|
assertThat("Libs", actualLibs, containsInAnyOrder(expectedLibs.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting Properties
|
||||||
|
Set<String> expectedProperties = new HashSet<>();
|
||||||
|
expectedProperties.add("main.prop=value0");
|
||||||
|
expectedProperties.add("direct.option=direct");
|
||||||
|
List<String> actualProperties = results.getProperties();
|
||||||
|
assertThat("Properties", actualProperties, containsInAnyOrder(expectedProperties.toArray()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTransientWithIniTemplateTest() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules"));
|
||||||
|
FS.ensureDirExists(baseDir.resolve("etc"));
|
||||||
|
FS.touch(baseDir.resolve("etc/d.xml"));
|
||||||
|
FS.touch(baseDir.resolve("etc/t.xml"));
|
||||||
|
Files.write(baseDir.resolve("modules/direct.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[xml]",
|
||||||
|
"etc/d.xml",
|
||||||
|
"[depend]",
|
||||||
|
"transient",
|
||||||
|
"[ini-template]",
|
||||||
|
"direct.option=direct"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/transient.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[xml]",
|
||||||
|
"etc/t.xml",
|
||||||
|
"[optional]",
|
||||||
|
"main",
|
||||||
|
"[ini]",
|
||||||
|
"transient.option=transient",
|
||||||
|
"[ini-template]",
|
||||||
|
"transient.option=transient"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("start.ini"),
|
||||||
|
Collections.singletonList(
|
||||||
|
"--module=main"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// === Prepare Jetty Base using Main
|
||||||
|
List<String> prepareArgs = Arrays.asList(
|
||||||
|
"--testing-mode",
|
||||||
|
"--add-to-start=direct"
|
||||||
|
);
|
||||||
|
exec(prepareArgs, true);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Collections.emptyList();
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Validate Resulting XMLs
|
||||||
|
List<String> expectedXmls = Arrays.asList(
|
||||||
|
"${jetty.home}/etc/base.xml",
|
||||||
|
"${jetty.home}/etc/main.xml",
|
||||||
|
"${jetty.base}/etc/t.xml",
|
||||||
|
"${jetty.base}/etc/d.xml"
|
||||||
|
);
|
||||||
|
List<String> actualXmls = results.getXmls();
|
||||||
|
assertThat("XML Resolution Order", actualXmls, contains(expectedXmls.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting LIBs
|
||||||
|
List<String> expectedLibs = Arrays.asList(
|
||||||
|
"${jetty.home}/lib/base.jar",
|
||||||
|
"${jetty.home}/lib/main.jar",
|
||||||
|
"${jetty.home}/lib/other.jar"
|
||||||
|
);
|
||||||
|
List<String> actualLibs = results.getLibs();
|
||||||
|
assertThat("Libs", actualLibs, containsInAnyOrder(expectedLibs.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting Properties
|
||||||
|
Set<String> expectedProperties = new HashSet<>();
|
||||||
|
expectedProperties.add("main.prop=value0");
|
||||||
|
expectedProperties.add("transient.option=transient");
|
||||||
|
expectedProperties.add("direct.option=direct");
|
||||||
|
List<String> actualProperties = results.getProperties();
|
||||||
|
assertThat("Properties", actualProperties, containsInAnyOrder(expectedProperties.toArray()));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,95 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// All rights reserved. This program and the accompanying materials
|
||||||
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
|
//
|
||||||
|
// The Eclipse Public License is available at
|
||||||
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
//
|
||||||
|
// The Apache License v2.0 is available at
|
||||||
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
|
//
|
||||||
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
|
// ========================================================================
|
||||||
|
//
|
||||||
|
|
||||||
|
package org.eclipse.jetty.start.usecases;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.toolchain.test.FS;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.contains;
|
||||||
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
|
|
||||||
|
public class VersionedModulesTest extends AbstractUseCase
|
||||||
|
{
|
||||||
|
@Test
|
||||||
|
public void testVersionedModulesTest() throws Exception
|
||||||
|
{
|
||||||
|
setupStandardHomeDir();
|
||||||
|
|
||||||
|
FS.ensureDirExists(baseDir.resolve("modules"));
|
||||||
|
Files.write(baseDir.resolve("modules/new.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[version]",
|
||||||
|
"9.3",
|
||||||
|
"[ini]",
|
||||||
|
"the-future=is-new"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("modules/old.mod"),
|
||||||
|
Arrays.asList(
|
||||||
|
"[defaults]",
|
||||||
|
"from-module=old"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
Files.write(baseDir.resolve("start.ini"),
|
||||||
|
Arrays.asList(
|
||||||
|
"--module=main",
|
||||||
|
"--module=old",
|
||||||
|
"--module=new"
|
||||||
|
),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// === Execute Main
|
||||||
|
List<String> runArgs = Collections.emptyList();
|
||||||
|
ExecResults results = exec(runArgs, false);
|
||||||
|
|
||||||
|
// === Validate Resulting XMLs
|
||||||
|
List<String> expectedXmls = Arrays.asList(
|
||||||
|
"${jetty.home}/etc/base.xml",
|
||||||
|
"${jetty.home}/etc/main.xml"
|
||||||
|
);
|
||||||
|
List<String> actualXmls = results.getXmls();
|
||||||
|
assertThat("XML Resolution Order", actualXmls, contains(expectedXmls.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting LIBs
|
||||||
|
List<String> expectedLibs = Arrays.asList(
|
||||||
|
"${jetty.home}/lib/base.jar",
|
||||||
|
"${jetty.home}/lib/main.jar",
|
||||||
|
"${jetty.home}/lib/other.jar"
|
||||||
|
);
|
||||||
|
List<String> actualLibs = results.getLibs();
|
||||||
|
assertThat("Libs", actualLibs, containsInAnyOrder(expectedLibs.toArray()));
|
||||||
|
|
||||||
|
// === Validate Resulting Properties
|
||||||
|
Set<String> expectedProperties = new HashSet<>();
|
||||||
|
expectedProperties.add("main.prop=value0");
|
||||||
|
expectedProperties.add("the-future=is-new");
|
||||||
|
expectedProperties.add("from-module=old");
|
||||||
|
List<String> actualProperties = results.getProperties();
|
||||||
|
assertThat("Properties", actualProperties, containsInAnyOrder(expectedProperties.toArray()));
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,24 +0,0 @@
|
||||||
# The XMLs we expect (order is important)
|
|
||||||
XML|${jetty.base}/etc/base.xml
|
|
||||||
XML|${jetty.base}/etc/main.xml
|
|
||||||
XML|${jetty.base}/etc/config.xml
|
|
||||||
XML|${jetty.base}/etc/config-foo.xml
|
|
||||||
XML|${jetty.base}/etc/config-bar.xml
|
|
||||||
|
|
||||||
# The LIBs we expect (order is irrelevant)
|
|
||||||
LIB|${maven-test-resources}/extra-resources
|
|
||||||
LIB|${maven-test-resources}/extra-libs/example.jar
|
|
||||||
LIB|${jetty.base}/lib/base.jar
|
|
||||||
LIB|${jetty.base}/lib/main.jar
|
|
||||||
LIB|${jetty.base}/lib/other.jar
|
|
||||||
jar
|
|
||||||
|
|
||||||
# The Properties we expect (order is irrelevant)
|
|
||||||
PROP|main.prop=value0
|
|
||||||
|
|
||||||
# JVM Args
|
|
||||||
JVM|-Xms1024m
|
|
||||||
JVM|-Xmx1024m
|
|
||||||
|
|
||||||
# Files / Directories to create
|
|
||||||
FILE|maindir/
|
|
|
@ -1,22 +0,0 @@
|
||||||
# The XMLs we expect (order is important)
|
|
||||||
XML|${jetty.base}/etc/optional.xml
|
|
||||||
XML|${jetty.base}/etc/base.xml
|
|
||||||
XML|${jetty.base}/etc/main.xml
|
|
||||||
XML|${jetty.base}/etc/extra.xml
|
|
||||||
|
|
||||||
# The LIBs we expect (order is irrelevant)
|
|
||||||
LIB|${jetty.base}/lib/optional.jar
|
|
||||||
LIB|${jetty.base}/lib/base.jar
|
|
||||||
LIB|${jetty.base}/lib/main.jar
|
|
||||||
LIB|${jetty.base}/lib/other.jar
|
|
||||||
LIB|${jetty.base}/lib/extra/extra0.jar
|
|
||||||
LIB|${jetty.base}/lib/extra/extra1.jar
|
|
||||||
jar
|
|
||||||
|
|
||||||
# The Properties we expect (order is irrelevant)
|
|
||||||
PROP|extra.prop=value0
|
|
||||||
PROP|main.prop=value0
|
|
||||||
PROP|optional.prop=value0
|
|
||||||
|
|
||||||
# Files / Directories to create
|
|
||||||
FILE|maindir/
|
|
|
@ -1,15 +0,0 @@
|
||||||
## The XMLs we expect (order is important)
|
|
||||||
XML|${jetty.base}/etc/base.xml
|
|
||||||
XML|${jetty.base}/etc/main.xml
|
|
||||||
|
|
||||||
# The LIBs we expect (order is irrelevant)
|
|
||||||
LIB|${jetty.base}/lib/a library.jar
|
|
||||||
LIB|${jetty.base}/lib/base.jar
|
|
||||||
LIB|${jetty.base}/lib/main.jar
|
|
||||||
LIB|${jetty.base}/lib/other.jar
|
|
||||||
|
|
||||||
# The Properties we expect (order is irrelevant)
|
|
||||||
PROP|main.prop=value0
|
|
||||||
|
|
||||||
# Files / Directories to create
|
|
||||||
FILE|maindir/
|
|
|
@ -1,15 +0,0 @@
|
||||||
## The XMLs we expect (order is important)
|
|
||||||
XML|${jetty.base}/etc/base.xml
|
|
||||||
XML|${jetty.base}/etc/main.xml
|
|
||||||
|
|
||||||
# The LIBs we expect (order is irrelevant)
|
|
||||||
LIB|${jetty.base}/lib/base.jar
|
|
||||||
LIB|${jetty.base}/lib/main.jar
|
|
||||||
LIB|${jetty.base}/lib/other.jar
|
|
||||||
|
|
||||||
# The Properties we expect (order is irrelevant)
|
|
||||||
PROP|main.prop=value0
|
|
||||||
|
|
||||||
# Files / Directories to create
|
|
||||||
FILE|maindir/
|
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
## The XMLs we expect (order is important)
|
|
||||||
XML|${jetty.home}/etc/base.xml
|
|
||||||
XML|${jetty.home}/etc/main.xml
|
|
||||||
|
|
||||||
# The LIBs we expect (order is irrelevant)
|
|
||||||
LIB|${jetty.home}/lib/base.jar
|
|
||||||
LIB|${jetty.home}/lib/main.jar
|
|
||||||
LIB|${jetty.home}/lib/other.jar
|
|
||||||
LIB|${jetty.base}/lib/agent-jdk-1.7.jar
|
|
||||||
|
|
||||||
# The Properties we expect (order is irrelevant)
|
|
||||||
PROP|main.prop=value0
|
|
|
@ -1 +0,0 @@
|
||||||
java.vm.specification.version=1.7
|
|
|
@ -1,6 +0,0 @@
|
||||||
[depend]
|
|
||||||
main
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
lib/agent-jdk-${java.vm.specification.version}.jar
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
--module=main,agent
|
|
|
@ -1,12 +0,0 @@
|
||||||
## The XMLs we expect (order is important)
|
|
||||||
XML|${jetty.home}/etc/base.xml
|
|
||||||
XML|${jetty.home}/etc/main.xml
|
|
||||||
|
|
||||||
# The LIBs we expect (order is irrelevant)
|
|
||||||
LIB|${jetty.home}/lib/base.jar
|
|
||||||
LIB|${jetty.home}/lib/main.jar
|
|
||||||
LIB|${jetty.home}/lib/other.jar
|
|
||||||
|
|
||||||
# The Properties we expect (order is irrelevant)
|
|
||||||
PROP|main.prop=value0
|
|
||||||
PROP|noDft.option=A
|
|
|
@ -1,2 +0,0 @@
|
||||||
--module=noDftOptionA
|
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
## The XMLs we expect (order is important)
|
|
||||||
XML|${jetty.home}/etc/base.xml
|
|
||||||
XML|${jetty.home}/etc/main.xml
|
|
||||||
XML|${jetty.base}/etc/d.xml
|
|
||||||
XML|${jetty.base}/etc/ndb.xml
|
|
||||||
|
|
||||||
# The LIBs we expect (order is irrelevant)
|
|
||||||
LIB|${jetty.home}/lib/base.jar
|
|
||||||
LIB|${jetty.home}/lib/main.jar
|
|
||||||
LIB|${jetty.home}/lib/other.jar
|
|
||||||
|
|
||||||
# The Properties we expect (order is irrelevant)
|
|
||||||
PROP|main.prop=value0
|
|
||||||
PROP|default.option=default
|
|
||||||
PROP|noDft.option=B
|
|
|
@ -1,2 +0,0 @@
|
||||||
--module=noDftOptionB
|
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
## The XMLs we expect (order is important)
|
|
||||||
XML|${jetty.home}/etc/base.xml
|
|
||||||
XML|${jetty.home}/etc/main.xml
|
|
||||||
XML|${jetty.base}/etc/ndb.xml
|
|
||||||
|
|
||||||
# The LIBs we expect (order is irrelevant)
|
|
||||||
LIB|${jetty.home}/lib/base.jar
|
|
||||||
LIB|${jetty.home}/lib/main.jar
|
|
||||||
LIB|${jetty.home}/lib/other.jar
|
|
||||||
|
|
||||||
# The Properties we expect (order is irrelevant)
|
|
||||||
PROP|main.prop=value0
|
|
||||||
PROP|default.option=alternate
|
|
||||||
PROP|noDft.option=B
|
|
|
@ -1,2 +0,0 @@
|
||||||
--module=alternate,noDftOptionB
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
EX|UsageException
|
|
||||||
EX|default, which is already provided by alternate
|
|
|
@ -1,2 +0,0 @@
|
||||||
--module=alternate,default
|
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
## The XMLs we expect (order is important)
|
|
||||||
XML|${jetty.home}/etc/base.xml
|
|
||||||
XML|${jetty.home}/etc/main.xml
|
|
||||||
XML|${jetty.base}/etc/ndb.xml
|
|
||||||
|
|
||||||
# The LIBs we expect (order is irrelevant)
|
|
||||||
LIB|${jetty.home}/lib/base.jar
|
|
||||||
LIB|${jetty.home}/lib/main.jar
|
|
||||||
LIB|${jetty.home}/lib/other.jar
|
|
||||||
|
|
||||||
# The Properties we expect (order is irrelevant)
|
|
||||||
PROP|main.prop=value0
|
|
||||||
PROP|default.option=alternate
|
|
||||||
PROP|noDft.option=B
|
|
|
@ -1 +0,0 @@
|
||||||
--module=alternate
|
|
|
@ -1 +0,0 @@
|
||||||
--add-to-start=noDftOptionB
|
|
|
@ -1,5 +0,0 @@
|
||||||
[provides]
|
|
||||||
default
|
|
||||||
|
|
||||||
[ini]
|
|
||||||
default.option=alternate
|
|
|
@ -1,5 +0,0 @@
|
||||||
[xml]
|
|
||||||
etc/d.xml
|
|
||||||
|
|
||||||
[ini]
|
|
||||||
default.option=default
|
|
|
@ -1,8 +0,0 @@
|
||||||
[provides]
|
|
||||||
noDft
|
|
||||||
|
|
||||||
[optional]
|
|
||||||
default
|
|
||||||
|
|
||||||
[ini]
|
|
||||||
noDft.option=A
|
|
|
@ -1,11 +0,0 @@
|
||||||
[provides]
|
|
||||||
noDft
|
|
||||||
|
|
||||||
[depend]
|
|
||||||
default
|
|
||||||
|
|
||||||
[xml]
|
|
||||||
etc/ndb.xml
|
|
||||||
|
|
||||||
[ini]
|
|
||||||
noDft.option=B
|
|
|
@ -1,2 +0,0 @@
|
||||||
--module=main
|
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
## The XMLs we expect (order is important)
|
|
||||||
XML|${jetty.home}/etc/optional.xml
|
|
||||||
XML|${jetty.home}/etc/base.xml
|
|
||||||
XML|${jetty.home}/etc/main.xml
|
|
||||||
|
|
||||||
# The LIBs we expect (order is irrelevant)
|
|
||||||
LIB|${jetty.home}/lib/base.jar
|
|
||||||
LIB|${jetty.home}/lib/main.jar
|
|
||||||
LIB|${jetty.home}/lib/other.jar
|
|
||||||
LIB|${jetty.home}/lib/optional.jar
|
|
||||||
|
|
||||||
# The Properties we expect (order is irrelevant)
|
|
||||||
PROP|main.prop=value0
|
|
||||||
PROP|optional.prop=value0
|
|
||||||
|
|
||||||
# Files / Directories to create
|
|
||||||
EXISTS|maindir/
|
|
||||||
EXISTS|start.ini
|
|
|
@ -1 +0,0 @@
|
||||||
--add-to-start=optional
|
|
|
@ -1,19 +0,0 @@
|
||||||
## The XMLs we expect (order is important)
|
|
||||||
XML|${jetty.home}/etc/optional.xml
|
|
||||||
XML|${jetty.home}/etc/base.xml
|
|
||||||
XML|${jetty.home}/etc/main.xml
|
|
||||||
|
|
||||||
# The LIBs we expect (order is irrelevant)
|
|
||||||
LIB|${jetty.home}/lib/base.jar
|
|
||||||
LIB|${jetty.home}/lib/main.jar
|
|
||||||
LIB|${jetty.home}/lib/other.jar
|
|
||||||
LIB|${jetty.home}/lib/optional.jar
|
|
||||||
|
|
||||||
# The Properties we expect (order is irrelevant)
|
|
||||||
PROP|main.prop=value0
|
|
||||||
PROP|optional.prop=value0
|
|
||||||
|
|
||||||
# Files / Directories to create
|
|
||||||
EXISTS|maindir/
|
|
||||||
EXISTS|start.d/start.ini
|
|
||||||
EXISTS|start.d/optional.ini
|
|
|
@ -1,2 +0,0 @@
|
||||||
--create-startd
|
|
||||||
--add-to-start=optional
|
|
|
@ -1 +0,0 @@
|
||||||
EX|UsageException
|
|
|
@ -1,2 +0,0 @@
|
||||||
--create-startd
|
|
||||||
--add-to-start=unknown
|
|
|
@ -1,17 +0,0 @@
|
||||||
## The XMLs we expect (order is important)
|
|
||||||
XML|${jetty.home}/etc/base.xml
|
|
||||||
XML|${jetty.home}/etc/main.xml
|
|
||||||
|
|
||||||
# The LIBs we expect (order is irrelevant)
|
|
||||||
LIB|${jetty.home}/lib/base.jar
|
|
||||||
LIB|${jetty.home}/lib/main.jar
|
|
||||||
LIB|${jetty.home}/lib/other.jar
|
|
||||||
|
|
||||||
# The Properties we expect (order is irrelevant)
|
|
||||||
PROP|main.prop=value0
|
|
||||||
|
|
||||||
# Files / Directories to create
|
|
||||||
EXISTS|maindir/
|
|
||||||
EXISTS|start.ini
|
|
||||||
|
|
||||||
OUTPUT|INFO : main already enabled by \[\$\{jetty.base}[\\/]start.ini\]
|
|
|
@ -1 +0,0 @@
|
||||||
--add-to-start=main
|
|
|
@ -1,11 +0,0 @@
|
||||||
## The XMLs we expect (order is important)
|
|
||||||
XML|${jetty.home}/etc/base.xml
|
|
||||||
XML|${jetty.home}/etc/main.xml
|
|
||||||
|
|
||||||
# The LIBs we expect (order is irrelevant)
|
|
||||||
LIB|${jetty.home}/lib/base.jar
|
|
||||||
LIB|${jetty.home}/lib/main.jar
|
|
||||||
LIB|${jetty.home}/lib/other.jar
|
|
||||||
|
|
||||||
# The Properties we expect (order is irrelevant)
|
|
||||||
PROP|main.prop=value0
|
|
|
@ -1 +0,0 @@
|
||||||
--module=main
|
|
|
@ -1,15 +0,0 @@
|
||||||
|
|
||||||
DOWNLOAD|basehome:modules/withfiles/test.txt|one/renamed.txt
|
|
||||||
DOWNLOAD|basehome:modules/withfiles/test.txt|two/
|
|
||||||
DOWNLOAD|basehome:modules/withfiles/test.txt|three
|
|
||||||
DOWNLOAD|basehome:modules/withfiles|null
|
|
||||||
DOWNLOAD|basehome:modules/withfiles/four/|five/
|
|
||||||
DOWNLOAD|basehome:modules/withfiles/four/sub|six
|
|
||||||
|
|
||||||
EXISTS|test.txt
|
|
||||||
EXISTS|one/renamed.txt
|
|
||||||
EXISTS|two/test.txt
|
|
||||||
EXISTS|three/test.txt
|
|
||||||
EXISTS|four/sub/dir/test.txt
|
|
||||||
EXISTS|five/sub/dir/test.txt
|
|
||||||
EXISTS|six/sub/dir/test.txt
|
|
|
@ -1,2 +0,0 @@
|
||||||
--create-startd
|
|
||||||
--add-to-start=withfiles
|
|
|
@ -1,12 +0,0 @@
|
||||||
|
|
||||||
[files]
|
|
||||||
|
|
||||||
basehome:modules/withfiles/test.txt|one/renamed.txt
|
|
||||||
basehome:modules/withfiles/test.txt|two/
|
|
||||||
three/
|
|
||||||
basehome:modules/withfiles/test.txt|three
|
|
||||||
|
|
||||||
basehome:modules/withfiles
|
|
||||||
basehome:modules/withfiles/four/|five/
|
|
||||||
six/
|
|
||||||
basehome:modules/withfiles/four/sub|six
|
|
|
@ -1 +0,0 @@
|
||||||
sub/dir/test.txt
|
|
|
@ -1 +0,0 @@
|
||||||
test.txt
|
|
|
@ -1 +0,0 @@
|
||||||
test.txt
|
|
|
@ -1,22 +0,0 @@
|
||||||
## The XMLs we expect (order is important)
|
|
||||||
XML|${jetty.home}/etc/base.xml
|
|
||||||
XML|${jetty.home}/etc/main.xml
|
|
||||||
|
|
||||||
# The LIBs we expect (order is irrelevant)
|
|
||||||
LIB|${jetty.home}/lib/base.jar
|
|
||||||
LIB|${jetty.home}/lib/main.jar
|
|
||||||
LIB|${jetty.home}/lib/other.jar
|
|
||||||
|
|
||||||
# The Properties we expect (order is irrelevant)
|
|
||||||
PROP|main.prop=value0
|
|
||||||
PROP|port=9090
|
|
||||||
PROP|other=value
|
|
||||||
PROP|jetty.http.port=9090
|
|
||||||
PROP|add=beginningmiddleend
|
|
||||||
PROP|list=one,two,three
|
|
||||||
PROP|name=value
|
|
||||||
PROP|name0=/
|
|
||||||
PROP|name1=/foo
|
|
||||||
PROP|name2=/foo/bar
|
|
||||||
SYS|SYSTEM=value
|
|
||||||
SYS|PRESET=value
|
|
|
@ -1,16 +0,0 @@
|
||||||
other=value
|
|
||||||
port=9090
|
|
||||||
add+=beginning
|
|
||||||
add+=middle
|
|
||||||
add+=end
|
|
||||||
list+=,one
|
|
||||||
list+=,two
|
|
||||||
list+=,three
|
|
||||||
name?=value
|
|
||||||
name?=enoughAlready
|
|
||||||
name0=/
|
|
||||||
name1=${name0}foo
|
|
||||||
name2=${name1}/bar
|
|
||||||
-DSYSTEM=${name}
|
|
||||||
-DSYSTEM?=IGNORED
|
|
||||||
-DPRESET?=${SYSTEM}
|
|
|
@ -1,2 +0,0 @@
|
||||||
--module=main
|
|
||||||
jetty.http.port=${port}
|
|
|
@ -1,16 +0,0 @@
|
||||||
## The XMLs we expect (order is important)
|
|
||||||
XML|${jetty.home}/etc/base.xml
|
|
||||||
XML|${jetty.home}/etc/main.xml
|
|
||||||
XML|${jetty.base}/etc/db.xml
|
|
||||||
|
|
||||||
# The LIBs we expect (order is irrelevant)
|
|
||||||
LIB|${jetty.home}/lib/base.jar
|
|
||||||
LIB|${jetty.home}/lib/main.jar
|
|
||||||
LIB|${jetty.home}/lib/other.jar
|
|
||||||
LIB|${jetty.base}/lib/db/bonecp.jar
|
|
||||||
LIB|${jetty.base}/lib/db/mysql-driver.jar
|
|
||||||
|
|
||||||
# The Properties we expect (order is irrelevant)
|
|
||||||
PROP|main.prop=value0
|
|
||||||
PROP|mysql.user=frank
|
|
||||||
PROP|mysql.pass=secret
|
|
|
@ -1 +0,0 @@
|
||||||
<!-- build up org.eclipse.jetty.plus.jndi.Resource here -->
|
|
|
@ -1,5 +0,0 @@
|
||||||
[lib]
|
|
||||||
lib/db/*.jar
|
|
||||||
|
|
||||||
[xml]
|
|
||||||
etc/db.xml
|
|
|
@ -1,3 +0,0 @@
|
||||||
--module=main,db
|
|
||||||
mysql.user=frank
|
|
||||||
mysql.pass=secret
|
|
|
@ -1,2 +0,0 @@
|
||||||
EX|CyclicException
|
|
||||||
EX|cyclic
|
|
|
@ -1,2 +0,0 @@
|
||||||
--create-startd
|
|
||||||
--add-to-start=tom
|
|
|
@ -1 +0,0 @@
|
||||||
--add-to-start=other
|
|
|
@ -1,3 +0,0 @@
|
||||||
|
|
||||||
[provides]
|
|
||||||
branch
|
|
|
@ -1,3 +0,0 @@
|
||||||
|
|
||||||
[depends]
|
|
||||||
dynamic/harry
|
|
|
@ -1,3 +0,0 @@
|
||||||
|
|
||||||
[depends]
|
|
||||||
tom
|
|
|
@ -1,3 +0,0 @@
|
||||||
|
|
||||||
[provides]
|
|
||||||
branch
|
|
|
@ -1,3 +0,0 @@
|
||||||
[depends]
|
|
||||||
branch
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
|
|
||||||
[depends]
|
|
||||||
dick
|
|
|
@ -1 +0,0 @@
|
||||||
--module=root
|
|
|
@ -1,12 +0,0 @@
|
||||||
## The XMLs we expect (order is important)
|
|
||||||
XML|${jetty.home}/etc/base.xml
|
|
||||||
XML|${jetty.home}/etc/main.xml
|
|
||||||
|
|
||||||
# The LIBs we expect (order is irrelevant)
|
|
||||||
LIB|${jetty.home}/lib/base.jar
|
|
||||||
LIB|${jetty.home}/lib/main.jar
|
|
||||||
LIB|${jetty.home}/lib/other.jar
|
|
||||||
|
|
||||||
# The Properties we expect (order is irrelevant)
|
|
||||||
PROP|main.prop=value0
|
|
||||||
PROP|dynamic=1.7.0_31-from-mod
|
|
|
@ -1,2 +0,0 @@
|
||||||
java.version=1.7.0_31
|
|
||||||
--module=dynamic
|
|
|
@ -1,12 +0,0 @@
|
||||||
## The XMLs we expect (order is important)
|
|
||||||
XML|${jetty.home}/etc/base.xml
|
|
||||||
XML|${jetty.home}/etc/main.xml
|
|
||||||
|
|
||||||
# The LIBs we expect (order is irrelevant)
|
|
||||||
LIB|${jetty.home}/lib/base.jar
|
|
||||||
LIB|${jetty.home}/lib/main.jar
|
|
||||||
LIB|${jetty.home}/lib/other.jar
|
|
||||||
|
|
||||||
# The Properties we expect (order is irrelevant)
|
|
||||||
PROP|main.prop=value0
|
|
||||||
PROP|dynamic=1.8.0_05_from_mod
|
|
|
@ -1,2 +0,0 @@
|
||||||
java.version=1.8.0_05
|
|
||||||
--module=dynamic
|
|
|
@ -1,3 +0,0 @@
|
||||||
[depend]
|
|
||||||
main
|
|
||||||
impl/dynamic-${java.version}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue