You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rave.apache.org by ca...@apache.org on 2012/02/17 22:23:52 UTC

svn commit: r1245766 - in /incubator/rave/trunk/rave-components/rave-web/src/test: java/org/apache/rave/portal/web/context/ resources/

Author: carlucci
Date: Fri Feb 17 21:23:51 2012
New Revision: 1245766

URL: http://svn.apache.org/viewvc?rev=1245766&view=rev
Log:
RAVE-471: test coverage

Added:
    incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/context/
    incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/context/RaveContextLoaderListenerTest.java
    incubator/rave/trunk/rave-components/rave-web/src/test/resources/portal.properties
    incubator/rave/trunk/rave-components/rave-web/src/test/resources/test-applicationContext.xml

Added: incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/context/RaveContextLoaderListenerTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/context/RaveContextLoaderListenerTest.java?rev=1245766&view=auto
==============================================================================
--- incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/context/RaveContextLoaderListenerTest.java (added)
+++ incubator/rave/trunk/rave-components/rave-web/src/test/java/org/apache/rave/portal/web/context/RaveContextLoaderListenerTest.java Fri Feb 17 21:23:51 2012
@@ -0,0 +1,53 @@
+/*
+ * 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.rave.portal.web.context;
+
+
+import org.junit.*;
+import static org.junit.Assert.*;
+import static org.hamcrest.CoreMatchers.*;
+import org.springframework.mock.web.MockServletContext;
+
+import javax.servlet.ServletContextEvent;
+import java.util.Map;
+
+public class RaveContextLoaderListenerTest {
+    private MockServletContext mockServletContext;
+    private ServletContextEvent servletContextEvent;
+    private RaveContextLoaderListener raveContextLoaderListener;
+
+    @Before
+    public void setup() {
+        mockServletContext = new MockServletContext("test");
+        mockServletContext.addInitParameter("contextConfigLocation", "../test-applicationContext.xml");
+        servletContextEvent = new ServletContextEvent(mockServletContext);
+
+        raveContextLoaderListener = new RaveContextLoaderListener();
+    }
+
+    @Test
+    public void contextInitialized() {
+        raveContextLoaderListener.contextInitialized(servletContextEvent);
+
+        Map<String, String> props = (Map<String, String>) servletContextEvent.getServletContext().getAttribute("applicationProperties");
+        assertThat(props.size(), is(2));
+        assertThat(props.get("portal.testprop1"), is("hello"));
+        assertThat(props.get("portal.testprop2"), is("goodbye"));
+    }
+}
\ No newline at end of file

Added: incubator/rave/trunk/rave-components/rave-web/src/test/resources/portal.properties
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-web/src/test/resources/portal.properties?rev=1245766&view=auto
==============================================================================
--- incubator/rave/trunk/rave-components/rave-web/src/test/resources/portal.properties (added)
+++ incubator/rave/trunk/rave-components/rave-web/src/test/resources/portal.properties Fri Feb 17 21:23:51 2012
@@ -0,0 +1,21 @@
+#
+# 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.
+#
+
+portal.testprop1=hello
+portal.testprop2=goodbye
\ No newline at end of file

Added: incubator/rave/trunk/rave-components/rave-web/src/test/resources/test-applicationContext.xml
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-web/src/test/resources/test-applicationContext.xml?rev=1245766&view=auto
==============================================================================
--- incubator/rave/trunk/rave-components/rave-web/src/test/resources/test-applicationContext.xml (added)
+++ incubator/rave/trunk/rave-components/rave-web/src/test/resources/test-applicationContext.xml Fri Feb 17 21:23:51 2012
@@ -0,0 +1,30 @@
+<!--
+  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 xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
+
+    <bean id="portalPropertyPlaceholder" class="org.apache.rave.util.OverridablePropertyPlaceholderConfigurer">
+        <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
+        <property name="systemPropertyName" value="portal.override.properties"/>
+        <property name="location" value="classpath:portal.properties"/>
+    </bean>
+
+</beans>
\ No newline at end of file