summaryrefslogtreecommitdiff
path: root/cpp/test
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/test')
-rw-r--r--cpp/test/Freeze/dbmap/config2
-rw-r--r--cpp/test/Makefile3
-rw-r--r--cpp/test/Yellow/Makefile22
-rw-r--r--cpp/test/Yellow/basicYellow/Client.cpp153
-rw-r--r--cpp/test/Yellow/basicYellow/Makefile38
-rw-r--r--cpp/test/Yellow/basicYellow/Test.ice9
-rw-r--r--cpp/test/Yellow/basicYellow/config_client2
-rw-r--r--cpp/test/Yellow/basicYellow/config_yellow2
-rw-r--r--cpp/test/Yellow/basicYellow/config_yellow_service6
-rwxr-xr-xcpp/test/Yellow/basicYellow/run.py81
10 files changed, 315 insertions, 3 deletions
diff --git a/cpp/test/Freeze/dbmap/config b/cpp/test/Freeze/dbmap/config
deleted file mode 100644
index d95ea4a9a2b..00000000000
--- a/cpp/test/Freeze/dbmap/config
+++ /dev/null
@@ -1,2 +0,0 @@
-Freeze.Trace.DB=0
-Freeze.Trace.DBCursor=0
diff --git a/cpp/test/Makefile b/cpp/test/Makefile
index 0a7086d4478..effae68adb0 100644
--- a/cpp/test/Makefile
+++ b/cpp/test/Makefile
@@ -19,7 +19,8 @@ SUBDIRS = IceUtil \
IceStorm \
IcePack \
Freeze \
- Glacier
+ Glacier \
+ Yellow
$(EVERYTHING)::
@for subdir in $(SUBDIRS); \
diff --git a/cpp/test/Yellow/Makefile b/cpp/test/Yellow/Makefile
new file mode 100644
index 00000000000..5bdc25c3886
--- /dev/null
+++ b/cpp/test/Yellow/Makefile
@@ -0,0 +1,22 @@
+# **********************************************************************
+#
+# Copyright (c) 2001
+# Mutable Realms, Inc.
+# Huntsville, AL, USA
+#
+# All Rights Reserved
+#
+# **********************************************************************
+
+top_srcdir = ../..
+
+include $(top_srcdir)/config/Make.rules
+
+SUBDIRS = basicYellow
+
+$(EVERYTHING)::
+ @for subdir in $(SUBDIRS); \
+ do \
+ echo "making $@ in $$subdir"; \
+ ( cd $$subdir && $(MAKE) $@ ) || exit 1; \
+ done
diff --git a/cpp/test/Yellow/basicYellow/Client.cpp b/cpp/test/Yellow/basicYellow/Client.cpp
new file mode 100644
index 00000000000..1c51c031d76
--- /dev/null
+++ b/cpp/test/Yellow/basicYellow/Client.cpp
@@ -0,0 +1,153 @@
+// **********************************************************************
+//
+// Copyright (c) 2001
+// Mutable Realms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#include <Ice/Ice.h>
+#include <Yellow/Yellow.h>
+#include <Test.h>
+#include <TestCommon.h>
+
+using namespace std;
+using namespace Ice;
+using namespace Yellow;
+
+static int
+run(int argc, char* argv[], const CommunicatorPtr& communicator)
+{
+ QueryPrx query = QueryPrx::checkedCast(
+ communicator->stringToProxy("Yellow/Query:default -p 12346"));
+
+ AdminPrx admin = AdminPrx::checkedCast(
+ communicator->stringToProxy("Yellow/Admin:default -p 12347"));
+
+ cout << "testing add... ";
+
+ ObjectAdapterPtr adapter = communicator->createObjectAdapter("dummy");
+ ObjectPrx test1 = adapter->createProxy(stringToIdentity("test"));
+ ObjectPrx test2 = adapter->createProxy(stringToIdentity("test2"));
+
+ ObjectPrx test3 = adapter->createProxy(stringToIdentity("test3"));
+ ObjectPrx test4 = adapter->createProxy(stringToIdentity("test4"));
+
+ admin->add("::Test", test1);
+ admin->add("::Test", test2);
+
+ ObjectProxySeq seq = query->lookupAll("::Test");
+ test(seq.size() == 2);
+ Identity ident = seq[0]->ice_getIdentity();
+ test(ident == stringToIdentity("test") || ident == stringToIdentity("test2"));
+ if(ident == stringToIdentity("test"))
+ {
+ test(seq[1]->ice_getIdentity() == stringToIdentity("test2"));
+ }
+ else
+ {
+ test(seq[1]->ice_getIdentity() == stringToIdentity("test"));
+ }
+
+ admin->add("::Test2", test3);
+ admin->add("::Test2", test4);
+
+ seq = query->lookupAll("::Test2");
+ test(seq.size() == 2);
+ ident = seq[0]->ice_getIdentity();
+ test(ident == stringToIdentity("test3") || ident == stringToIdentity("test4"));
+ if(ident == stringToIdentity("test3"))
+ {
+ test(seq[1]->ice_getIdentity() == stringToIdentity("test4"));
+ }
+ else
+ {
+ test(seq[1]->ice_getIdentity() == stringToIdentity("test3"));
+ }
+
+ cout << "ok" << endl;
+
+ cout << "testing lookup... ";
+ try
+ {
+ query->lookup("::Foo");
+ test(false);
+ }
+ catch(const NoSuchOfferException&)
+ {
+ // Expected
+ }
+ ObjectPrx obj = query->lookup("::Test");
+ ident = obj->ice_getIdentity();
+ test(ident == stringToIdentity("test") || ident == stringToIdentity("test2"));
+
+ obj = query->lookup("::Test2");
+ ident = obj->ice_getIdentity();
+ test(ident == stringToIdentity("test3") || ident == stringToIdentity("test4"));
+
+ cout << "ok" << endl;
+
+ cout << "testing remove... ";
+ try
+ {
+ admin->remove("::Test2", test1);
+ test(false);
+ }
+ catch(const NoSuchOfferException&)
+ {
+ // Expected
+ }
+
+ admin->remove("::Test2", test3);
+
+ obj = query->lookup("::Test2");
+ ident = obj->ice_getIdentity();
+ test(ident == stringToIdentity("test4"));
+
+ admin->remove("::Test2", test4);
+
+ try
+ {
+ query->lookup("::Test2");
+ test(false);
+ }
+ catch(const NoSuchOfferException&)
+ {
+ // Expected
+ }
+ cout << "ok" << endl;
+
+ return EXIT_SUCCESS;
+}
+
+int
+main(int argc, char* argv[])
+{
+ int status;
+ Ice::CommunicatorPtr communicator;
+
+ try
+ {
+ communicator = Ice::initialize(argc, argv);
+ status = run(argc, argv, communicator);
+ }
+ catch(const Ice::Exception& ex)
+ {
+ cerr << ex << endl;
+ status = EXIT_FAILURE;
+ }
+
+ try
+ {
+ communicator->destroy();
+ }
+ catch(const Ice::Exception& ex)
+ {
+ cerr << ex << endl;
+ status = EXIT_FAILURE;
+ }
+
+ return status;
+}
diff --git a/cpp/test/Yellow/basicYellow/Makefile b/cpp/test/Yellow/basicYellow/Makefile
new file mode 100644
index 00000000000..fb4b98f74fc
--- /dev/null
+++ b/cpp/test/Yellow/basicYellow/Makefile
@@ -0,0 +1,38 @@
+# **********************************************************************
+#
+# Copyright (c) 2001
+# Mutable Realms, Inc.
+# Huntsville, AL, USA
+#
+# All Rights Reserved
+#
+# **********************************************************************
+
+top_srcdir = ../../..
+
+CLIENT = client
+
+TARGETS = $(CLIENT)
+
+OBJS = Test.o \
+ Client.o
+
+SRCS = $(OBJS:.o=.cpp)
+
+include $(top_srcdir)/config/Make.rules
+
+CPPFLAGS := -I. -I../../include -I$(DB_HOME)/include $(CPPFLAGS)
+LDFLAGS := $(LDFLAGS) -L$(DB_HOME)/lib
+
+$(CLIENT): $(OBJS)
+ rm -f $@
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(OBJS) -lYellow $(LIBS)
+
+Test.h Test.cpp: Test.ice $(SLICE2CPP)
+ rm -f Test.h Test.cpp
+ $(SLICE2CPP) -I$(slicedir) Test.ice
+
+clean::
+ rm -f Test.h Test.cpp
+
+include .depend
diff --git a/cpp/test/Yellow/basicYellow/Test.ice b/cpp/test/Yellow/basicYellow/Test.ice
new file mode 100644
index 00000000000..9d1bab11fb7
--- /dev/null
+++ b/cpp/test/Yellow/basicYellow/Test.ice
@@ -0,0 +1,9 @@
+interface Test
+{
+ void dummy();
+};
+
+interface Test2
+{
+ void dummy();
+};
diff --git a/cpp/test/Yellow/basicYellow/config_client b/cpp/test/Yellow/basicYellow/config_client
new file mode 100644
index 00000000000..e5f518da475
--- /dev/null
+++ b/cpp/test/Yellow/basicYellow/config_client
@@ -0,0 +1,2 @@
+Yellow.Admin=Yellow/Admin:tcp -p 10001 -h 127.0.0.1
+Yellow.Query=Yellow/Query:tcp -p 10000 -h 127.0.0.1
diff --git a/cpp/test/Yellow/basicYellow/config_yellow b/cpp/test/Yellow/basicYellow/config_yellow
new file mode 100644
index 00000000000..e659b547394
--- /dev/null
+++ b/cpp/test/Yellow/basicYellow/config_yellow
@@ -0,0 +1,2 @@
+Yellow.Query.Endpoints=tcp -p 10000 -h 127.0.0.1
+Yellow.Admin.Endpoints=tcp -p 10001 -h 127.0.0.1
diff --git a/cpp/test/Yellow/basicYellow/config_yellow_service b/cpp/test/Yellow/basicYellow/config_yellow_service
new file mode 100644
index 00000000000..450bf511a48
--- /dev/null
+++ b/cpp/test/Yellow/basicYellow/config_yellow_service
@@ -0,0 +1,6 @@
+#Ice.Trace.Network=1
+
+Ice.ConnectionWarnings=1
+
+IceBox.Service.Yellow=YellowService:create --Ice.Config=config_yellow
+IceBox.DBEnvName.Yellow=db
diff --git a/cpp/test/Yellow/basicYellow/run.py b/cpp/test/Yellow/basicYellow/run.py
new file mode 100755
index 00000000000..c1f2ba90b34
--- /dev/null
+++ b/cpp/test/Yellow/basicYellow/run.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2001
+# Mutable Realms, Inc.
+# Huntsville, AL, USA
+#
+# All Rights Reserved
+#
+# **********************************************************************
+
+import os, sys, time
+
+for toplevel in [".", "..", "../..", "../../..", "../../../.."]:
+ toplevel = os.path.normpath(toplevel)
+ if os.path.exists(os.path.join(toplevel, "config", "TestUtil.py")):
+ break
+else:
+ raise "can't find toplevel directory!"
+
+sys.path.append(os.path.join(toplevel, "config"))
+import TestUtil
+
+name = os.path.join("Yellow", "basicYellow")
+testdir = os.path.join(toplevel, "test", name)
+
+IceBox = os.path.join(toplevel, "bin", "icebox")
+IceBoxAdmin = os.path.join(toplevel, "bin", "iceboxadmin")
+
+updatedServerOptions = TestUtil.serverOptions.replace("TOPLEVELDIR", toplevel)
+updatedClientOptions = TestUtil.clientOptions.replace("TOPLEVELDIR", toplevel)
+updatedClientServerOptions = TestUtil.clientServerOptions.replace("TOPLEVELDIR", toplevel)
+
+IceBoxEndpoints=' --IceBox.ServiceManager.Endpoints="default -p 12345"'
+IceBoxReference=' --IceBox.ServiceManager="ServiceManager:default -p 12345"'
+YellowService=" --IceBox.Service.Yellow=YellowService:create" + \
+ ' --Yellow.Query.Endpoints="default -p 12346" --Yellow.Admin.Endpoints="default -p 12347"'
+
+dbEnvName = os.path.join(testdir, "db")
+TestUtil.cleanDbDir(dbEnvName)
+YellowDBEnv=" --IceBox.DBEnvName.Yellow=" + dbEnvName
+
+print "starting yellow service...",
+command = IceBox + updatedClientServerOptions + IceBoxEndpoints + YellowService + YellowDBEnv
+IceBoxPipe = os.popen(command)
+TestUtil.getServerPid(IceBoxPipe)
+TestUtil.getAdapterReady(IceBoxPipe)
+print "ok"
+
+client = os.path.join(testdir, "client")
+#
+# Start the client.
+#
+print "starting client...",
+command = client + updatedClientOptions
+clientPipe = os.popen(command)
+print "ok"
+
+for output in clientPipe.xreadlines():
+ print output,
+
+#
+# Shutdown yellow.
+#
+print "shutting down yellow...",
+command = IceBoxAdmin + updatedClientOptions + IceBoxReference + r' shutdown'
+IceBoxAdminPipe = os.popen(command)
+IceBoxAdminStatus = IceBoxAdminPipe.close()
+if IceBoxAdminStatus:
+ TestUtil.killServers()
+ sys.exit(1)
+print "ok"
+
+YellowStatus = IceBoxPipe.close()
+clientStatus = clientPipe.close();
+
+if YellowStatus or clientStatus:
+ TestUtil.killServers()
+ sys.exit(1)
+
+sys.exit(0)