You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ma...@apache.org on 2015/10/21 22:33:13 UTC
incubator-geode git commit: [GEODE-409] - Fixing
CacheXml41DUnitTest.testBridgeServers test by using InetSocketAddress
ephemeral port set to 0 and changing the cacheServer comparison to ignore
port check if it's configured to 0.
Repository: incubator-geode
Updated Branches:
refs/heads/feature/GEODE-409 25bce9646 -> e792e29d1
[GEODE-409] - Fixing CacheXml41DUnitTest.testBridgeServers test by using
InetSocketAddress ephemeral port set to 0 and changing the cacheServer comparison
to ignore port check if it's configured to 0.
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/e792e29d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/e792e29d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/e792e29d
Branch: refs/heads/feature/GEODE-409
Commit: e792e29d1d3a5d5414a9fc976182d6ec23aa0fc1
Parents: 25bce96
Author: William Markito <wm...@pivotal.io>
Authored: Wed Oct 21 13:30:10 2015 -0700
Committer: William Markito <wm...@pivotal.io>
Committed: Wed Oct 21 13:32:50 2015 -0700
----------------------------------------------------------------------
.../cache/xmlcache/CacheServerCreation.java | 24 ++++++++++++++------
.../gemfire/cache30/CacheXml40DUnitTest.java | 16 +++++++++----
2 files changed, 28 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e792e29d/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheServerCreation.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheServerCreation.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheServerCreation.java
index d961d14..d555798 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheServerCreation.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheServerCreation.java
@@ -7,11 +7,6 @@
*/
package com.gemstone.gemfire.internal.cache.xmlcache;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Set;
-
-import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.ClientSession;
import com.gemstone.gemfire.cache.InterestRegistrationListener;
import com.gemstone.gemfire.cache.server.CacheServer;
@@ -21,6 +16,10 @@ import com.gemstone.gemfire.internal.cache.AbstractCacheServer;
import com.gemstone.gemfire.internal.cache.InternalCache;
import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Set;
+
/**
* Represents a {@link CacheServer} that is created declaratively.
*
@@ -166,8 +165,7 @@ public class CacheServerCreation extends AbstractCacheServer {
public boolean sameAs(CacheServer other) {
ClientSubscriptionConfig cscThis = this.getClientSubscriptionConfig();
ClientSubscriptionConfig cscOther = other.getClientSubscriptionConfig();
- boolean result =
- this.getPort() == other.getPort() &&
+ boolean result = isCacheServerPortEquals(other) &&
this.getSocketBufferSize() == other.getSocketBufferSize() &&
this.getMaximumTimeBetweenPings() == other.getMaximumTimeBetweenPings() &&
this.getNotifyBySubscription() == other.getNotifyBySubscription() &&
@@ -187,6 +185,18 @@ public class CacheServerCreation extends AbstractCacheServer {
return result;
}
+ /**
+ * Compare configured cacheServer port against the running cacheServer port.
+ * If the current cacheServer port is set to 0 a random ephemeral
+ * port will be used so there is no need to compare returning <code>true</code>.
+ * If a port is specified, return the proper comparison.
+ * @param other CacheServer
+ * @return
+ */
+ private boolean isCacheServerPortEquals(CacheServer other) {
+ return (this.getPort() == 0) ? true : this.getPort() == other.getPort();
+ }
+
@Override
public String toString()
{
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e792e29d/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/CacheXml40DUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/CacheXml40DUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/CacheXml40DUnitTest.java
index acaf91a..49b6149 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/CacheXml40DUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/CacheXml40DUnitTest.java
@@ -7,10 +7,14 @@
*/
package com.gemstone.gemfire.cache30;
-import com.gemstone.gemfire.cache.*;
+import com.gemstone.gemfire.cache.CacheException;
+import com.gemstone.gemfire.cache.MirrorType;
+import com.gemstone.gemfire.cache.Scope;
import com.gemstone.gemfire.cache.server.CacheServer;
-import com.gemstone.gemfire.internal.AvailablePortHelper;
-import com.gemstone.gemfire.internal.cache.xmlcache.*;
+import com.gemstone.gemfire.internal.cache.xmlcache.CacheCreation;
+import com.gemstone.gemfire.internal.cache.xmlcache.CacheTransactionManagerCreation;
+import com.gemstone.gemfire.internal.cache.xmlcache.CacheXml;
+import com.gemstone.gemfire.internal.cache.xmlcache.RegionAttributesCreation;
/**
* Tests the declarative caching functionality introduced in GemFire
@@ -58,8 +62,9 @@ public class CacheXml40DUnitTest extends CacheXml30DUnitTest {
CacheServer bridge1 = cache.addCacheServer();
setBridgeAttributes(bridge1);
+
CacheServer bridge2 = cache.addCacheServer();
- bridge2.setPort(AvailablePortHelper.getRandomAvailableTCPPort());
+ setBridgeAttributes(bridge2);
testXml(cache);
}
@@ -70,7 +75,8 @@ public class CacheXml40DUnitTest extends CacheXml30DUnitTest {
*/
public void setBridgeAttributes(CacheServer bridge1)
{
- bridge1.setPort(AvailablePortHelper.getRandomAvailableTCPPort());
+ //@see http://docs.oracle.com/javase/7/docs/api/java/net/InetSocketAddress.html#InetSocketAddress(int)
+ bridge1.setPort(0);
}
/**