cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gkossakow...@apache.org
Subject svn commit: r611986 - in /cocoon/trunk/core/cocoon-servlet-service: cocoon-servlet-service-components/ cocoon-servlet-service-components/src/ cocoon-servlet-service-components/src/main/java/org/apache/cocoon/servletservice/components/ cocoon-servlet-se...
Date Tue, 15 Jan 2008 01:19:31 GMT
Author: gkossakowski
Date: Mon Jan 14 17:19:28 2008
New Revision: 611986

URL: http://svn.apache.org/viewvc?rev=611986&view=rev
Log:
COCOON-2161: Fixed bug in creation of absolute URI and added test case covering this functionality.

Added:
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/test/
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/test/java/
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/test/java/org/
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/test/java/org/apache/
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/test/java/org/apache/cocoon/
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/test/java/org/apache/cocoon/servletservice/
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/test/java/org/apache/cocoon/servletservice/AbsoluteServletConnectionTestCase.java
  (with props)
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/test/java/org/apache/cocoon/servletservice/MockServlet.java
  (with props)
Modified:
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/pom.xml
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/   (props
changed)
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/java/org/apache/cocoon/servletservice/components/ServletSource.java
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/AbsoluteServletConnection.java

Modified: cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/pom.xml?rev=611986&r1=611985&r2=611986&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/pom.xml (original)
+++ cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/pom.xml Mon
Jan 14 17:19:28 2008
@@ -71,6 +71,24 @@
       <artifactId>servlet-api</artifactId>
       <scope>provided</scope>
     </dependency>
+    <!-- test -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.cocoon</groupId>
+      <artifactId>cocoon-core</artifactId>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.cocoon</groupId>
+      <artifactId>cocoon-sitemap-impl</artifactId>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   
   <build>

Propchange: cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon Jan 14 17:19:28 2008
@@ -1 +1 @@
-site
+site

Modified: cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/java/org/apache/cocoon/servletservice/components/ServletSource.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/java/org/apache/cocoon/servletservice/components/ServletSource.java?rev=611986&r1=611985&r2=611986&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/java/org/apache/cocoon/servletservice/components/ServletSource.java
(original)
+++ cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/java/org/apache/cocoon/servletservice/components/ServletSource.java
Mon Jan 14 17:19:28 2008
@@ -107,6 +107,10 @@
     private ServletConnection createServletConnection(String location) throws MalformedURLException
{
         URI locationUri = null;
         try {
+            if (logger.isDebugEnabled()) {
+                logger.debug("Trying to create a servlet connection for location " + location);
+            }
+            
             locationUri = new URI(location);
             if (!locationUri.isAbsolute()) {
                 throw new MalformedURLException("Only absolute URIs are allowed for the block
protocol. "

Added: cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/test/java/org/apache/cocoon/servletservice/AbsoluteServletConnectionTestCase.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/test/java/org/apache/cocoon/servletservice/AbsoluteServletConnectionTestCase.java?rev=611986&view=auto
==============================================================================
--- cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/test/java/org/apache/cocoon/servletservice/AbsoluteServletConnectionTestCase.java
(added)
+++ cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/test/java/org/apache/cocoon/servletservice/AbsoluteServletConnectionTestCase.java
Mon Jan 14 17:19:28 2008
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.servletservice;
+
+import java.net.URI;
+
+import org.apache.avalon.framework.configuration.DefaultConfiguration;
+import org.apache.cocoon.callstack.CallStack;
+import org.apache.cocoon.callstack.environment.CallFrameHelper;
+import org.apache.cocoon.core.container.ContainerTestCase;
+import org.apache.cocoon.core.container.spring.avalon.ComponentInfo;
+import org.apache.cocoon.core.container.spring.avalon.ConfigurationInfo;
+
+public class AbsoluteServletConnectionTestCase extends ContainerTestCase {
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        CallStack.enter();
+        CallStack.getCurrentFrame().setAttribute(CallStackHelper.SUPER_CALL, new Boolean(false));
+        CallFrameHelper.setContext(getContext());
+        new MockServlet();
+    }
+    
+    protected void addComponents(ConfigurationInfo info) throws Exception {
+        super.addComponents(info);
+        //Add MockServlet bean
+        ComponentInfo componentInfo = new ComponentInfo();
+        componentInfo.setComponentClassName(MockServlet.class.getName());
+        componentInfo.setRole(MockServlet.beanId);
+        componentInfo.setConfiguration(new DefaultConfiguration("-"));
+        info.addComponent(componentInfo);
+    }
+    
+    /**
+     * Tests if absolute URI conforms our definition of absolute URI when servlet protocol
is used.
+     * Test for COCOON-2161.
+     */
+    public void testURI() throws Exception {
+        String path = "/path";
+        AbsoluteServletConnection connection = new AbsoluteServletConnection(MockServlet.beanId,
path, null);
+        URI uri = new URI(MockServlet.beanId + AbsoluteServletConnection.ABSOLUTE_SERVLET_SOURCE_POSTFIX,
null, path, null, null);
+        uri = new URI("servlet", uri.toASCIIString(), null);
+        assertEquals("Check if absolute URI is constructed properly", uri, connection.getURI());
+    }
+}

Propchange: cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/test/java/org/apache/cocoon/servletservice/AbsoluteServletConnectionTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/test/java/org/apache/cocoon/servletservice/MockServlet.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/test/java/org/apache/cocoon/servletservice/MockServlet.java?rev=611986&view=auto
==============================================================================
--- cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/test/java/org/apache/cocoon/servletservice/MockServlet.java
(added)
+++ cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/test/java/org/apache/cocoon/servletservice/MockServlet.java
Mon Jan 14 17:19:28 2008
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.servletservice;
+
+import javax.servlet.http.HttpServlet;
+
+public class MockServlet extends HttpServlet {
+
+    static final String beanId = "test.servlet";
+
+    public MockServlet() { }
+}

Propchange: cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/test/java/org/apache/cocoon/servletservice/MockServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/AbsoluteServletConnection.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/AbsoluteServletConnection.java?rev=611986&r1=611985&r2=611986&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/AbsoluteServletConnection.java
(original)
+++ cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/AbsoluteServletConnection.java
Mon Jan 14 17:19:28 2008
@@ -67,7 +67,7 @@
 
         URI reqUri = null;
         try {
-            this.uri = new URI(serviceName, null, path, queryString, null);
+            this.uri = new URI(serviceName  + ABSOLUTE_SERVLET_SOURCE_POSTFIX, null, path,
queryString, null);
             this.uri = new URI("servlet", this.uri.toASCIIString(), null);
             reqUri = new URI("servlet", null, path, queryString, null);
         } catch (URISyntaxException e) {



Mime
View raw message