summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreea1 <eea1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-08-24 23:14:16 +0000
committereea1 <eea1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-08-24 23:14:16 +0000
commit401cec63fa64516712b822a880191bda19654a40 (patch)
tree05355310b501fef96116c3fb04b7eb5fd3cb4a21
parent6f55b2a957b19fdc7059a66191a18453e8e53f8d (diff)
downloadATCD-401cec63fa64516712b822a880191bda19654a40.tar.gz
Updated source files for tests/netsvcs/Logger.
-rw-r--r--java/JACE/tests/netsvcs/Logger/LoggerTest.java115
1 files changed, 115 insertions, 0 deletions
diff --git a/java/JACE/tests/netsvcs/Logger/LoggerTest.java b/java/JACE/tests/netsvcs/Logger/LoggerTest.java
new file mode 100644
index 00000000000..ae835b07753
--- /dev/null
+++ b/java/JACE/tests/netsvcs/Logger/LoggerTest.java
@@ -0,0 +1,115 @@
+/*************************************************
+ *
+ * = FILENAME
+ * LoggerTest.java
+ *
+ *@author Everett Anderson
+ *
+ *************************************************/
+package JACE.tests.netsvcs.Logger;
+
+import JACE.SOCK_SAP.*;
+import java.io.*;
+import java.net.*;
+import JACE.OS.*;
+import JACE.netsvcs.Logger.*;
+
+/**
+ *
+ * This is a simple test log client very similar to the direct_logging
+ * client of C++ ACE. The logging service should correctly receive
+ * messages from both the C++ and Java version.
+ *
+ * @see JACE.netsvcs.Logger.ServerLoggingAcceptor
+ */
+public class LoggerTest {
+
+ /** Command line: <hostname> [<port>]
+ *
+ * Creates a "hello world" log message and sends it to the server logging
+ * service.
+ */
+ public static void main(String args[])
+ {
+ if (args.length != 2) {
+ System.err.println("Use: LoggerTest <host name> [<port>]");
+ System.exit(0);
+ }
+
+ ACE.enableDebugging ();
+
+ // Set the port
+ int port = args.length > 1 ?
+ (new Integer(args[1])).intValue() : ACE.DEFAULT_SERVER_PORT;
+
+ SOCKStream cli_stream = new SOCKStream();
+ INETAddr remote_addr;
+ String host;
+
+ // Try to find the host
+ try {
+
+ host = args[0];
+
+ remote_addr = new INETAddr(port, host);
+
+ } catch (UnknownHostException uhe) {
+ ACE.ERROR("UnknownHostException " + uhe);
+ return;
+ }
+
+ System.out.println("Connecting to " + host + " on port " + port);
+
+ SOCKConnector con = new SOCKConnector();
+
+ try {
+
+ // Connect to the service
+ con.connect(cli_stream, remote_addr);
+
+ } catch (SocketException se) {
+
+ ACE.ERROR("Socket Exception " + se);
+ return;
+
+ } catch (IOException ie) {
+
+ ACE.ERROR("IOException " + ie);
+ return;
+ }
+
+
+ // Send a message with priority 4, the current time,
+ // and 0 for the process ID.
+ LogRecord record = new LogRecord(4,
+ System.currentTimeMillis(),
+ 0);
+
+ // Set the text of the message
+ record.msgData("hello world");
+
+ try {
+
+ // Send it
+ record.streamOutTo(cli_stream.socket().getOutputStream ());
+
+ // Close the socket
+ cli_stream.close();
+
+ } catch (IOException ie) {
+
+ ACE.ERROR("" + ie);
+ return;
+ }
+ }
+};
+
+
+
+
+
+
+
+
+
+