rave-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfrank...@apache.org
Subject svn commit: r1128388 - in /incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave: exception/ portal/repository/ portal/service/ portal/web/tag/
Date Fri, 27 May 2011 16:44:40 GMT
Author: mfranklin
Date: Fri May 27 16:44:40 2011
New Revision: 1128388

URL: http://svn.apache.org/viewvc?rev=1128388&view=rev
Log:
Added unit tests; optomized imports

Added:
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/exception/
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/exception/NotSupportedExceptionTest.java
Modified:
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/repository/JpaWidgetRepositoryTest.java
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/service/RegionWidgetServiceTest.java
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/tag/RegionWidgetTagTest.java

Added: incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/exception/NotSupportedExceptionTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/exception/NotSupportedExceptionTest.java?rev=1128388&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/exception/NotSupportedExceptionTest.java
(added)
+++ incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/exception/NotSupportedExceptionTest.java
Fri May 27 16:44:40 2011
@@ -0,0 +1,69 @@
+/*
+ * 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.exception;
+
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
+
+/**
+ */
+public class NotSupportedExceptionTest {
+
+    private static final String MESSAGE = "MESSAGE";
+
+    @Test
+    public void defaultConstructor() {
+        try {
+            throw new NotSupportedException();
+        } catch (NotSupportedException e) {
+           assertThat(e.getMessage(), is(nullValue()));
+        }
+    }
+    @Test
+    public void stringConstructor() {
+        try {
+            throw new NotSupportedException(MESSAGE);
+        } catch (NotSupportedException e) {
+           assertThat(e.getMessage(), is(equalTo(MESSAGE)));
+        }
+    }
+    @Test
+    public void stringAndCauseConstructor() {
+        Throwable throwable = new RuntimeException();
+        try {
+            throw new NotSupportedException(MESSAGE, throwable);
+        } catch (NotSupportedException e) {
+           assertThat(e.getMessage(), is(equalTo(MESSAGE)));
+           assertThat(e.getCause(), is(sameInstance(throwable)));
+        }
+    }
+    @Test
+    public void causeConstructor() {
+        Throwable throwable = new RuntimeException(MESSAGE);
+        try {
+            throw new NotSupportedException(throwable);
+        } catch (NotSupportedException e) {
+           assertThat(e.getMessage(), is(equalTo(throwable.getClass().getCanonicalName()
+ ": " + MESSAGE)));
+           assertThat(e.getCause(), is(sameInstance(throwable)));
+        }
+    }
+}

Modified: incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/repository/JpaWidgetRepositoryTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/repository/JpaWidgetRepositoryTest.java?rev=1128388&r1=1128387&r2=1128388&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/repository/JpaWidgetRepositoryTest.java
(original)
+++ incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/repository/JpaWidgetRepositoryTest.java
Fri May 27 16:44:40 2011
@@ -29,10 +29,8 @@ import org.springframework.transaction.a
 
 import javax.persistence.EntityManager;
 import javax.persistence.PersistenceContext;
-
 import java.util.List;
 
-import static org.easymock.EasyMock.notNull;
 import static org.hamcrest.CoreMatchers.*;
 import static org.junit.Assert.assertThat;
 

Modified: incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/service/RegionWidgetServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/service/RegionWidgetServiceTest.java?rev=1128388&r1=1128387&r2=1128388&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/service/RegionWidgetServiceTest.java
(original)
+++ incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/service/RegionWidgetServiceTest.java
Fri May 27 16:44:40 2011
@@ -28,7 +28,10 @@ import org.hamcrest.CoreMatchers;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 import static org.easymock.EasyMock.*;
 import static org.junit.Assert.assertThat;

Modified: incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/tag/RegionWidgetTagTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/tag/RegionWidgetTagTest.java?rev=1128388&r1=1128387&r2=1128388&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/tag/RegionWidgetTagTest.java
(original)
+++ incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/tag/RegionWidgetTagTest.java
Fri May 27 16:44:40 2011
@@ -99,6 +99,32 @@ public class RegionWidgetTagTest {
         tag.doStartTag();
     }
 
+
+    @Test(expected = JspException.class)
+    public void doStartTag_IOException() throws JspException, IOException {
+
+        RegionWidget regionWidget = new RegionWidget();
+        Widget widget = new Widget();
+        regionWidget.setWidget(widget);
+        widget.setType("INVALID");
+
+        Set<String> strings = new HashSet<String>();
+        strings.add(WIDGET_TYPE);
+
+        expect(service.getSupportedWidgetTypes()).andReturn(strings);
+        replay(service);
+
+        JspWriter writer = createNiceMock(JspWriter.class);
+        writer.print(RENDERED);
+        expectLastCall().andThrow(new IOException());
+        replay(writer);
+
+        replay(pageContext);
+
+        tag.doStartTag();
+        tag.doStartTag();
+    }
+
     @Test(expected = JspException.class)
     public void doStartTag_unsupportedWidget() throws JspException {
         replay(pageContext);



Mime
View raw message