Issue #2985 Clean configs after each test

This commit is contained in:
Jan Bartel 2018-10-18 10:23:56 +11:00
parent 2bb8902286
commit 6c809fea62
2 changed files with 16 additions and 5 deletions

View File

@ -18,6 +18,7 @@
package org.eclipse.jetty.webapp;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import static java.util.stream.Collectors.toList;
@ -29,11 +30,15 @@ import static org.hamcrest.MatcherAssert.assertThat;
public class ConfigurationsTest
{
@AfterEach
public void tearDown()
{
Configurations.cleanKnown();
}
@Test
public void testSetKnown()
{
Configurations.cleanKnown();
Configurations.setKnown(
ConfigBar.class.getName(),
ConfigZ.class.getName(),
@ -66,7 +71,6 @@ public class ConfigurationsTest
@Test
public void testConfigurations()
{
Configurations.cleanKnown();
Configurations.setKnown(
ConfigBar.class.getName(),
ConfigZ.class.getName(),
@ -115,7 +119,6 @@ public class ConfigurationsTest
@Test
public void testDuplicates()
{
Configurations.cleanKnown();
Configurations.setKnown(
ConfigBar.class.getName(),
ConfigZ.class.getName()
@ -134,7 +137,6 @@ public class ConfigurationsTest
@Test
public void testReplacement()
{
Configurations.cleanKnown();
Configurations.setKnown(
ConfigBar.class.getName(),
ConfigZ.class.getName(),
@ -186,7 +188,6 @@ public class ConfigurationsTest
@Test
public void testTransitiveReplacements () throws Exception
{
Configurations.cleanKnown();
Configurations.setKnown(
ConfigBar.class.getName(),
ConfigZ.class.getName(),

View File

@ -58,6 +58,7 @@ import org.eclipse.jetty.util.resource.PathResource;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.util.resource.ResourceCollection;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
public class WebAppContextTest
@ -81,6 +82,12 @@ public class WebAppContextTest
}
@AfterEach
public void tearDown()
{
Configurations.cleanKnown();
}
@Test
public void testSessionListeners ()
throws Exception
@ -103,6 +110,7 @@ public class WebAppContextTest
@Test
public void testConfigurationClassesFromDefault ()
{
Configurations.cleanKnown();
String[] known_and_enabled=Configurations.getKnown().stream()
.filter(c->!c.isDisabledByDefault())
.map(c->c.getClass().getName())
@ -125,6 +133,7 @@ public class WebAppContextTest
@Test
public void testConfigurationOrder ()
{
Configurations.cleanKnown();
WebAppContext wac = new WebAppContext();
wac.setServer(new Server());
assertThat(wac.getWebAppConfigurations().stream().map(c->c.getClass().getName()).collect(Collectors.toList()),
@ -141,6 +150,7 @@ public class WebAppContextTest
@Test
public void testConfigurationInstances ()
{
Configurations.cleanKnown();
Configuration[] configs = {new WebInfConfiguration()};
WebAppContext wac = new WebAppContext();
wac.setConfigurations(configs);