cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r605665 - /cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/components/source/impl/ZipSourceTestCase.java
Date Wed, 19 Dec 2007 19:24:56 GMT
Author: cziegeler
Date: Wed Dec 19 11:24:56 2007
New Revision: 605665

URL: http://svn.apache.org/viewvc?rev=605665&view=rev
Log:
Hopefully fix the zip test case.

Modified:
    cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/components/source/impl/ZipSourceTestCase.java

Modified: cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/components/source/impl/ZipSourceTestCase.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/components/source/impl/ZipSourceTestCase.java?rev=605665&r1=605664&r2=605665&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/components/source/impl/ZipSourceTestCase.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/components/source/impl/ZipSourceTestCase.java
Wed Dec 19 11:24:56 2007
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,9 +17,7 @@
 package org.apache.cocoon.components.source.impl;
 
 import org.apache.avalon.framework.service.ServiceException;
-
 import org.apache.cocoon.core.container.ContainerTestCase;
-
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceException;
 import org.apache.excalibur.source.SourceResolver;
@@ -27,7 +25,9 @@
 public class ZipSourceTestCase extends ContainerTestCase {
 
     public void testURIHandling() throws Exception {
-        final String zipSourceUri = "zip:file://test.zip!/test.xml";
+        final String zipFilePath = "/test.zip";
+        final String filePath = "test.xml";
+        final String zipSourceUri = "zip:file:/" + zipFilePath + "!/" + filePath;
         Source zipSource;
         SourceResolver resolver = null;
         try {
@@ -38,10 +38,19 @@
         } finally {
             getManager().release(resolver);
         }
-        assertTrue("Resolved Source is not an instance of ZipSource.", 
+        assertTrue("Resolved Source is not an instance of ZipSource.",
                    zipSource instanceof ZipSource);
         assertEquals("Scheme/protocol is wrong.", "zip", zipSource.getScheme());
-        assertEquals("Uri is wrong.", zipSourceUri, zipSource.getURI());
+        // test file path
+        int index = zipSource.getURI().lastIndexOf(':');
+        String testFilePath = zipSource.getURI().substring(index + 2);
+        // depending on the operation system, the uri can either contain two or three slashes
+        // so we remove all slashed and then append one slash
+        while ( testFilePath.startsWith("/") ) {
+            testFilePath = testFilePath.substring(1);
+        }
+        testFilePath = "/" + testFilePath;
+        assertEquals("Uri is wrong.", zipSourceUri, zipSource.getURI().substring(0, index
+ 2) + testFilePath);
     }
-    
+
 }



Mime
View raw message