Revision: 8539
Author: [email protected]
Date: Fri Aug 13 10:45:41 2010
Log: Incorporated Ray's feedback on http://code.google.com/p/google-web-toolkit/source/detail?r=8533 Fixed the comment in RequestFactoryJreSuite and added a test to RecordKeyTest.

Patch by: amitmanjhi
Review by: rjrjr

Review at http://gwt-code-reviews.appspot.com/768801

http://code.google.com/p/google-web-toolkit/source/detail?r=8539

Added:
/trunk/user/test/com/google/gwt/requestfactory/client/impl/SimpleBazRecordImpl.java
Modified:
 /trunk/user/test/com/google/gwt/requestfactory/RequestFactoryJreSuite.java
/trunk/user/test/com/google/gwt/requestfactory/client/impl/RecordKeyTest.java

=======================================
--- /dev/null
+++ /trunk/user/test/com/google/gwt/requestfactory/client/impl/SimpleBazRecordImpl.java Fri Aug 13 10:45:41 2010
@@ -0,0 +1,72 @@
+/*
+ * 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 com.google.gwt.valuestore.shared.Property;
+import com.google.gwt.valuestore.shared.Record;
+import com.google.gwt.valuestore.shared.RecordChangedEvent;
+import com.google.gwt.valuestore.shared.WriteOperation;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Just a dummy class for testing purposes.
+ */
+public class SimpleBazRecordImpl extends RecordImpl {
+
+  /**
+   * The Schema class.
+   */
+  public static class MySchema extends RecordSchema<SimpleBazRecordImpl> {
+    private final Set<Property<?>> allProperties;
+    {
+      Set<Property<?>> set = new HashSet<Property<?>>();
+      set.addAll(super.allProperties());
+      allProperties = Collections.unmodifiableSet(set);
+    }
+
+    @Override
+    public Set<Property<?>> allProperties() {
+      return allProperties;
+    }
+
+    @Override
+ public SimpleBazRecordImpl create(RecordJsoImpl jso, boolean isFuture) {
+      return new SimpleBazRecordImpl(jso, isFuture);
+    }
+
+    @Override
+    public RecordChangedEvent<?, ?> createChangeEvent(Record record,
+        WriteOperation writeOperation) {
+      // ignore
+      return null;
+    }
+
+    @Override
+    public Class<? extends Record> getToken() {
+      // ignore
+      return null;
+    }
+  }
+
+ public static final RecordSchema<SimpleBazRecordImpl> SCHEMA = new MySchema();
+
+  private SimpleBazRecordImpl(RecordJsoImpl jso, boolean isFuture) {
+    super(jso, isFuture);
+  }
+}
=======================================
--- /trunk/user/test/com/google/gwt/requestfactory/RequestFactoryJreSuite.java Thu Aug 12 17:13:04 2010 +++ /trunk/user/test/com/google/gwt/requestfactory/RequestFactoryJreSuite.java Fri Aug 13 10:45:41 2010
@@ -23,7 +23,7 @@
 import junit.framework.TestSuite;

 /**
- * Suite of UiBinder tests that require the JRE.
+ * Suite of RequestFactory tests that require the JRE.
  */
 public class RequestFactoryJreSuite {
   public static Test suite() {
=======================================
--- /trunk/user/test/com/google/gwt/requestfactory/client/impl/RecordKeyTest.java Thu Aug 12 17:13:04 2010 +++ /trunk/user/test/com/google/gwt/requestfactory/client/impl/RecordKeyTest.java Fri Aug 13 10:45:41 2010
@@ -25,20 +25,25 @@
   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());
-
+
+    RecordKey newKey2 = new RecordKey(newKey1.id + 1, newKey1.schema,
+        newKey1.isFuture);
     assertFalse(newKey1.equals(newKey2));
     assertFalse(newKey1.hashCode() == newKey2.hashCode());
-
+
+    RecordKey newKey1NoSchema = new RecordKey(newKey1.id,
+        SimpleBazRecordImpl.SCHEMA, newKey1.isFuture);
+    assertFalse(newKey1.equals(newKey1NoSchema));
+    assertFalse(newKey1.hashCode() == newKey1NoSchema.hashCode());
+
+    RecordKey oldKey1 = new RecordKey(newKey1.id, newKey1.schema,
+        !newKey1.isFuture);
     assertFalse(newKey1.equals(oldKey1));
-    assertFalse(newKey1.hashCode() == newKey2.hashCode());
+    assertFalse(newKey1.hashCode() == oldKey1.hashCode());
   }
 }

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to