summaryrefslogtreecommitdiff
path: root/java/tests
diff options
context:
space:
mode:
authoreea1 <eea1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-11-12 03:13:20 +0000
committereea1 <eea1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-11-12 03:13:20 +0000
commitd587704f52cc129616ecfedf90717d9853e48804 (patch)
tree661b3b175826ed4744c036da2cef8e469782e8ae /java/tests
parent8a79d73984529c66db645f7bf929641001fab726 (diff)
downloadATCD-d587704f52cc129616ecfedf90717d9853e48804.tar.gz
These form a test of the JACE Naming Service, as well as the NameProxy
clients can use to access it. It is compatible with the C++ remote naming service, as well.
Diffstat (limited to 'java/tests')
-rw-r--r--java/tests/netsvcs/Naming/ClientTest.java115
-rw-r--r--java/tests/netsvcs/Naming/Makefile21
2 files changed, 136 insertions, 0 deletions
diff --git a/java/tests/netsvcs/Naming/ClientTest.java b/java/tests/netsvcs/Naming/ClientTest.java
new file mode 100644
index 00000000000..64a87a2fe66
--- /dev/null
+++ b/java/tests/netsvcs/Naming/ClientTest.java
@@ -0,0 +1,115 @@
+package tests.netsvcs.Naming;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import JACE.OS.*;
+import JACE.Connection.*;
+import JACE.SOCK_SAP.*;
+import netsvcs.Naming.*;
+
+public class ClientTest
+{
+ void print_usage_and_die ()
+ {
+ System.out.println ("Usage: ClientTest <hostname> [<port>]");
+ System.exit (0);
+ }
+
+ public SOCKStream init (SOCKStream socket, String hostname, int port)
+ {
+ try
+ {
+ SOCKConnector sc = new SOCKConnector(socket, hostname, port);
+ }
+ catch (UnknownHostException e)
+ {
+ ACE.ERROR (e);
+ System.exit(0);
+ }
+ catch (SocketException e)
+ {
+ ACE.ERROR ("Connection refused");
+ System.exit(0);
+ }
+ catch (IOException e)
+ {
+ ACE.ERROR (e);
+ System.exit(0);
+ }
+
+ return socket;
+ }
+
+ public static void main (String [] args)
+ {
+ SOCKStream socket;
+ int port = ACE.DEFAULT_SERVER_PORT;
+ ClientTest clientTest = new ClientTest ();
+
+ if (args.length == 2)
+ {
+ try
+ {
+ port = Integer.parseInt (args[1]);
+ }
+ catch (NumberFormatException e)
+ {
+ clientTest.print_usage_and_die ();
+ }
+ }
+ System.out.println("Trying to open port " + port + " on " + args[0]);
+
+ socket = clientTest.init (new SOCKStream(), args[0], port);
+
+ NameProxy proxy = new NameProxy(socket);
+
+ System.out.println("---- Beginning tests ----");
+
+ try {
+
+ System.out.println("Binding (five, six, seven): " + proxy.bind("five", "six", "seven"));
+ System.out.println("Binding (filth, rat, eats): " + proxy.bind("filth", "rat", "eats"));
+
+ Vector res = proxy.resolve("five");
+
+ System.out.println("Resolve (five) : " + (String)res.elementAt(1) + " "
+ + (String)res.elementAt(2));
+
+ System.out.println("Binding (fish, words, him): " + proxy.bind("fish", "words", "him"));
+
+ System.out.println("Unbind (five, six, seven): " + proxy.unbind("five"));
+
+ System.out.println("Resolve (five) : " + (String)res.elementAt(1) + " "
+ + (String)res.elementAt(2));
+ System.out.println("Binding (fiction, us, you): " + proxy.bind("fiction", "us", "you"));
+
+ System.out.println("\nGetting all records whose names begin with fi:\n");
+ Vector res2 = proxy.listNameEntries("fi");
+
+ Enumeration iter = res2.elements();
+
+ while (iter.hasMoreElements()) {
+ Vector res3 = (Vector)(iter.nextElement());
+
+ System.out.println((String)res3.elementAt(0) + "\t" + (String)res3.elementAt(1)
+ + "\t" + (String)res3.elementAt(2));
+ }
+
+ } catch (IOException e)
+ {
+ ACE.ERROR("" + e);
+ }
+ finally
+ {
+ try {
+ socket.close();
+ } catch (IOException e) {
+ ACE.ERROR("" + e);
+ }
+ }
+
+ }
+
+};
+
diff --git a/java/tests/netsvcs/Naming/Makefile b/java/tests/netsvcs/Naming/Makefile
new file mode 100644
index 00000000000..be6e9c45848
--- /dev/null
+++ b/java/tests/netsvcs/Naming/Makefile
@@ -0,0 +1,21 @@
+# Makefile
+
+.SUFFIXES: .java .class
+
+JACE_WRAPPER = ../../..
+CLASSDIR = $(JACE_WRAPPER)/classes
+
+CLASSPATH := $(CLASSDIR):$(CLASSPATH)
+
+all:
+ javac -d ${JACE_WRAPPER}/classes $(files)
+doc:
+ javadoc -d ${JACE_WRAPPER}/doc $(files) $(packages)
+
+
+files = ClientTest.java
+
+packages = tests.netsvcs.Naming
+
+realclean:
+ find ${JACE_WRAPPER}/classes/tests/netsvcs/Naming -name '*.class' -print | xargs ${RM}