You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2014/07/31 13:50:53 UTC

git commit: [OLINGO-377] Fixed test issue for windows environments

Repository: olingo-odata4
Updated Branches:
  refs/heads/master 101266e86 -> 29d374740


[OLINGO-377] Fixed test issue for windows environments


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/29d37474
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/29d37474
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/29d37474

Branch: refs/heads/master
Commit: 29d374740ff9c7d97a1ce90d3508305545def899
Parents: 101266e
Author: Michael Bolz <mi...@sap.com>
Authored: Thu Jul 31 13:42:15 2014 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Thu Jul 31 13:42:18 2014 +0200

----------------------------------------------------------------------
 .../olingo/fit/server/TomcatTestServer.java     | 44 ++++----------------
 fit/src/main/resources/tomcat-fit.properties    |  1 -
 2 files changed, 7 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/29d37474/fit/src/main/java/org/apache/olingo/fit/server/TomcatTestServer.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/server/TomcatTestServer.java b/fit/src/main/java/org/apache/olingo/fit/server/TomcatTestServer.java
index e14a420..4d7924b 100644
--- a/fit/src/main/java/org/apache/olingo/fit/server/TomcatTestServer.java
+++ b/fit/src/main/java/org/apache/olingo/fit/server/TomcatTestServer.java
@@ -34,13 +34,12 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
-import java.io.FilenameFilter;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
 import java.util.Enumeration;
-import java.util.Locale;
 import java.util.Properties;
+import java.util.UUID;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 
@@ -96,7 +95,6 @@ public class TomcatTestServer {
     String[] portParam = portParameter.split("=");
     if(portParam.length == 2) {
       try {
-
         return Integer.parseInt(portParam[1]);
       } catch (NumberFormatException e) {
         throw new IllegalArgumentException("Port parameter (" + portParameter +
@@ -199,41 +197,12 @@ public class TomcatTestServer {
         throw new RuntimeException("Unable to create temporary directory at {" + webAppDir.getAbsolutePath() + "}");
       }
       FileUtils.copyDirectory(webAppProjectDir, webAppDir);
-      File libDir = new File(webAppDir, "WEB-INF/lib");
-      File classesDir = new File(webAppDir, "WEB-INF/classes");
-      String[] libsToExtract = libDir.list(new FilenameFilter() {
-        @Override public boolean accept(File dir, String name) {
-          return name.toLowerCase(Locale.ENGLISH).contains("olingo")
-              && name.toLowerCase(Locale.ENGLISH).endsWith("jar");
-        }
-      });
-      for (String lib : libsToExtract) {
-        File libFile = new File(libDir, lib);
-        extract(libFile, classesDir);
-        FileUtils.forceDelete(libFile);
-      }
 
-//      String[] libsToRemove = libDir.list(new FilenameFilter() {
-//        @Override public boolean accept(File dir, String name) {
-//          return
-//              (name.toLowerCase(Locale.ENGLISH).contains("tomcat")
-//              || name.toLowerCase(Locale.ENGLISH).contains("maven"))
-//              && name.toLowerCase(Locale.ENGLISH).endsWith("jar");
-//        }
-//      });
-//      for (String lib : libsToRemove) {
-//        FileUtils.forceDelete(new File(libDir, lib));
-//      }
-
-      String contextPath = "/stub"; // contextFile.getName()
+      String contextPath = "/stub";
       Context context = tomcat.addWebapp(tomcat.getHost(), contextPath, webAppDir.getAbsolutePath());
+      context.setLoader(new WebappLoader(Thread.currentThread().getContextClassLoader()));
       LOG.info("Webapp {} at context {}.", webAppDir.getName(), contextPath);
 
-      //
-      WebappLoader solrLoader = new WebappLoader(Thread.currentThread().getContextClassLoader());
-      context.setLoader(solrLoader);
-      //
-
       return this;
     }
 
@@ -260,10 +229,11 @@ public class TomcatTestServer {
       String odataServlet = factoryClass.getName();
       HttpServlet httpServlet = (HttpServlet) Class.forName(odataServlet).newInstance();
       Context cxt = getContext();
-      Tomcat.addServlet(cxt, odataServlet, httpServlet);
-      cxt.addServletMapping(path, odataServlet);
+      String randomServletId = UUID.randomUUID().toString();
+      Tomcat.addServlet(cxt, randomServletId, httpServlet);
+      cxt.addServletMapping(path, randomServletId);
       //
-      LOG.info("Added servlet {} at context {}.", odataServlet, path);
+      LOG.info("Added servlet {} at context {} (mapping id={}).", odataServlet, path, randomServletId);
       return this;
     }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/29d37474/fit/src/main/resources/tomcat-fit.properties
----------------------------------------------------------------------
diff --git a/fit/src/main/resources/tomcat-fit.properties b/fit/src/main/resources/tomcat-fit.properties
index 36a6687..acebff4 100644
--- a/fit/src/main/resources/tomcat-fit.properties
+++ b/fit/src/main/resources/tomcat-fit.properties
@@ -17,6 +17,5 @@
 # under the License.
 #
 TOMCAT_BASE_DIR=${project.build.directory}/emb-tom-fit
-PROJECT_TARGET_DIR=${project.build.directory}
 PROJECT_WEB_APP_DIR=${project.build.directory}/${project.build.finalName}
 PROJECT_RESOURCES_DIR=${project.build.outputDirectory}