You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by at...@apache.org on 2008/03/22 22:56:44 UTC

svn commit: r640090 - in /portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src: main/java/org/apache/jetspeed/components/portletentity/ test/java/org/apache/jetspeed/ test/java/org/apache/jetspeed/request/ test/resources/

Author: ate
Date: Sat Mar 22 14:56:44 2008
New Revision: 640090

URL: http://svn.apache.org/viewvc?rev=640090&view=rev
Log:
Fix for TestPortletEntityDAO: PortletEntityImpl requires RequestContextComponent to be set

Added:
    portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/test/java/org/apache/jetspeed/request/
    portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/test/java/org/apache/jetspeed/request/MockRequestContextComponent.java   (with props)
Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/test/java/org/apache/jetspeed/   (props changed)
    portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/test/resources/registry-test.xml

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java?rev=640090&r1=640089&r2=640090&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java Sat Mar 22 14:56:44 2008
@@ -533,6 +533,10 @@
             return new PortletEntityUserPrincipal(NO_PRINCIPAL);
         }            
         RequestContext rc = rcc.getRequestContext();
+        if (rc == null)
+        {
+            return new PortletEntityUserPrincipal(NO_PRINCIPAL);
+        }
         Principal principal = rc.getUserPrincipal();
         if (principal == null)
         {

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/test/java/org/apache/jetspeed/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Sat Mar 22 14:56:44 2008
@@ -1,2 +1,2 @@
-target
+target
 surefire*.properties

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/test/java/org/apache/jetspeed/request/MockRequestContextComponent.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/test/java/org/apache/jetspeed/request/MockRequestContextComponent.java?rev=640090&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/test/java/org/apache/jetspeed/request/MockRequestContextComponent.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/test/java/org/apache/jetspeed/request/MockRequestContextComponent.java Sat Mar 22 14:56:44 2008
@@ -0,0 +1,48 @@
+/*
+ * 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.jetspeed.request;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @version $Id$
+ *
+ */
+public class MockRequestContextComponent implements RequestContextComponent
+{
+
+    public RequestContext create(HttpServletRequest req, HttpServletResponse resp, ServletConfig config)
+    {
+        return null;
+    }
+
+    public RequestContext getRequestContext(HttpServletRequest request)
+    {
+        return null;
+    }
+
+    public RequestContext getRequestContext()
+    {
+        return null;
+    }
+
+    public void release(RequestContext context)
+    {
+    }
+}

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/test/java/org/apache/jetspeed/request/MockRequestContextComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/test/java/org/apache/jetspeed/request/MockRequestContextComponent.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/test/java/org/apache/jetspeed/request/MockRequestContextComponent.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/test/resources/registry-test.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/test/resources/registry-test.xml?rev=640090&r1=640089&r2=640090&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/test/resources/registry-test.xml (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/test/resources/registry-test.xml Sat Mar 22 14:56:44 2008
@@ -1,34 +1,34 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
-<!--
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
+<!--
     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.
--->
-<beans>
-
-    <!-- Portlet Factory -->
-    <bean id="portletFactory" class="org.apache.jetspeed.factory.JetspeedPortletFactory"></bean>
-
-    <!-- Portlet Registry DAO-->
-    <bean id="portletRegistryImpl" class="org.apache.jetspeed.components.portletregistry.PersistenceBrokerPortletRegistry" init-method="init">
-
-        <constructor-arg index="0">
-            <value>JETSPEED-INF/ojb/registry_repository.xml</value>
-        </constructor-arg>
-        <constructor-arg index="1">
-            <ref bean="portletFactory" />
+    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.
+-->
+<beans>
+
+    <!-- Portlet Factory -->
+    <bean id="portletFactory" class="org.apache.jetspeed.factory.JetspeedPortletFactory"></bean>
+
+    <!-- Portlet Registry DAO-->
+    <bean id="portletRegistryImpl" class="org.apache.jetspeed.components.portletregistry.PersistenceBrokerPortletRegistry" init-method="init">
+
+        <constructor-arg index="0">
+            <value>JETSPEED-INF/ojb/registry_repository.xml</value>
+        </constructor-arg>
+        <constructor-arg index="1">
+            <ref bean="portletFactory" />
         </constructor-arg>
         <constructor-arg index="2">
             <ref bean="portletApplicationOidCache" />
@@ -42,72 +42,77 @@
         <constructor-arg index="5">
             <ref bean="portletDefinitionNameCache" />
         </constructor-arg>        
-    </bean>
-
-    <bean id="org.apache.jetspeed.components.portletregistry.PortletRegistry" name="portletRegistry" parent="baseTransactionProxy">
-        <property name="proxyInterfaces">
-            <value>org.apache.jetspeed.components.portletregistry.PortletRegistry</value>
-        </property>
-
-        <property name="target">
-            <ref bean="portletRegistryImpl" />
-        </property>
-        <property name="transactionAttributes">
-            <props>
-                <prop key="register*">PROPAGATION_REQUIRED,-org.apache.jetspeed.components.portletregistry.RegistryException</prop>
-                <prop key="remove*">PROPAGATION_REQUIRED,-org.apache.jetspeed.components.portletregistry.RegistryException</prop>
-                <prop key="update*">PROPAGATION_REQUIRED,-org.apache.jetspeed.components.portletregistry.RegistryException</prop>
-                <prop key="save*">PROPAGATION_REQUIRED,-org.apache.jetspeed.components.portletregistry.RegistryException</prop>
-                <prop key="*">PROPAGATION_SUPPORTS</prop>
-            </props>
-        </property>
-    </bean>
-
-    <!--
-        - PortletEntity business object: OJB implementation, as an inner bean wrapped
-        - by an outer transactional proxy. The two bean definitions could have been separate,
-        - but this is cleaner as there is no need to ever access the unwrapped object.
-    -->
-
-    <bean id="portletEntityAccessImpl" class="org.apache.jetspeed.components.portletentity.PersistenceBrokerPortletEntityAccess">
-        <constructor-arg>
-            <ref bean="portletRegistry" />
-        </constructor-arg>
-    </bean>
-
-    <bean id="org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent" parent="baseTransactionProxy" name="portletEntityAccess">
-        <property name="proxyInterfaces">
-            <value>org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent</value>
-        </property>
-        <property name="target">
-            <ref bean="portletEntityAccessImpl" />
-        </property>
-        <!--
-            <property name="preInterceptors">
-            <list>
-            <ref bean="portletEntityCachingAdvisor"/>
-            <ref bean="portletEntityRemoveFromCacheAdvisor"/>
-            </list>
-            </property>
-        -->
-        <property name="transactionAttributes">
-            <props>
-                <prop key="remove*">PROPAGATION_REQUIRED</prop>
-                <prop key="store*">PROPAGATION_REQUIRED,-org.apache.jetspeed.components.portletentity.PortletEntityNotStoredException</prop>
-                <prop key="*">PROPAGATION_SUPPORTS</prop>
-            </props>
-        </property>
-    </bean>
-    
-  <!-- Inject Portlet Entity Proxy into Portlet Entity impl -->
-  <bean id="injectEntityAccessProxy" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
-      <property name="targetObject"><ref bean="portletEntityAccessImpl"/></property>
-      <property name="targetMethod"><value>setEntityAccessProxy</value></property>
-      <property name="arguments">
-          <list>
-              <ref bean="org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent"/>
-          </list>
-      </property>
-  </bean>
-    
-</beans>
+    </bean>
+
+    <bean id="org.apache.jetspeed.request.RequestContextComponent" class="org.apache.jetspeed.request.MockRequestContextComponent"/>
+    
+    <bean id="org.apache.jetspeed.components.portletregistry.PortletRegistry" name="portletRegistry" parent="baseTransactionProxy">
+        <property name="proxyInterfaces">
+            <value>org.apache.jetspeed.components.portletregistry.PortletRegistry</value>
+        </property>
+
+        <property name="target">
+            <ref bean="portletRegistryImpl" />
+        </property>
+        <property name="transactionAttributes">
+            <props>
+                <prop key="register*">PROPAGATION_REQUIRED,-org.apache.jetspeed.components.portletregistry.RegistryException</prop>
+                <prop key="remove*">PROPAGATION_REQUIRED,-org.apache.jetspeed.components.portletregistry.RegistryException</prop>
+                <prop key="update*">PROPAGATION_REQUIRED,-org.apache.jetspeed.components.portletregistry.RegistryException</prop>
+                <prop key="save*">PROPAGATION_REQUIRED,-org.apache.jetspeed.components.portletregistry.RegistryException</prop>
+                <prop key="*">PROPAGATION_SUPPORTS</prop>
+            </props>
+        </property>
+    </bean>
+
+    <!--
+        - PortletEntity business object: OJB implementation, as an inner bean wrapped
+        - by an outer transactional proxy. The two bean definitions could have been separate,
+        - but this is cleaner as there is no need to ever access the unwrapped object.
+    -->
+
+    <bean id="portletEntityAccessImpl" class="org.apache.jetspeed.components.portletentity.PersistenceBrokerPortletEntityAccess">
+        <constructor-arg>
+            <ref bean="portletRegistry" />
+        </constructor-arg>
+        <constructor-arg>
+            <ref bean="org.apache.jetspeed.request.RequestContextComponent" />
+        </constructor-arg>    
+    </bean>
+
+    <bean id="org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent" parent="baseTransactionProxy" name="portletEntityAccess">
+        <property name="proxyInterfaces">
+            <value>org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent</value>
+        </property>
+        <property name="target">
+            <ref bean="portletEntityAccessImpl" />
+        </property>
+        <!--
+            <property name="preInterceptors">
+            <list>
+            <ref bean="portletEntityCachingAdvisor"/>
+            <ref bean="portletEntityRemoveFromCacheAdvisor"/>
+            </list>
+            </property>
+        -->
+        <property name="transactionAttributes">
+            <props>
+                <prop key="remove*">PROPAGATION_REQUIRED</prop>
+                <prop key="store*">PROPAGATION_REQUIRED,-org.apache.jetspeed.components.portletentity.PortletEntityNotStoredException</prop>
+                <prop key="*">PROPAGATION_SUPPORTS</prop>
+            </props>
+        </property>
+    </bean>
+    
+  <!-- Inject Portlet Entity Proxy into Portlet Entity impl -->
+  <bean id="injectEntityAccessProxy" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
+      <property name="targetObject"><ref bean="portletEntityAccessImpl"/></property>
+      <property name="targetMethod"><value>setEntityAccessProxy</value></property>
+      <property name="arguments">
+          <list>
+              <ref bean="org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent"/>
+          </list>
+      </property>
+  </bean>
+    
+</beans>



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