You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by ie...@apache.org on 2008/08/29 02:50:44 UTC

svn commit: r690063 - /incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/ResponseItemTest.java

Author: ieb
Date: Thu Aug 28 17:50:44 2008
New Revision: 690063

URL: http://svn.apache.org/viewvc?rev=690063&view=rev
Log:
Added some missing equality and hash code tests for ResponseItem.

Added:
    incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/ResponseItemTest.java

Added: incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/ResponseItemTest.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/ResponseItemTest.java?rev=690063&view=auto
==============================================================================
--- incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/ResponseItemTest.java (added)
+++ incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/ResponseItemTest.java Thu Aug 28 17:50:44 2008
@@ -0,0 +1,55 @@
+/*
+ * 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.shindig.social.opensocial.service;
+
+import org.apache.shindig.social.ResponseError;
+
+import org.junit.Test;
+
+import junit.framework.Assert;
+
+
+/**
+ * Tests Response Item equality methods.
+ */
+public class ResponseItemTest {
+  
+  @Test
+  public void testEquals() {
+    ResponseItem responseItem = new ResponseItem(ResponseError.BAD_REQUEST, "message1");
+    ResponseItem responseItemSame = new ResponseItem(ResponseError.BAD_REQUEST, "message1");
+    ResponseItem responseItemDifferent = new ResponseItem(ResponseError.FORBIDDEN, "message2");
+    ResponseItem simpleResponse = new ResponseItem("simple");
+    ResponseItem simpleResponseSame = new ResponseItem("simple");
+    ResponseItem simpleResponseDifferent = new ResponseItem("simpleDiffernt");
+    Assert.assertTrue(responseItem.hashCode() == responseItemSame.hashCode());
+    Assert.assertTrue(responseItem.equals(responseItem));
+    Assert.assertTrue(responseItem.equals(responseItemSame));
+    Assert.assertFalse(responseItem.hashCode() == responseItemDifferent.hashCode());
+    Assert.assertFalse(responseItem.equals(responseItemDifferent));
+    Assert.assertFalse(responseItem.equals(null));
+    Assert.assertFalse(responseItem.equals("A String"));
+    Assert.assertTrue(simpleResponse.hashCode() == simpleResponseSame.hashCode());
+    Assert.assertTrue(simpleResponse.equals(simpleResponse));
+    Assert.assertTrue(simpleResponse.equals(simpleResponseSame));
+    Assert.assertFalse(simpleResponse.hashCode() == simpleResponseDifferent.hashCode());
+    Assert.assertFalse(simpleResponse.equals(simpleResponseDifferent));
+    Assert.assertFalse(simpleResponse.equals(null));
+    Assert.assertFalse(simpleResponse.equals("A String"));
+  }
+}