Repository: geode Updated Branches: refs/heads/feature/GEODE-3027 6f2b73823 -> d039aeb61
spotless Project: http://git-wip-us.apache.org/repos/asf/geode/repo Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/d039aeb6 Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/d039aeb6 Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/d039aeb6 Branch: refs/heads/feature/GEODE-3027 Commit: d039aeb614c52fca7837f72f87d9792b85179ac4 Parents: 6f2b738 Author: Darrel Schneider <[email protected]> Authored: Mon Jun 5 17:32:10 2017 -0700 Committer: Darrel Schneider <[email protected]> Committed: Mon Jun 5 17:32:10 2017 -0700 ---------------------------------------------------------------------- .../cache/StringPrefixPartitionResolver.java | 48 +++++++++----------- .../StringPrefixPartitionResolverJUnitTest.java | 41 ++++++++++------- 2 files changed, 46 insertions(+), 43 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/geode/blob/d039aeb6/geode-core/src/main/java/org/apache/geode/cache/StringPrefixPartitionResolver.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/cache/StringPrefixPartitionResolver.java b/geode-core/src/main/java/org/apache/geode/cache/StringPrefixPartitionResolver.java index 3093788..8171b81 100644 --- a/geode-core/src/main/java/org/apache/geode/cache/StringPrefixPartitionResolver.java +++ b/geode-core/src/main/java/org/apache/geode/cache/StringPrefixPartitionResolver.java @@ -1,46 +1,42 @@ /* - * 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.cache; /** - * This partition resolver requires every key of the partitioned region - * to be an instance of String and to contain at least one ":" delimiter. - * The prefix, the substring of the key that precedes the first delimiter, - * is returned by getRoutingObject. + * This partition resolver requires every key of the partitioned region to be an instance of String + * and to contain at least one ":" delimiter. The prefix, the substring of the key that precedes the + * first delimiter, is returned by getRoutingObject. * * @since Geode 1.2.0 */ public class StringPrefixPartitionResolver implements PartitionResolver<String, Object> { /** - * The default delimiter is ":". - * Currently this class only uses the default delimiter - * but in a future release configuring the delimiter may - * be supported. + * The default delimiter is ":". Currently this class only uses the default delimiter but in a + * future release configuring the delimiter may be supported. */ public static final String DEFAULT_DELIMITER = ":"; + /** * Creates a prefix resolver with the default delimiter. */ - public StringPrefixPartitionResolver() { - } + public StringPrefixPartitionResolver() {} /** * Returns the prefix of the String key that precedes the first ":" in the key. + * * @throws ClassCastException if the key is not an instance of String * @throws IllegalArgumentException if the key does not contain at least one ":". */ @@ -50,7 +46,8 @@ public class StringPrefixPartitionResolver implements PartitionResolver<String, String delimiter = getDelimiter(); int idx = key.indexOf(delimiter); if (idx == -1) { - throw new IllegalArgumentException("The key \"" + key + "\" does not contains the \"" + delimiter + "\" delimiter."); + throw new IllegalArgumentException( + "The key \"" + key + "\" does not contains the \"" + delimiter + "\" delimiter."); } return key.substring(0, idx); } @@ -75,8 +72,7 @@ public class StringPrefixPartitionResolver implements PartitionResolver<String, StringPrefixPartitionResolver other = (StringPrefixPartitionResolver) o; return other.getName().equals(getName()); } - + @Override - public void close() { - } + public void close() {} } http://git-wip-us.apache.org/repos/asf/geode/blob/d039aeb6/geode-core/src/test/java/org/apache/geode/cache/StringPrefixPartitionResolverJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/cache/StringPrefixPartitionResolverJUnitTest.java b/geode-core/src/test/java/org/apache/geode/cache/StringPrefixPartitionResolverJUnitTest.java index 6aa6c4a..feca54c 100644 --- a/geode-core/src/test/java/org/apache/geode/cache/StringPrefixPartitionResolverJUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/cache/StringPrefixPartitionResolverJUnitTest.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.cache; @@ -30,8 +28,10 @@ public class StringPrefixPartitionResolverJUnitTest { @Test public void testGetName() { - assertEquals("org.apache.geode.cache.StringPrefixPartitionResolver:", (new StringPrefixPartitionResolver()).getName()); + assertEquals("org.apache.geode.cache.StringPrefixPartitionResolver:", + (new StringPrefixPartitionResolver()).getName()); } + @Test public void testEquals() { StringPrefixPartitionResolver pr1 = new StringPrefixPartitionResolver(); @@ -40,22 +40,25 @@ public class StringPrefixPartitionResolverJUnitTest { assertEquals(true, pr1.equals(pr2)); assertEquals(false, pr1.equals(new Object())); } - + @Test public void testNonStringKey() { @SuppressWarnings("unchecked") - EntryOperation<String, Object> eo = new EntryOperationImpl(null, null, new Object(), null, null); + EntryOperation<String, Object> eo = + new EntryOperationImpl(null, null, new Object(), null, null); StringPrefixPartitionResolver pr = new StringPrefixPartitionResolver(); assertThatThrownBy(() -> pr.getRoutingObject(eo)).isInstanceOf(ClassCastException.class); } + @Test public void testNoDelimiterKey() { @SuppressWarnings("unchecked") EntryOperation<String, Object> eo = new EntryOperationImpl(null, null, "foobar", null, null); StringPrefixPartitionResolver pr = new StringPrefixPartitionResolver(); assertThatThrownBy(() -> pr.getRoutingObject(eo)).isInstanceOf(IllegalArgumentException.class) - .hasMessage("The key \"foobar\" does not contains the \":\" delimiter."); + .hasMessage("The key \"foobar\" does not contains the \":\" delimiter."); } + @Test public void testEmptyPrefix() { @SuppressWarnings("unchecked") @@ -63,6 +66,7 @@ public class StringPrefixPartitionResolverJUnitTest { StringPrefixPartitionResolver pr = new StringPrefixPartitionResolver(); assertEquals("", pr.getRoutingObject(eo)); } + @Test public void testAllPrefix() { @SuppressWarnings("unchecked") @@ -70,6 +74,7 @@ public class StringPrefixPartitionResolverJUnitTest { StringPrefixPartitionResolver pr = new StringPrefixPartitionResolver(); assertEquals("foobar", pr.getRoutingObject(eo)); } + @Test public void testSimpleKey() { @SuppressWarnings("unchecked") @@ -77,10 +82,12 @@ public class StringPrefixPartitionResolverJUnitTest { StringPrefixPartitionResolver pr = new StringPrefixPartitionResolver(); assertEquals("1", pr.getRoutingObject(eo)); } + @Test public void testMulitPrefix() { @SuppressWarnings("unchecked") - EntryOperation<String, Object> eo = new EntryOperationImpl(null, null, "one:two:three", null, null); + EntryOperation<String, Object> eo = + new EntryOperationImpl(null, null, "one:two:three", null, null); StringPrefixPartitionResolver pr = new StringPrefixPartitionResolver(); assertEquals("one", pr.getRoutingObject(eo)); }
