tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1382602 - /tomcat/sandbox/trunk-resources/test/org/apache/catalina/loader/TestVirtualContext.java
Date Sun, 09 Sep 2012 22:36:52 GMT
Author: markt
Date: Sun Sep  9 22:36:52 2012
New Revision: 1382602

URL: http://svn.apache.org/viewvc?rev=1382602&view=rev
Log:
Tweak unit test to work with new resources - still fails. There is work to do in the JarScanner.

Modified:
    tomcat/sandbox/trunk-resources/test/org/apache/catalina/loader/TestVirtualContext.java

Modified: tomcat/sandbox/trunk-resources/test/org/apache/catalina/loader/TestVirtualContext.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/test/org/apache/catalina/loader/TestVirtualContext.java?rev=1382602&r1=1382601&r2=1382602&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/test/org/apache/catalina/loader/TestVirtualContext.java
(original)
+++ tomcat/sandbox/trunk-resources/test/org/apache/catalina/loader/TestVirtualContext.java
Sun Sep  9 22:36:52 2012
@@ -31,11 +31,12 @@ import static org.junit.Assert.assertTru
 import org.junit.Assert;
 import org.junit.Test;
 
+import org.apache.catalina.WebResourceRoot;
 import org.apache.catalina.core.JreMemoryLeakPreventionListener;
 import org.apache.catalina.core.StandardContext;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
-import org.apache.naming.resources.VirtualDirContext;
+import org.apache.catalina.webresources.StandardRoot;
 import org.apache.tomcat.util.buf.ByteChunk;
 import org.apache.tomcat.util.http.fileupload.FileUtils;
 import org.apache.tomcat.util.http.fileupload.IOUtils;
@@ -66,20 +67,27 @@ public class TestVirtualContext extends 
         StandardContext ctx = (StandardContext) tomcat.addWebapp(null, "/test",
             appDir.getAbsolutePath());
 
-        VirtualWebappLoader loader = new VirtualWebappLoader(ctx.getParentClassLoader());
-        loader.setVirtualClasspath(//
-            "test/webapp-3.0-virtual-webapp/target/classes;" + //
-                "test/webapp-3.0-virtual-library/target/classes;" + //
-                "test/webapp-3.0-virtual-webapp/src/main/webapp/WEB-INF/classes;" + //
+        ctx.setResources(new StandardRoot(ctx));
+        File f1 = new File("test/webapp-3.0-virtual-webapp/target/classes");
+        File f2 = new File("test/webapp-3.0-virtual-library/target/classes");
+        File f3 = new File(
+                "test/webapp-3.0-virtual-webapp/src/main/webapp/WEB-INF/classes");
+        File f4 = new File(
                 "test/webapp-3.0-virtual-webapp/src/main/webapp2/WEB-INF/classes");
-        ctx.setLoader(loader);
-
-        String extraMappings = "/=test/webapp-3.0-virtual-webapp/src/main/webapp2" + //
-            ",/other=test/webapp-3.0-virtual-webapp/src/main/misc" + //
-            ",/WEB-INF/classes=test/webapp-3.0-virtual-webapp/target/classes";
-        VirtualDirContext resources = new VirtualDirContext();
-        resources.setExtraResourcePaths(extraMappings);
-        ctx.setResources(resources);
+        File f5 = new File("test/webapp-3.0-virtual-webapp/src/main/misc");
+        File f6 = new File("test/webapp-3.0-virtual-webapp/src/main/webapp2");
+        ctx.getResources().createWebResourceSet(
+                WebResourceRoot.ResourceSetType.POST, f1, "/WEB-INF/classes", "");
+        ctx.getResources().createWebResourceSet(
+                WebResourceRoot.ResourceSetType.POST, f2, "/WEB-INF/classes", "");
+        ctx.getResources().createWebResourceSet(
+                WebResourceRoot.ResourceSetType.POST, f3, "/WEB-INF/classes", "");
+        ctx.getResources().createWebResourceSet(
+                WebResourceRoot.ResourceSetType.POST, f4, "/WEB-INF/classes", "");
+        ctx.getResources().createWebResourceSet(
+                WebResourceRoot.ResourceSetType.POST, f5, "/other", "");
+        ctx.getResources().createWebResourceSet(
+                WebResourceRoot.ResourceSetType.POST, f6, "", "");
 
         StandardJarScanner jarScanner = new StandardJarScanner();
         jarScanner.setScanAllDirectories(true);
@@ -261,11 +269,13 @@ public class TestVirtualContext extends 
         annotatedServletClassInputStream.close();
         annotatedServletClassOutputStream.close();
 
-        VirtualWebappLoader loader = new VirtualWebappLoader(ctx.getParentClassLoader());
-        loader.setVirtualClasspath("test/webapp-3.0-virtual-webapp/target/classes;" + //
-            "test/webapp-3.0-virtual-library/target/classes;" + //
-            additionWebInfClasses.getAbsolutePath());
-        ctx.setLoader(loader);
+        ctx.setResources(new StandardRoot(ctx));
+        File f1 = new File("test/webapp-3.0-virtual-webapp/target/classes");
+        File f2 = new File("test/webapp-3.0-virtual-library/target/classes");
+        ctx.getResources().createWebResourceSet(
+                WebResourceRoot.ResourceSetType.POST, f1, "/WEB-INF/classes", "");
+        ctx.getResources().createWebResourceSet(
+                WebResourceRoot.ResourceSetType.POST, f2, "/WEB-INF/classes", "");
 
         tomcat.start();
         // first test that without the setting on StandardContext the annotated
@@ -276,10 +286,14 @@ public class TestVirtualContext extends 
 
         // then test that if we configure StandardContext with the additional
         // path, the servlet is detected
-        // ctx.setAdditionalVirtualWebInfClasses(additionWebInfClasses.getAbsolutePath());
-        VirtualDirContext resources = new VirtualDirContext();
-        resources.setExtraResourcePaths("/WEB-INF/classes=" + additionWebInfClasses);
-        ctx.setResources(resources);
+        ctx.setResources(new StandardRoot(ctx));
+        ctx.getResources().createWebResourceSet(
+                WebResourceRoot.ResourceSetType.POST, f1, "/WEB-INF/classes", "");
+        ctx.getResources().createWebResourceSet(
+                WebResourceRoot.ResourceSetType.POST, f2, "/WEB-INF/classes", "");
+        ctx.getResources().createWebResourceSet(
+                WebResourceRoot.ResourceSetType.POST, additionWebInfClasses,
+                "/WEB-INF/classes", "");
 
         tomcat.start();
         assertPageContains("/test/annotatedServlet", MyAnnotatedServlet.MESSAGE);



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message