use of org.apache.catalina.webresources.DirResourceSet in project joinfaces by joinfaces.
the class JsfTomcatApplicationListenerIT method embeddedJarWithoutAppResources2.
@Test
public void embeddedJarWithoutAppResources2() throws LifecycleException {
ContextMock contextMock = new ContextMock();
File file = new File(TARGET + File.separator + TEST_CLASSES + File.separator + "test.jar");
JarWarResourceSet jarWarResourceSet = new JarWarResourceSet(contextMock.getWebResourceRoot(), "/", file.getAbsolutePath(), INTERNAL_JAR, METAINF_RESOURCES);
jarWarResourceSet.init();
DirResourceSet dirResourceSet = new DirResourceSet(contextMock.getWebResourceRoot(), TEST, TEST, TEST);
contextMock.init(dirResourceSet, jarWarResourceSet);
callApplicationEvent(contextMock);
assertThat(contextMock.getWebResourceRoot().getCreateWebResourceSetCalls()).isEqualTo(2);
}
use of org.apache.catalina.webresources.DirResourceSet in project joinfaces by joinfaces.
the class JsfTomcatApplicationListenerIT method embeddedWarWithoutAppResources.
@Test
public void embeddedWarWithoutAppResources() throws LifecycleException {
ContextMock contextMock = new ContextMock();
File file = new File(TARGET + File.separator + TEST_CLASSES + File.separator + "test.war");
JarWarResourceSet jarWarResourceSet = new JarWarResourceSet(contextMock.getWebResourceRoot(), "/", file.getAbsolutePath(), INTERNAL_JAR, METAINF_RESOURCES);
jarWarResourceSet.init();
DirResourceSet dirResourceSet = new DirResourceSet(contextMock.getWebResourceRoot(), TEST, TEST, TEST);
contextMock.init(jarWarResourceSet, dirResourceSet);
callApplicationEvent(contextMock);
assertThat(contextMock.getWebResourceRoot().getCreateWebResourceSetCalls()).isEqualTo(0);
}
use of org.apache.catalina.webresources.DirResourceSet in project joinfaces by joinfaces.
the class JsfTomcatApplicationListenerIT method testingResources.
@Test
public void testingResources() throws LifecycleException {
ContextMock contextMock = new ContextMock();
DirResourceSet dirResourceSet = new DirResourceSet(contextMock.getWebResourceRoot(), TEST, TEST, TEST);
contextMock.init(dirResourceSet);
callApplicationEvent(contextMock);
assertThat(contextMock.getWebResourceRoot().getCreateWebResourceSetCalls()).isEqualTo(0);
}
use of org.apache.catalina.webresources.DirResourceSet in project hazelcast by hazelcast.
the class ServiceLoaderTest method testClassIteratorInTomcat_whenClassesInBothLibs.
@Test
public void testClassIteratorInTomcat_whenClassesInBothLibs() throws Exception {
ClassLoader launchClassLoader = this.getClass().getClassLoader();
ClassLoader webappClassLoader;
// setup embedded tomcat
Tomcat tomcat = new Tomcat();
// 8080 may be used by some other tests
tomcat.setPort(13256);
Context ctx = tomcat.addContext("", null);
// Map target/classes as WEB-INF/classes, so webapp classloader
// will locate compiled production classes in the webapp classpath.
// The purpose of this setup is to make project classes available
// to both launch classloader and webapplication classloader,
// modeling a Tomcat deployment in which Hazelcast JARs are deployed
// in both tomcat/lib and webapp/lib
File webInfClasses = new File("target/classes");
WebResourceRoot resources = new StandardRoot(ctx);
resources.addPreResources(new DirResourceSet(resources, "/WEB-INF/classes", webInfClasses.getAbsolutePath(), "/"));
ctx.setResources(resources);
TestServiceLoaderServlet testServlet = new TestServiceLoaderServlet();
Wrapper wrapper = tomcat.addServlet("", "testServlet", testServlet);
wrapper.setLoadOnStartup(1);
ctx.addServletMappingDecoded("/", "testServlet");
tomcat.start();
try {
assertTrueEventually(() -> assertTrue(testServlet.isInitDone()));
assertNull("No failure is expected from servlet init() method", testServlet.failure());
webappClassLoader = testServlet.getWebappClassLoader();
assertNotEquals(launchClassLoader, webappClassLoader);
Iterator<? extends Class<?>> iterator = ServiceLoader.classIterator(DataSerializerHook.class, "com.hazelcast.DataSerializerHook", webappClassLoader);
assertTrue(iterator.hasNext());
while (iterator.hasNext()) {
Class<?> klass = iterator.next();
assertEquals(launchClassLoader, klass.getClassLoader());
}
} finally {
tomcat.stop();
}
}
Aggregations