Fix the equals method for RecordKey. Forgot to make this change in the just
submitted patch. Added tests for it, and organized other tests in suites.
Patch by: amitmanjhi
Review by: rjrjr (tbr)
Review at http://gwt-code-reviews.appspot.com/766801
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@8533 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/requestfactory/client/impl/RecordKey.java b/user/src/com/google/gwt/requestfactory/client/impl/RecordKey.java
index 410089c..c860ae1 100644
--- a/user/src/com/google/gwt/requestfactory/client/impl/RecordKey.java
+++ b/user/src/com/google/gwt/requestfactory/client/impl/RecordKey.java
@@ -58,6 +58,9 @@
return false;
}
RecordKey other = (RecordKey) obj;
+ if (isFuture != other.isFuture) {
+ return false;
+ }
if (!id.equals(other.id)) {
return false;
}
diff --git a/user/test/com/google/gwt/app/AppJreSuite.java b/user/test/com/google/gwt/app/AppJreSuite.java
index da566a4..29a3bbf 100644
--- a/user/test/com/google/gwt/app/AppJreSuite.java
+++ b/user/test/com/google/gwt/app/AppJreSuite.java
@@ -15,6 +15,7 @@
*/
package com.google.gwt.app;
+import com.google.gwt.app.place.ActivityManagerTest;
import com.google.gwt.app.place.PlaceChangeRequestedEventTest;
import com.google.gwt.app.place.PlaceControllerTest;
@@ -27,6 +28,7 @@
public class AppJreSuite {
public static Test suite() {
TestSuite suite = new TestSuite("app package tests that require the JRE");
+ suite.addTestSuite(ActivityManagerTest.class);
suite.addTestSuite(PlaceControllerTest.class);
suite.addTestSuite(PlaceChangeRequestedEventTest.class);
return suite;
diff --git a/user/test/com/google/gwt/requestfactory/RequestFactoryJreSuite.java b/user/test/com/google/gwt/requestfactory/RequestFactoryJreSuite.java
new file mode 100644
index 0000000..b816af2
--- /dev/null
+++ b/user/test/com/google/gwt/requestfactory/RequestFactoryJreSuite.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed 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 com.google.gwt.requestfactory;
+
+import com.google.gwt.requestfactory.client.impl.RecordKeyTest;
+import com.google.gwt.requestfactory.server.JsonRequestProcessorTest;
+import com.google.gwt.requestfactory.server.ReflectionBasedOperationRegistryTest;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Suite of UiBinder tests that require the JRE.
+ */
+public class RequestFactoryJreSuite {
+ public static Test suite() {
+ TestSuite suite = new TestSuite("requestfactory package tests that require the JRE");
+ suite.addTestSuite(RecordKeyTest.class);
+ suite.addTestSuite(JsonRequestProcessorTest.class);
+ suite.addTestSuite(ReflectionBasedOperationRegistryTest.class);
+ return suite;
+ }
+}
diff --git a/user/test/com/google/gwt/requestfactory/RequestFactorySuite.java b/user/test/com/google/gwt/requestfactory/RequestFactorySuite.java
index 67a43c2..b3290ad 100644
--- a/user/test/com/google/gwt/requestfactory/RequestFactorySuite.java
+++ b/user/test/com/google/gwt/requestfactory/RequestFactorySuite.java
@@ -27,7 +27,7 @@
public class RequestFactorySuite {
public static Test suite() {
GWTTestSuite suite = new GWTTestSuite(
- "Test suite for all requestfactory code.");
+ "Test suite for requestfactory gwt code.");
suite.addTestSuite(RecordJsoImplTest.class);
suite.addTestSuite(DeltaValueStoreJsonImplTest.class);
return suite;
diff --git a/user/test/com/google/gwt/requestfactory/client/impl/RecordKeyTest.java b/user/test/com/google/gwt/requestfactory/client/impl/RecordKeyTest.java
new file mode 100644
index 0000000..6eaffa1
--- /dev/null
+++ b/user/test/com/google/gwt/requestfactory/client/impl/RecordKeyTest.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed 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 com.google.gwt.requestfactory.client.impl;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for {@link RecordJsoImpl}.
+ */
+public class RecordKeyTest extends TestCase {
+
+ public void testEquals() {
+ RecordKey newKey1 = new RecordKey(1L, SimpleFooRecordImpl.SCHEMA,
+ RequestFactoryJsonImpl.IS_FUTURE);
+ RecordKey newKey2 = new RecordKey(newKey1.id + 1, newKey1.schema,
+ newKey1.isFuture);
+ RecordKey oldKey1 = new RecordKey(newKey1.id, newKey1.schema,
+ !newKey1.isFuture);
+ RecordKey anotherNewKey1 = new RecordKey(newKey1.id, newKey1.schema,
+ newKey1.isFuture);
+
+ assertTrue(newKey1.equals(anotherNewKey1));
+ assertTrue(newKey1.hashCode() == anotherNewKey1.hashCode());
+
+ assertFalse(newKey1.equals(newKey2));
+ assertFalse(newKey1.hashCode() == newKey2.hashCode());
+
+ assertFalse(newKey1.equals(oldKey1));
+ assertFalse(newKey1.hashCode() == newKey2.hashCode());
+ }
+}