This is an automated email from the ASF dual-hosted git repository.
bbender pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-native.git
The following commit(s) were added to refs/heads/develop by this push:
new 3d733d2 GEODE-5746: deflakify cli integration test2 (#380)
3d733d2 is described below
commit 3d733d2bc1e86d201ba6cab41262f5e7e1ab4348
Author: Blake Bender <[email protected]>
AuthorDate: Fri Oct 19 08:51:12 2018 -0700
GEODE-5746: deflakify cli integration test2 (#380)
- Refactor C# test framework to look like C++ framework
- Pay attention to gfsh exit codes and fail on non-zero exit
- Ensure all tests create their own jmx manager, and test exit gets rid of
all java instances
- verify all tests run properly in parallel
Co-authored-by: Ivan Godwin <[email protected]>
Co-authored-by: Ernest Burghardt <[email protected]>
---
clicache/integration-test2/CMakeLists.txt | 10 +-
clicache/integration-test2/CacheXml.cs | 6 +-
clicache/integration-test2/CacheXmlTests.cs | 100 ++-
clicache/integration-test2/Cluster.cs | 257 ++++++
clicache/integration-test2/ClusterTest.cs | 62 ++
clicache/integration-test2/Command.cs | 17 +
clicache/integration-test2/CqOperationTest.cs | 282 +++----
clicache/integration-test2/GeodeServer.cs | 225 ------
clicache/integration-test2/Gfsh.cs | 451 +++++++++++
clicache/integration-test2/GfshExecute.cs | 156 ++++
clicache/integration-test2/GfshExecuteTest.cs | 276 +++++++
clicache/integration-test2/GfshTest.cs | 247 ++++++
clicache/integration-test2/RegionSSLTest.cs | 109 +--
clicache/integration-test2/RegionTest.cs | 85 +-
clicache/integration-test2/SerializationTests.cs | 872 ++++++++++-----------
.../{GeodeServerTests.cs => TestBase.cs} | 40 +-
clicache/integration-test2/server.xml | 26 -
clicache/integration-test2/xunit.runner.json | 4 +-
clicache/test2/xunit.runner.json | 7 +-
cppcache/integration-test-2/framework/Cluster.cpp | 4 +-
cppcache/integration-test-2/framework/Cluster.h | 8 +-
.../cli/InstantiateDataSerializable.java | 51 ++
22 files changed, 2313 insertions(+), 982 deletions(-)
diff --git a/clicache/integration-test2/CMakeLists.txt
b/clicache/integration-test2/CMakeLists.txt
index 46a4891..f555ef1 100644
--- a/clicache/integration-test2/CMakeLists.txt
+++ b/clicache/integration-test2/CMakeLists.txt
@@ -27,18 +27,22 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/packages.config
${CMAKE_CURRENT_BINAR
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cs.in
${CMAKE_CURRENT_BINARY_DIR}/Config.cs)
add_library( ${PROJECT_NAME} SHARED
+ Cluster.cs
+ ClusterTest.cs
Config.cs.in
${CMAKE_CURRENT_BINARY_DIR}/Config.cs
- GeodeServer.cs
- GeodeServerTests.cs
+ GfshTest.cs
+ GfshExecuteTest.cs
+ Gfsh.cs
+ GfshExecute.cs
CacheXml.cs
CacheXmlTests.cs
CqOperationTest.cs
RegionTest.cs
RegionSSLTest.cs
Position.cs
+ TestBase.cs
cache.xml
- server.xml
geode.properties
xunit.runner.json
packages.config
diff --git a/clicache/integration-test2/CacheXml.cs
b/clicache/integration-test2/CacheXml.cs
index 9d0f278..91dc032 100644
--- a/clicache/integration-test2/CacheXml.cs
+++ b/clicache/integration-test2/CacheXml.cs
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
using System;
using System.IO;
using System.Diagnostics;
@@ -27,7 +27,7 @@ public class CacheXml : IDisposable
private set;
}
- public CacheXml(FileInfo template, GeodeServer gfs, string regionName =
"testRegion")
+ public CacheXml(FileInfo template, int locatorPort, string regionName =
"testRegion")
{
string content;
@@ -36,7 +36,7 @@ public class CacheXml : IDisposable
content = input.ReadToEnd();
}
- content = content.Replace("LOCATOR_PORT", gfs.LocatorPort.ToString());
+ content = content.Replace("LOCATOR_PORT", locatorPort.ToString());
content = content.Replace("REGION_NAME", regionName);
Debug.WriteLine(content);
diff --git a/clicache/integration-test2/CacheXmlTests.cs
b/clicache/integration-test2/CacheXmlTests.cs
index 3ab291a..4315d69 100644
--- a/clicache/integration-test2/CacheXmlTests.cs
+++ b/clicache/integration-test2/CacheXmlTests.cs
@@ -19,48 +19,86 @@ using System.IO;
using System.Threading;
using Xunit;
-[Trait("Category", "Integration")]
-public class CacheXmlTests
+namespace Apache.Geode.Client.IntegrationTests
{
- [Fact]
- public void ConstructAndGenerate()
+
+ [Trait("Category", "Integration")]
+ public class CacheXmlTests : TestBase
{
- using (var gfs = new GeodeServer())
+ [Fact]
+ public void ConstructAndGenerate()
{
- var template = new FileInfo("cache.xml");
- var cacheXml = new CacheXml(template, gfs);
- Assert.NotNull(cacheXml.File);
- Assert.True(cacheXml.File.Exists);
-
- using (var input = cacheXml.File.OpenText())
+ using (var gfsh = new GfshExecute())
{
- var content = input.ReadToEnd();
- Assert.True(content.Contains(gfs.LocatorPort.ToString()));
+ try
+ {
+ string testDir = CreateTestCaseDirectoryName();
+ CleanTestCaseDirectory(testDir);
+
+ Assert.Equal(gfsh.start()
+ .locator()
+ .withDir(testDir)
+ .withHttpServicePort(0)
+ .execute(), 0);
+ var template = new FileInfo("cache.xml");
+ var cacheXml = new CacheXml(template, gfsh.LocatorPort);
+ Assert.NotNull(cacheXml.File);
+ Assert.True(cacheXml.File.Exists);
+
+ using (var input = cacheXml.File.OpenText())
+ {
+ var content = input.ReadToEnd();
+
Assert.True(content.Contains(gfsh.LocatorPort.ToString()));
+ }
+ }
+ finally
+ {
+ Assert.Equal(gfsh.shutdown()
+ .withIncludeLocators(true)
+ .execute(), 0);
+ }
}
}
- }
- [Fact]
- public void DisposeAndCleanup()
- {
- using (var gfs = new GeodeServer())
+ [Fact]
+ public void DisposeAndCleanup()
{
- FileInfo file;
-
- var template = new FileInfo("cache.xml");
- using (var cacheXml = new CacheXml(template, gfs))
+ using (var gfsh = new GfshExecute())
{
- Assert.NotNull(cacheXml.File);
- file = cacheXml.File;
- Assert.True(file.Exists);
- }
+ try
+ {
+ var testDir = CreateTestCaseDirectoryName();
+ CleanTestCaseDirectory(testDir);
+
+ Assert.Equal(gfsh.start()
+ .locator()
+ .withDir(testDir)
+ .withHttpServicePort(0)
+ .execute(), 0);
+ FileInfo file;
- file.Refresh();
+ var template = new FileInfo("cache.xml");
+ using (var cacheXml = new CacheXml(template,
gfsh.LocatorPort))
+ {
+ Assert.NotNull(cacheXml.File);
+ file = cacheXml.File;
+ Assert.True(file.Exists);
+ }
- // File deletion via File.Delete (inside the file.Refresh() call)
- // is not synchronous so we need to potentially wait until the
file
- // has been deleted here
- Assert.True(SpinWait.SpinUntil(() => !file.Exists, 10000));
+ file.Refresh();
+
+ // File deletion via File.Delete (inside the
file.Refresh() call)
+ // is not synchronous so we need to potentially wait until
the file
+ // has been deleted here
+ Assert.True(SpinWait.SpinUntil(() => !file.Exists, 10000));
+ }
+ finally
+ {
+ Assert.Equal(gfsh.shutdown()
+ .withIncludeLocators(true)
+ .execute(), 0);
+ }
+ }
}
}
}
diff --git a/clicache/integration-test2/Cluster.cs
b/clicache/integration-test2/Cluster.cs
new file mode 100644
index 0000000..5b5a442
--- /dev/null
+++ b/clicache/integration-test2/Cluster.cs
@@ -0,0 +1,257 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Net;
+using System.IO;
+using System.Net.Sockets;
+using Xunit;
+
+namespace Apache.Geode.Client.IntegrationTests
+{
+ public class Cluster : IDisposable
+ {
+ private int locatorCount_;
+ private int serverCount_;
+ private bool started_;
+ private List<Locator> locators_;
+ private List<Server> servers_;
+ private string name_;
+ private bool usessl_;
+
+ public Gfsh Gfsh { get; private set; }
+
+ private const string sslPassword_ = "gemstone";
+
+ public bool UseSSL
+ {
+ get
+ {
+ return usessl_;
+ }
+ set
+ {
+ usessl_ = value;
+ Gfsh.UseSSL = value;
+ if (value)
+ {
+ var currentDir = Environment.CurrentDirectory;
+ Gfsh.Keystore = currentDir +
"/ServerSslKeys/server_keystore.jks";
+ Gfsh.KeystorePassword = sslPassword_;
+ Gfsh.Truststore = currentDir +
"/ServerSslKeys/server_truststore.jks";
+ Gfsh.TruststorePassword = sslPassword_;
+ }
+ }
+ }
+
+ public Cluster(string name, int locatorCount, int serverCount)
+ {
+ started_ = false;
+ Gfsh = new GfshExecute();
+ UseSSL = false;
+ name_ = name;
+ locatorCount_ = locatorCount;
+ serverCount_ = serverCount;
+ locators_ = new List<Locator>();
+ servers_ = new List<Server>();
+ }
+
+ private bool StartLocators()
+ {
+ var success = true;
+
+ for (var i = 0; i < locatorCount_; i++)
+ {
+ var locator = new Locator(this, new List<Locator>(),
+ name_ + "/locator/" + i.ToString());
+ locators_.Add(locator);
+ success = (locator.Start() == 0);
+ }
+ return success;
+ }
+
+ private bool StartServers()
+ {
+ var success = true;
+
+ for (var i = 0; i < serverCount_; i++)
+ {
+ var server = new Server(this, locators_,
+ name_ + "/server/" + i.ToString());
+ servers_.Add(server);
+ var localResult = server.Start();
+ if (localResult != 0)
+ {
+ success = false;
+ }
+ }
+ return success;
+ }
+
+ private void RemoveClusterDirectory()
+ {
+ if (Directory.Exists(name_))
+ {
+ Directory.Delete(name_, true);
+ }
+ }
+
+ public bool Start()
+ {
+ if (!started_)
+ {
+ RemoveClusterDirectory();
+ var locatorSuccess = StartLocators();
+ var serverSuccess = StartServers();
+ started_ = (locatorSuccess && serverSuccess);
+ }
+ return (started_);
+ }
+
+ public void Dispose()
+ {
+ if (started_)
+ {
+ this.Gfsh
+ .shutdown()
+ .withIncludeLocators(true)
+ .execute();
+ }
+ }
+ }
+
+ public struct Address
+ {
+ public string address;
+ public int port;
+ }
+
+ public class Locator
+ {
+ private Cluster cluster_;
+ private string name_;
+ private List<Locator> locators_;
+ private bool started_;
+
+ public Locator(Cluster cluster, List<Locator> locators, string name)
+ {
+ cluster_ = cluster;
+ locators_ = locators;
+ name_ = name;
+ var address = new Address();
+ address.address = "localhost";
+ address.port = cluster.Gfsh.LocatorPort;
+ Address = address;
+ }
+
+ public Address Address { get; private set; }
+
+ public int Start()
+ {
+ var result = -1;
+ if (!started_)
+ {
+ var locator = cluster_.Gfsh
+ .start()
+ .locator()
+ .withDir(name_)
+ .withName(name_.Replace('/', '_'))
+ .withBindAddress(Address.address)
+ .withPort(Address.port)
+ .withMaxHeap("256m")
+ .withJmxManagerPort(cluster_.Gfsh.JmxManagerPort)
+ .withHttpServicePort(0);
+ if (cluster_.UseSSL)
+ {
+ locator.withUseSsl()
+ .withConnect(false);
+ }
+ result = locator.execute();
+ started_ = true;
+ }
+ return result;
+ }
+
+ public int Stop()
+ {
+ var result = cluster_.Gfsh
+ .stop()
+ .locator()
+ .withDir(name_)
+ .execute();
+ started_ = false;
+ return result;
+ }
+ }
+
+ public class Server
+ {
+ private Cluster cluster_;
+ private string name_;
+ private List<Locator> locators_;
+ private bool started_;
+
+ public Server(Cluster cluster, List<Locator> locators, string name)
+ {
+ cluster_ = cluster;
+ locators_ = locators;
+ name_ = name;
+ var address = new Address();
+ address.address = "localhost";
+ address.port = 0;
+ Address = address;
+ }
+
+ public Address Address { get; private set; }
+
+ public int Start()
+ {
+ var result = -1;
+ if (!started_)
+ {
+ var server = cluster_.Gfsh
+ .start()
+ .server()
+ .withDir(name_)
+ .withName(name_.Replace('/', '_'))
+ .withBindAddress(Address.address)
+ .withPort(Address.port)
+ .withMaxHeap("1g");
+ if (cluster_.UseSSL)
+ {
+ server.withUseSsl();
+ }
+ result = server.execute();
+ started_ = true;
+ }
+ return result;
+ }
+
+ public int Stop()
+ {
+ var result = cluster_.Gfsh
+ .stop()
+ .server()
+ .withDir(name_)
+ .execute();
+ started_ = false;
+ return result;
+ }
+ }
+}
diff --git a/clicache/integration-test2/ClusterTest.cs
b/clicache/integration-test2/ClusterTest.cs
new file mode 100644
index 0000000..1b91ebf
--- /dev/null
+++ b/clicache/integration-test2/ClusterTest.cs
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Diagnostics;
+using System.Reflection;
+using Xunit;
+
+namespace Apache.Geode.Client.IntegrationTests
+{
+ [Trait("Category", "Integration")]
+ public class ClusterTest : TestBase, IDisposable
+ {
+ public void Dispose()
+ {
+
+ }
+
+ [Fact]
+ public void ClusterStartTest()
+ {
+ using (var cluster = new Cluster(CreateTestCaseDirectoryName(), 1,
1))
+ {
+ Assert.True(cluster.Start());
+ }
+ }
+
+ [Fact]
+ public void ClusterStartWithTwoServersTest()
+ {
+ using (var cluster = new Cluster(CreateTestCaseDirectoryName(), 1,
2))
+ {
+ Assert.True(cluster.Start());
+ }
+ }
+
+ [Fact]
+ public void ClusterStartWithSslTest()
+ {
+ using (var cluster = new Cluster(CreateTestCaseDirectoryName(), 1,
1))
+ {
+ cluster.UseSSL = true;
+
+ Assert.True(cluster.Start());
+ }
+ }
+ }
+}
diff --git a/clicache/integration-test2/Command.cs
b/clicache/integration-test2/Command.cs
new file mode 100644
index 0000000..a6250a9
--- /dev/null
+++ b/clicache/integration-test2/Command.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Diagnostics;
+using System.Net;
+using System.IO;
+using System.Net.Sockets;
+using Xunit;
+
+public class Command
+{
+ #region Public methods
+
+ public Command()
+ {
+ }
+
+ #endregion
+}
diff --git a/clicache/integration-test2/CqOperationTest.cs
b/clicache/integration-test2/CqOperationTest.cs
index 9a6f99e..2824df9 100644
--- a/clicache/integration-test2/CqOperationTest.cs
+++ b/clicache/integration-test2/CqOperationTest.cs
@@ -31,7 +31,7 @@ namespace Apache.Geode.Client.IntegrationTests
public long OrderId { get; set; }
public string Name { get; set; }
public short Quantity { get; set; }
- // A default constructor is required for deserialization
+ // A default constructor is required for deserialization
public MyOrder() { }
public MyOrder(int orderId, string name, short quantity)
{
@@ -64,7 +64,7 @@ namespace Apache.Geode.Client.IntegrationTests
}
}
- public class CqListener<TKey, TResult> : ICqListener<TKey, TResult>
+ public abstract class CqListener<TKey, TResult> : ICqListener<TKey,
TResult>
{
public AutoResetEvent RegionClearEvent { get; private set; }
public AutoResetEvent CreatedEvent { get; private set; }
@@ -85,16 +85,14 @@ namespace Apache.Geode.Client.IntegrationTests
ReceivedUnknownEventType = false;
}
- public virtual void OnEvent(CqEvent<TKey, TResult> ev)
- {
- }
+ public abstract void OnEvent(CqEvent<TKey, TResult> ev);
public virtual void OnError(CqEvent<TKey, TResult> ev)
{
}
-
public virtual void Close()
{
+
}
}
@@ -102,7 +100,7 @@ namespace Apache.Geode.Client.IntegrationTests
{
public override void OnEvent(CqEvent<TKey, TResult> ev)
{
- Debug.WriteLine("CqListener::OnEvent called");
+ Debug.WriteLine("PdxCqListener::OnEvent called");
var val = ev.getNewValue() as MyOrder;
TKey key = ev.getKey();
@@ -177,150 +175,168 @@ namespace Apache.Geode.Client.IntegrationTests
}
[Trait("Category", "Integration")]
- public class CqOperationTest : IDisposable
+ public class CqOperationTest : TestBase, IDisposable
{
- private readonly Cache _cache;
- private readonly GeodeServer _geodeServer;
- private static int _waitInterval = 1000;
-
+ private readonly Cache cache_;
+ private static int waitInterval_ = 1000;
+
public CqOperationTest()
{
var cacheFactory = new CacheFactory()
.Set("log-level", "error");
-
- _cache = cacheFactory.Create();
- _geodeServer = new GeodeServer();
-
+ cache_ = cacheFactory.Create();
}
public void Dispose()
{
- _cache.Close();
- _geodeServer.Dispose();
+ cache_.Close();
}
[Fact]
- public void NotificationsHaveCorrectValuesPdxSerializable()
+ public void PdxSerializableNotificationsHaveCorrectValues()
{
- _cache.TypeRegistry.RegisterPdxType(MyOrder.CreateDeserializable);
-
- var poolFactory = _cache.GetPoolFactory()
- .AddLocator("localhost", _geodeServer.LocatorPort);
- var pool = poolFactory
- .SetSubscriptionEnabled(true)
- .Create("pool");
-
- var regionFactory =
_cache.CreateRegionFactory(RegionShortcut.PROXY)
- .SetPoolName("pool");
-
- var region = regionFactory.Create<string, MyOrder>("cqTestRegion");
-
- var queryService = pool.GetQueryService();
- var cqAttributesFactory = new CqAttributesFactory<string,
MyOrder>();
- var cqListener = new PdxCqListener<string, MyOrder>();
- cqAttributesFactory.AddCqListener(cqListener);
- var cqAttributes = cqAttributesFactory.Create();
-
- var query = queryService.NewCq("MyCq", "SELECT * FROM
/cqTestRegion WHERE quantity > 30", cqAttributes, false);
- Debug.WriteLine("Executing continuous query");
- query.Execute();
+ using (var cluster_ = new Cluster(CreateTestCaseDirectoryName(),
1, 1))
+ {
+ Assert.Equal(cluster_.Start(), true);
+ Assert.Equal(cluster_.Gfsh.create()
+ .region()
+ .withName("cqTestRegion")
+ .withType("REPLICATE")
+ .execute(), 0);
+
cache_.TypeRegistry.RegisterPdxType(MyOrder.CreateDeserializable);
+ var poolFactory = cache_.GetPoolFactory()
+ .AddLocator("localhost", cluster_.Gfsh.LocatorPort);
+ var pool = poolFactory
+ .SetSubscriptionEnabled(true)
+ .Create("pool");
+
+ var regionFactory =
cache_.CreateRegionFactory(RegionShortcut.PROXY)
+ .SetPoolName("pool");
+
+ var region = regionFactory.Create<string,
MyOrder>("cqTestRegion");
+
+ var queryService = pool.GetQueryService();
+ var cqAttributesFactory = new CqAttributesFactory<string,
MyOrder>();
+ var cqListener = new PdxCqListener<string, MyOrder>();
+ cqAttributesFactory.AddCqListener(cqListener);
+ var cqAttributes = cqAttributesFactory.Create();
+
+ var query = queryService.NewCq("MyCq", "SELECT * FROM
/cqTestRegion WHERE quantity > 30", cqAttributes, false);
+ Debug.WriteLine("Executing continuous query");
+ query.Execute();
- Debug.WriteLine("Putting and changing Position objects in the
region");
- var order1 = new MyOrder(1, "product x", 23);
- var order2 = new MyOrder(2, "product y", 37);
- var order3 = new MyOrder(3, "product z", 101);
-
- region.Put("order1", order1);
-
- region.Put("order2", order2);
- Assert.True(cqListener.CreatedEvent.WaitOne(_waitInterval),
"Didn't receive expected CREATE event");
-
- order1.Quantity = 60;
- region.Put("order1", order1);
- Assert.True(cqListener.CreatedEvent.WaitOne(_waitInterval),
"Didn't receive expected CREATE event");
-
- order2.Quantity = 45;
- region.Put("order2", order2);
- Assert.True(cqListener.UpdatedEvent.WaitOne(_waitInterval),
"Didn't receive expected UPDATE event");
-
- order2.Quantity = 11;
- region.Put("order2", order2);
-
Assert.True(cqListener.DestroyedNonNullEvent.WaitOne(_waitInterval), "Didn't
receive expected DESTROY event");
-
- region.Remove("order1");
- Assert.True(cqListener.DestroyedNullEvent.WaitOne(_waitInterval),
"Didn't receive expected DESTROY event");
-
- region.Put("order3", order3);
- Assert.True(cqListener.CreatedEvent.WaitOne(_waitInterval),
"Didn't receive expected CREATE event");
-
- region.Clear();
- Assert.True(cqListener.RegionClearEvent.WaitOne(_waitInterval),
"Didn't receive expected CLEAR event");
-
- Assert.False(cqListener.ReceivedUnknownEventType, "An unknown
event was received by CQ listener");
+ Debug.WriteLine("Putting and changing Position objects in the
region");
+ var order1 = new MyOrder(1, "product x", 23);
+ var order2 = new MyOrder(2, "product y", 37);
+ var order3 = new MyOrder(3, "product z", 101);
+
+ region.Put("order1", order1);
+
+ region.Put("order2", order2);
+ Assert.True(cqListener.CreatedEvent.WaitOne(waitInterval_),
"Didn't receive expected CREATE event");
+
+ order1.Quantity = 60;
+ region.Put("order1", order1);
+ Assert.True(cqListener.CreatedEvent.WaitOne(waitInterval_),
"Didn't receive expected CREATE event");
+
+ order2.Quantity = 45;
+ region.Put("order2", order2);
+ Assert.True(cqListener.UpdatedEvent.WaitOne(waitInterval_),
"Didn't receive expected UPDATE event");
+
+ order2.Quantity = 11;
+ region.Put("order2", order2);
+
Assert.True(cqListener.DestroyedNonNullEvent.WaitOne(waitInterval_), "Didn't
receive expected DESTROY event");
+
+ region.Remove("order1");
+
Assert.True(cqListener.DestroyedNullEvent.WaitOne(waitInterval_), "Didn't
receive expected DESTROY event");
+
+ region.Put("order3", order3);
+ Assert.True(cqListener.CreatedEvent.WaitOne(waitInterval_),
"Didn't receive expected CREATE event");
+
+ region.Clear();
+
Assert.True(cqListener.RegionClearEvent.WaitOne(waitInterval_), "Didn't receive
expected CLEAR event");
+
+ Assert.False(cqListener.ReceivedUnknownEventType, "An unknown
event was received by CQ listener");
+ }
}
[Fact]
- public void NotificationsHaveCorrectValuesDataSerializable()
+ public void DataSerializableNotificationsHaveCorrectValues()
{
- _cache.TypeRegistry.RegisterType(Position.CreateDeserializable,
22);
-
- var poolFactory = _cache.GetPoolFactory()
- .AddLocator("localhost", _geodeServer.LocatorPort);
- var pool = poolFactory
- .SetSubscriptionEnabled(true)
- .Create("pool");
-
- var regionFactory =
_cache.CreateRegionFactory(RegionShortcut.PROXY)
- .SetPoolName("pool");
-
- var region = regionFactory.Create<string,
Position>("cqTestRegion");
-
- var queryService = pool.GetQueryService();
- var cqAttributesFactory = new CqAttributesFactory<string,
Position>();
- var cqListener = new DataCqListener<string, Position>();
- cqAttributesFactory.AddCqListener(cqListener);
- var cqAttributes = cqAttributesFactory.Create();
-
- var query = queryService.NewCq("MyCq", "SELECT * FROM
/cqTestRegion WHERE sharesOutstanding > 30", cqAttributes, false);
- Debug.WriteLine("Executing continuous query");
- query.Execute();
-
- Debug.WriteLine("Putting and changing Position objects in the
region");
- var order1 = new Position("GOOG", 23);
- var order2 = new Position("IBM", 37);
- var order3 = new Position("PVTL", 101);
-
- region.Put("order1", order1);
- var Value = region["order1"];
-
- region.Put("order2", order2);
- Assert.True(cqListener.CreatedEvent.WaitOne(_waitInterval),
"Didn't receive expected CREATE event");
-
- order1.SharesOutstanding = 55;
- region.Put("order1", order1);
- Assert.True(cqListener.CreatedEvent.WaitOne(_waitInterval),
"Didn't receive expected CREATE event");
-
- order2.SharesOutstanding = 77;
- region.Put("order2", order2);
- Assert.True(cqListener.UpdatedEvent.WaitOne(_waitInterval),
"Didn't receive expected UPDATE event");
-
- order2.SharesOutstanding = 11;
- region.Put("order2", order2);
-
Assert.True(cqListener.DestroyedNonNullEvent.WaitOne(_waitInterval), "Didn't
receive expected DESTROY event");
-
- region.Remove("order1");
- Assert.True(cqListener.DestroyedNullEvent.WaitOne(_waitInterval),
"Didn't receive expected DESTROY event");
-
- region.Put("order3", order3);
- Assert.True(cqListener.CreatedEvent.WaitOne(_waitInterval),
"Didn't receive expected CREATE event");
-
- region.Clear();
- Assert.True(cqListener.RegionClearEvent.WaitOne(_waitInterval),
"Didn't receive expected CLEAR event");
-
- Assert.False(cqListener.ReceivedUnknownEventType, "An unknown
event was received by CQ listener");
- }
- }
-}
+ using (var cluster_ = new Cluster(CreateTestCaseDirectoryName(),
1, 1))
+ {
+ Assert.Equal(cluster_.Start(), true);
+ Assert.Equal(cluster_.Gfsh.deploy()
+ .withJar(Config.JavaobjectJarPath)
+ .execute(), 0);
+ Assert.Equal(cluster_.Gfsh.create()
+ .region()
+ .withName("cqTestRegion")
+ .withType("REPLICATE")
+ .execute(), 0);
+
+ cluster_.Gfsh.executeFunction()
+ .withId("InstantiateDataSerializable")
+ .withMember("DataSerializableNotificationsH_server_0")
+ .execute();
+
+
cache_.TypeRegistry.RegisterType(Position.CreateDeserializable, 22);
+
+ var poolFactory = cache_.GetPoolFactory()
+ .AddLocator("localhost", cluster_.Gfsh.LocatorPort);
+ var pool = poolFactory
+ .SetSubscriptionEnabled(true)
+ .Create("pool");
+ var regionFactory =
cache_.CreateRegionFactory(RegionShortcut.PROXY)
+ .SetPoolName("pool");
+ var region = regionFactory.Create<string,
Position>("cqTestRegion");
+ var queryService = pool.GetQueryService();
+ var cqAttributesFactory = new CqAttributesFactory<string,
Position>();
+ var cqListener = new DataCqListener<string, Position>();
+ cqAttributesFactory.AddCqListener(cqListener);
+ var cqAttributes = cqAttributesFactory.Create();
+
+ var query = queryService.NewCq("MyCq", "SELECT * FROM
/cqTestRegion WHERE sharesOutstanding > 30", cqAttributes, false);
+ Debug.WriteLine("Executing continuous query");
+ query.Execute();
+
+ Debug.WriteLine("Putting and changing Position objects in the
region");
+ var order1 = new Position("GOOG", 23);
+ var order2 = new Position("IBM", 37);
+ var order3 = new Position("PVTL", 101);
+
+ region.Put("order1", order1);
+ var Value = region["order1"];
+
+ region.Put("order2", order2);
+ Assert.True(cqListener.CreatedEvent.WaitOne(waitInterval_),
"Didn't receive expected CREATE event");
+
+ order1.SharesOutstanding = 55;
+ region.Put("order1", order1);
+ Assert.True(cqListener.CreatedEvent.WaitOne(waitInterval_),
"Didn't receive expected CREATE event");
+
+ order2.SharesOutstanding = 77;
+ region.Put("order2", order2);
+ Assert.True(cqListener.UpdatedEvent.WaitOne(waitInterval_),
"Didn't receive expected UPDATE event");
+
+ order2.SharesOutstanding = 11;
+ region.Put("order2", order2);
+
Assert.True(cqListener.DestroyedNonNullEvent.WaitOne(waitInterval_), "Didn't
receive expected DESTROY event");
+
+ region.Remove("order1");
+
Assert.True(cqListener.DestroyedNullEvent.WaitOne(waitInterval_), "Didn't
receive expected DESTROY event");
+
+ region.Put("order3", order3);
+ Assert.True(cqListener.CreatedEvent.WaitOne(waitInterval_),
"Didn't receive expected CREATE event");
+
+ region.Clear();
+
Assert.True(cqListener.RegionClearEvent.WaitOne(waitInterval_), "Didn't receive
expected CLEAR event");
+
+ Assert.False(cqListener.ReceivedUnknownEventType, "An unknown
event was received by CQ listener");
+ }
+ }
+ }
+}
diff --git a/clicache/integration-test2/GeodeServer.cs
b/clicache/integration-test2/GeodeServer.cs
deleted file mode 100644
index 3f34905..0000000
--- a/clicache/integration-test2/GeodeServer.cs
+++ /dev/null
@@ -1,225 +0,0 @@
-using System;
-using System.Diagnostics;
-using System.Net;
-using System.IO;
-using System.Net.Sockets;
-using Xunit;
-
-public class GeodeServer : IDisposable
-{
- #region Properties/Fields
-
- public int LocatorPort { get; private set; }
- public int LocatorJmxPort { get; private set; }
-
- private bool _useSsl;
-
- #endregion
-
- #region Public methods
-
- public GeodeServer(string regionName = "testRegion", bool readSerialized =
false, bool useSsl = false)
- {
- _useSsl = useSsl;
- try
- {
- //Clean up previous server dirs
- foreach (var dir in new
DirectoryInfo(Environment.CurrentDirectory).GetDirectories())
- {
- if (!dir.Name.Equals("ServerSslKeys",
StringComparison.OrdinalIgnoreCase)
- && !dir.Name.Equals("ClientSslKeys",
StringComparison.OrdinalIgnoreCase))
- {
- dir.Delete(true);
- }
- }
- }
- catch
- {
- //Ignored
- }
-
- LocatorPort = FreeTcpPort();
- LocatorJmxPort = FreeTcpPort();
-
- var readSerializedStr = readSerialized ? "--read-serialized=true" :
"--read-serialized=false";
-
- Process gfsh;
- if (_useSsl)
- {
- gfsh = new Process
- {
- StartInfo =
- {
- FileName = Config.GeodeGfsh,
- Arguments = " -e \"start locator --bind-address=localhost --port=" +
LocatorPort +
- " --J=-Dgemfire.jmx-manager-port=" + LocatorJmxPort +
- " --http-service-port=0 --connect=false
--J=-Dgemfire.ssl-enabled-components=locator,jmx" +
- " --J=-Dgemfire.ssl-keystore=" +
Environment.CurrentDirectory +
- "/ServerSslKeys/server_keystore.jks
--J=-Dgemfire.ssl-keystore-password=gemstone" +
- " --J=-Dgemfire.ssl-truststore=" +
Environment.CurrentDirectory +
- "/ServerSslKeys/server_truststore.jks
--J=-Dgemfire.ssl-truststore-password=gemstone\"" +
- " -e \"connect --locator=localhost[" + LocatorPort + "]
--use-ssl --key-store=" +
- Environment.CurrentDirectory +
- "/ServerSslKeys/server_keystore.jks
--key-store-password=gemstone " +
- " --trust-store=" + Environment.CurrentDirectory +
- "/ServerSslKeys/server_truststore.jks
--trust-store-password=gemstone\"" +
- " -e \"configure pdx " + readSerializedStr + "\"" +
- " -e \"start server --bind-address=localhost
--server-port=0 --log-level=all" +
- "
--J=-Dgemfire.ssl-enabled-components=server,locator,jmx
--J=-Dgemfire.ssl-keystore=" +
- Environment.CurrentDirectory +
"/ServerSslKeys/server_keystore.jks" +
- " --J=-Dgemfire.ssl-keystore-password=gemstone
--J=-Dgemfire.ssl-truststore=" +
- Environment.CurrentDirectory +
- "/ServerSslKeys/server_truststore.jks
--J=-Dgemfire.ssl-truststore-password=gemstone\"" +
- " -e \"create region --name=" + regionName + "
--type=PARTITION\"" +
- " -e \"create region --name=testRegion1
--type=PARTITION\"" +
- " -e \"create region --name=cqTestRegion
--type=REPLICATE\"",
- WindowStyle = ProcessWindowStyle.Hidden,
- UseShellExecute = false,
- RedirectStandardOutput = true,
- RedirectStandardError = true,
- CreateNoWindow = false
- }
- };
- }
- else
- {
- gfsh = new Process
- {
- StartInfo =
- {
-
- FileName = Config.GeodeGfsh,
- Arguments = " -e \"start locator --name=locator1
--bind-address=localhost --port=" + LocatorPort +
- " --J=-Dgemfire.jmx-manager-port=" + LocatorJmxPort +
" --http-service-port=0" + "\"" +
- " -e \"deploy
--jar=..\\..\\..\\tests\\javaobject\\javaobject.jar\"" +
- " -e \"start server --name=server1
--bind-address=localhost --cache-xml-file=server.xml --server-port=0\"" +
- " -e \"start server --name=server1
--bind-address=localhost --server-port=0\"" +
- " -e \"create region --name=" + regionName + "
--type=PARTITION\"" +
- " -e \"create region --name=testRegion1
--type=PARTITION\"" +
- " -e \"create region --name=cqTestRegion
--type=REPLICATE\"",
- WindowStyle = ProcessWindowStyle.Hidden,
- UseShellExecute = false,
- RedirectStandardOutput = true,
- RedirectStandardError = true,
- CreateNoWindow = true
- }
- };
- }
-
- gfsh.OutputDataReceived += (sender, args) =>
- {
- if (null != args.Data)
- Debug.WriteLine("GeodeServer: " + args.Data);
- };
-
- gfsh.ErrorDataReceived += (sender, args) =>
- {
- if (null != args.Data)
- Debug.WriteLine("GeodeServer: ERROR: " + args.Data);
- };
-
-
- gfsh.Start();
- gfsh.BeginOutputReadLine();
- gfsh.BeginErrorReadLine();
- if (gfsh.WaitForExit(60000))
- {
- Debug.WriteLine("GeodeServer Start: gfsh.HasExited = {0}, gfsh.ExitCode
= {1}",
- gfsh.HasExited, gfsh.ExitCode);
- }
- else
- {
- Debug.WriteLine("GeodeServer Start: gfsh failed to exit, force
killing.");
- try
- {
- gfsh.Kill();
- }
- catch
- {
- // ignored
- }
- }
- }
-
- public void Dispose()
- {
- try
- {
- Process gfsh;
-
- if (_useSsl)
- {
- gfsh = new Process
- {
- StartInfo =
- {
- FileName = Config.GeodeGfsh,
- Arguments = "-e \"connect --jmx-manager=localhost[" +
LocatorJmxPort + "] --use-ssl --key-store=" +
- Environment.CurrentDirectory +
- "/ServerSslKeys/server_keystore.jks
--key-store-password=gemstone --trust-store=" +
- Environment.CurrentDirectory +
- "/ServerSslKeys/server_truststore.jks
--trust-store-password=gemstone\" -e \"shutdown --include-locators true\" ",
- WindowStyle = ProcessWindowStyle.Hidden,
- UseShellExecute = false,
- RedirectStandardOutput = true,
- RedirectStandardError = true,
- CreateNoWindow = true
- }
- };
- }
- else
- {
- gfsh = new Process
- {
- StartInfo =
- {
- FileName = Config.GeodeGfsh,
- Arguments = "-e \"connect --jmx-manager=localhost[" +
LocatorJmxPort +
- "]\" -e \"shutdown --include-locators true\" ",
- WindowStyle = ProcessWindowStyle.Hidden,
- UseShellExecute = false,
- RedirectStandardOutput = true,
- RedirectStandardError = true,
- CreateNoWindow = true
- }
- };
- }
-
- gfsh.OutputDataReceived += (sender, args) =>
- {
- if (null != args.Data)
- Debug.WriteLine("GeodeServer: " + args.Data);
- };
-
- gfsh.ErrorDataReceived += (sender, args) =>
- {
- if (null != args.Data)
- Debug.WriteLine("GeodeServer: ERROR: " + args.Data);
- };
-
- gfsh.Start();
- gfsh.BeginOutputReadLine();
- gfsh.BeginErrorReadLine();
- gfsh.WaitForExit(30000);
- }
- catch
- {
- // ignored
- }
- }
-
- #endregion
-
- #region Private Methods
-
- private static int FreeTcpPort()
- {
- var tcpListner = new TcpListener(IPAddress.Loopback, 0);
- tcpListner.Start();
- var port = ((IPEndPoint) tcpListner.LocalEndpoint).Port;
- tcpListner.Stop();
- return port;
- }
-
- #endregion
-}
diff --git a/clicache/integration-test2/Gfsh.cs
b/clicache/integration-test2/Gfsh.cs
new file mode 100644
index 0000000..7984fd6
--- /dev/null
+++ b/clicache/integration-test2/Gfsh.cs
@@ -0,0 +1,451 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Diagnostics;
+using System.Net;
+using System.IO;
+using System.Net.Sockets;
+using System.Reflection;
+using Xunit;
+using System.Collections.Generic;
+
+namespace Apache.Geode.Client.IntegrationTests
+{
+ public abstract class Gfsh : IDisposable
+ {
+ public string Name { get; private set; }
+ public string LocatorBindAddress { get; set; }
+ public int LocatorPort { get; private set; }
+ public int JmxManagerPort { get; private set; }
+ public int HttpServicePort { get; private set; }
+ public string ServerBindAddress { get; private set; }
+ public bool UseSSL { get; set; }
+ public string Keystore { get; set; }
+ public string KeystorePassword { get; set; }
+ public string Truststore { get; set; }
+ public string TruststorePassword { get; set; }
+
+ public abstract void Dispose();
+
+ //TODO: Understand what C++ Command class is doing. Why is it a
template,
+ //when the only <T> class we're passing is void? How can you call a
ctor
+ //or a (non-existent?) 'parse' function on void? So many questions...
+ public class Command
+ {
+ public Command(Gfsh gfsh, string command)
+ {
+ gfsh_ = gfsh;
+ command_ = command;
+ }
+ public int execute()
+ {
+ return gfsh_.execute(command_);
+ }
+
+ public override string ToString()
+ {
+ return command_;
+ }
+
+ protected Gfsh gfsh_;
+ protected string command_;
+ }
+
+ public class Start
+ {
+ public Start(Gfsh gfsh)
+ {
+ gfsh_ = gfsh;
+ }
+
+ public class Server : Command
+ {
+ public Server(Gfsh gfsh) : base(gfsh, "start server")
+ {
+ gfsh_ = gfsh;
+ }
+ public Server withName(string name)
+ {
+ command_ += " --name=" + name;
+ return this;
+ }
+
+ public Server withDir(string dir)
+ {
+ command_ += " --dir=" + dir;
+ return this;
+ }
+
+ public Server withBindAddress(string bindAddress)
+ {
+ gfsh_.ServerBindAddress = bindAddress;
+ return this;
+ }
+
+ public Server withPort(int port)
+ {
+ command_ += " --server-port=" + port.ToString();
+ return this;
+ }
+
+ public Server withLocators(string locators)
+ {
+ command_ += " --locators=" + locators;
+ return this;
+ }
+
+ public Server withLogLevel(string logLevel)
+ {
+ command_ += " --log-level=" + logLevel;
+ return this;
+ }
+
+ public Server withMaxHeap(string maxHeap)
+ {
+ command_ += " --max-heap=" + maxHeap;
+ return this;
+ }
+
+ public Server withUseSsl()
+ {
+ command_ += "
--J=-Dgemfire.ssl-enabled-components=server,locator,jmx" +
+ " --J=-Dgemfire.ssl-keystore=" + gfsh_.Keystore +
+ " --J=-Dgemfire.ssl-keystore-password=" +
gfsh_.KeystorePassword +
+ " --J=-Dgemfire.ssl-truststore=" + gfsh_.Truststore +
+ " --J=-Dgemfire.ssl-truststore-password=" +
gfsh_.TruststorePassword;
+ return this;
+ }
+ }
+
+ public Server server()
+ {
+ return new Server(gfsh_);
+ }
+
+ public class Locator : Command
+ {
+ public Locator(Gfsh gfsh) : base(gfsh, "start locator")
+ {
+ }
+
+ public Locator withName(string name)
+ {
+ command_ += " --name=" + name;
+ return this;
+ }
+
+ public Locator withDir(string dir)
+ {
+ command_ += " --dir=" + dir;
+ return this;
+ }
+
+ public Locator withBindAddress(string bindAddress)
+ {
+ gfsh_.LocatorBindAddress = bindAddress;
+ return this;
+ }
+
+ public Locator withPort(int port)
+ {
+ gfsh_.LocatorPort = port;
+ return this;
+ }
+ public Locator withJmxManagerPort(int jmxManagerPort)
+ {
+ gfsh_.JmxManagerPort = jmxManagerPort;
+ return this;
+ }
+
+ public Locator withHttpServicePort(short httpServicePort)
+ {
+ command_ += " --http-service-port=" +
Convert.ToString(httpServicePort);
+ return this;
+ }
+
+ public Locator withLogLevel(string logLevel)
+ {
+ command_ += " --log-level=" + logLevel;
+ return this;
+ }
+
+ public Locator withMaxHeap(string maxHeap)
+ {
+ command_ += " --max-heap=" + maxHeap;
+ return this;
+ }
+
+ public Locator withConnect(bool connect)
+ {
+ command_ += " --connect=";
+ command_ += connect ? "true" : "false";
+ return this;
+ }
+
+ public Locator withUseSsl()
+ {
+ command_ += "
--J=-Dgemfire.ssl-enabled-components=locator,jmx" +
+ " --J=-Dgemfire.ssl-keystore=" + gfsh_.Keystore +
+ " --J=-Dgemfire.ssl-keystore-password=" +
gfsh_.KeystorePassword +
+ " --J=-Dgemfire.ssl-truststore=" + gfsh_.Truststore +
+ " --J=-Dgemfire.ssl-truststore-password=" +
gfsh_.TruststorePassword;
+ return this;
+ }
+ }
+
+ public Locator locator()
+ {
+ return new Locator(gfsh_);
+ }
+
+ private Gfsh gfsh_;
+ }
+
+ public Start start()
+ {
+ return new Start(this);
+ }
+
+ public class Stop
+ {
+ public Stop(Gfsh gfsh)
+ {
+ gfsh_ = gfsh;
+ }
+ public class Locator : Command
+ {
+ public Locator(Gfsh gfsh) : base(gfsh, "stop locator")
+ {
+ }
+
+ public Locator withName(string name)
+ {
+ command_ += " --name=" + name;
+ return this;
+ }
+
+ public Locator withDir(string dir)
+ {
+ command_ += " --dir=" + dir;
+ return this;
+ }
+ }
+
+ public Locator locator()
+ {
+ return new Locator(gfsh_);
+ }
+ public class Server : Command
+ {
+ public Server(Gfsh gfsh) : base(gfsh, "stop server")
+ {
+ }
+
+ public Server withName(string name)
+ {
+ command_ += " --name=" + name;
+ return this;
+ }
+
+ public Server withDir(string dir)
+ {
+ command_ += " --dir=" + dir;
+ return this;
+ }
+ }
+ public Server server()
+ {
+ return new Server(gfsh_);
+ }
+
+ private Gfsh gfsh_;
+ }
+
+ public Stop stop()
+ {
+ return new Stop(this);
+ }
+
+ public class Create
+ {
+ public Create(Gfsh gfsh)
+ {
+ gfsh_ = gfsh;
+ }
+
+ public class Region : Command
+ {
+ public Region(Gfsh gfsh) : base(gfsh, "create region") { }
+
+ public Region withName(string name)
+ {
+ command_ += " --name=" + name;
+ return this;
+ }
+
+ public Region withType(string type)
+ {
+ command_ += " --type=" + type;
+ return this;
+ }
+ }
+
+ public Region region()
+ {
+ return new Region(gfsh_);
+ }
+
+ private Gfsh gfsh_;
+ }
+ public Create create()
+ {
+ return new Create(this);
+ }
+
+ public class Shutdown : Command
+ {
+ public Shutdown(Gfsh gfsh) : base(gfsh, "shutdown") { }
+
+ public Shutdown withIncludeLocators(bool includeLocators)
+ {
+ command_ += " --include-locators=";
+ command_ += includeLocators ? "true" : "false";
+ return this;
+ }
+ }
+
+ public Shutdown shutdown()
+ {
+ return new Shutdown(this);
+ }
+
+ public class Connect : Command
+ {
+ public Connect(Gfsh gfsh) : base(gfsh, "connect") { }
+
+ public Connect withJmxManager(string jmxManagerAddress, int
jmxManagerPort)
+ {
+ command_ += " --jmx-manager=" + jmxManagerAddress + "[" +
jmxManagerPort.ToString() + "]";
+ return this;
+ }
+
+ public Connect withUseSsl()
+ {
+ command_ += " --use-ssl --key-store=" + gfsh_.Keystore +
+ " --key-store-password=" + gfsh_.KeystorePassword +
+ " --trust-store=" + gfsh_.Truststore +
+ " --trust-store-password=" + gfsh_.TruststorePassword;
+ return this;
+ }
+ }
+
+ public Connect connect()
+ {
+ return new Connect(this);
+ }
+
+ public class ConfigurePdx : Command
+ {
+ public ConfigurePdx(Gfsh gfsh) : base(gfsh, "configure pdx") { }
+
+ public ConfigurePdx withReadSerialized(bool readSerialized)
+ {
+ command_ += " --read-serialized=";
+ command_ += readSerialized ? "true" : "false";
+ return this;
+ }
+ }
+
+ public ConfigurePdx configurePdx()
+ {
+ return new ConfigurePdx(this);
+ }
+
+ public class Deploy : Command
+ {
+ public Deploy(Gfsh gfsh) : base(gfsh, "deploy") { }
+
+ public Deploy withJar(string fullPathToJar)
+ {
+ command_ += " --jar=" + fullPathToJar;
+ return this;
+ }
+
+ public Deploy withDir(string fullPathToDir)
+ {
+ command_ += " --dir=" + fullPathToDir;
+ return this;
+ }
+
+ public Deploy withGroup(string groupName)
+ {
+ command_ += " --group=" + groupName;
+ return this;
+ }
+ }
+
+ public Deploy deploy()
+ {
+ return new Deploy(this);
+ }
+
+ public class ExecuteFunction : Command
+ {
+ public ExecuteFunction(Gfsh gfsh) : base(gfsh, "execute function")
{ }
+
+ public ExecuteFunction withId(string functionId)
+ {
+ command_ += " --id=" + functionId;
+ return this;
+ }
+
+ public ExecuteFunction withMember(string memberName)
+ {
+ command_ += " --member=" + memberName;
+ return this;
+ }
+ }
+
+ public ExecuteFunction executeFunction()
+ {
+ return new ExecuteFunction(this);
+ }
+
+ private static string defaultBindAddress = "localhost";
+ private static int defaultHttpServicePort = 0;
+ public Gfsh()
+ {
+ LocatorBindAddress = defaultBindAddress;
+ HttpServicePort = defaultHttpServicePort;
+ ServerBindAddress = defaultBindAddress;
+ LocatorPort = FreeTcpPort();
+ JmxManagerPort = FreeTcpPort();
+ }
+
+ private static int FreeTcpPort()
+ {
+ var tcpListner = new TcpListener(IPAddress.Loopback, 0);
+ tcpListner.Start();
+ var port = ((IPEndPoint)tcpListner.LocalEndpoint).Port;
+ tcpListner.Stop();
+ return port;
+ }
+
+ public abstract int execute(string cmd);
+ }
+}
diff --git a/clicache/integration-test2/GfshExecute.cs
b/clicache/integration-test2/GfshExecute.cs
new file mode 100644
index 0000000..29098f5
--- /dev/null
+++ b/clicache/integration-test2/GfshExecute.cs
@@ -0,0 +1,156 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Diagnostics;
+using System.Net;
+using System.IO;
+using System.Net.Sockets;
+using Xunit;
+
+namespace Apache.Geode.Client.IntegrationTests
+{
+ public class GfshExecute : Gfsh
+ {
+ public GfshExecute()
+ {
+ }
+ public override void Dispose()
+ {
+ }
+
+ private static string startLocator = "start locator";
+ private static string startServer = "start server";
+
+ private string buildStartLocatorCommand(string options)
+ {
+ var locatorCmd = startLocator;
+ locatorCmd += " --port=" + LocatorPort;
+ locatorCmd += " --bind-address=" + LocatorBindAddress;
+ locatorCmd += " --J=-Dgemfire.jmx-manager-port=" + JmxManagerPort
+ " ";
+ locatorCmd += " --J=-Dgemfire.jmx-manager-start=true";
+ locatorCmd += options;
+ return locatorCmd;
+ }
+
+ private string buildStartServerCommand(string options)
+ {
+ var connectObject = connect()
+ .withJmxManager(LocatorBindAddress, JmxManagerPort);
+ if (UseSSL)
+ {
+ connectObject
+ .withUseSsl();
+ }
+ var serverCmd = "-e \"" + connectObject.ToString() + "\" -e \"" +
startServer;
+ serverCmd += " --bind-address=" + ServerBindAddress;
+ serverCmd += options + "\"";
+ return serverCmd;
+ }
+
+ private string buildConnectAndExecuteString(string options)
+ {
+ var connectObject = connect()
+ .withJmxManager(LocatorBindAddress, JmxManagerPort);
+ if (UseSSL)
+ {
+ connectObject
+ .withUseSsl();
+ }
+ return "-e \"" + connectObject.ToString() + "\" -e \"" + options +
"\"";
+ }
+
+ private string BuildFullCommandString(string baseCmd)
+ {
+ string fullCmd;
+
+ if (baseCmd.IndexOf(startLocator) == 0)
+ {
+ fullCmd =
buildStartLocatorCommand(baseCmd.Substring(startLocator.Length));
+ }
+ else if (baseCmd.IndexOf(startServer) == 0)
+ {
+ fullCmd =
buildStartServerCommand(baseCmd.Substring(startServer.Length));
+ }
+ else
+ {
+ fullCmd = buildConnectAndExecuteString(baseCmd);
+ }
+
+ return fullCmd;
+ }
+
+ public override int execute(string cmd)
+ {
+ var fullCmd = BuildFullCommandString(cmd);
+
+ var gfsh = new Process
+ {
+ StartInfo =
+ {
+ FileName = Config.GeodeGfsh,
+ Arguments = fullCmd,
+ WindowStyle = ProcessWindowStyle.Hidden,
+ UseShellExecute = false,
+ RedirectStandardOutput = true,
+ RedirectStandardError = true,
+ CreateNoWindow = false
+ }
+ };
+
+ gfsh.OutputDataReceived += (sender, args) =>
+ {
+ if (args.Data != null)
+ {
+ Debug.WriteLine("GfshExecute: " + args.Data);
+ }
+ };
+
+ gfsh.ErrorDataReceived += (sender, args) =>
+ {
+ if (args.Data != null)
+ {
+ Debug.WriteLine("GfshExecute: ERROR: " + args.Data);
+ }
+ };
+
+ gfsh.Start();
+ gfsh.BeginOutputReadLine();
+ gfsh.BeginErrorReadLine();
+ if (gfsh.WaitForExit(60000))
+ {
+ Debug.WriteLine("GeodeServer Start: gfsh.HasExited = {0},
gfsh.ExitCode = {1}",
+ gfsh.HasExited,
+ gfsh.ExitCode);
+ }
+ else
+ {
+ Debug.WriteLine("GeodeServer Start: gfsh failed to exit, force
killing.");
+ try
+ {
+ gfsh.Kill();
+ }
+ catch
+ {
+ // ignored
+ }
+ }
+
+ return gfsh.ExitCode;
+ }
+ }
+}
diff --git a/clicache/integration-test2/GfshExecuteTest.cs
b/clicache/integration-test2/GfshExecuteTest.cs
new file mode 100644
index 0000000..16a0f83
--- /dev/null
+++ b/clicache/integration-test2/GfshExecuteTest.cs
@@ -0,0 +1,276 @@
+/*
+ * 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.
+ */
+
+using System;
+using Xunit;
+
+namespace Apache.Geode.Client.IntegrationTests
+{
+ [Trait("Category", "Integration")]
+ public class GfshExecuteTest : TestBase, IDisposable
+ {
+ public void Dispose()
+ {
+
+ }
+
+ [Fact]
+ public void GfshExecuteStartLocatorTest()
+ {
+ using (var gfsh = new GfshExecute())
+ {
+ var testDir = CreateTestCaseDirectoryName();
+ CleanTestCaseDirectory(testDir);
+
+ try
+ {
+ Assert.Equal(gfsh.start()
+ .locator()
+ .withDir(testDir)
+ .withHttpServicePort(0)
+ .withPort(gfsh.LocatorPort)
+ .execute(), 0);
+ }
+ finally
+ {
+ Assert.Equal(gfsh
+ .shutdown()
+ .withIncludeLocators(true)
+ .execute(), 0);
+ }
+ }
+ }
+
+ [Fact]
+ public void GfshExecuteStartServerTest()
+ {
+ using (var gfsh = new GfshExecute())
+ {
+ var testDir = CreateTestCaseDirectoryName();
+ CleanTestCaseDirectory(testDir);
+
+ try
+ {
+ Assert.Equal(gfsh.start()
+ .locator()
+ .withDir(testDir)
+ .withHttpServicePort(0)
+ .withPort(gfsh.LocatorPort)
+ .execute(), 0);
+
+ Assert.Equal(gfsh.start()
+ .server()
+ .withDir(testDir + "/server/0")
+ .withPort(0)
+ .execute(), 0);
+ }
+ finally
+ {
+ Assert.Equal(gfsh
+ .shutdown()
+ .withIncludeLocators(true)
+ .execute(), 0);
+ }
+ }
+ }
+
+ [Fact]
+ public void GfshExecuteStartTwoServersTest()
+ {
+ using (var gfsh1 = new GfshExecute())
+ {
+ var testDir = CreateTestCaseDirectoryName();
+ CleanTestCaseDirectory(testDir);
+
+ try
+ {
+ Assert.Equal(gfsh1.start()
+ .locator()
+ .withDir(testDir)
+ .withHttpServicePort(0)
+ .execute(), 0);
+
+ Assert.Equal(gfsh1.start()
+ .server()
+ .withDir(testDir + "/server/0")
+ .withPort(0)
+ .execute(), 0);
+
+ Assert.Equal(gfsh1.start()
+ .server()
+ .withDir(testDir + "/server/1")
+ .withPort(0)
+ .execute(), 0);
+ }
+ finally
+ {
+ Assert.Equal(gfsh1.shutdown()
+ .withIncludeLocators(true)
+ .execute(), 0);
+ }
+ }
+ }
+
+ [Fact]
+ public void GfshExecuteStartLocatorWithUseSslTest()
+ {
+ using (var gfsh = new GfshExecute())
+ {
+ var testDir = CreateTestCaseDirectoryName();
+ CleanTestCaseDirectory(testDir);
+
+ var sslPassword = "gemstone";
+ var currentDir = Environment.CurrentDirectory;
+ gfsh.Keystore = currentDir +
"/ServerSslKeys/server_keystore.jks";
+ gfsh.KeystorePassword = sslPassword;
+ gfsh.Truststore = currentDir +
"/ServerSslKeys/server_truststore.jks";
+ gfsh.TruststorePassword = sslPassword;
+ gfsh.UseSSL = true;
+
+ try
+ {
+ var locator = gfsh
+ .start()
+ .locator()
+ .withDir(testDir)
+ .withHttpServicePort(0)
+ .withUseSsl()
+ .withConnect(false);
+
+ Assert.Equal(locator.execute(), 0);
+ }
+ finally
+ {
+ Assert.Equal(gfsh
+ .shutdown()
+ .withIncludeLocators(true)
+ .execute(), 0);
+ }
+ }
+ }
+
+ [Fact]
+ public void GfshExecuteStartLocatorAndServerWithUseSslTest()
+ {
+ using (var gfsh = new GfshExecute())
+ {
+ var testDir = CreateTestCaseDirectoryName();
+ CleanTestCaseDirectory(testDir);
+
+ var sslPassword = "gemstone";
+ var currentDir = Environment.CurrentDirectory;
+ gfsh.Keystore = currentDir +
"/ServerSslKeys/server_keystore.jks";
+ gfsh.KeystorePassword = sslPassword;
+ gfsh.Truststore = currentDir +
"/ServerSslKeys/server_truststore.jks";
+ gfsh.TruststorePassword = sslPassword;
+ gfsh.UseSSL = true;
+
+ try
+ {
+ Assert.Equal(gfsh
+ .start()
+ .locator()
+ .withDir(testDir)
+ .withHttpServicePort(0)
+ .withUseSsl()
+ .withConnect(false)
+ .execute(), 0);
+
+ Assert.Equal(gfsh
+ .start()
+ .server()
+ .withDir(testDir + "/server/0")
+ .withPort(0)
+ .withUseSsl()
+ .execute(), 0);
+ }
+ finally
+ {
+ Assert.Equal(gfsh
+ .shutdown()
+ .withIncludeLocators(true)
+ .execute(), 0);
+ }
+ }
+ }
+
+ [Fact]
+ public void GfshExecuteStartLocatorAndVerifyPortTest()
+ {
+ using (var gfsh = new GfshExecute())
+ {
+ var testDir = CreateTestCaseDirectoryName();
+ CleanTestCaseDirectory(testDir);
+
+ Assert.Equal(gfsh.start()
+ .locator()
+ .withDir(testDir)
+ .withHttpServicePort(0)
+ .execute(), 0);
+
+ Assert.NotEqual(0, gfsh.LocatorPort);
+
+ Assert.Equal(gfsh.shutdown()
+ .withIncludeLocators(true)
+ .execute(), 0);
+ }
+ }
+
+ [Fact]
+ public void GfshExecuteStartTwoLocatorsTest()
+ {
+ using (var gfsh1 = new GfshExecute())
+ {
+ var testDir = CreateTestCaseDirectoryName();
+ CleanTestCaseDirectory(testDir);
+
+ try
+ {
+ Assert.Equal(gfsh1.start()
+ .locator()
+ .withDir(testDir + "/locator/0")
+ .withHttpServicePort(0)
+ .execute(), 0);
+
+ using (var gfsh2 = new GfshExecute())
+ {
+ try
+ {
+ Assert.Equal(gfsh2.start()
+ .locator()
+ .withDir(testDir + "/locator/1")
+ .withHttpServicePort(0)
+ .execute(), 0);
+ }
+ finally
+ {
+ Assert.Equal(gfsh2.shutdown()
+ .withIncludeLocators(true)
+ .execute(), 0);
+ }
+ }
+ }
+ finally
+ {
+ Assert.Equal(gfsh1.shutdown()
+ .withIncludeLocators(true)
+ .execute(), 0);
+ }
+ }
+ }
+ }
+}
diff --git a/clicache/integration-test2/GfshTest.cs
b/clicache/integration-test2/GfshTest.cs
new file mode 100644
index 0000000..452bb3d
--- /dev/null
+++ b/clicache/integration-test2/GfshTest.cs
@@ -0,0 +1,247 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using Xunit;
+
+namespace Apache.Geode.Client.IntegrationTests
+{
+
+ [Trait("Category", "Integration")]
+ public class GfshTest : IDisposable
+ {
+ public void Dispose()
+ {
+
+ }
+
+ [Fact]
+ public void InstantiateGfshClassesTest()
+ {
+ var gfsh = new GfshExecute();
+ var start = gfsh.start();
+ Assert.NotNull(start);
+
+ var stop = gfsh.stop();
+ Assert.NotNull(stop);
+
+ var create = gfsh.create();
+ Assert.NotNull(create);
+
+ var shutdown = gfsh.shutdown();
+ Assert.NotNull(shutdown);
+
+ var configurePdx = gfsh.configurePdx();
+ Assert.NotNull(configurePdx);
+ }
+
+ [Fact]
+ public void StartLocatorStringsTest()
+ {
+ var Gfsh = new GfshExecute();
+
+ var currentDir = Environment.CurrentDirectory;
+ Gfsh.Keystore = "some/path/keystore.jks";
+ Gfsh.KeystorePassword = "password";
+ Gfsh.Truststore = "some/path/truststore.jks";
+ Gfsh.TruststorePassword = "password";
+
+ var locator = Gfsh
+ .start()
+ .locator();
+ var s = locator.ToString();
+ Assert.True(s.Equals("start locator"));
+
+ locator = Gfsh
+ .start()
+ .locator()
+ .withName("name")
+ .withDir("dir")
+ .withBindAddress("address")
+ .withPort(420)
+ .withJmxManagerPort(1111)
+ .withHttpServicePort(2222)
+ .withLogLevel("fine")
+ .withMaxHeap("someHugeAmount")
+ .withConnect(false)
+ .withUseSsl();
+ s = locator.ToString();
+ Assert.Equal(s, "start locator --name=name --dir=dir " +
+ "--http-service-port=2222 --log-level=fine
--max-heap=someHugeAmount " +
+ "--connect=false
--J=-Dgemfire.ssl-enabled-components=locator,jmx " +
+ "--J=-Dgemfire.ssl-keystore=some/path/keystore.jks
--J=-Dgemfire.ssl-keystore-password=password " +
+ "--J=-Dgemfire.ssl-truststore=some/path/truststore.jks
--J=-Dgemfire.ssl-truststore-password=password");
+ }
+
+ [Fact]
+ public void StartServerStringsTest()
+ {
+ var Gfsh = new GfshExecute();
+
+ var currentDir = Environment.CurrentDirectory;
+ Gfsh.Keystore = "some/path/keystore.jks";
+ Gfsh.KeystorePassword = "password";
+ Gfsh.Truststore = "some/path/truststore.jks";
+ Gfsh.TruststorePassword = "password";
+
+ var server = Gfsh
+ .start()
+ .server();
+ var s = server.ToString();
+ Assert.True(s.Equals("start server"));
+
+ server = Gfsh
+ .start()
+ .server()
+ .withName("server")
+ .withDir("someDir")
+ .withBindAddress("someAddress")
+ .withPort(1234)
+ .withLocators("someLocator")
+ .withLogLevel("debug")
+ .withMaxHeap("1.21gigabytes")
+ .withUseSsl();
+ s = server.ToString();
+ Assert.Equal(s, "start server --name=server " +
+ "--dir=someDir --server-port=1234 --locators=someLocator
--log-level=debug " +
+ "--max-heap=1.21gigabytes
--J=-Dgemfire.ssl-enabled-components=server,locator,jmx " +
+ "--J=-Dgemfire.ssl-keystore=some/path/keystore.jks
--J=-Dgemfire.ssl-keystore-password=password " +
+ "--J=-Dgemfire.ssl-truststore=some/path/truststore.jks
--J=-Dgemfire.ssl-truststore-password=password");
+ }
+
+ [Fact]
+ public void StopLocatorStringsTest()
+ {
+ var locator = new GfshExecute()
+ .stop()
+ .locator();
+ var s = locator.ToString();
+ Assert.True(s.Equals("stop locator"));
+
+ locator = new GfshExecute().stop().locator()
+ .withName("name")
+ .withDir("dir");
+ s = locator.ToString();
+ Assert.True(s.Equals("stop locator --name=name --dir=dir"));
+ }
+
+ [Fact]
+ public void StopServerStringsTest()
+ {
+ var server = new GfshExecute()
+ .stop()
+ .server();
+ var s = server.ToString();
+ Assert.True(s.Equals("stop server"));
+
+ server = new GfshExecute()
+ .stop()
+ .server()
+ .withName("server")
+ .withDir("someDir");
+ s = server.ToString();
+ Assert.True(s.Equals("stop server --name=server --dir=someDir"));
+ }
+
+ [Fact]
+ public void CreateRegionStringsTest()
+ {
+ var region = new GfshExecute()
+ .create()
+ .region();
+ var s = region.ToString();
+ Assert.True(s.Equals("create region"));
+
+ region = new GfshExecute()
+ .create()
+ .region()
+ .withName("region")
+ .withType("PARTITION");
+ s = region.ToString();
+ Assert.True(s.Equals("create region --name=region
--type=PARTITION"));
+ }
+
+ [Fact]
+ public void ShutdownStringsTest()
+ {
+ var shutdown = new GfshExecute()
+ .shutdown();
+ var s = shutdown.ToString();
+ Assert.True(s.Equals("shutdown"));
+
+ shutdown = new GfshExecute()
+ .shutdown()
+ .withIncludeLocators(true);
+ s = shutdown.ToString();
+ Assert.True(s.Equals("shutdown --include-locators=true"));
+
+ shutdown = new GfshExecute()
+ .shutdown()
+ .withIncludeLocators(false);
+ s = shutdown.ToString();
+ Assert.True(s.Equals("shutdown --include-locators=false"));
+ }
+
+ [Fact]
+ public void ConfigurePdxStringsTest()
+ {
+ var configurePdx = new GfshExecute()
+ .configurePdx();
+ var s = configurePdx.ToString();
+ Assert.Equal(s, "configure pdx");
+
+ configurePdx = new GfshExecute()
+ .configurePdx()
+ .withReadSerialized(true);
+ s = configurePdx.ToString();
+ Assert.Equal(s, "configure pdx --read-serialized=true");
+
+ configurePdx = new GfshExecute()
+ .configurePdx()
+ .withReadSerialized(false);
+ s = configurePdx.ToString();
+ Assert.Equal(s, "configure pdx --read-serialized=false");
+ }
+
+ [Fact]
+ public void ConnectStringsTest()
+ {
+ var Gfsh = new GfshExecute();
+
+ var currentDir = Environment.CurrentDirectory;
+ Gfsh.Keystore = "some/path/keystore.jks";
+ Gfsh.KeystorePassword = "password";
+ Gfsh.Truststore = "some/path/truststore.jks";
+ Gfsh.TruststorePassword = "password";
+
+ var connect = Gfsh
+ .connect();
+ var s = connect.ToString();
+ Assert.Equal(s, "connect");
+
+ connect = Gfsh
+ .connect()
+ .withJmxManager("localhost", 1234)
+ .withUseSsl();
+ s = connect.ToString();
+ Assert.Equal(s, "connect --jmx-manager=localhost[1234] --use-ssl "
+
+ "--key-store=some/path/keystore.jks
--key-store-password=password " +
+ "--trust-store=some/path/truststore.jks
--trust-store-password=password");
+ }
+ }
+}
diff --git a/clicache/integration-test2/RegionSSLTest.cs
b/clicache/integration-test2/RegionSSLTest.cs
index a7e21a5..5446c4c 100644
--- a/clicache/integration-test2/RegionSSLTest.cs
+++ b/clicache/integration-test2/RegionSSLTest.cs
@@ -21,69 +21,80 @@ using Xunit;
namespace Apache.Geode.Client.IntegrationTests
{
- [Trait("Category", "Integration")]
- public class RegionSSLTest : IDisposable
- {
- private readonly Cache _cacheOne;
- private readonly GeodeServer _geodeServer;
-
- public RegionSSLTest()
+ [Trait("Category", "Integration")]
+ public class RegionSSLTest : TestBase, IDisposable
{
- var pathvar = Environment.GetEnvironmentVariable("PATH");
+ private readonly Cache cacheOne_;
- var openSslPath = Environment.CurrentDirectory + Config.OpenSSLPath;
+ public RegionSSLTest()
+ {
+ var pathvar = Environment.GetEnvironmentVariable("PATH");
- if (!Directory.Exists(openSslPath))
- {
- throw new DirectoryNotFoundException("OpenSSL is a prerequisite for
integration tests and the directory was not found.");
- }
+ var openSslPath = Environment.CurrentDirectory +
Config.OpenSSLPath;
- pathvar += ";" + openSslPath;
+ if (!Directory.Exists(openSslPath))
+ {
+ throw new DirectoryNotFoundException("OpenSSL is a
prerequisite for integration tests and the directory was not found.");
+ }
- var cryptoImplPath = Environment.CurrentDirectory +
Config.CryptoImplPath;
+ pathvar += ";" + openSslPath;
- if (!File.Exists(cryptoImplPath + "\\cryptoImpl.dll"))
- {
- throw new System.IO.FileNotFoundException("cryptoImpl.dll was not
found at " + cryptoImplPath);
- }
+ var cryptoImplPath = Environment.CurrentDirectory +
Config.CryptoImplPath;
- pathvar += ";" + cryptoImplPath;
+ if (!File.Exists(cryptoImplPath + "\\cryptoImpl.dll"))
+ {
+ throw new System.IO.FileNotFoundException("cryptoImpl.dll was
not found at " + cryptoImplPath);
+ }
- Environment.SetEnvironmentVariable("PATH", pathvar);
+ pathvar += ";" + cryptoImplPath;
- var cacheFactory = new CacheFactory();
- cacheFactory.Set("ssl-enabled", "true");
- cacheFactory.Set("ssl-keystore", Environment.CurrentDirectory +
"\\ClientSslKeys\\client_keystore.password.pem");
- cacheFactory.Set("ssl-keystore-password", "gemstone" );
- cacheFactory.Set("ssl-truststore", Environment.CurrentDirectory +
"\\ClientSslKeys\\client_truststore.pem");
+ Environment.SetEnvironmentVariable("PATH", pathvar);
- _cacheOne = cacheFactory.Create();
- _geodeServer = new GeodeServer(useSsl: true);
- }
+ var cacheFactory = new CacheFactory();
+ cacheFactory.Set("ssl-enabled", "true");
+ cacheFactory.Set("ssl-keystore", Environment.CurrentDirectory +
"\\ClientSslKeys\\client_keystore.password.pem");
+ cacheFactory.Set("ssl-keystore-password", "gemstone");
+ cacheFactory.Set("ssl-truststore", Environment.CurrentDirectory +
"\\ClientSslKeys\\client_truststore.pem");
- public void Dispose()
- {
- _cacheOne.Close();
- _geodeServer.Dispose();
- }
+ cacheOne_ = cacheFactory.Create();
+ }
- [Fact]
- public void PutGet_Works()
- {
- using (var cacheXml = new CacheXml(new FileInfo("cache.xml"),
_geodeServer))
- {
- _cacheOne.InitializeDeclarativeCache(cacheXml.File.FullName);
+ public void Dispose()
+ {
+ cacheOne_.Close();
+ }
+
+ [Fact]
+ public void SslPutGetTest()
+ {
+ using (var cluster = new Cluster(CreateTestCaseDirectoryName(), 1,
1))
+ {
+ cluster.UseSSL = true;
+ Assert.True(cluster.Start());
+ Assert.Equal(cluster.Gfsh
+ .create()
+ .region()
+ .withName("testRegion1")
+ .withType("PARTITION")
+ .execute(), 0);
+
+ cacheOne_.GetPoolFactory()
+ .AddLocator(cluster.Gfsh.LocatorBindAddress,
cluster.Gfsh.LocatorPort)
+ .Create("default");
+
+ var regionFactory =
cacheOne_.CreateRegionFactory(RegionShortcut.PROXY)
+ .SetPoolName("default");
- var regionForCache1 = _cacheOne.GetRegion<string,
string>("testRegion1");
+ var region = regionFactory.Create<string,
string>("testRegion1");
- const string key = "hello";
- const string expectedResult = "dave";
+ const string key = "hello";
+ const string expectedResult = "dave";
- regionForCache1.Put(key, expectedResult);
- var actualResult = regionForCache1.Get(key);
+ region.Put(key, expectedResult);
+ var actualResult = region.Get(key);
- Assert.Equal(expectedResult, actualResult);
- }
+ Assert.Equal(expectedResult, actualResult);
+ }
+ }
}
- }
-}
\ No newline at end of file
+}
diff --git a/clicache/integration-test2/RegionTest.cs
b/clicache/integration-test2/RegionTest.cs
index fd81290..104bb72 100644
--- a/clicache/integration-test2/RegionTest.cs
+++ b/clicache/integration-test2/RegionTest.cs
@@ -21,52 +21,63 @@ using Xunit;
namespace Apache.Geode.Client.IntegrationTests
{
- [Trait("Category", "Integration")]
- public class RegionTest
- {
-
- [Fact]
- public void PutOnOneCacheGetOnAnotherCache()
+ [Trait("Category", "Integration")]
+ public class RegionTest : TestBase
{
- using (var geodeServer = new GeodeServer())
- {
- using (var cacheXml = new CacheXml(new FileInfo("cache.xml"),
geodeServer))
+ [Fact]
+ public void PutOnOneCacheGetOnAnotherCache()
{
- var cacheFactory = new CacheFactory();
+ using (var cluster = new Cluster(CreateTestCaseDirectoryName(), 1,
1))
+ {
+ Assert.True(cluster.Start());
+ Assert.Equal(cluster.Gfsh
+ .create()
+ .region()
+ .withName("testRegion1")
+ .withType("PARTITION")
+ .execute(), 0);
- var cacheOne = cacheFactory.Create();
- try
- {
- cacheOne.InitializeDeclarativeCache(cacheXml.File.FullName);
+ var cacheFactory = new CacheFactory();
+ var cacheOne = cacheFactory.Create();
+ cacheOne.GetPoolFactory()
+ .AddLocator(cluster.Gfsh.LocatorBindAddress,
cluster.Gfsh.LocatorPort)
+ .Create("default");
- var cacheTwo = cacheFactory.Create();
- try
- {
- cacheTwo.InitializeDeclarativeCache(cacheXml.File.FullName);
+ try
+ {
+ var cacheTwo = cacheFactory.Create();
+ try
+ {
+ cacheTwo.GetPoolFactory()
+ .AddLocator(cluster.Gfsh.LocatorBindAddress,
cluster.Gfsh.LocatorPort)
+ .Create("default");
- var regionForCache1 = cacheOne.GetRegion<string,
string>("testRegion1");
- var regionForCache2 = cacheTwo.GetRegion<string,
string>("testRegion1");
+ var regionFactory1 =
cacheOne.CreateRegionFactory(RegionShortcut.PROXY)
+ .SetPoolName("default");
+ var regionFactory2 =
cacheTwo.CreateRegionFactory(RegionShortcut.PROXY)
+ .SetPoolName("default");
- const string key = "hello";
- const string expectedResult = "dave";
+ var regionForCache1 = regionFactory1.Create<string,
string>("testRegion1");
+ var regionForCache2 = regionFactory2.Create<string,
string>("testRegion1");
- regionForCache1.Put(key, expectedResult);
- var actualResult = regionForCache2.Get(key);
+ const string key = "hello";
+ const string expectedResult = "dave";
- Assert.Equal(expectedResult, actualResult);
- }
- finally
- {
- cacheTwo.Close();
+ regionForCache1.Put(key, expectedResult);
+ var actualResult = regionForCache2.Get(key);
+
+ Assert.Equal(expectedResult, actualResult);
+ }
+ finally
+ {
+ cacheTwo.Close();
+ }
+ }
+ finally
+ {
+ cacheOne.Close();
+ }
}
- }
- finally
- {
- cacheOne.Close();
- }
}
- }
}
- }
-
}
diff --git a/clicache/integration-test2/SerializationTests.cs
b/clicache/integration-test2/SerializationTests.cs
index 9ece2bc..6b5afc5 100644
--- a/clicache/integration-test2/SerializationTests.cs
+++ b/clicache/integration-test2/SerializationTests.cs
@@ -24,516 +24,496 @@ using System.Collections.Generic;
namespace Apache.Geode.Client.IntegrationTests
{
- public class Order : IDataSerializable
- {
- public int OrderId { get; set; }
- public string Name { get; set; }
- public short Quantity { get; set; }
-
- // A default constructor is required for deserialization
- public Order() { }
-
- public Order(int orderId, string name, short quantity)
- {
- OrderId = orderId;
- Name = name;
- Quantity = quantity;
- }
-
- public override string ToString()
- {
- return string.Format("Order: [{0}, {1}, {2}]", OrderId, Name, Quantity);
- }
-
- public void ToData(DataOutput output)
+ public class Order : IDataSerializable
{
- output.WriteInt32(OrderId);
- output.WriteUTF(Name);
- output.WriteInt16(Quantity);
- }
+ public int OrderId { get; set; }
+ public string Name { get; set; }
+ public short Quantity { get; set; }
- public void FromData(DataInput input)
- {
- OrderId = input.ReadInt32();
- Name = input.ReadUTF();
- Quantity = input.ReadInt16();
- }
+ // A default constructor is required for deserialization
+ public Order() { }
- public ulong ObjectSize
- {
- get { return 0; }
- }
-
- public static ISerializable CreateDeserializable()
- {
- return new Order();
- }
+ public Order(int orderId, string name, short quantity)
+ {
+ OrderId = orderId;
+ Name = name;
+ Quantity = quantity;
+ }
- }
+ public override string ToString()
+ {
+ return string.Format("Order: [{0}, {1}, {2}]", OrderId, Name,
Quantity);
+ }
- public struct CData
- {
- #region Private members
+ public void ToData(DataOutput output)
+ {
+ output.WriteInt32(OrderId);
+ output.WriteUTF(Name);
+ output.WriteInt16(Quantity);
+ }
- private Int32 m_first;
- private Int64 m_second;
+ public void FromData(DataInput input)
+ {
+ OrderId = input.ReadInt32();
+ Name = input.ReadUTF();
+ Quantity = input.ReadInt16();
+ }
- #endregion
+ public ulong ObjectSize
+ {
+ get { return 0; }
+ }
- #region Public accessors
+ public static ISerializable CreateDeserializable()
+ {
+ return new Order();
+ }
- public Int32 First
- {
- get
- {
- return m_first;
- }
- set
- {
- m_first = value;
- }
}
- public Int64 Second
+ public struct CData
{
- get
- {
- return m_second;
- }
- set
- {
- m_second = value;
- }
- }
+ #region Private members
- #endregion
+ private Int32 m_first;
+ private Int64 m_second;
- public CData(Int32 first, Int64 second)
- {
- m_first = first;
- m_second = second;
- }
+ #endregion
- public static bool operator ==(CData obj1, CData obj2)
- {
- return ((obj1.m_first == obj2.m_first) && (obj1.m_second ==
obj2.m_second));
- }
+ #region Public accessors
- public static bool operator !=(CData obj1, CData obj2)
- {
- return ((obj1.m_first != obj2.m_first) || (obj1.m_second !=
obj2.m_second));
- }
+ public Int32 First
+ {
+ get
+ {
+ return m_first;
+ }
+ set
+ {
+ m_first = value;
+ }
+ }
- public override bool Equals(object obj)
- {
- if (obj is CData)
- {
- CData otherObj = (CData)obj;
- return ((m_first == otherObj.m_first) && (m_second ==
otherObj.m_second));
- }
- return false;
- }
+ public Int64 Second
+ {
+ get
+ {
+ return m_second;
+ }
+ set
+ {
+ m_second = value;
+ }
+ }
- public override int GetHashCode()
- {
- return m_first.GetHashCode() ^ m_second.GetHashCode();
- }
- };
- public class OtherType : IDataSerializable
- {
- private CData m_struct;
- private ExceptionType m_exType;
+ #endregion
- public enum ExceptionType
- {
- None,
- Geode,
- System,
- // below are with inner exceptions
- GeodeGeode,
- GeodeSystem,
- SystemGeode,
- SystemSystem
- }
+ public CData(Int32 first, Int64 second)
+ {
+ m_first = first;
+ m_second = second;
+ }
- public OtherType()
- {
- m_exType = ExceptionType.None;
- }
+ public static bool operator ==(CData obj1, CData obj2)
+ {
+ return ((obj1.m_first == obj2.m_first) && (obj1.m_second ==
obj2.m_second));
+ }
- public OtherType(Int32 first, Int64 second)
- : this(first, second, ExceptionType.None)
- {
- }
+ public static bool operator !=(CData obj1, CData obj2)
+ {
+ return ((obj1.m_first != obj2.m_first) || (obj1.m_second !=
obj2.m_second));
+ }
- public OtherType(Int32 first, Int64 second, ExceptionType exType)
- {
- m_struct.First = first;
- m_struct.Second = second;
- m_exType = exType;
- }
+ public override bool Equals(object obj)
+ {
+ if (obj is CData)
+ {
+ CData otherObj = (CData)obj;
+ return ((m_first == otherObj.m_first) && (m_second ==
otherObj.m_second));
+ }
+ return false;
+ }
- public CData Data
+ public override int GetHashCode()
+ {
+ return m_first.GetHashCode() ^ m_second.GetHashCode();
+ }
+ };
+ public class OtherType : IDataSerializable
{
- get
- {
- return m_struct;
- }
- }
+ private CData m_struct;
+ private ExceptionType m_exType;
- #region IDataSerializable Members
+ public enum ExceptionType
+ {
+ None,
+ Geode,
+ System,
+ // below are with inner exceptions
+ GeodeGeode,
+ GeodeSystem,
+ SystemGeode,
+ SystemSystem
+ }
- public void FromData(DataInput input)
- {
- m_struct.First = input.ReadInt32();
- m_struct.Second = input.ReadInt64();
- switch (m_exType)
- {
- case ExceptionType.None:
- break;
- case ExceptionType.Geode:
- throw new GeodeIOException("Throwing an exception");
- case ExceptionType.System:
- throw new IOException("Throwing an exception");
- case ExceptionType.GeodeGeode:
- throw new GeodeIOException("Throwing an exception with inner " +
- "exception", new CacheServerException("This is an inner
exception"));
- case ExceptionType.GeodeSystem:
- throw new CacheServerException("Throwing an exception with inner " +
- "exception", new IOException("This is an inner exception"));
- case ExceptionType.SystemGeode:
- throw new ApplicationException("Throwing an exception with inner " +
- "exception", new CacheServerException("This is an inner
exception"));
- case ExceptionType.SystemSystem:
- throw new ApplicationException("Throwing an exception with inner " +
- "exception", new IOException("This is an inner exception"));
- }
- }
+ public OtherType()
+ {
+ m_exType = ExceptionType.None;
+ }
- public void ToData(DataOutput output)
- {
- output.WriteInt32(m_struct.First);
- output.WriteInt64(m_struct.Second);
- switch (m_exType)
- {
- case ExceptionType.None:
- break;
- case ExceptionType.Geode:
- throw new GeodeIOException("Throwing an exception");
- case ExceptionType.System:
- throw new IOException("Throwing an exception");
- case ExceptionType.GeodeGeode:
- throw new GeodeIOException("Throwing an exception with inner " +
- "exception", new CacheServerException("This is an inner
exception"));
- case ExceptionType.GeodeSystem:
- throw new CacheServerException("Throwing an exception with inner " +
- "exception", new IOException("This is an inner exception"));
- case ExceptionType.SystemGeode:
- throw new ApplicationException("Throwing an exception with inner " +
- "exception", new CacheServerException("This is an inner
exception"));
- case ExceptionType.SystemSystem:
- throw new ApplicationException("Throwing an exception with inner " +
- "exception", new IOException("This is an inner exception"));
- }
- }
+ public OtherType(Int32 first, Int64 second)
+ : this(first, second, ExceptionType.None)
+ {
+ }
- public UInt64 ObjectSize
- {
- get
- {
- return (UInt32)(sizeof(Int32) + sizeof(Int64));
- }
- }
+ public OtherType(Int32 first, Int64 second, ExceptionType exType)
+ {
+ m_struct.First = first;
+ m_struct.Second = second;
+ m_exType = exType;
+ }
- #endregion
+ public CData Data
+ {
+ get
+ {
+ return m_struct;
+ }
+ }
- public static ISerializable CreateDeserializable()
- {
- return new OtherType();
- }
+ #region IDataSerializable Members
- public override int GetHashCode()
- {
- return m_struct.First.GetHashCode() ^ m_struct.Second.GetHashCode();
- }
+ public void FromData(DataInput input)
+ {
+ m_struct.First = input.ReadInt32();
+ m_struct.Second = input.ReadInt64();
+ switch (m_exType)
+ {
+ case ExceptionType.None:
+ break;
+ case ExceptionType.Geode:
+ throw new GeodeIOException("Throwing an exception");
+ case ExceptionType.System:
+ throw new IOException("Throwing an exception");
+ case ExceptionType.GeodeGeode:
+ throw new GeodeIOException("Throwing an exception with
inner " +
+ "exception", new CacheServerException("This is an inner
exception"));
+ case ExceptionType.GeodeSystem:
+ throw new CacheServerException("Throwing an exception with
inner " +
+ "exception", new IOException("This is an inner
exception"));
+ case ExceptionType.SystemGeode:
+ throw new ApplicationException("Throwing an exception with
inner " +
+ "exception", new CacheServerException("This is an inner
exception"));
+ case ExceptionType.SystemSystem:
+ throw new ApplicationException("Throwing an exception with
inner " +
+ "exception", new IOException("This is an inner
exception"));
+ }
+ }
- public override bool Equals(object obj)
- {
- OtherType ot = obj as OtherType;
- if (ot != null)
- {
- return (m_struct.Equals(ot.m_struct));
- }
- return false;
- }
- }
+ public void ToData(DataOutput output)
+ {
+ output.WriteInt32(m_struct.First);
+ output.WriteInt64(m_struct.Second);
+ switch (m_exType)
+ {
+ case ExceptionType.None:
+ break;
+ case ExceptionType.Geode:
+ throw new GeodeIOException("Throwing an exception");
+ case ExceptionType.System:
+ throw new IOException("Throwing an exception");
+ case ExceptionType.GeodeGeode:
+ throw new GeodeIOException("Throwing an exception with
inner " +
+ "exception", new CacheServerException("This is an inner
exception"));
+ case ExceptionType.GeodeSystem:
+ throw new CacheServerException("Throwing an exception with
inner " +
+ "exception", new IOException("This is an inner
exception"));
+ case ExceptionType.SystemGeode:
+ throw new ApplicationException("Throwing an exception with
inner " +
+ "exception", new CacheServerException("This is an inner
exception"));
+ case ExceptionType.SystemSystem:
+ throw new ApplicationException("Throwing an exception with
inner " +
+ "exception", new IOException("This is an inner
exception"));
+ }
+ }
- public class OtherType2 : IDataSerializable
- {
- private CData m_struct;
- private ExceptionType m_exType;
+ public UInt64 ObjectSize
+ {
+ get
+ {
+ return (UInt32)(sizeof(Int32) + sizeof(Int64));
+ }
+ }
- public enum ExceptionType
- {
- None,
- Geode,
- System,
- // below are with inner exceptions
- GeodeGeode,
- GeodeSystem,
- SystemGeode,
- SystemSystem
- }
+ #endregion
- public OtherType2()
- {
- m_exType = ExceptionType.None;
- }
+ public static ISerializable CreateDeserializable()
+ {
+ return new OtherType();
+ }
- public OtherType2(Int32 first, Int64 second)
- : this(first, second, ExceptionType.None)
- {
- }
+ public override int GetHashCode()
+ {
+ return m_struct.First.GetHashCode() ^
m_struct.Second.GetHashCode();
+ }
- public OtherType2(Int32 first, Int64 second, ExceptionType exType)
- {
- m_struct.First = first;
- m_struct.Second = second;
- m_exType = exType;
+ public override bool Equals(object obj)
+ {
+ OtherType ot = obj as OtherType;
+ if (ot != null)
+ {
+ return (m_struct.Equals(ot.m_struct));
+ }
+ return false;
+ }
}
- public CData Data
+ public class OtherType2 : IDataSerializable
{
- get
- {
- return m_struct;
- }
- }
- #region IDataSerializable Members
+ private CData m_struct;
+ private ExceptionType m_exType;
- public void FromData(DataInput input)
- {
- m_struct.First = input.ReadInt32();
- m_struct.Second = input.ReadInt64();
- switch (m_exType)
- {
- case ExceptionType.None:
- break;
- case ExceptionType.Geode:
- throw new GeodeIOException("Throwing an exception");
- case ExceptionType.System:
- throw new IOException("Throwing an exception");
- case ExceptionType.GeodeGeode:
- throw new GeodeIOException("Throwing an exception with inner " +
- "exception", new CacheServerException("This is an inner
exception"));
- case ExceptionType.GeodeSystem:
- throw new CacheServerException("Throwing an exception with inner " +
- "exception", new IOException("This is an inner exception"));
- case ExceptionType.SystemGeode:
- throw new ApplicationException("Throwing an exception with inner " +
- "exception", new CacheServerException("This is an inner
exception"));
- case ExceptionType.SystemSystem:
- throw new ApplicationException("Throwing an exception with inner " +
- "exception", new IOException("This is an inner exception"));
- }
- }
+ public enum ExceptionType
+ {
+ None,
+ Geode,
+ System,
+ // below are with inner exceptions
+ GeodeGeode,
+ GeodeSystem,
+ SystemGeode,
+ SystemSystem
+ }
- public void ToData(DataOutput output)
- {
- output.WriteInt32(m_struct.First);
- output.WriteInt64(m_struct.Second);
- switch (m_exType)
- {
- case ExceptionType.None:
- break;
- case ExceptionType.Geode:
- throw new GeodeIOException("Throwing an exception");
- case ExceptionType.System:
- throw new IOException("Throwing an exception");
- case ExceptionType.GeodeGeode:
- throw new GeodeIOException("Throwing an exception with inner " +
- "exception", new CacheServerException("This is an inner
exception"));
- case ExceptionType.GeodeSystem:
- throw new CacheServerException("Throwing an exception with inner " +
- "exception", new IOException("This is an inner exception"));
- case ExceptionType.SystemGeode:
- throw new ApplicationException("Throwing an exception with inner " +
- "exception", new CacheServerException("This is an inner
exception"));
- case ExceptionType.SystemSystem:
- throw new ApplicationException("Throwing an exception with inner " +
- "exception", new IOException("This is an inner exception"));
- }
- }
+ public OtherType2()
+ {
+ m_exType = ExceptionType.None;
+ }
- public UInt64 ObjectSize
- {
- get
- {
- return (UInt32)(sizeof(Int32) + sizeof(Int64));
- }
- }
+ public OtherType2(Int32 first, Int64 second)
+ : this(first, second, ExceptionType.None)
+ {
+ }
- #endregion
+ public OtherType2(Int32 first, Int64 second, ExceptionType exType)
+ {
+ m_struct.First = first;
+ m_struct.Second = second;
+ m_exType = exType;
+ }
- public static ISerializable CreateDeserializable()
- {
- return new OtherType2();
- }
+ public CData Data
+ {
+ get
+ {
+ return m_struct;
+ }
+ }
+ #region IDataSerializable Members
- public override int GetHashCode()
- {
- return m_struct.First.GetHashCode() ^ m_struct.Second.GetHashCode();
- }
+ public void FromData(DataInput input)
+ {
+ m_struct.First = input.ReadInt32();
+ m_struct.Second = input.ReadInt64();
+ switch (m_exType)
+ {
+ case ExceptionType.None:
+ break;
+ case ExceptionType.Geode:
+ throw new GeodeIOException("Throwing an exception");
+ case ExceptionType.System:
+ throw new IOException("Throwing an exception");
+ case ExceptionType.GeodeGeode:
+ throw new GeodeIOException("Throwing an exception with
inner " +
+ "exception", new CacheServerException("This is an inner
exception"));
+ case ExceptionType.GeodeSystem:
+ throw new CacheServerException("Throwing an exception with
inner " +
+ "exception", new IOException("This is an inner
exception"));
+ case ExceptionType.SystemGeode:
+ throw new ApplicationException("Throwing an exception with
inner " +
+ "exception", new CacheServerException("This is an inner
exception"));
+ case ExceptionType.SystemSystem:
+ throw new ApplicationException("Throwing an exception with
inner " +
+ "exception", new IOException("This is an inner
exception"));
+ }
+ }
- public override bool Equals(object obj)
- {
- OtherType2 ot = obj as OtherType2;
- if (ot != null)
- {
- return (m_struct.Equals(ot.m_struct));
- }
- return false;
- }
- }
+ public void ToData(DataOutput output)
+ {
+ output.WriteInt32(m_struct.First);
+ output.WriteInt64(m_struct.Second);
+ switch (m_exType)
+ {
+ case ExceptionType.None:
+ break;
+ case ExceptionType.Geode:
+ throw new GeodeIOException("Throwing an exception");
+ case ExceptionType.System:
+ throw new IOException("Throwing an exception");
+ case ExceptionType.GeodeGeode:
+ throw new GeodeIOException("Throwing an exception with
inner " +
+ "exception", new CacheServerException("This is an inner
exception"));
+ case ExceptionType.GeodeSystem:
+ throw new CacheServerException("Throwing an exception with
inner " +
+ "exception", new IOException("This is an inner
exception"));
+ case ExceptionType.SystemGeode:
+ throw new ApplicationException("Throwing an exception with
inner " +
+ "exception", new CacheServerException("This is an inner
exception"));
+ case ExceptionType.SystemSystem:
+ throw new ApplicationException("Throwing an exception with
inner " +
+ "exception", new IOException("This is an inner
exception"));
+ }
+ }
- [Trait("Category", "Integration")]
- public class SerializationTests : IDisposable
- {
- private GeodeServer GeodeServer;
- private CacheXml CacheXml;
- private Cache Cache;
+ public UInt64 ObjectSize
+ {
+ get
+ {
+ return (UInt32)(sizeof(Int32) + sizeof(Int64));
+ }
+ }
- public SerializationTests()
- {
- GeodeServer = new GeodeServer();
- }
+ #endregion
- public void Dispose()
- {
- try
+ public static ISerializable CreateDeserializable()
{
- if (null != Cache)
- {
- Cache.Close();
- }
+ return new OtherType2();
}
- finally
+
+ public override int GetHashCode()
{
- try
- {
- if (null != CacheXml)
+ return m_struct.First.GetHashCode() ^
m_struct.Second.GetHashCode();
+ }
+
+ public override bool Equals(object obj)
+ {
+ OtherType2 ot = obj as OtherType2;
+ if (ot != null)
{
- CacheXml.Dispose();
+ return (m_struct.Equals(ot.m_struct));
}
- }
- finally
- {
- GeodeServer.Dispose();
- }
+ return false;
}
- }
-
+ }
+ [Trait("Category", "Integration")]
+ public class SerializationTests : TestBase
+ {
private void putAndCheck(IRegion<object, object> region, object key,
object value)
{
- region[key] = value;
- var retrievedValue = region[key];
- Assert.Equal(value, retrievedValue);
+ region[key] = value;
+ var retrievedValue = region[key];
+ Assert.Equal(value, retrievedValue);
}
[Fact]
public void BuiltInSerializableTypes()
{
- var cacheFactory = new CacheFactory()
- .Set("log-level", "none");
- var cache = cacheFactory.Create();
-
- var poolFactory = cache.GetPoolFactory()
- .AddLocator("localhost", GeodeServer.LocatorPort);
- poolFactory.Create("pool");
-
- var regionFactory = cache.CreateRegionFactory(RegionShortcut.PROXY)
- .SetPoolName("pool");
- var region = regionFactory.Create<object, object>("testRegion");
- Assert.NotNull(region);
-
- putAndCheck(region, "CacheableString", "foo");
- putAndCheck(region, "CacheableByte", (Byte)8);
- putAndCheck(region, "CacheableInt16", (Int16)16);
- putAndCheck(region, "CacheableInt32", (Int32)32);
- putAndCheck(region, "CacheableInt64", (Int64)64);
- putAndCheck(region, "CacheableBoolean", (Boolean)true);
- putAndCheck(region, "CacheableCharacter", 'c');
- putAndCheck(region, "CacheableDouble", (Double)1.5);
- putAndCheck(region, "CacheableFloat", (float)2.5);
-
- putAndCheck(region, "CacheableStringArray", new String[] { "foo",
"bar" });
- putAndCheck(region, "CacheableBytes", new Byte[] { 8, 8 });
- putAndCheck(region, "CacheableInt16Array", new Int16[] { 16, 16 });
- putAndCheck(region, "CacheableInt32Array", new Int32[] { 32, 32 });
- putAndCheck(region, "CacheableInt64Array", new Int64[] { 64, 64 });
- putAndCheck(region, "CacheableBooleanArray", new Boolean[] { true,
false });
- putAndCheck(region, "CacheableCharacterArray", new Char[] { 'c', 'a'
});
- putAndCheck(region, "CacheableDoubleArray", new Double[] { 1.5, 1.7
});
- putAndCheck(region, "CacheableFloatArray", new float[] { 2.5F, 2.7F
});
-
- putAndCheck(region, "CacheableDate", new DateTime());
-
- putAndCheck(region, "CacheableHashMap", new Dictionary<int,
string>() { { 1, "one" }, { 2, "two" } });
- putAndCheck(region, "CacheableHashTable", new Hashtable() { { 1,
"one" }, { 2, "two" } });
- putAndCheck(region, "CacheableVector", new ArrayList() { "one",
"two" });
- putAndCheck(region, "CacheableArrayList", new List<string>() {
"one", "two" });
- putAndCheck(region, "CacheableLinkedList", new
LinkedList<object>(new string[] { "one", "two" }));
- putAndCheck(region, "CacheableStack", new Stack<object>(new string[]
{ "one", "two" }));
-
- {
- var cacheableHashSet = new CacheableHashSet();
- cacheableHashSet.Add("one");
- cacheableHashSet.Add("two");
- putAndCheck(region, "CacheableHashSet", cacheableHashSet);
- }
-
- {
- var cacheableLinkedHashSet = new CacheableLinkedHashSet();
- cacheableLinkedHashSet.Add("one");
- cacheableLinkedHashSet.Add("two");
- putAndCheck(region, "CacheableLinkedHashSet",
cacheableLinkedHashSet);
- }
-
- cache.TypeRegistry.RegisterPdxType(PdxType.CreateDeserializable);
- putAndCheck(region, "PdxType", new PdxType());
- }
-
- [Fact]
- public void PutGetCustomSerializableTypes()
- {
- var cacheFactory = new CacheFactory()
- .Set("log-level", "none");
- var cache = cacheFactory.Create();
-
- Console.WriteLine("Registering for data serialization");
-
- cache.TypeRegistry.RegisterType(Order.CreateDeserializable, 0x42);
-
- var poolFactory = cache.GetPoolFactory()
- .AddLocator("localhost", GeodeServer.LocatorPort);
- poolFactory.Create("pool");
-
- var regionFactory = cache.CreateRegionFactory(RegionShortcut.PROXY)
- .SetPoolName("pool");
- var orderRegion = regionFactory.Create<int, Order>("testRegion");
- Assert.NotNull(orderRegion);
-
- const int orderKey = 65;
- var order = new Order(orderKey, "Donuts", 12);
-
- orderRegion.Put(orderKey, order, null);
- var orderRetrieved = orderRegion.Get(orderKey, null);
- Assert.Equal(order.ToString(), orderRetrieved.ToString());
-
- cache.Close();
- }
- }
+ using (var cluster = new Cluster(CreateTestCaseDirectoryName(), 1,
1))
+ {
+ Assert.True(cluster.Start());
+ Assert.Equal(cluster.Gfsh.create()
+ .region()
+ .withName("testRegion")
+ .withType("REPLICATE")
+ .execute(), 0);
+ var cacheFactory = new CacheFactory()
+ .Set("log-level", "none");
+ var cache = cacheFactory.Create();
+
+ var poolFactory = cache.GetPoolFactory()
+ .AddLocator("localhost", cluster.Gfsh.LocatorPort);
+ poolFactory.Create("pool");
+
+ var regionFactory =
cache.CreateRegionFactory(RegionShortcut.PROXY)
+ .SetPoolName("pool");
+ var region = regionFactory.Create<object,
object>("testRegion");
+ Assert.NotNull(region);
+
+ putAndCheck(region, "CacheableString", "foo");
+ putAndCheck(region, "CacheableByte", (Byte)8);
+ putAndCheck(region, "CacheableInt16", (Int16)16);
+ putAndCheck(region, "CacheableInt32", (Int32)32);
+ putAndCheck(region, "CacheableInt64", (Int64)64);
+ putAndCheck(region, "CacheableBoolean", (Boolean)true);
+ putAndCheck(region, "CacheableCharacter", 'c');
+ putAndCheck(region, "CacheableDouble", (Double)1.5);
+ putAndCheck(region, "CacheableFloat", (float)2.5);
+
+ putAndCheck(region, "CacheableStringArray", new String[] {
"foo", "bar" });
+ putAndCheck(region, "CacheableBytes", new Byte[] { 8, 8 });
+ putAndCheck(region, "CacheableInt16Array", new Int16[] { 16,
16 });
+ putAndCheck(region, "CacheableInt32Array", new Int32[] { 32,
32 });
+ putAndCheck(region, "CacheableInt64Array", new Int64[] { 64,
64 });
+ putAndCheck(region, "CacheableBooleanArray", new Boolean[] {
true, false });
+ putAndCheck(region, "CacheableCharacterArray", new Char[] {
'c', 'a' });
+ putAndCheck(region, "CacheableDoubleArray", new Double[] {
1.5, 1.7 });
+ putAndCheck(region, "CacheableFloatArray", new float[] { 2.5F,
2.7F });
+
+ putAndCheck(region, "CacheableDate", new DateTime());
+
+ putAndCheck(region, "CacheableHashMap", new Dictionary<int,
string>() { { 1, "one" }, { 2, "two" } });
+ putAndCheck(region, "CacheableHashTable", new Hashtable() { {
1, "one" }, { 2, "two" } });
+ putAndCheck(region, "CacheableVector", new ArrayList() {
"one", "two" });
+ putAndCheck(region, "CacheableArrayList", new List<string>() {
"one", "two" });
+ putAndCheck(region, "CacheableLinkedList", new
LinkedList<object>(new string[] { "one", "two" }));
+ putAndCheck(region, "CacheableStack", new Stack<object>(new
string[] { "one", "two" }));
+
+ {
+ var cacheableHashSet = new CacheableHashSet();
+ cacheableHashSet.Add("one");
+ cacheableHashSet.Add("two");
+ putAndCheck(region, "CacheableHashSet", cacheableHashSet);
+ }
+
+ {
+ var cacheableLinkedHashSet = new CacheableLinkedHashSet();
+ cacheableLinkedHashSet.Add("one");
+ cacheableLinkedHashSet.Add("two");
+ putAndCheck(region, "CacheableLinkedHashSet",
cacheableLinkedHashSet);
+ }
+
+
cache.TypeRegistry.RegisterPdxType(PdxType.CreateDeserializable);
+ putAndCheck(region, "PdxType", new PdxType());
+ }
+ }
+ [Fact]
+ public void PutGetCustomSerializableTypes()
+ {
+ using (var cluster = new Cluster(CreateTestCaseDirectoryName(), 1,
1))
+ {
+ Assert.True(cluster.Start());
+ Assert.Equal(cluster.Gfsh.create()
+ .region()
+ .withName("testRegion")
+ .withType("REPLICATE")
+ .execute(), 0);
+ var cacheFactory = new CacheFactory()
+ .Set("log-level", "none");
+ var cache = cacheFactory.Create();
+
+ cache.TypeRegistry.RegisterType(Order.CreateDeserializable,
0x42);
+
+ var poolFactory = cache.GetPoolFactory()
+ .AddLocator("localhost", cluster.Gfsh.LocatorPort);
+ poolFactory.Create("pool");
+
+ var regionFactory =
cache.CreateRegionFactory(RegionShortcut.PROXY)
+ .SetPoolName("pool");
+ var orderRegion = regionFactory.Create<int,
Order>("testRegion");
+ Assert.NotNull(orderRegion);
+
+ const int orderKey = 65;
+ var order = new Order(orderKey, "Donuts", 12);
+
+ orderRegion.Put(orderKey, order, null);
+ var orderRetrieved = orderRegion.Get(orderKey, null);
+ Assert.Equal(order.ToString(), orderRetrieved.ToString());
+
+ cache.Close();
+ }
+ }
+ }
}
diff --git a/clicache/integration-test2/GeodeServerTests.cs
b/clicache/integration-test2/TestBase.cs
similarity index 52%
rename from clicache/integration-test2/GeodeServerTests.cs
rename to clicache/integration-test2/TestBase.cs
index 2374310..34fdbce 100644
--- a/clicache/integration-test2/GeodeServerTests.cs
+++ b/clicache/integration-test2/TestBase.cs
@@ -15,35 +15,39 @@
* limitations under the License.
*/
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Reflection;
using Xunit;
-[Trait("Category", "Integration")]
-public class GeodeServerTest
+namespace Apache.Geode.Client.IntegrationTests
{
- [Fact]
- public void Start()
+ [Trait("Category", "Integration")]
+ public class TestBase
{
- using (var geodeServer = new GeodeServer())
+ private const int MaxAllowedDirectoryCharacters = 30;
+
+ public void CleanTestCaseDirectory(string directory)
{
- Assert.NotNull(geodeServer);
- Assert.NotEqual(0, geodeServer.LocatorPort);
+ if (Directory.Exists(directory))
+ {
+ Directory.Delete(directory, true);
+ }
}
- }
- [Fact]
- public void StartTwo()
- {
- using (var geodeServer1 = new GeodeServer())
+ public string CreateTestCaseDirectoryName()
{
- Assert.NotNull(geodeServer1);
- Assert.NotEqual(0, geodeServer1.LocatorPort);
+ var st = new StackTrace();
+ var sf = st.GetFrame(1);
+ var currentMethod = sf.GetMethod();
+ var dirName = currentMethod.Name;
- using (var geodeServer2 = new GeodeServer())
+ if (dirName.Length > MaxAllowedDirectoryCharacters)
{
- Assert.NotNull(geodeServer2);
- Assert.NotEqual(0, geodeServer2.LocatorPort);
- Assert.NotEqual(geodeServer1.LocatorPort,
geodeServer2.LocatorPort);
+ dirName = dirName.Substring(0, MaxAllowedDirectoryCharacters);
}
+ return dirName;
}
}
}
diff --git a/clicache/integration-test2/server.xml
b/clicache/integration-test2/server.xml
deleted file mode 100644
index 8d8a088..0000000
--- a/clicache/integration-test2/server.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0"?>
-<!--
- 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.
--->
-<cache
- xmlns="http://geode.apache.org/schema/cache"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://geode.apache.org/schema/cache
http://geode.apache.org/schema/cache/cache-1.0.xsd" version="1.0">
- <serialization-registration>
- <instantiator id="22">
- <class-name>javaobject.cli.Position</class-name>
- </instantiator>
- </serialization-registration>
-</cache>
\ No newline at end of file
diff --git a/clicache/integration-test2/xunit.runner.json
b/clicache/integration-test2/xunit.runner.json
index 6d84265..20169fe 100644
--- a/clicache/integration-test2/xunit.runner.json
+++ b/clicache/integration-test2/xunit.runner.json
@@ -1,5 +1,5 @@
{
"methodDisplay": "classAndMethod",
- "parallelizeAssembly": false ,
- "parallelizeTestCollections": false
+ "parallelizeAssembly": true,
+ "parallelizeTestCollections": true
}
diff --git a/clicache/test2/xunit.runner.json b/clicache/test2/xunit.runner.json
index dcfc797..20169fe 100644
--- a/clicache/test2/xunit.runner.json
+++ b/clicache/test2/xunit.runner.json
@@ -1,4 +1,5 @@
{
- "methodDisplay": "classAndMethod",
- "parallelizeTestCollections": "false"
-}
\ No newline at end of file
+ "methodDisplay": "classAndMethod",
+ "parallelizeAssembly": true,
+ "parallelizeTestCollections": true
+}
diff --git a/cppcache/integration-test-2/framework/Cluster.cpp
b/cppcache/integration-test-2/framework/Cluster.cpp
index 72477e0..21c1bbd 100644
--- a/cppcache/integration-test-2/framework/Cluster.cpp
+++ b/cppcache/integration-test-2/framework/Cluster.cpp
@@ -70,8 +70,8 @@ void Server::start() {
.withBindAddress(serverAddress_.address)
.withPort(serverAddress_.port)
.withMaxHeap("1g")
- .withLocators(locators_.front().getAdddress().address + "[" +
- std::to_string(locators_.front().getAdddress().port) + "]")
+ .withLocators(locators_.front().getAddress().address + "[" +
+ std::to_string(locators_.front().getAddress().port) + "]")
.execute();
// std::cout << "server: " << serverAddress_.port << ": started" <<
diff --git a/cppcache/integration-test-2/framework/Cluster.h
b/cppcache/integration-test-2/framework/Cluster.h
index c9d0ad8..a8aefad 100644
--- a/cppcache/integration-test-2/framework/Cluster.h
+++ b/cppcache/integration-test-2/framework/Cluster.h
@@ -88,7 +88,7 @@ class Locator {
};
// Locator &operator=(Locator &&move) = default;
- const LocatorAddress &getAdddress() const { return locatorAddress_; }
+ const LocatorAddress &getAddress() const { return locatorAddress_; }
void start();
@@ -201,7 +201,7 @@ class Cluster {
Cluster &operator=(Cluster &&other) = default;
std::string getJmxManager() {
- return locators_.begin()->getAdddress().address + "[" +
+ return locators_.begin()->getAddress().address + "[" +
std::to_string(jmxManagerPort_) + "]";
}
@@ -239,8 +239,8 @@ class Cluster {
void applyLocators(apache::geode::client::PoolFactory &poolFactory) {
for (const auto &locator : locators_) {
- poolFactory.addLocator(locator.getAdddress().address,
- locator.getAdddress().port);
+ poolFactory.addLocator(locator.getAddress().address,
+ locator.getAddress().port);
}
}
diff --git a/tests/javaobject/cli/InstantiateDataSerializable.java
b/tests/javaobject/cli/InstantiateDataSerializable.java
new file mode 100644
index 0000000..99dff29
--- /dev/null
+++ b/tests/javaobject/cli/InstantiateDataSerializable.java
@@ -0,0 +1,51 @@
+/*
+ * 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 javaobject.cli;
+
+
+import java.util.*;
+import java.io.*;
+import org.apache.geode.*; // for DataSerializable
+import org.apache.geode.cache.Declarable;
+
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.execute.FunctionAdapter;
+import org.apache.geode.cache.execute.FunctionContext;
+import org.apache.geode.cache.execute.ResultSender;
+import org.apache.geode.cache.execute.RegionFunctionContext;
+import org.apache.geode.cache.partition.PartitionRegionHelper;
+
+public class InstantiateDataSerializable extends FunctionAdapter implements
Declarable{
+
+public void execute(FunctionContext context) {
+ Instantiator.register(new Instantiator(javaobject.cli.Position.class, 22) {
+ public DataSerializable newInstance() {
+ return new javaobject.cli.Position();
+ }
+ });
+
+ ResultSender sender = context.getResultSender();
+ sender.lastResult(0);
+ }
+
+ public String getId() {
+ return "InstantiateDataSerializable";
+ }
+
+ public void init(Properties arg0) {
+ }
+}