geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From u..@apache.org
Subject [2/3] geode git commit: GEODE-3503: fixed tests and reverted change to region_API.proto
Date Fri, 25 Aug 2017 17:08:05 GMT
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/cbe51bd1
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/cbe51bd1
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/cbe51bd1

Branch: refs/heads/develop
Commit: cbe51bd1a0ed32a7ea33f18d181e73bbb8a157fa
Parents: 51338e4
Author: Udo Kohlmeyer <ukohlmeyer@pivotal.io>
Authored: Wed Aug 23 17:02:12 2017 -0700
Committer: Udo Kohlmeyer <ukohlmeyer@pivotal.io>
Committed: Fri Aug 25 10:00:57 2017 -0700

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


http://git-wip-us.apache.org/repos/asf/geode/blob/cbe51bd1/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 d44d3dd..77a164b 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/cbe51bd1/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 afd5de1..122b8e3 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,11 +17,11 @@ 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.internal.AvailablePortHelper;
 import org.apache.geode.management.internal.security.ResourceConstants;
 import org.apache.geode.internal.protocol.protobuf.AuthenticationAPI;
 import org.apache.geode.internal.protocol.protobuf.ClientProtocol;
-import org.apache.geode.protocol.protobuf.ProtobufSerializationService;
 import org.apache.geode.internal.protocol.protobuf.RegionAPI;
 import org.apache.geode.protocol.protobuf.serializer.ProtobufProtocolSerializer;
 import org.apache.geode.security.SecurityManager;
@@ -56,16 +56,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 {
@@ -73,34 +66,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/cbe51bd1/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 a7d633e..91e839c 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
@@ -122,7 +122,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/cbe51bd1/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 019210b..7ee307b 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,31 +15,9 @@
 
 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.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.tier.sockets.AcceptorImpl;
 import org.apache.geode.protocol.exception.InvalidProtocolMessageException;
@@ -53,12 +31,20 @@ import org.apache.geode.test.dunit.DistributedTestUtils;
 import org.apache.geode.test.dunit.Host;
 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;
 
   @Rule
   public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
@@ -72,7 +58,7 @@ public class RoundTripLocatorConnectionJUnitTest extends JUnit4CacheTestCase
{
     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/cbe51bd1/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/cbe51bd1/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


Mime
View raw message