You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ud...@apache.org on 2017/08/24 00:02:33 UTC

geode git commit: GEODE-3503: fixed tests and reverted change to region_API.proto

Repository: geode
Updated Branches:
  refs/heads/feature/GEODE-3503 42eb4b926 -> 6ce005987


GEODE-3503: fixed tests and reverted change to region_API.proto


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

Branch: refs/heads/feature/GEODE-3503
Commit: 6ce00598757d5b30e7bd4df0f80098400066ed36
Parents: 42eb4b9
Author: Udo Kohlmeyer <uk...@pivotal.io>
Authored: Wed Aug 23 17:02:12 2017 -0700
Committer: Udo Kohlmeyer <uk...@pivotal.io>
Committed: Wed Aug 23 17:02:12 2017 -0700

----------------------------------------------------------------------
 geode-protobuf/src/main/proto/region_API.proto  |  1 -
 .../protocol/AuthenticationIntegrationTest.java | 26 ++++++-------
 .../RoundTripCacheConnectionJUnitTest.java      |  9 ++++-
 .../RoundTripLocatorConnectionJUnitTest.java    | 40 ++++++--------------
 .../serialization/codec/JSONCodecJUnitTest.java | 25 ++++++++++--
 .../registry/CodecRegistryJUnitTest.java        |  4 +-
 6 files changed, 54 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/6ce00598/geode-protobuf/src/main/proto/region_API.proto
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/proto/region_API.proto b/geode-protobuf/src/main/proto/region_API.proto
index 7900f5e..40bf882 100644
--- a/geode-protobuf/src/main/proto/region_API.proto
+++ b/geode-protobuf/src/main/proto/region_API.proto
@@ -58,7 +58,6 @@ message GetAllRequest {
 
 message GetAllResponse {
     repeated Entry entries = 1;
-    repeated KeyedErrorResponse failedKeys = 2;
 }
 
 message RemoveRequest {

http://git-wip-us.apache.org/repos/asf/geode/blob/6ce00598/geode-protobuf/src/test/java/org/apache/geode/protocol/AuthenticationIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/AuthenticationIntegrationTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/AuthenticationIntegrationTest.java
index f138538..df80c70 100644
--- a/geode-protobuf/src/test/java/org/apache/geode/protocol/AuthenticationIntegrationTest.java
+++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/AuthenticationIntegrationTest.java
@@ -17,6 +17,7 @@ package org.apache.geode.protocol;
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.server.CacheServer;
+import org.apache.geode.distributed.ConfigurationProperties;
 import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.management.internal.security.ResourceConstants;
@@ -57,16 +58,9 @@ public class AuthenticationIntegrationTest {
   @Rule
   public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
 
-  private Cache cache;
-  private int cacheServerPort;
-  private CacheServer cacheServer;
-  private Socket socket;
   private OutputStream outputStream;
-  private ProtobufSerializationService serializationService;
   private InputStream inputStream;
   private ProtobufProtocolSerializer protobufProtocolSerializer;
-  private Object securityPrincipal;
-  private SecurityManager mockSecurityManager;
 
   public void setUp(String authenticationMode)
       throws IOException, CodecAlreadyRegisteredForTypeException {
@@ -74,34 +68,36 @@ public class AuthenticationIntegrationTest {
     expectedAuthProperties.setProperty(ResourceConstants.USER_NAME, TEST_USERNAME);
     expectedAuthProperties.setProperty(ResourceConstants.PASSWORD, TEST_PASSWORD);
 
-    securityPrincipal = new Object();
-    mockSecurityManager = mock(SecurityManager.class);
+    Object securityPrincipal = new Object();
+    SecurityManager mockSecurityManager = mock(SecurityManager.class);
     when(mockSecurityManager.authenticate(expectedAuthProperties)).thenReturn(securityPrincipal);
     when(mockSecurityManager.authorize(same(securityPrincipal), any())).thenReturn(true);
 
     Properties properties = new Properties();
     CacheFactory cacheFactory = new CacheFactory(properties);
-    cacheFactory.set("mcast-port", "0"); // sometimes it isn't due to other tests.
+    cacheFactory.set(ConfigurationProperties.MCAST_PORT, "0"); // sometimes it isn't due to other
+                                                               // tests.
+    cacheFactory.set(ConfigurationProperties.USE_CLUSTER_CONFIGURATION, "false");
+    cacheFactory.set(ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION, "false");
 
     cacheFactory.setSecurityManager(mockSecurityManager);
-    cache = cacheFactory.create();
+    Cache cache = cacheFactory.create();
 
-    cacheServer = cache.addCacheServer();
-    cacheServerPort = AvailablePortHelper.getRandomAvailableTCPPort();
+    CacheServer cacheServer = cache.addCacheServer();
+    int cacheServerPort = AvailablePortHelper.getRandomAvailableTCPPort();
     cacheServer.setPort(cacheServerPort);
     cacheServer.start();
 
 
     System.setProperty("geode.feature-protobuf-protocol", "true");
     System.setProperty("geode.protocol-authentication-mode", authenticationMode);
-    socket = new Socket("localhost", cacheServerPort);
+    Socket socket = new Socket("localhost", cacheServerPort);
 
     Awaitility.await().atMost(5, TimeUnit.SECONDS).until(socket::isConnected);
     outputStream = socket.getOutputStream();
     inputStream = socket.getInputStream();
     outputStream.write(110);
 
-    serializationService = new ProtobufSerializationService();
     protobufProtocolSerializer = new ProtobufProtocolSerializer();
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/6ce00598/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripCacheConnectionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripCacheConnectionJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripCacheConnectionJUnitTest.java
index 12cc08b..ae8424d 100644
--- a/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripCacheConnectionJUnitTest.java
+++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripCacheConnectionJUnitTest.java
@@ -119,7 +119,14 @@ public class RoundTripCacheConnectionJUnitTest {
     }
 
     CacheFactory cacheFactory = new CacheFactory(properties);
-    cacheFactory.set("mcast-port", "0"); // sometimes it isn't due to other tests.
+    cacheFactory.set(ConfigurationProperties.MCAST_PORT, "0"); // sometimes it isn't due to other
+                                                               // tests.
+    cacheFactory.set(ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION, "false"); // sometimes it
+                                                                                     // isn't due to
+                                                                                     // other tests.
+    cacheFactory.set(ConfigurationProperties.USE_CLUSTER_CONFIGURATION, "false"); // sometimes it
+                                                                                  // isn't due to
+                                                                                  // other tests.
     cache = cacheFactory.create();
 
     CacheServer cacheServer = cache.addCacheServer();

http://git-wip-us.apache.org/repos/asf/geode/blob/6ce00598/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripLocatorConnectionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripLocatorConnectionJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripLocatorConnectionJUnitTest.java
index 14d8c44..b58268e 100644
--- a/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripLocatorConnectionJUnitTest.java
+++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripLocatorConnectionJUnitTest.java
@@ -15,33 +15,10 @@
 
 package org.apache.geode.protocol;
 
-import static org.apache.geode.distributed.ConfigurationProperties.DISABLE_AUTO_RECONNECT;
-import static org.apache.geode.distributed.ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION;
-import static org.apache.geode.distributed.ConfigurationProperties.ENABLE_NETWORK_PARTITION_DETECTION;
-import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
-import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
-import static org.apache.geode.distributed.ConfigurationProperties.MAX_WAIT_TIME_RECONNECT;
-import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
-import static org.apache.geode.distributed.ConfigurationProperties.MEMBER_TIMEOUT;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.net.Socket;
-import java.util.Properties;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.contrib.java.lang.system.RestoreSystemProperties;
-import org.junit.experimental.categories.Category;
 
 import org.apache.geode.cache.server.CacheServer;
 import org.apache.geode.distributed.Locator;
-import org.apache.geode.distributed.internal.InternalLocator;
-import org.apache.geode.internal.AvailablePort;
 import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.tier.sockets.AcceptorImpl;
 import org.apache.geode.protocol.exception.InvalidProtocolMessageException;
@@ -53,17 +30,22 @@ import org.apache.geode.protocol.protobuf.utilities.ProtobufRequestUtilities;
 import org.apache.geode.protocol.protobuf.utilities.ProtobufUtilities;
 import org.apache.geode.test.dunit.DistributedTestUtils;
 import org.apache.geode.test.dunit.Host;
-import org.apache.geode.test.dunit.LogWriterUtils;
-import org.apache.geode.test.dunit.VM;
 import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
 import org.apache.geode.test.junit.categories.DistributedTest;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.contrib.java.lang.system.RestoreSystemProperties;
+import org.junit.experimental.categories.Category;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.net.Socket;
 
 @Category(DistributedTest.class)
 public class RoundTripLocatorConnectionJUnitTest extends JUnit4CacheTestCase {
 
   private Socket socket;
-  private DataOutputStream dataOutputStream;
-  private Locator locator;
 
   @Rule
   public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
@@ -72,12 +54,12 @@ public class RoundTripLocatorConnectionJUnitTest extends JUnit4CacheTestCase {
   public void setup() throws IOException {
     Host host = Host.getHost(0);
     int locatorPort = DistributedTestUtils.getDUnitLocatorPort();
-    int cacheServer1Port = startCacheWithCacheServer();
+    startCacheWithCacheServer();
 
     Host.getLocator().invoke(() -> System.setProperty("geode.feature-protobuf-protocol", "true"));
 
     socket = new Socket(host.getHostName(), locatorPort);
-    dataOutputStream = new DataOutputStream(socket.getOutputStream());
+    DataOutputStream dataOutputStream = new DataOutputStream(socket.getOutputStream());
     dataOutputStream.writeInt(0);
     // Using the constant from AcceptorImpl to ensure that magic byte is the same
     dataOutputStream.writeByte(AcceptorImpl.PROTOBUF_CLIENT_SERVER_PROTOCOL);

http://git-wip-us.apache.org/repos/asf/geode/blob/6ce00598/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/JSONCodecJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/JSONCodecJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/JSONCodecJUnitTest.java
index ebd8ef6..ffdd744 100644
--- a/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/JSONCodecJUnitTest.java
+++ b/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/JSONCodecJUnitTest.java
@@ -1,3 +1,17 @@
+/*
+ * 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.geode.serialization.codec;
 
 import static java.util.Arrays.asList;
@@ -7,6 +21,8 @@ import static org.junit.Assert.assertNotNull;
 
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.distributed.ConfigurationProperties;
+import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.pdx.JSONFormatter;
 import org.apache.geode.pdx.PdxInstance;
@@ -50,7 +66,11 @@ public class JSONCodecJUnitTest {
 
   @Before
   public void setUp() throws Exception {
-    cache = new CacheFactory().create();
+    CacheFactory cacheFactory = new CacheFactory();
+    cacheFactory.set(ConfigurationProperties.MCAST_PORT, "0");
+    cacheFactory.set(ConfigurationProperties.USE_CLUSTER_CONFIGURATION, "false");
+    cacheFactory.set(ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION, "false");
+    cache = cacheFactory.create();
   }
 
   @After
@@ -62,9 +82,8 @@ public class JSONCodecJUnitTest {
 
   @Test
   public void testSimpleJSONEncode() throws Exception {
-    InternalCache cache = (InternalCache) new CacheFactory().create();
     PdxInstanceFactory pdxInstanceFactory =
-        cache.createPdxInstanceFactory(JSONFormatter.JSON_CLASSNAME, false);
+        ((GemFireCacheImpl) cache).createPdxInstanceFactory(JSONFormatter.JSON_CLASSNAME, false);
 
     pdxInstanceFactory.writeString("string", "someString");
     pdxInstanceFactory.writeBoolean("boolean", true);

http://git-wip-us.apache.org/repos/asf/geode/blob/6ce00598/geode-protobuf/src/test/java/org/apache/geode/serialization/registry/CodecRegistryJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/serialization/registry/CodecRegistryJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/serialization/registry/CodecRegistryJUnitTest.java
index 578d263..935c886 100644
--- a/geode-protobuf/src/test/java/org/apache/geode/serialization/registry/CodecRegistryJUnitTest.java
+++ b/geode-protobuf/src/test/java/org/apache/geode/serialization/registry/CodecRegistryJUnitTest.java
@@ -50,10 +50,10 @@ public class CodecRegistryJUnitTest {
 
   @Test
   public void testRegisterCodec() throws CodecAlreadyRegisteredForTypeException {
-    Assert.assertEquals(10, codecRegistry.getRegisteredCodecCount());
+    Assert.assertEquals(1, codecRegistry.getRegisteredCodecCount());
     SerializationType mockSerializationType = PowerMockito.mock(SerializationType.class);
     codecRegistry.register(mockSerializationType, new DummyTypeCodec());
-    Assert.assertEquals(11, codecRegistry.getRegisteredCodecCount());
+    Assert.assertEquals(2, codecRegistry.getRegisteredCodecCount());
   }
 
   @Test