geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmil...@apache.org
Subject [10/10] geode-examples git commit: GEODE-2231 intermediate commit
Date Tue, 31 Jan 2017 00:43:14 GMT
GEODE-2231 intermediate commit

- added an EmployeeKey test class
- update start script to rename the jar file with revised repo
that versions the examples
- format with spotLess


Project: http://git-wip-us.apache.org/repos/asf/geode-examples/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode-examples/commit/7e4fb3fa
Tree: http://git-wip-us.apache.org/repos/asf/geode-examples/tree/7e4fb3fa
Diff: http://git-wip-us.apache.org/repos/asf/geode-examples/diff/7e4fb3fa

Branch: refs/heads/feature/GEODE-2231
Commit: 7e4fb3fa36272ab1a9891f47639759ac1a86a5d2
Parents: 0f98a40
Author: Karen Miller <kmiller@pivotal.io>
Authored: Mon Jan 30 16:39:34 2017 -0800
Committer: Karen Miller <kmiller@pivotal.io>
Committed: Mon Jan 30 16:39:34 2017 -0800

----------------------------------------------------------------------
 partitioned/README.md                           | 44 ++++++++++++++---
 partitioned/scripts/startAll.sh                 |  2 +-
 .../examples/partitioned/BadEmployeeKey.java    | 47 ++++++++----------
 .../geode/examples/partitioned/BaseClient.java  | 29 +++++------
 .../geode/examples/partitioned/Consumer.java    | 36 +++++++-------
 .../examples/partitioned/EmployeeData.java      | 48 ++++++++++--------
 .../geode/examples/partitioned/EmployeeKey.java | 38 ++++++--------
 .../geode/examples/partitioned/Producer.java    | 25 +++++-----
 .../examples/partitioned/ConsumerTest.java      | 27 +++++-----
 .../examples/partitioned/EmployeeKeyTest.java   | 52 ++++++++++++++++++++
 .../examples/partitioned/PartitionedTest.java   | 47 +++++++++---------
 .../examples/partitioned/ProducerTest.java      | 24 +++++----
 12 files changed, 244 insertions(+), 175 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode-examples/blob/7e4fb3fa/partitioned/README.md
----------------------------------------------------------------------
diff --git a/partitioned/README.md b/partitioned/README.md
index 9c091b9..d82e398 100644
--- a/partitioned/README.md
+++ b/partitioned/README.md
@@ -1,3 +1,20 @@
+<!--
+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.
+-->
+
 # Geode partitioned region example
 
 This basic example demonstrates the properties of a partitioned region. 
@@ -18,23 +35,34 @@ as well how to write tests using mocks for Geode applications.
 build the jar (with the EmployeeKey and EmployeeData classes),
 which is put onto the classpath when starting the servers:
 
-        $   ../gradlew -x rat build -x spotLessCheck -x test
+        $   ../gradlew build
 
 1. From the ```geode-examples/partitioned``` directory,
 run a script that starts a locator and two servers:
 
         $ scripts/startAll.sh
 
-    Each of the servers hosts the partitioned region called ```myRegion```.
+    Each of the servers hosts the partitioned region called ```EmployeeRegion```.
 
-2. Run the producer to put 50 entries into ```myRegion```:
+2. Run the producer to put 50 entries into ```EmployeeRegion```:
 
         $ ../gradlew run -Pmain=Producer
         ...
         ... 
         INFO: Done. Inserted 50 entries.
 
-3. Run the consumer to observe that there are 50 entries in ```myRegion```:
+    To see contents of the region keys, use a ```gfsh``` query:
+ 
+        $ $GEODE_HOME/bin/gfsh
+        ...
+        gfsh>connect
+        gfsh>query --query="select e.key from /EmployeeRegion.entries e"
+
+    or, to see contents of the region values, use a ```gfsh``` query:
+
+        gfsh>query --query="select * from /EmployeeRegion"
+
+3. Run the consumer to observe that there are 50 entries in ```EmployeeRegion```:
 
         $ ../gradlew run -Pmain=Consumer
         ...
@@ -46,9 +74,9 @@ run a script that starts a locator and two servers:
         $ $GEODE_HOME/bin/gfsh
         ...
         gfsh>connect
-        gfsh>describe region --name=myRegion
+        gfsh>describe region --name=EmployeeRegion
         ..........................................................
-        Name            : myRegion
+        Name            : EmployeeRegion
         Data Policy     : partition
         Hosting Members : server2
                           server1
@@ -83,9 +111,9 @@ the entries are still available:
         $ $GEODE_HOME/bin/gfsh
         ...
         gfsh>connect
-        gfsh>describe region --name=myRegion
+        gfsh>describe region --name=EmployeeRegion
         ..........................................................
-        Name            : myRegion
+        Name            : EmployeeRegion
         Data Policy     : partition
         Hosting Members : server2
 

http://git-wip-us.apache.org/repos/asf/geode-examples/blob/7e4fb3fa/partitioned/scripts/startAll.sh
----------------------------------------------------------------------
diff --git a/partitioned/scripts/startAll.sh b/partitioned/scripts/startAll.sh
index 7c72643..e3e6ab9 100755
--- a/partitioned/scripts/startAll.sh
+++ b/partitioned/scripts/startAll.sh
@@ -33,7 +33,7 @@ gfsh start locator --name=locator1 --mcast-port=0 --port=${GEODE_LOCATOR_PORT}
 # start 2 servers on a random available port
 for N in {1..2}
 do
- gfsh start server --locators=localhost[${GEODE_LOCATOR_PORT}] --name=server$N  --server-port=0
--mcast-port=0 --classpath=${PWD}/build/libs/partitioned.jar
+ gfsh start server --locators=localhost[${GEODE_LOCATOR_PORT}] --name=server$N  --server-port=0
--mcast-port=0 --classpath=${PWD}/build/libs/partitioned-0.1.0-SNAPSHOT.jar
 done
 
 # create a region using GFSH

http://git-wip-us.apache.org/repos/asf/geode-examples/blob/7e4fb3fa/partitioned/src/main/java/org/apache/geode/examples/partitioned/BadEmployeeKey.java
----------------------------------------------------------------------
diff --git a/partitioned/src/main/java/org/apache/geode/examples/partitioned/BadEmployeeKey.java
b/partitioned/src/main/java/org/apache/geode/examples/partitioned/BadEmployeeKey.java
index 2c83227..4aab20a 100644
--- a/partitioned/src/main/java/org/apache/geode/examples/partitioned/BadEmployeeKey.java
+++ b/partitioned/src/main/java/org/apache/geode/examples/partitioned/BadEmployeeKey.java
@@ -1,18 +1,16 @@
 /*
- * 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
+ * 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
+ * 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.
+ * 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.geode.examples.partitioned;
 
@@ -26,8 +24,7 @@ public class BadEmployeeKey implements Serializable {
   private String name;
   private int emplNumber;
 
-  public BadEmployeeKey() {
-  }
+  public BadEmployeeKey() {}
 
   public BadEmployeeKey(String n, int en) {
     this.name = n;
@@ -35,35 +32,33 @@ public class BadEmployeeKey implements Serializable {
   }
 
   public String getName() {
-    return(name);
+    return (name);
   }
 
   public int getEmplNumber() {
-    return(emplNumber);
+    return (emplNumber);
   }
 
   public boolean equals(EmployeeKey key) {
-    if ( this.name.equals(key.getName()) && 
-        this.emplNumber==key.getEmplNumber() ) {
+    if (this.name.equals(key.getName()) && this.emplNumber == key.getEmplNumber())
{
       return true;
     }
     return false;
   }
 
   /*
-   *  This hashCode is what make this class a very poor implementation.
-   *  It always returns the value 1, so that every key gets placed in
-   *  the same bucket, and partitioning is useless.
-   *  
-   *  Forgetting to define, or implementing an erroneous hashCode can result
-   *  in rotten distribution of region entries across buckets.
+   * This hashCode is what make this class a very poor implementation. It always returns
the value
+   * 1, so that every key gets placed in the same bucket, and partitioning is useless.
+   * 
+   * Forgetting to define, or implementing an erroneous hashCode can result in rotten distribution
+   * of region entries across buckets.
    */
   public int hashCode() {
-    return(1);
+    return (1);
   }
 
   public String toString() {
-    return("Name: " + this.name + " Employee Number: " + this.emplNumber);
+    return ("Name: " + this.name + " Employee Number: " + this.emplNumber);
   }
 
 }

http://git-wip-us.apache.org/repos/asf/geode-examples/blob/7e4fb3fa/partitioned/src/main/java/org/apache/geode/examples/partitioned/BaseClient.java
----------------------------------------------------------------------
diff --git a/partitioned/src/main/java/org/apache/geode/examples/partitioned/BaseClient.java
b/partitioned/src/main/java/org/apache/geode/examples/partitioned/BaseClient.java
index c4d0e63..cdf20e3 100644
--- a/partitioned/src/main/java/org/apache/geode/examples/partitioned/BaseClient.java
+++ b/partitioned/src/main/java/org/apache/geode/examples/partitioned/BaseClient.java
@@ -1,18 +1,16 @@
 /*
- * 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
+ * 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
+ * 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.
+ * 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.geode.examples.partitioned;
 
@@ -46,8 +44,8 @@ public abstract class BaseClient {
   protected Region getRegion() {
     if (region == null) {
       region = getClientCache()
-              .<EmployeeKey, EmployeeData>createClientRegionFactory(ClientRegionShortcut.PROXY)
-              .create(REGION_NAME);
+          .<EmployeeKey, EmployeeData>createClientRegionFactory(ClientRegionShortcut.PROXY)
+          .create(REGION_NAME);
     }
     return region;
   }
@@ -55,8 +53,7 @@ public abstract class BaseClient {
   protected ClientCache getClientCache() {
     if (clientCache == null) {
       clientCache = new ClientCacheFactory().addPoolLocator(locatorHost, locatorPort)
-              .set("log-level", "WARN")
-              .create();
+          .set("log-level", "WARN").create();
     }
     return clientCache;
   }

http://git-wip-us.apache.org/repos/asf/geode-examples/blob/7e4fb3fa/partitioned/src/main/java/org/apache/geode/examples/partitioned/Consumer.java
----------------------------------------------------------------------
diff --git a/partitioned/src/main/java/org/apache/geode/examples/partitioned/Consumer.java
b/partitioned/src/main/java/org/apache/geode/examples/partitioned/Consumer.java
index 6ea91df..352e695 100644
--- a/partitioned/src/main/java/org/apache/geode/examples/partitioned/Consumer.java
+++ b/partitioned/src/main/java/org/apache/geode/examples/partitioned/Consumer.java
@@ -1,18 +1,16 @@
 /*
- * 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
+ * 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
+ * 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.
+ * 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.geode.examples.partitioned;
 
@@ -27,8 +25,7 @@ public class Consumer extends BaseClient {
     c.printRegionContents();
   }
 
-  public Consumer() {
-  }
+  public Consumer() {}
 
   public Consumer(ClientCache clientCache) {
     this.clientCache = clientCache;
@@ -42,14 +39,17 @@ public class Consumer extends BaseClient {
 
   public void printRegionContents() {
     Set<EmployeeKey> setOfKeys = this.getRegion().keySetOnServer();
-    /* for each key in setOfKeys
-     *   print the entry
+    /*
+     * for each key in setOfKeys print the entry
      */
-    if (setOfKeys.equals(null)) {
-       logger.info("setOfKeys is a null reference");
+    if (setOfKeys == null) {
+      logger.info("setOfKeys is a null reference");
     }
     logger.info("Region contents:");
     for (EmployeeKey key : setOfKeys) {
+      if (this.getRegion().getEntry(key) == null ) {
+        logger.info("getEntry returned null");
+      }
       logger.info(this.getRegion().getEntry(key).toString());
     }
   }

http://git-wip-us.apache.org/repos/asf/geode-examples/blob/7e4fb3fa/partitioned/src/main/java/org/apache/geode/examples/partitioned/EmployeeData.java
----------------------------------------------------------------------
diff --git a/partitioned/src/main/java/org/apache/geode/examples/partitioned/EmployeeData.java
b/partitioned/src/main/java/org/apache/geode/examples/partitioned/EmployeeData.java
index b3f554f..6225e7a 100644
--- a/partitioned/src/main/java/org/apache/geode/examples/partitioned/EmployeeData.java
+++ b/partitioned/src/main/java/org/apache/geode/examples/partitioned/EmployeeData.java
@@ -1,18 +1,16 @@
 /*
- * 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
+ * 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
+ * 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.
+ * 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.geode.examples.partitioned;
 
@@ -26,8 +24,7 @@ public class EmployeeData implements Serializable {
   private int salary;
   private int hoursPerWeek;
 
-  public EmployeeData() {
-  }
+  public EmployeeData() {}
 
   public EmployeeData(EmployeeKey k, int s, int hrs) {
     this.nameAndNumber = k;
@@ -35,21 +32,32 @@ public class EmployeeData implements Serializable {
     this.hoursPerWeek = hrs;
   }
 
-  public EmployeeKey getEmployeeKey() {
-    return(nameAndNumber);
+  public EmployeeKey getNameAndNumber() {
+    return (nameAndNumber);
   }
 
   public int getSalary() {
-    return(salary);
+    return (salary);
   }
 
   public int getHoursPerWeek() {
-    return(hoursPerWeek);
+    return (hoursPerWeek);
+  }
+
+  public boolean equals(EmployeeData e) {
+    if (this.nameAndNumber.equals(e.getNameAndNumber()) && (this.salary == e.getSalary())
+        && (this.hoursPerWeek == e.getHoursPerWeek())) {
+      return true;
+    }
+    return false;
   }
 
   public String toString() {
-    return(this.nameAndNumber.toString() + " salary=" + this.salary +
-     " hoursPerWeek=" + this.hoursPerWeek);
+    return ("bogus EmployeeData string");
+    /*
+     * return (this.nameAndNumber.toString() + " salary=" + this.salary + " hoursPerWeek="
+
+     * this.hoursPerWeek);
+     */
   }
 
 }

http://git-wip-us.apache.org/repos/asf/geode-examples/blob/7e4fb3fa/partitioned/src/main/java/org/apache/geode/examples/partitioned/EmployeeKey.java
----------------------------------------------------------------------
diff --git a/partitioned/src/main/java/org/apache/geode/examples/partitioned/EmployeeKey.java
b/partitioned/src/main/java/org/apache/geode/examples/partitioned/EmployeeKey.java
index 5445967..cfa6224 100644
--- a/partitioned/src/main/java/org/apache/geode/examples/partitioned/EmployeeKey.java
+++ b/partitioned/src/main/java/org/apache/geode/examples/partitioned/EmployeeKey.java
@@ -1,18 +1,16 @@
 /*
- * 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
+ * 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
+ * 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.
+ * 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.geode.examples.partitioned;
 
@@ -26,8 +24,7 @@ public class EmployeeKey implements Serializable {
   private String name;
   private int emplNumber;
 
-  public EmployeeKey() {
-  }
+  public EmployeeKey() {}
 
   public EmployeeKey(String n, int en) {
     this.name = n;
@@ -35,16 +32,15 @@ public class EmployeeKey implements Serializable {
   }
 
   public String getName() {
-    return(name);
+    return (name);
   }
 
   public int getEmplNumber() {
-    return(emplNumber);
+    return (emplNumber);
   }
 
   public boolean equals(EmployeeKey key) {
-    if ( this.name.equals(key.getName()) && 
-        this.emplNumber==key.getEmplNumber() ) {
+    if (this.name.equals(key.getName()) && this.emplNumber == key.getEmplNumber())
{
       return true;
     }
     return false;
@@ -53,13 +49,11 @@ public class EmployeeKey implements Serializable {
   public int hashCode() {
     int nameHashValue = this.name.hashCode();
     int numHashValue = this.emplNumber;
-    logger.info("Key: name hash=" + nameHashValue + " num hash=" +
-      numHashValue);
-    return(nameHashValue + numHashValue);
+    return (nameHashValue + numHashValue);
   }
 
   public String toString() {
-    return("Name: " + this.name + " Employee Number: " + this.emplNumber);
+    return ("Name: " + this.name + " Employee Number: " + this.emplNumber);
   }
 
 }

http://git-wip-us.apache.org/repos/asf/geode-examples/blob/7e4fb3fa/partitioned/src/main/java/org/apache/geode/examples/partitioned/Producer.java
----------------------------------------------------------------------
diff --git a/partitioned/src/main/java/org/apache/geode/examples/partitioned/Producer.java
b/partitioned/src/main/java/org/apache/geode/examples/partitioned/Producer.java
index ac2b316..a645e59 100644
--- a/partitioned/src/main/java/org/apache/geode/examples/partitioned/Producer.java
+++ b/partitioned/src/main/java/org/apache/geode/examples/partitioned/Producer.java
@@ -1,18 +1,16 @@
 /*
- * 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
+ * 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
+ * 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.
+ * 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.geode.examples.partitioned;
 
@@ -25,8 +23,7 @@ public class Producer extends BaseClient {
     new Producer().populateRegion();
   }
 
-  public Producer() {
-  }
+  public Producer() {}
 
   public Producer(ClientCache clientCache) {
     this.clientCache = clientCache;

http://git-wip-us.apache.org/repos/asf/geode-examples/blob/7e4fb3fa/partitioned/src/test/java/org/apache/geode/examples/partitioned/ConsumerTest.java
----------------------------------------------------------------------
diff --git a/partitioned/src/test/java/org/apache/geode/examples/partitioned/ConsumerTest.java
b/partitioned/src/test/java/org/apache/geode/examples/partitioned/ConsumerTest.java
index e48f1ce..37a7842 100644
--- a/partitioned/src/test/java/org/apache/geode/examples/partitioned/ConsumerTest.java
+++ b/partitioned/src/test/java/org/apache/geode/examples/partitioned/ConsumerTest.java
@@ -1,18 +1,16 @@
 /*
- * 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
+ * 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
+ * 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.
+ * 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.geode.examples.partitioned;
@@ -62,10 +60,11 @@ public class ConsumerTest {
   }
 
   @Test
-  public void countingEntriesWithoutConnectionShouldThrowNoAvailableLocatorsException() throws
Exception {
+  public void countingEntriesWithoutConnectionShouldThrowNoAvailableLocatorsException()
+      throws Exception {
     consumer = new Consumer();
     expectedException.expect(NoAvailableLocatorsException.class);
     assertEquals(consumer.NUM_ENTRIES, consumer.countEntriesOnServer());
   }
 
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/geode-examples/blob/7e4fb3fa/partitioned/src/test/java/org/apache/geode/examples/partitioned/EmployeeKeyTest.java
----------------------------------------------------------------------
diff --git a/partitioned/src/test/java/org/apache/geode/examples/partitioned/EmployeeKeyTest.java
b/partitioned/src/test/java/org/apache/geode/examples/partitioned/EmployeeKeyTest.java
new file mode 100644
index 0000000..5001f8a
--- /dev/null
+++ b/partitioned/src/test/java/org/apache/geode/examples/partitioned/EmployeeKeyTest.java
@@ -0,0 +1,52 @@
+package org.apache.geode.examples.partitioned;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+/**
+ * Created by kmiller on 1/30/17.
+ */
+public class EmployeeKeyTest {
+
+  private EmployeeKey k;
+
+  @Rule
+  public ExpectedException expectedException = ExpectedException.none();
+
+  @Before
+  public void setup() {
+    k = new EmployeeKey("First Last", 3001);
+  }
+
+  @Test
+  public void testGetName() {
+    assertEquals("First Last", k.getName());
+  }
+
+  @Test
+  public void testGetEmplNumber() {
+    assertEquals(3001, k.getEmplNumber());
+  }
+
+  @Test
+  public void testEquals() {
+    EmployeeKey otherKey = new EmployeeKey("First Last", 3001);
+    assertTrue(k.equals(otherKey));
+    EmployeeKey nonMatchingKey = new EmployeeKey("Othername", 1);
+    assertFalse(k.equals(nonMatchingKey));
+  }
+
+  @Test
+  public void testHashCode() {
+    assertEquals(1773287935, k.hashCode());
+  }
+
+  @Test
+  public void testToString() {
+    assertEquals("Name: First Last Employee Number: 3001", k.toString());
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/geode-examples/blob/7e4fb3fa/partitioned/src/test/java/org/apache/geode/examples/partitioned/PartitionedTest.java
----------------------------------------------------------------------
diff --git a/partitioned/src/test/java/org/apache/geode/examples/partitioned/PartitionedTest.java
b/partitioned/src/test/java/org/apache/geode/examples/partitioned/PartitionedTest.java
index aa746a4..4d41a5b 100644
--- a/partitioned/src/test/java/org/apache/geode/examples/partitioned/PartitionedTest.java
+++ b/partitioned/src/test/java/org/apache/geode/examples/partitioned/PartitionedTest.java
@@ -1,18 +1,16 @@
 /*
- * 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
+ * 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
+ * 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.
+ * 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.geode.examples.partitioned;
 
@@ -43,7 +41,7 @@ import org.junit.rules.TemporaryFolder;
  */
 public class PartitionedTest {
 
-  //TODO: parameterize
+  // TODO: parameterize
   public static final String GEODE_LOCATOR_PORT = "GEODE_LOCATOR_PORT=";
   private static final String startScriptFileName = "startAll.sh";
   private static final String stopScriptFileName = "stopAll.sh";
@@ -72,7 +70,8 @@ public class PartitionedTest {
 
   @Test
   public void checkIfScriptsExistsAndAreExecutable() throws IOException {
-    assertTrue(shell.getFileFromClassLoader(startScriptFileName).map(x -> x.isFile()).orElse(false));
+    assertTrue(
+        shell.getFileFromClassLoader(startScriptFileName).map(x -> x.isFile()).orElse(false));
     assertTrue(shell.getFileFromClassLoader(stopScriptFileName).map(x -> x.isFile()).orElse(false));
   }
 
@@ -95,23 +94,24 @@ public class PartitionedTest {
 
   /**
    * Execute the kill script that looks for pid files
+   * 
    * @throws IOException
    * @throws InterruptedException
    */
   private void runKillScript() throws IOException, InterruptedException {
     CommandLine cmdLine = CommandLine.parse(shell.getFileFromClassLoader(pidkillerScriptFileName)
-                                                 .map(x -> x.getAbsolutePath())
-                                                 .orElseThrow(IllegalArgumentException::new));
+        .map(x -> x.getAbsolutePath()).orElseThrow(IllegalArgumentException::new));
     cmdLine.addArgument(testFolder.getRoot().getAbsolutePath());
 
-    DefaultExecuteResultHandler resultHandler = shell.execute(cmdLine, scriptTimeout, environment,
testFolder
-      .getRoot());
+    DefaultExecuteResultHandler resultHandler =
+        shell.execute(cmdLine, scriptTimeout, environment, testFolder.getRoot());
     resultHandler.waitFor(scriptTimeout);
   }
 
   /**
-   * Given a script file name, runs the script and return the exit code.
-   * If exitCode != 0 extract and prints exception.
+   * Given a script file name, runs the script and return the exit code. If exitCode != 0
extract
+   * and prints exception.
+   * 
    * @param scriptName
    * @return <code>int</code> with exitCode
    * @throws IOException
@@ -119,8 +119,8 @@ public class PartitionedTest {
    */
   private int executeScript(String scriptName) throws IOException, InterruptedException {
     final int exitCode;
-    DefaultExecuteResultHandler resultHandler = shell.execute(scriptName, scriptTimeout,
environment, testFolder
-      .getRoot());
+    DefaultExecuteResultHandler resultHandler =
+        shell.execute(scriptName, scriptTimeout, environment, testFolder.getRoot());
     processRunning = true;
     resultHandler.waitFor();
 
@@ -148,7 +148,8 @@ public class PartitionedTest {
 
   /**
    * Get a random available port
-   * @return <code>int</code>  port number
+   * 
+   * @return <code>int</code> port number
    */
   private static int getAvailablePort() {
     try (ServerSocket socket = new ServerSocket(0)) {

http://git-wip-us.apache.org/repos/asf/geode-examples/blob/7e4fb3fa/partitioned/src/test/java/org/apache/geode/examples/partitioned/ProducerTest.java
----------------------------------------------------------------------
diff --git a/partitioned/src/test/java/org/apache/geode/examples/partitioned/ProducerTest.java
b/partitioned/src/test/java/org/apache/geode/examples/partitioned/ProducerTest.java
index f654b2f..439f9c1 100644
--- a/partitioned/src/test/java/org/apache/geode/examples/partitioned/ProducerTest.java
+++ b/partitioned/src/test/java/org/apache/geode/examples/partitioned/ProducerTest.java
@@ -1,18 +1,16 @@
 /*
- * 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
+ * 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
+ * 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.
+ * 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.geode.examples.partitioned;
 
@@ -67,4 +65,4 @@ public class ProducerTest {
   public void tearDown() {
 
   }
-}
\ No newline at end of file
+}


Mime
View raw message