Issue #515 Alternate start modules
Added another test case. Handle (poorly) the case where a default transitive module adds ini properties and is then replaced by a non transitive module.
This commit is contained in:
parent
62563beee7
commit
e846379c2c
|
@ -30,8 +30,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import javax.management.RuntimeErrorException;
|
||||
|
||||
import org.eclipse.jetty.start.builders.StartDirBuilder;
|
||||
import org.eclipse.jetty.start.builders.StartIniBuilder;
|
||||
import org.eclipse.jetty.start.fileinits.MavenLocalRepoFileInitializer;
|
||||
|
|
|
@ -378,9 +378,11 @@ public class Module
|
|||
}
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled)
|
||||
public void clearTransitiveEnable()
|
||||
{
|
||||
throw new RuntimeException("Don't enable directly");
|
||||
if (_notTransitive)
|
||||
throw new IllegalStateException("Not Transitive");
|
||||
_enables.clear();
|
||||
}
|
||||
|
||||
public void setSkipFilesValidation(boolean skipFilesValidation)
|
||||
|
|
|
@ -34,8 +34,6 @@ import java.util.function.Consumer;
|
|||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
|
||||
import org.eclipse.jetty.util.TopologicalSort;
|
||||
|
||||
/**
|
||||
|
@ -225,6 +223,7 @@ public class Modules implements Iterable<Module>
|
|||
private void enable(Set<String> newlyEnabled, Module module, String enabledFrom, boolean transitive)
|
||||
{
|
||||
StartLog.debug("enable %s from %s transitive=%b",module,enabledFrom,transitive);
|
||||
AtomicBoolean replace_ini_properties=new AtomicBoolean(false);
|
||||
|
||||
// Check that this is not already provided by another module!
|
||||
for (String name:module.getProvides())
|
||||
|
@ -234,8 +233,19 @@ public class Modules implements Iterable<Module>
|
|||
{
|
||||
providers.forEach(p->
|
||||
{
|
||||
if (p!=module && p.isEnabled() && !p.isTransitive())
|
||||
throw new UsageException("Capability %s already enabled by %s for %s",name,p.getName(),module.getName());
|
||||
if (p!=module && p.isEnabled())
|
||||
{
|
||||
// If the already enabled module is transitive and this enable is not
|
||||
if (p.isTransitive() && !transitive)
|
||||
{
|
||||
p.clearTransitiveEnable();
|
||||
// TODO this is not a rigorous way to handle
|
||||
// ini properties that were added by a default transitive module
|
||||
replace_ini_properties.set(true);
|
||||
}
|
||||
else
|
||||
throw new UsageException("Capability %s already enabled by %s for %s",name,p.getName(),module.getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -253,7 +263,7 @@ public class Modules implements Iterable<Module>
|
|||
if (module.hasDefaultConfig())
|
||||
{
|
||||
for(String line:module.getDefaultConfig())
|
||||
_args.parse(line,module.getName(),false);
|
||||
_args.parse(line,module.getName(),replace_ini_properties.get());
|
||||
for (Module m:_modules)
|
||||
m.expandProperties(_args.getProperties());
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
package org.eclipse.jetty.start;
|
||||
|
||||
import static org.eclipse.jetty.start.UsageException.ERR_BAD_ARG;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
|
@ -32,8 +34,6 @@ import java.util.regex.Pattern;
|
|||
|
||||
import org.eclipse.jetty.start.Props.Prop;
|
||||
|
||||
import static org.eclipse.jetty.start.UsageException.ERR_BAD_ARG;
|
||||
|
||||
/**
|
||||
* Management of Properties.
|
||||
* <p>
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
package org.eclipse.jetty.start;
|
||||
|
||||
import static org.eclipse.jetty.start.UsageException.ERR_BAD_ARG;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -41,8 +43,6 @@ import org.eclipse.jetty.start.config.ConfigSource;
|
|||
import org.eclipse.jetty.start.config.ConfigSources;
|
||||
import org.eclipse.jetty.start.config.DirConfigSource;
|
||||
|
||||
import static org.eclipse.jetty.start.UsageException.ERR_BAD_ARG;
|
||||
|
||||
/**
|
||||
* The Arguments required to start Jetty.
|
||||
*/
|
||||
|
|
|
@ -25,7 +25,6 @@ import java.nio.file.Path;
|
|||
|
||||
import org.eclipse.jetty.start.BaseHome;
|
||||
import org.eclipse.jetty.start.FS;
|
||||
import org.eclipse.jetty.start.FileInitializer;
|
||||
import org.eclipse.jetty.start.StartLog;
|
||||
import org.eclipse.jetty.start.Utils;
|
||||
|
||||
|
|
|
@ -35,8 +35,6 @@ import java.util.Set;
|
|||
|
||||
import org.eclipse.jetty.start.Props.Prop;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hamcrest.core.StringStartsWith;
|
||||
import org.junit.Assert;
|
||||
|
||||
public class ConfigurationAssert
|
||||
|
|
|
@ -18,6 +18,10 @@
|
|||
|
||||
package org.eclipse.jetty.start;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -32,10 +36,6 @@ import org.junit.Assert;
|
|||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
||||
public class IncludeJettyDirTest
|
||||
{
|
||||
private static class MainResult
|
||||
|
|
|
@ -18,8 +18,9 @@
|
|||
|
||||
package org.eclipse.jetty.start;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
|
|
|
@ -18,13 +18,15 @@
|
|||
|
||||
package org.eclipse.jetty.start;
|
||||
|
||||
import static org.hamcrest.Matchers.anyOf;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.jetty.start.config.CommandLineConfigSource;
|
||||
import org.eclipse.jetty.start.config.ConfigSources;
|
||||
|
@ -33,13 +35,9 @@ import org.eclipse.jetty.start.config.JettyHomeConfigSource;
|
|||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.toolchain.test.TestingDir;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
public class ModulesTest
|
||||
{
|
||||
private final static String TEST_SOURCE = "<test>";
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
|
||||
package org.eclipse.jetty.start;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
|
|
|
@ -18,18 +18,15 @@
|
|||
|
||||
package org.eclipse.jetty.start;
|
||||
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
import org.eclipse.jetty.start.Props.Prop;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import org.eclipse.jetty.start.Props.Prop;
|
||||
import org.junit.Test;
|
||||
|
||||
public class PropsTest
|
||||
{
|
||||
private static final String FROM_TEST = "(test)";
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
package org.eclipse.jetty.start;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -33,8 +35,6 @@ import org.junit.runners.Parameterized;
|
|||
import org.junit.runners.Parameterized.Parameter;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
|
||||
/**
|
||||
* Test bad configuration scenarios.
|
||||
*/
|
||||
|
|
|
@ -18,8 +18,9 @@
|
|||
|
||||
package org.eclipse.jetty.start;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
|
@ -18,6 +18,10 @@
|
|||
|
||||
package org.eclipse.jetty.start.config;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
@ -35,10 +39,6 @@ import org.junit.Assert;
|
|||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
||||
public class ConfigSourcesTest
|
||||
{
|
||||
@Rule
|
||||
|
|
Loading…
Reference in New Issue