fixed test

This commit is contained in:
Greg Wilkins 2017-05-09 12:03:50 +02:00
parent 1fc046fb3d
commit 2e299a7ebd
2 changed files with 68 additions and 57 deletions

View File

@ -134,6 +134,10 @@ public class TestAnnotationConfiguration
assertTrue(testSciJar.exists());
URLClassLoader webAppLoader = new URLClassLoader(new URL[]{testSciJar.toURI().toURL()}, Thread.currentThread().getContextClassLoader());
ClassLoader orig = Thread.currentThread().getContextClassLoader();
try
{
//test 3.1 webapp loads both server and app scis
AnnotationConfiguration config = new AnnotationConfiguration();
WebAppContext context = new WebAppContext();
@ -141,7 +145,9 @@ public class TestAnnotationConfiguration
context.getMetaData().setWebXml(Resource.newResource(web31true));
context.getServletContext().setEffectiveMajorVersion(3);
context.getServletContext().setEffectiveMinorVersion(1);
Thread.currentThread().setContextClassLoader(webAppLoader);
List<ServletContainerInitializer> scis = config.getNonExcludedInitializers(context);
assertNotNull(scis);
assertEquals(2, scis.size());
assertTrue(sciNames.contains(scis.get(0).getClass().getName()));
@ -187,6 +193,11 @@ public class TestAnnotationConfiguration
assertTrue(sciNames.contains(scis.get(0).getClass().getName()));
assertTrue(sciNames.contains(scis.get(1).getClass().getName()));
}
finally
{
Thread.currentThread().setContextClassLoader(orig);
}
}
@Test