diff options
Diffstat (limited to 'java/tests')
33 files changed, 0 insertions, 2499 deletions
diff --git a/java/tests/ASX/BufferStreamTest.java b/java/tests/ASX/BufferStreamTest.java deleted file mode 100644 index c61f94f281e..00000000000 --- a/java/tests/ASX/BufferStreamTest.java +++ /dev/null @@ -1,185 +0,0 @@ -// ============================================================================ -// -// = PACKAGE -// tests.ASX -// -// = FILENAME -// BufferStreamTest.java -// -// = AUTHOR -// Prashant Jain -// -// ============================================================================ -package tests.ASX; - -import java.io.*; -import JACE.OS.*; -import JACE.ASX.*; - -// This short program copies stdin to stdout via the use of an ASX -// STREAM. It illustrates an implementation of the classic "bounded -// buffer" program using an ASX STREAM containing two Modules. Each -// Module contains two Tasks. - -class CommonTask extends Task -{ - // ACE_Task hooks - public int open (Object obj) - { - if (this.activate (0, 1, false) == -1) - ACE.ERROR ("spawn"); - return 0; - } - - public int close (long exitStatus) - { - ACE.DEBUG (Thread.currentThread () + " thread is exiting with status " + - exitStatus + " in module " + this.name () + "\n"); - return 0; - } - - public int put (MessageBlock mb, TimeValue tv) - { - return 0; - } - - public int handleTimeout (TimeValue tv, Object obj) - { - return 0; - } -} - -// Define the Producer interface. - -class Producer extends CommonTask -{ - // Read data from stdin and pass to consumer. - // The Consumer reads data from the stdin stream, creates a message, - // and then queues the message in the message list, where it is - // removed by the consumer thread. A 0-sized message is enqueued when - // there is no more data to read. The consumer uses this as a flag to - // know when to exit. - - public int svc () - { - // Keep reading stdin, until we reach EOF. - - BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); - - String msg = null; - try - { - while (true) - { - System.out.print ("Enter input: "); - System.out.flush (); - msg = in.readLine (); - if (msg == null) - { - // Send a shutdown message to the other thread and exit. - if (this.putNext (new MessageBlock (0), new TimeValue ()) == -1) - ACE.ERROR ("putNext"); - break; - } - else - { - // Send the message to the other thread. - if (this.putNext (new MessageBlock (msg), new TimeValue ()) == -1) - ACE.ERROR ("putNext"); - } - } - } - catch (IOException e) - { - } - return 0; - } -} - -class Consumer extends CommonTask - // = TITLE - // Define the Consumer interface. -{ - // Enqueue the message on the MessageQueue for subsequent - // handling in the svc() method. - public int put (MessageBlock mb, TimeValue tv) - { - try - { - return this.putq (mb, tv); - } - catch (InterruptedException e) - { - } - return 0; - } - - // The consumer dequeues a message from the ACE_Message_Queue, writes - // the message to the stderr stream, and deletes the message. The - // Consumer sends a 0-sized message to inform the consumer to stop - // reading and exit. - - public int svc () - { - MessageBlock mb = null; - - // Keep looping, reading a message out of the queue, until we - // timeout or get a message with a length == 0, which signals us to - // quit. - try - { - while (true) - { - // Wait for upto 4 seconds - mb = this.getq (new TimeValue (4)); - - if (mb == null) - break; - - int length = mb.length (); - - if (length > 0) - System.out.println ("\n" + mb.base ()); - - if (length == 0) - break; - } - } - catch (InterruptedException e) - { - } - if (mb == null) - { - ACE.ERROR ("timed out waiting for message"); - System.exit (1); - } - return 0; - } -} - -// Spawn off a new thread. - -public class BufferStreamTest -{ - public static void main (String args[]) - { - // Control hierachically-related active objects - Stream stream = new Stream (); - Module pm = new Module ("Consumer", new Consumer (), null, null); - Module cm = new Module ("Producer", new Producer (), null, null); - - // Create Producer and Consumer Modules and push them onto the - // STREAM. All processing is performed in the STREAM. - - if (stream.push (pm) == -1) - { - ACE.ERROR ("push"); - return; - } - else if (stream.push (cm) == -1) - { - ACE.ERROR ("push"); - return; - } - } -} diff --git a/java/tests/ASX/MessageQueueTest.java b/java/tests/ASX/MessageQueueTest.java deleted file mode 100644 index c22d2cf041d..00000000000 --- a/java/tests/ASX/MessageQueueTest.java +++ /dev/null @@ -1,50 +0,0 @@ -// ============================================================================ -// -// = PACKAGE -// tests.ASX -// -// = FILENAME -// MessageQueueTest.java -// -// = AUTHOR -// Prashant Jain -// -// ============================================================================ -package tests.ASX; - -import java.io.*; -import JACE.OS.*; -import JACE.ASX.*; - -public class MessageQueueTest -{ - public static void main (String args[]) - { - try - { - MessageBlock conMb; - MessageQueue msgQueue = new MessageQueue (); - MessageBlock mb1 = new MessageBlock ("hello"); - MessageBlock mb2 = new MessageBlock ("world"); - mb1.msgPriority (5); - mb2.msgPriority (7); - - // Enqueue in priority order. - if (msgQueue.enqueue (mb1) == -1) - ACE.ERROR ("put_next"); - - if (msgQueue.enqueue (mb2) == -1) - ACE.ERROR ("put_next"); - - // Now try to dequeue - if ((conMb = msgQueue.dequeueHead ()) == null) - ACE.ERROR ("dequeueHead"); - else - ACE.DEBUG ("Consumer: removed item " + conMb.base () + " of priority " + conMb.msgPriority ()); - } - catch (InterruptedException e) - { - } - } -} - diff --git a/java/tests/ASX/PriorityBufferTest.java b/java/tests/ASX/PriorityBufferTest.java deleted file mode 100644 index 5cce32fa3b1..00000000000 --- a/java/tests/ASX/PriorityBufferTest.java +++ /dev/null @@ -1,116 +0,0 @@ -// ============================================================================ -// -// = PACKAGE -// tests.ASX -// -// = FILENAME -// PriorityBufferTest.java -// -// = AUTHOR -// Prashant Jain -// -// ============================================================================ -package tests.ASX; - -import java.io.*; -import JACE.OS.*; -import JACE.ASX.*; - -class consumer extends Thread -{ - public void run () - { - MessageBlock mb = null; - long curPriority = 0; - int length = 0; - - try - { - // Keep looping, reading a message out of the queue, until we - // get a message with a length == 0, which signals us to quit. - for (;;) - { - if ((mb = PriorityBufferTest.msgQueue.dequeueHead ()) == null) - break; - - length = mb.length (); - curPriority = mb.msgPriority (); - - if (length > 0) - ACE.DEBUG ("Consumer: removed item \"" + mb.base () + "\" of priority: " + curPriority); - - if (length == 0) - break; - } - } - catch (InterruptedException e) - { - } - } -} - -class producer extends Thread -{ - producer (int delay) - { - this.delay_ = delay; - } - - public void run () - { - try - { - long count = 0; - for (char c = 'a'; c <= 'z'; c++) - { - count++; - // Allocate a new message - MessageBlock mb = new MessageBlock (new Character (c).toString ()); - // Set the priority - mb.msgPriority (count); - - // Enqueue in priority order. - if (PriorityBufferTest.msgQueue.enqueue (mb) == -1) - ACE.ERROR ("put_next"); - else - { - ACE.DEBUG ("Producer: inserted item \"" + mb.base () + "\" of priority: " + count); - if (this.delay_ > 0) - this.sleep (this.delay_); - } - } - - // Now send a 0-sized shutdown message to the other thread - if (PriorityBufferTest.msgQueue.enqueueTail (new MessageBlock (0)) == -1) - ACE.ERROR ("put_next"); - } - catch (InterruptedException e) - { - } - } - - private int delay_; -} - -public class PriorityBufferTest -{ - public static MessageQueue msgQueue = new MessageQueue (); - - public static void main (String args[]) - { - int delay = 0; - if (args.length == 1) - { - try - { - delay = Integer.parseInt (args[0]); - } - catch (NumberFormatException e) - { - ACE.ERROR ("Illegal argument."); - } - } - new producer (delay).start (); - new consumer ().start (); - } -} diff --git a/java/tests/ASX/TaskTest.java b/java/tests/ASX/TaskTest.java deleted file mode 100644 index b26b48ea148..00000000000 --- a/java/tests/ASX/TaskTest.java +++ /dev/null @@ -1,86 +0,0 @@ -// ============================================================================ -// -// = PACKAGE -// tests.ASX -// -// = FILENAME -// TaskTest.java -// -// = AUTHOR -// Prashant Jain -// -// ============================================================================ -package tests.ASX; - -import java.io.*; -import JACE.OS.*; -import JACE.ASX.*; -import JACE.Reactor.*; - -public class TaskTest extends Task -{ - int nThreads_; - int nIterations_; - - public TaskTest (int nThreads, int nIterations) - { - this.nIterations_ = nIterations; - this.nThreads_ = nThreads; - if (this.activate (0, nThreads, true) == -1) - ACE.ERROR ("activate failed"); - } - - public int open (Object obj) - { - return 0; - } - - public int close (long flags) - { - return 0; - } - - public int put (MessageBlock mb, TimeValue tv) - { - return 0; - } - - public int handleTimeout (TimeValue tv, Object obj) - { - return 0; - } - - public int svc () - { - for (int i = 1; i <= this.nIterations_; i++) - { - ACE.DEBUG (Thread.currentThread ().toString () + " in iteration " + i); - // Allow other threads to run - Thread.yield (); - } - return 0; - } - - public static void main (String args[]) - { - int nThreads = 1; - int nIterations = 1; - try - { - if (args.length == 2) - { - nThreads = Integer.parseInt (args[0]); - nIterations = Integer.parseInt (args[1]); - } - else if (args.length == 1) - { - nThreads = Integer.parseInt (args[0]); - } - } - catch (NumberFormatException e) - { - ACE.ERROR ("Illegal argument."); - } - TaskTest tt = new TaskTest (nThreads, nIterations); - } -} diff --git a/java/tests/ASX/ThreadPoolTest.java b/java/tests/ASX/ThreadPoolTest.java deleted file mode 100644 index cfb20f87adb..00000000000 --- a/java/tests/ASX/ThreadPoolTest.java +++ /dev/null @@ -1,185 +0,0 @@ -// ============================================================================ -// -// = PACKAGE -// tests.ASX -// -// = FILENAME -// ThreadPoolTest.java -// -// = AUTHOR -// Prashant Jain -// -// ============================================================================ -package tests.ASX; - -import java.io.*; -import JACE.OS.*; -import JACE.ASX.*; -import JACE.Reactor.*; - -public class ThreadPoolTest extends Task -{ - int nThreads_; - int nIterations_; - - public static int MAX_MB_SIZE = 1024; - - public ThreadPoolTest (int nThreads, int nIterations) - { - this.nIterations_ = nIterations; - this.nThreads_ = nThreads; - if (this.activate (0, nThreads, true) == -1) - ACE.ERROR ("activate failed"); - } - - public int handleTimeout (TimeValue tv, Object obj) - { - return 0; - } - - public int open (Object obj) - { - return 0; - } - - public int close (long flags) - { - return 0; - } - - public int put (MessageBlock mb, TimeValue tv) - { - try - { - return this.putq (mb, tv); - } - catch (InterruptedException e) - { - } - return 0; - } - - public int svc () - { - int result = 0; - int count = 1; - - // Keep looping, reading a message out of the queue, until we get a - // message with a length == 0, which signals us to quit. - try - { - for (;; count++) - { - MessageBlock mb = this.getq (new TimeValue ()); - if (mb == null) - { - ACE.ERROR (Thread.currentThread ().toString () + " in iteration " + count + ", got result -1, exiting"); - break; - } - int length = mb.length (); - - if (length > 0) - ACE.DEBUG (Thread.currentThread ().toString () + - " in iteration " + count + ", length = " + - length + ", text = \"" + mb.base () + "\""); - - if (length == 0) - { - ACE.DEBUG (Thread.currentThread ().toString () + - " in iteration " + count + - ", got NULL message, exiting"); - break; - } - Thread.yield (); - } - } - catch (InterruptedException e) - { - } - return 0; - } - - public static void produce (ThreadPoolTest threadPool, int nIterations) - { - int count = 0; - for (int n = 0;;) - { - // Allocate a new message. - MessageBlock mb = new MessageBlock (new Integer (count).toString ()); - - if (count == nIterations) - n = 1; // Indicate that we need to shut down. - else - count++; - - if (count == 0 || (count % 20 == 0)) - { - try - { - Thread.sleep (1); - } - catch (InterruptedException e) - { - } - } - if (n != 1) - { - ACE.DEBUG ("Producing..."); - // Pass the message to the Thread_Pool. - if (threadPool.put (mb, new TimeValue ()) == -1) - ACE.ERROR ("put"); - } - else - { - // Send a shutdown message to the waiting threads and exit. - ACE.DEBUG ("start loop, dump of task"); - - for (int i = threadPool.thrCount (); i > 0; i--) - { - ACE.DEBUG (Thread.currentThread ().toString () + - "EOF, enqueueing NULL block for thread " + i); - - // Enqueue a NULL message to flag each consumer to - // shutdown. - if (threadPool.put (new MessageBlock (0), new TimeValue ()) == -1) - ACE.ERROR ("put"); - } - - break; - } - } - } - - public static void main (String args[]) - { - int nThreads = 1; - int nIterations = 100; - try - { - if (args.length == 2) - { - nThreads = Integer.parseInt (args[0]); - nIterations = Integer.parseInt (args[1]); - } - else if (args.length == 1) - { - nThreads = Integer.parseInt (args[0]); - } - } - catch (NumberFormatException e) - { - ACE.ERROR ("Illegal argument."); - } - ACE.DEBUG ("Threads = " + nThreads + " Iterations = " + nIterations); - - // Create the worker tasks. - ThreadPoolTest threadPool = new ThreadPoolTest (nThreads, - nIterations); - - // Create work for the worker tasks to process in their own threads. - produce (threadPool, nIterations); - ACE.DEBUG ("exiting..."); - } -} - - diff --git a/java/tests/Concurrency/Condition/Consumer.java b/java/tests/Concurrency/Condition/Consumer.java deleted file mode 100644 index ff4f5ff4a4b..00000000000 --- a/java/tests/Concurrency/Condition/Consumer.java +++ /dev/null @@ -1,73 +0,0 @@ -//File: Consumer.java -//Seth Widoff 8/8/96 -//This class attempts at random intervals to dequeue random elements -//from a queue. If the queue is empty the thread waits until an element -//has been enqueued and another thread has invoked the notify() method. - -package tests.Concurrency.Condition; - -import JACE.ASX.TimeValue; -import java.util.Random; - -public class Consumer implements Runnable -{ - //Maximum pause between dequeues (in milliseconds) - private static final int MAX_PAUSE = 1000; - - private SimpleMessageQueue queue_; - private boolean stop_requested_ = false; - private String name_; - private int iterations_; - private TimeValue timeout_; - - public Consumer(String name, - SimpleMessageQueue queue, - int iterations, - TimeValue timeout) - { - name_ = "Consumer " + name; - queue_ = queue; - iterations_ = iterations; - timeout_ = timeout; - } - - public void run() - { - //Set the random number generator seed to the current time in - //milliseconds. - - Random random = new Random(System.currentTimeMillis()); - Integer element; - - for (int i = 0; i < iterations_; ) - { - try - { - element = (Integer)queue_.dequeue(timeout_); - if (element != null) - { - - System.out.print("Consumer::run() " + name_ + " dequeued " + element.toString()); - System.out.println(" Queue size: " + queue_.size()); - - Thread.sleep(random.nextLong() % MAX_PAUSE); - } - else - { - System.out.println ("Null"); - } - i++; - } - catch(Exception excp) - { - System.out.print ("Consumer::run() Exception: "); - System.out.println(excp); - } - } - } - - public void requestStop() - { - stop_requested_ = true; - } -} diff --git a/java/tests/Concurrency/Condition/JoinableThreadGroup.java b/java/tests/Concurrency/Condition/JoinableThreadGroup.java deleted file mode 100644 index c878eb026d3..00000000000 --- a/java/tests/Concurrency/Condition/JoinableThreadGroup.java +++ /dev/null @@ -1,24 +0,0 @@ -package tests.Concurrency.Condition; - -public class JoinableThreadGroup extends ThreadGroup -{ - public JoinableThreadGroup(String name) - { - super(name); - } - - public JoinableThreadGroup(ThreadGroup parent, String name) - { - super(parent, name); - } - - public void join() throws InterruptedException - { - Thread list[] = new Thread[activeCount()]; - - enumerate(list, true); - - for (int i = 0; i < list.length; i++) - list[i].join(); - } -} diff --git a/java/tests/Concurrency/Condition/Producer.java b/java/tests/Concurrency/Condition/Producer.java deleted file mode 100644 index ed6da2251ba..00000000000 --- a/java/tests/Concurrency/Condition/Producer.java +++ /dev/null @@ -1,67 +0,0 @@ -//File: Producer.java -//Seth Widoff 8/8/96 -//This class attempts at random intervals to enqueue random elements -//into a queue. If the queue is full the thread waits until an element -//has been dequeued and another thread has invoked the notify() method. - -package tests.Concurrency.Condition; - -import JACE.ASX.TimeValue; -import java.util.Random; - -public class Producer implements Runnable -{ - //Maximum pause between enqueues (in milliseconds) - private static final int MAX_PAUSE = 1000; - - private SimpleMessageQueue queue_; - private boolean stop_requested_ = false; - private String name_; - private int iterations_; - private TimeValue timeout_; - - public Producer(String name, - SimpleMessageQueue queue, - int iterations, - TimeValue timeout) - { - name_ = "Producer " + name; - queue_ = queue; - iterations_ = iterations; - timeout_ = timeout; - } - - public void run() - { - //Set the random number generator seed to the current time in milliseconds. - Random random = new Random(System.currentTimeMillis()); - int element = 1; - - for (int i = 0; i < iterations_; ) - { - try - { - // element = random.nextInt(); - - queue_.enqueue((Object)new Integer(element), timeout_); - System.out.print("Producer::run() " + name_ + " enqueued " + element); - System.out.println(" Queue size: " + queue_.size()); - - Thread.sleep(random.nextLong() % MAX_PAUSE); - i++; - element++; - } - catch(Exception excp) - { - System.out.print("Producer::run() Exception: "); - System.out.println(excp); - } - } - } - - public void requestStop() - { - stop_requested_ = true; - } -} - diff --git a/java/tests/Concurrency/Condition/QueueTest.java b/java/tests/Concurrency/Condition/QueueTest.java deleted file mode 100644 index 87e7d57bbbd..00000000000 --- a/java/tests/Concurrency/Condition/QueueTest.java +++ /dev/null @@ -1,64 +0,0 @@ -//File: QueueTest.java -//Seth Widoff, 8/8/96 -//This class is a test method for the Producer and Consumer classes. -//The main method takes as arguments the number of producers, the -//number of consumers and the number of elements in the queue. It then -//spawn the specified threads and starts them. - -package tests.Concurrency.Condition; - -import JACE.ASX.TimeValue; - -public class QueueTest -{ - public static void main(String[] args) - { - if (args.length < 5) - { - System.out.println("Usage: java QueueTest <# producers> <# consumers> <# elements> <#iterations> <#timeout secs> <#timeout nano secs>"); - System.exit(1); - } - - int num_producers = Integer.parseInt(args[0]), - num_consumers = Integer.parseInt(args[1]), - num_elements = Integer.parseInt(args[2]), - num_iterations = Integer.parseInt(args[3]), - num_timeout_secs = Integer.parseInt(args[4]), - num_timeout_nano_secs = Integer.parseInt(args[5]); - - if (num_elements < 1 - || num_consumers < 1 - || num_producers < 1) - { - System.out.println("All the parameters must be larger than zero."); - System.exit(1); - } - - SimpleMessageQueue queue = new SimpleMessageQueue(num_elements); - Consumer[] consumers = new Consumer[num_consumers]; - Producer[] producers = new Producer[num_producers]; - JoinableThreadGroup thread_group = new JoinableThreadGroup("Producer Consumer"); - - for (int i = 0; i < num_producers; i++) - { - producers[i] = new Producer("Number " + (i + 1), queue, num_iterations, new TimeValue (num_timeout_secs, num_timeout_nano_secs)); - new Thread(thread_group, producers[i]).start(); - } - - for (int i = 0; i < num_consumers; i++) - { - consumers[i] = new Consumer("Number " + (i + 1), queue, num_iterations, new TimeValue (num_timeout_secs, num_timeout_nano_secs)); - new Thread(thread_group, consumers[i]).start(); - } - - try - { - thread_group.join(); - } - catch(InterruptedException excp) - { - System.out.println("QueueTest::main"); - System.out.println(excp); - } - } -} diff --git a/java/tests/Concurrency/Condition/SimpleMessageQueue.java b/java/tests/Concurrency/Condition/SimpleMessageQueue.java deleted file mode 100644 index bb703516858..00000000000 --- a/java/tests/Concurrency/Condition/SimpleMessageQueue.java +++ /dev/null @@ -1,86 +0,0 @@ -package tests.Concurrency.Condition; - -import JACE.ASX.TimeoutException; -import JACE.ASX.TimeValue; -import JACE.Concurrency.*; - -public class SimpleMessageQueue -{ - private int num_items_ = 0; - private int head_ = 0, tail_ = 0; - private Object[] queue_; - - private Mutex lock_ = new Mutex (); - private Condition notFull_ = new Condition (lock_); - private Condition notEmpty_ = new Condition (lock_); - - public SimpleMessageQueue(int size) - { - queue_ = new Object[size]; - } - - public void enqueue(Object element, TimeValue timeout) - throws TimeoutException, InterruptedException - { - try - { - lock_.acquire (); - while (this.isFull ()) - notFull_.Wait (timeout); - - if (tail_ == queue_.length) - tail_ = 0; - queue_[tail_] = element; - tail_++; - - num_items_++; - notEmpty_.signal (); - } - finally - { - lock_.release (); - } - } - - public Object dequeue (TimeValue timeout) - throws TimeoutException, InterruptedException - { - Object return_value = null; - - try - { - lock_.acquire (); - while (this.isEmpty ()) - notEmpty_.Wait (timeout); - - return_value = queue_[head_]; - head_++; - if (head_ == queue_.length) - head_ = 0; - - num_items_--; - notFull_.signal (); - } - finally - { - lock_.release (); - } - return return_value; - } - - public boolean isEmpty() - { - return num_items_ == 0; - } - - public boolean isFull() - { - return num_items_ == queue_.length; - } - - public int size() - { - return num_items_; - } -} - diff --git a/java/tests/Concurrency/MutexTest.java b/java/tests/Concurrency/MutexTest.java deleted file mode 100644 index 680266ef071..00000000000 --- a/java/tests/Concurrency/MutexTest.java +++ /dev/null @@ -1,154 +0,0 @@ -/************************************************* - * - * = PACKAGE - * tests.Concurrency - * - * = FILENAME - * MutexTest.java - * - *@author Prashant Jain - * - *************************************************/ -package tests.Concurrency; - -import java.io.*; -import JACE.OS.*; -import JACE.Concurrency.*; - -class MutexReader extends Thread -{ - MutexReader (int nIterations, Mutex mutex) - { - this.nIterations_ = nIterations; - this.mutex_ = mutex; - } - - public void run () - { - for (int i = 1; i <= this.nIterations_; i++) - { - // Acquire the mutex (will block until it gets it) - try - { - this.mutex_.acquire (); - } - catch (InterruptedException e) - { - ACE.ERROR (e); - } - - MutexTest.count++; - ACE.DEBUG (Thread.currentThread ().toString () + - " reader acquired mutex in iteration " + i + - ", count = " + MutexTest.count); - - try - { - Thread.sleep (1); - } - catch (InterruptedException e) - { - } - // Release the mutex - this.mutex_.release (); - try - { - Thread.sleep (1); - } - catch (InterruptedException e) - { - } - - } - } - - int nIterations_; - Mutex mutex_; -} - -class MutexWriter extends Thread -{ - MutexWriter (int nIterations, Mutex mutex) - { - this.nIterations_ = nIterations; - this.mutex_ = mutex; - } - - public void run () - { - for (int i = 1; i <= this.nIterations_; i++) - { - // Acquire the mutex (will block until it gets it) - try - { - this.mutex_.acquire (); - } - catch (InterruptedException e) - { - ACE.ERROR (e); - } - - MutexTest.count++; - ACE.DEBUG (Thread.currentThread ().toString () + - " writer acquired mutex in iteration " + i + - ", count = " + MutexTest.count); - - try - { - Thread.sleep (1); - } - catch (InterruptedException e) - { - } - - // Release the mutex - this.mutex_.release (); - try - { - Thread.sleep (1); - } - catch (InterruptedException e) - { - } - - } - } - - int nIterations_; - Mutex mutex_; -} - -public class MutexTest -{ - public static void main (String args[]) - { - int nReaders = 1; - int nWriters = 1; - int nIterations = 100; - int i; - try - { - if (args.length == 3) - { - nReaders = Integer.parseInt (args[0]); - nWriters = Integer.parseInt (args[1]); - nIterations = Integer.parseInt (args[2]); - } - } - catch (NumberFormatException e) - { - ACE.ERROR ("Illegal argument."); - } - - // Create a lock - Mutex mutex = new Mutex (); - - // Now spawn off the readers and writers - for (i = 0; i < nReaders; i++) - new MutexReader (nIterations, mutex).start (); - - for (i = 0; i < nWriters; i++) - new MutexWriter (nIterations, mutex).start (); - } - public static int count; -} diff --git a/java/tests/Concurrency/RWMutexTest.java b/java/tests/Concurrency/RWMutexTest.java deleted file mode 100644 index ab28c9a83fd..00000000000 --- a/java/tests/Concurrency/RWMutexTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/************************************************* - * - * = PACKAGE - * tests.Concurrency - * - * = FILENAME - * RWMutexTest.java - * - *@author Ross Dargahi (rossd@krinfo.com) - * - *************************************************/ -package tests.Concurrency; - -import JACE.OS.*; -import JACE.Concurrency.*; - -class TestThread extends Thread -{ - TestThread(String name, - boolean writer, - RWMutex lock) - { - super (name); - mWriter = writer; - mLock = lock; - } - - public void run() - { - for (int i = 0; i < 10; i++) - { - try - { - if (!mWriter) - { - mLock.acquireRead(); - ACE.DEBUG (getName() + ": Acquired Read Lock"); - - int sleepTime = i * 100; - sleep (sleepTime); - - mLock.release (); - ACE.DEBUG (getName () + ": Released Read Lock"); - } - else - { - mLock.acquireWrite (); - ACE.DEBUG (getName () + ": Acquired Write Lock"); - - int sleepTime = i * 100; - sleep (sleepTime); - - mLock.release (); - ACE.DEBUG (getName () + ": Released Write Lock"); - } - } - catch (InterruptedException ex) - { - ACE.ERROR ("InterruptedException"); - } - } - } - - RWMutex mLock; - boolean mWriter; -} - -public class RWMutexTest -{ - public static void main(String [] args) - { - RWMutex lock = new RWMutex(); - - TestThread t1 = new TestThread ("1", false, lock); - TestThread t2 = new TestThread ("2", false, lock); - TestThread t3 = new TestThread ("3", false, lock); - TestThread t4 = new TestThread ("4", true, lock); - TestThread t5 = new TestThread ("5", false, lock); - TestThread t6 = new TestThread ("6", false, lock); - TestThread t7 = new TestThread ("7", false, lock); - TestThread t8 = new TestThread ("8", true, lock); - - t1.start (); - t2.start (); - t3.start (); - t4.start (); - t5.start (); - t6.start (); - t7.start (); - t8.start (); - } -} - diff --git a/java/tests/Concurrency/SemaphoreTest.java b/java/tests/Concurrency/SemaphoreTest.java deleted file mode 100644 index b45929daa55..00000000000 --- a/java/tests/Concurrency/SemaphoreTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/************************************************* - * - * = PACKAGE - * tests.Concurrency - * - * = FILENAME - * SemaphoreTest.java - * - *@author Prashant Jain - * - *************************************************/ -package tests.Concurrency; - -import java.io.*; -import JACE.OS.*; -import JACE.Concurrency.*; - -class SemaphoreWriter extends Thread -{ - SemaphoreWriter (int nIterations, Semaphore s) - { - this.nIterations_ = nIterations; - this.s_ = s; - } - - public void run () - { - for (int i = 1; i <= this.nIterations_; i++) - { - // Acquire the semaphore (will block until it gets it) - try - { - this.s_.acquire (); - } - catch (InterruptedException e) - { - ACE.ERROR (e); - } - - SemaphoreTest.counter++; - ACE.DEBUG (Thread.currentThread ().toString () + - " acquired semaphore in iteration " + i + - ", counter = " + SemaphoreTest.counter); - - try - { - Thread.sleep (1); - } - catch (InterruptedException e) - { - } - - // Release the semaphore - this.s_.release (); - ACE.DEBUG (Thread.currentThread ().toString () + - " released semaphore in iteration " + i); - try - { - Thread.sleep (1); - } - catch (InterruptedException e) - { - } - - } - } - - int nIterations_; - Semaphore s_; -} - -public class SemaphoreTest -{ - public static void main (String args[]) - { - int nThreads = 1; - int count = 1; - int nIterations = 100; - int i; - try - { - if (args.length == 3) - { - nThreads = Integer.parseInt (args[0]); - count = Integer.parseInt (args[1]); - nIterations = Integer.parseInt (args[2]); - } - } - catch (NumberFormatException e) - { - ACE.ERROR ("Illegal argument."); - } - - // Create a lock - Semaphore s = new Semaphore (count); - - // Spawn off n_threads - for (i = 0; i < nThreads; i++) - new SemaphoreWriter (nIterations, s).start (); - } - public static int counter; -} diff --git a/java/tests/Concurrency/TokenTest.java b/java/tests/Concurrency/TokenTest.java deleted file mode 100644 index ededed9fed9..00000000000 --- a/java/tests/Concurrency/TokenTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/************************************************* - * - * = PACKAGE - * tests.Concurrency - * - * = FILENAME - * TokenTest.java - * - *@author Prashant Jain - * - *************************************************/ -package tests.Concurrency; - -import java.io.*; -import JACE.OS.*; -import JACE.Concurrency.*; - -class MyToken extends Token -{ - public void sleepHook () - { - ACE.DEBUG (Thread.currentThread () + " blocking, sleepHook called"); - } -} - -public class TokenTest implements Runnable -{ - public void run () - { - try - { - this.token_.acquire (); - ACE.DEBUG (Thread.currentThread () + " acquired token"); - this.token_.acquire (); - ACE.DEBUG (Thread.currentThread () + " acquired token"); - Thread.sleep (100); - - this.token_.renew (1); - - this.token_.release (); - ACE.DEBUG (Thread.currentThread () + " released token"); - this.token_.release (); - ACE.DEBUG (Thread.currentThread () + " released token"); - } - catch (InterruptedException e) - { - this.token_.release (); - } - } - - public static void main (String args []) - { - ThreadManager tm = new ThreadManager (); - int n = 1; - try - { - if (args.length == 1) - { - n = Integer.parseInt (args[0]); - } - } - catch (NumberFormatException e) - { - ACE.ERROR ("Illegal argument."); - } - - tm.spawnN (n, - new TokenTest (), - false); - } - - private MyToken token_ = new MyToken (); -} diff --git a/java/tests/Connection/AcceptorTest.java b/java/tests/Connection/AcceptorTest.java deleted file mode 100644 index 0f8877f52d9..00000000000 --- a/java/tests/Connection/AcceptorTest.java +++ /dev/null @@ -1,79 +0,0 @@ -// ============================================================================ -// -// = PACKAGE -// tests.Connection -// -// = FILENAME -// AcceptorTest.java -// -// = AUTHOR -// Prashant Jain -// -// ============================================================================ -package tests.Connection; - -import java.io.*; -import java.net.*; -import JACE.OS.*; -import JACE.Connection.*; - -public class AcceptorTest -{ - void print_usage_and_die () - { - System.out.println ("Usage: test_server [<port>]"); - System.exit (0); - } - - public void init (int port) - { - try - { - Acceptor acceptor = new Acceptor (Class.forName ("tests.Connection.ServerHandler")); - acceptor.open (port); - while (true) - { - acceptor.accept (); - } - } - catch (ClassNotFoundException e) - { - ACE.ERROR (e); - } - catch (SocketException e) - { - ACE.ERROR ("Socket Exception: " + e); - } - catch (InstantiationException e) - { - ACE.ERROR (e); - } - catch (IllegalAccessException e) - { - ACE.ERROR ("Dang!" + e); - } - catch (IOException e) - { - ACE.ERROR (e); - } - } - - public static void main (String [] args) - { - int port = ACE.DEFAULT_SERVER_PORT; - AcceptorTest acceptorTest = new AcceptorTest (); - - if (args.length == 1) - { - try - { - port = Integer.parseInt (args[0]); - } - catch (NumberFormatException e) - { - acceptorTest.print_usage_and_die (); - } - } - acceptorTest.init (port); - } -} diff --git a/java/tests/Connection/ClientHandler.java b/java/tests/Connection/ClientHandler.java deleted file mode 100644 index a18f7740cce..00000000000 --- a/java/tests/Connection/ClientHandler.java +++ /dev/null @@ -1,77 +0,0 @@ -// ============================================================================ -// -// = PACKAGE -// tests.Connection -// -// = FILENAME -// ClientHandler.java -// -// = AUTHOR -// Prashant Jain -// -// ============================================================================ -package tests.Connection; - -import java.io.*; -import java.net.*; -import JACE.OS.*; -import JACE.Connection.*; - -public class ClientHandler extends SvcHandler -{ - public ClientHandler () - { - } - - public int open (Object obj) - { - new Thread (this).start (); - return 0; - } - - public void run () - { - BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); - - String msg; - StringBuffer ack = new StringBuffer (); - int ack_len; - try - { - while (true) - { - System.out.print ("Enter input: "); - System.out.flush (); - msg = in.readLine (); - if (msg == null) - break; - this.peer ().send (new StringBuffer (msg)); - System.out.println ("Waiting for ack..."); - ack_len = this.peer ().recv (ack); - if (ack_len == 0) - break; - else - System.out.println (ack); - } - } - catch (NullPointerException e) - { - ACE.ERROR ("connection reset by peer"); - } - catch (IOException e) - { - ACE.ERROR (e); - } - finally - { - try - { - this.peer ().close (); - } - catch (IOException e) - { - } - } - - } -} diff --git a/java/tests/Connection/ConnectorTest.java b/java/tests/Connection/ConnectorTest.java deleted file mode 100644 index 605d5e7a400..00000000000 --- a/java/tests/Connection/ConnectorTest.java +++ /dev/null @@ -1,76 +0,0 @@ -// ============================================================================ -// -// = PACKAGE -// tests.Connection -// -// = FILENAME -// ConnectorTest.java -// -// = AUTHOR -// Prashant Jain -// -// ============================================================================ -package tests.Connection; - -import java.io.*; -import java.net.*; -import JACE.OS.*; -import JACE.Connection.*; - -public class ConnectorTest -{ - void print_usage_and_die () - { - System.out.println ("Usage: test_Connector <hostname> [<port>]"); - System.exit (0); - } - - public void init (String hostname, int port) - { - try - { - Connector connector = new Connector (); - connector.open (hostname, port); - connector.connect (new ClientHandler ()); - } - catch (UnknownHostException e) - { - ACE.ERROR (e); - } - catch (SocketException e) - { - ACE.ERROR ("Connection refused"); - } - catch (InstantiationException e) - { - ACE.ERROR (e); - } - catch (IllegalAccessException e) - { - ACE.ERROR (e); - } - catch (IOException e) - { - ACE.ERROR (e); - } - } - - public static void main (String [] args) - { - int port = ACE.DEFAULT_SERVER_PORT; - ConnectorTest connectorTest = new ConnectorTest (); - - if (args.length == 2) - { - try - { - port = Integer.parseInt (args[1]); - } - catch (NumberFormatException e) - { - connectorTest.print_usage_and_die (); - } - } - connectorTest.init (args[0], port); - } -} diff --git a/java/tests/Connection/HTTPHelperTest.java b/java/tests/Connection/HTTPHelperTest.java deleted file mode 100644 index 02a16d838af..00000000000 --- a/java/tests/Connection/HTTPHelperTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package tests.Connection; - -import java.io.*; -import JACE.Connection.*; - -public class HTTPHelperTest -{ - public static void main(String args[]) - { - // This is just a quick test to confirm that the Base 64 encoding and decoding work - // (tests the example given in the HTTP 1.1 RFC) - - String secret = "Aladdin:open sesame"; - - String encoded = JACE.Connection.HTTPHelper.EncodeBase64(secret); - - System.err.println("Encoding string: " + secret); - - System.err.println("Result: " + encoded); - - System.err.println("Is this right? " + (encoded.equals("QWxhZGRpbjpvcGVuIHNlc2FtZQ==") ? "Yes" : "No")); - - // Decode should also be tested - // - } -}; - diff --git a/java/tests/Connection/ServerHandler.java b/java/tests/Connection/ServerHandler.java deleted file mode 100644 index 7cdd50d7d37..00000000000 --- a/java/tests/Connection/ServerHandler.java +++ /dev/null @@ -1,68 +0,0 @@ -// ============================================================================ -// -// = PACKAGE -// tests.Connection -// -// = FILENAME -// ServerHandler.java -// -// = AUTHOR -// Prashant Jain -// -// ============================================================================ -package tests.Connection; - -import java.io.*; -import java.net.*; -import JACE.OS.*; -import JACE.Connection.*; - -public class ServerHandler extends SvcHandler -{ - public ServerHandler () - { - } - - public int open (Object obj) - { - new Thread (this).start (); - return 0; - } - - public void run () - { - int msg_len; - System.out.println ("Waiting for messages..."); - try - { - while (true) - { - StringBuffer msg = new StringBuffer (); - msg_len = this.peer ().recv (msg); - if (msg_len == 0) - break; - System.out.println ("Received: " + msg); - this.peer ().send (new StringBuffer ("Got it!")); - } - } - catch (NullPointerException e) - { - ACE.ERROR ("connection reset by peer"); - } - catch (IOException e) - { - ACE.ERROR (e); - } - finally - { - try - { - this.peer ().close (); - } - catch (IOException e) - { - } - } - - } -} diff --git a/java/tests/Misc/ParseArgsTest.java b/java/tests/Misc/ParseArgsTest.java deleted file mode 100644 index 5baddd2745d..00000000000 --- a/java/tests/Misc/ParseArgsTest.java +++ /dev/null @@ -1,45 +0,0 @@ -// ============================================================================ -// -// = PACKAGE -// tests.Misc -// -// = FILENAME -// ParseArgsTest.java -// -// = AUTHOR -// Prashant Jain -// -// ============================================================================ -package tests.Misc; - -import JACE.OS.*; -import JACE.Misc.*; - -public class ParseArgsTest -{ - public static void main (String args[]) - { - String s; - GetOpt opt = new GetOpt (args, "p:rs:"); - for (int c; (c = opt.next ()) != -1; ) - { - switch (c) - { - case 'p': - s = opt.optarg (); - ACE.DEBUG ("Option <p> selected with argument " + s); - break; - case 'r': - ACE.DEBUG ("Option <r> selected"); - break; - case 's': - s = opt.optarg (); - ACE.DEBUG ("Option <s> selected with argument " + s); - break; - default: - ACE.DEBUG ("Usage: java tests.Misc.ParseArgsTest [-p arg1] [-r] [-s arg2]"); - break; - } - } - } -} diff --git a/java/tests/Reactor/TimeValueTest.java b/java/tests/Reactor/TimeValueTest.java deleted file mode 100644 index b4f3e420ae1..00000000000 --- a/java/tests/Reactor/TimeValueTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/************************************************* - * - * = PACKAGE - * ACE.Reactor - * - * = FILENAME - * TimeValueTest.java - * - *@author Prashant Jain - * - *************************************************/ -package tests.Reactor; - -import JACE.OS.*; -import JACE.ASX.*; - -public class TimeValueTest -{ - public void ASSERT (boolean expression, int i) - { - if (!expression) - ACE.DEBUG ("ASSERT failed for " + i); - } - - public void runTest () - { - TimeValue tv1 = new TimeValue (); - TimeValue tv2 = new TimeValue (2); - TimeValue tv3 = new TimeValue (100); - TimeValue tv4 = new TimeValue (1, 1000000000); - TimeValue tv5 = new TimeValue (2); - TimeValue tv6 = new TimeValue (1, -1000000000); - - this.ASSERT (tv1.equals (new TimeValue (0)), 1); - this.ASSERT (tv2.lessThan (tv3), 2); - this.ASSERT (tv2.lessThanEqual (tv2), 3); - this.ASSERT (tv2.greaterThanEqual (tv4), 4); - this.ASSERT (tv5.greaterThanEqual (tv6), 5); - this.ASSERT (tv2.equals (new TimeValue (1, 1000000000)), 6); - this.ASSERT (tv5.equals (tv4), 7); - this.ASSERT (tv2.equals (tv4), 8); - this.ASSERT (tv1.notEquals (tv2), 9); - this.ASSERT (tv6.equals (tv1), 10); - } - - public static void main (String [] args) - { - new TimeValueTest ().runTest (); - } -} diff --git a/java/tests/Reactor/TimerQueueTest.java b/java/tests/Reactor/TimerQueueTest.java deleted file mode 100644 index d34439dcf9b..00000000000 --- a/java/tests/Reactor/TimerQueueTest.java +++ /dev/null @@ -1,80 +0,0 @@ -// ============================================================================ -// -// = PACKAGE -// tests.Reactor -// -// = FILENAME -// TimerQueueTest.java -// -// = AUTHOR -// Prashant Jain -// -// ============================================================================ -package tests.Reactor; - -import JACE.OS.*; -import JACE.ASX.*; -import JACE.Reactor.*; - -public class TimerQueueTest implements EventHandler -{ - public int handleTimeout (TimeValue tv, Object obj) - { - ACE.DEBUG ("handleTimeout: " + tv.toString () + " " + (String) obj); - return 0; - } - - public static void main (String args []) - { - TimerQueue tq = new TimerQueue (true); - TimerQueueTest th1 = new TimerQueueTest (); - int n = 5; - - try - { - if (args.length == 1) - { - n = Integer.parseInt (args[0]); - } - } - catch (NumberFormatException e) - { - ACE.ERROR ("Illegal argument."); - } - - // Set a periodic timer - int id= tq.scheduleTimer (th1, - "periodic", - new TimeValue (2), - new TimeValue (3)); - - int i; - // Set a bunch of single timers - for (i=1; i <= n; i++) - { - tq.scheduleTimer (th1, - "A-timer-" + new Integer (i), - new TimeValue (i*2)); - } - - TimerQueueTest th2 = new TimerQueueTest (); - for (i=1; i <= n; i++) - { - tq.scheduleTimer (th2, - "B-timer-" + new Integer (i), - new TimeValue (i*3)); - } - // Cancel all timers associated with this handler - tq.cancelTimer (th2); - - try - { - Thread.sleep (30000); - } - catch (InterruptedException e) - { - } - tq.cancelTimer (id); - System.exit (0); - } -} diff --git a/java/tests/SOCK_SAP/SOCKAcceptorTest.java b/java/tests/SOCK_SAP/SOCKAcceptorTest.java deleted file mode 100644 index 34ab8ecb6c9..00000000000 --- a/java/tests/SOCK_SAP/SOCKAcceptorTest.java +++ /dev/null @@ -1,108 +0,0 @@ -// ============================================================================ -// -// = PACKAGE -// tests.SOCK_SAP -// -// = FILENAME -// SOCKAcceptorTest.java -// -// = AUTHOR -// Prashant Jain -// -// ============================================================================ -package tests.SOCK_SAP; - -import java.io.*; -import java.net.*; -import JACE.OS.*; -import JACE.SOCK_SAP.*; - -class TestHandler extends Thread -{ - public TestHandler (SOCKStream stream) - { - this.stream_ = stream; - this.start (); - } - - public void run () - { - int msgLen; - System.out.println ("Waiting for messages..."); - try - { - while (true) - { - StringBuffer msg = new StringBuffer (); - msgLen = this.stream_.recv (msg); - if (msgLen == 0) - break; - ACE.DEBUG ("Received: " + msg); - this.stream_.send ("Got it!"); - } - } - catch (NullPointerException e) - { - ACE.ERROR ("connection reset by peer"); - } - catch (IOException e) - { - ACE.ERROR (e); - } - finally - { - try - { - this.stream_.close (); - } - catch (IOException e) - { - } - } - } - SOCKStream stream_; -} - -public class SOCKAcceptorTest -{ - void print_usage_and_die () - { - ACE.DEBUG ("Usage: SOCKAcceptorTest [<port>]"); - System.exit (0); - } - - public void init (int port) - { - try - { - SOCKAcceptor acceptor = new SOCKAcceptor (port); - while (true) - { - SOCKStream stream = new SOCKStream (); - acceptor.accept (stream); - TestHandler handler = new TestHandler (stream); - } - } - catch (IOException e) - { - } - } - - public static void main (String [] args) - { - int port = ACE.DEFAULT_SERVER_PORT; - SOCKAcceptorTest server = new SOCKAcceptorTest (); - if (args.length == 1) - { - try - { - port = Integer.parseInt (args[0]); - } - catch (NumberFormatException e) - { - server.print_usage_and_die (); - } - } - server.init (port); - } -} diff --git a/java/tests/SOCK_SAP/SOCKConnectorTest.java b/java/tests/SOCK_SAP/SOCKConnectorTest.java deleted file mode 100644 index d1fdacc48a4..00000000000 --- a/java/tests/SOCK_SAP/SOCKConnectorTest.java +++ /dev/null @@ -1,95 +0,0 @@ -// ============================================================================ -// -// = PACKAGE -// tests.SOCK_SAP -// -// = FILENAME -// SOCKConnectorTest.java -// -// = AUTHOR -// Prashant Jain -// -// ============================================================================ -package tests.SOCK_SAP; - -import java.io.*; -import java.net.*; -import JACE.OS.*; -import JACE.SOCK_SAP.*; - -public class SOCKConnectorTest -{ - static void print_usage_and_die () - { - System.out.println ("Usage: SOCKConnectorTest <hostname> [<port>]"); - System.exit (0); - } - - void processRequests (SOCKStream stream) throws IOException - { - // 1.0 JDK DataInputStream in = new DataInputStream (System.in); - BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); - String msg; - int ack_len; - - while (true) - { - StringBuffer ack = new StringBuffer (); - ACE.DEBUG ("Enter input: "); - ACE.FLUSH (); - msg = in.readLine (); - if (msg == null) - break; - stream.send (msg); - ACE.DEBUG ("Waiting for ack..."); - ack_len = stream.recv (ack); - if (ack_len == 0) - break; - else - ACE.DEBUG (ack.toString ()); - } - } - - public void init (String host, int port) - { - SOCKStream stream = new SOCKStream (); - SOCKConnector connector = new SOCKConnector (); - try - { - connector.connect (stream, - host, - port); - processRequests (stream); - } - catch (IOException e) - { - ACE.ERROR (e); - } - } - - public static void main (String [] args) - { - int port = ACE.DEFAULT_SERVER_PORT; - SOCKConnectorTest client = new SOCKConnectorTest (); - - // check arg count - if (args.length == 0 || args.length > 2) - print_usage_and_die(); - - if (args.length == 2) - { - try - { - port = Integer.parseInt (args[1]); - } - catch (NumberFormatException e) - { - client.print_usage_and_die (); - } - } - client.init (args[0], port); - - - } -} - diff --git a/java/tests/ServiceConfigurator/TestService.java b/java/tests/ServiceConfigurator/TestService.java deleted file mode 100644 index 7b34c181c60..00000000000 --- a/java/tests/ServiceConfigurator/TestService.java +++ /dev/null @@ -1,52 +0,0 @@ -/************************************************* - * - * = PACKAGE - * tests.ServiceConfigurator - * - * = FILENAME - * TestService.java - * - *@author Prashant Jain - * - *************************************************/ -package tests.ServiceConfigurator; - -import JACE.ServiceConfigurator.*; -import JACE.OS.*; - -public class TestService extends ServiceObject -{ - public int init (String [] args) - { - System.out.println("TestService init with arguments: "); - - if (args != null) - for (int i = 0; i < args.length; i++) - ACE.DEBUG (args[i]); - - return 0; - } - - public int suspend() - { - System.out.println("TestService suspend ----"); - - return 0; - } - - public int resume() - { - System.out.println("TestService resume ----"); - - return 0; - } - - public int fini() - { - System.out.println("TestService remove ----"); - - return 0; - } - -} - diff --git a/java/tests/ServiceConfigurator/reloadTest.java b/java/tests/ServiceConfigurator/reloadTest.java deleted file mode 100644 index 27806890239..00000000000 --- a/java/tests/ServiceConfigurator/reloadTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/************************************************* - * - * = PACKAGE - * tests.ServiceConfigurator - * - * = FILENAME - * mainTest.java - * - *@author Prashant Jain, Everett Anderson - * - *************************************************/ -package tests.ServiceConfigurator; - -import JACE.ServiceConfigurator.*; -import JACE.OS.*; -import java.io.*; - -public class reloadTest -{ - - public static void main (String args []) - { - ServiceConfig daemon = new ServiceConfig (); - try - { - daemon.open (args); - Thread.sleep (10000); - - daemon.remove("TimeService"); - - daemon.open (args); - } - catch (InterruptedException e) - { - ACE.ERROR (e); - } - catch (FileNotFoundException e) - { - ACE.ERROR (e); - } - catch (IOException e) - { - ACE.ERROR (e); - } - catch (ClassNotFoundException e) - { - ACE.ERROR (e + "foo"); - } - catch (IllegalAccessException e) - { - ACE.ERROR (e); - } - catch (InstantiationException e) - { - ACE.ERROR (e); - } - - System.err.println("End of reloadTest"); - } - -} diff --git a/java/tests/ServiceConfigurator/suspendTest.java b/java/tests/ServiceConfigurator/suspendTest.java deleted file mode 100644 index ab12d06f2f5..00000000000 --- a/java/tests/ServiceConfigurator/suspendTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/************************************************* - * - * = PACKAGE - * tests.ServiceConfigurator - * - * = FILENAME - * mainTest.java - * - *@author Prashant Jain, Everett Anderson - * - *************************************************/ -package tests.ServiceConfigurator; - -import JACE.ServiceConfigurator.*; -import JACE.OS.*; -import java.io.*; - -public class suspendTest -{ - - public static void main (String args []) - { - ServiceConfig daemon = new ServiceConfig (); - ACE.enableDebugging(); - - try - { - String args1 = "-f suspendTest1.conf"; - String[] argv1 = OS.createStringArray(args1, " "); - - daemon.open (argv1); - - Thread.sleep (10000); - - - System.err.println("Suspending"); - String args2 = "-f suspendTest2.conf"; - String[] argv2 = OS.createStringArray(args2, " "); - - daemon.open (argv2); - - Thread.sleep (10000); - - System.err.println("Resuming"); - String args3 = "-f suspendTest3.conf"; - String[] argv3 = OS.createStringArray(args3, " "); - - daemon.open (argv3); - - Thread.sleep(10000); - } - catch (InterruptedException e) - { - ACE.ERROR (e); - } - catch (FileNotFoundException e) - { - ACE.ERROR (e); - } - catch (IOException e) - { - ACE.ERROR (e); - } - catch (ClassNotFoundException e) - { - ACE.ERROR (e + "foo"); - } - catch (IllegalAccessException e) - { - ACE.ERROR (e); - } - catch (InstantiationException e) - { - ACE.ERROR (e); - } - - System.err.println("End of suspendTest"); - } - -} diff --git a/java/tests/ServiceConfigurator/suspendTest1.conf b/java/tests/ServiceConfigurator/suspendTest1.conf deleted file mode 100644 index 983af3234c1..00000000000 --- a/java/tests/ServiceConfigurator/suspendTest1.conf +++ /dev/null @@ -1 +0,0 @@ -load TestService tests.ServiceConfigurator.TestService ServiceObject "-p 10002" diff --git a/java/tests/ServiceConfigurator/suspendTest2.conf b/java/tests/ServiceConfigurator/suspendTest2.conf deleted file mode 100644 index 5cd6cd0fc77..00000000000 --- a/java/tests/ServiceConfigurator/suspendTest2.conf +++ /dev/null @@ -1 +0,0 @@ -suspend TestService diff --git a/java/tests/ServiceConfigurator/suspendTest3.conf b/java/tests/ServiceConfigurator/suspendTest3.conf deleted file mode 100644 index 71250c3acd7..00000000000 --- a/java/tests/ServiceConfigurator/suspendTest3.conf +++ /dev/null @@ -1 +0,0 @@ -resume TestService diff --git a/java/tests/ServiceConfigurator/svc.conf b/java/tests/ServiceConfigurator/svc.conf deleted file mode 100644 index 983af3234c1..00000000000 --- a/java/tests/ServiceConfigurator/svc.conf +++ /dev/null @@ -1 +0,0 @@ -load TestService tests.ServiceConfigurator.TestService ServiceObject "-p 10002" diff --git a/java/tests/netsvcs/Logger/LoggerTest.java b/java/tests/netsvcs/Logger/LoggerTest.java deleted file mode 100644 index 40ac903a1d3..00000000000 --- a/java/tests/netsvcs/Logger/LoggerTest.java +++ /dev/null @@ -1,122 +0,0 @@ -/************************************************* - * - * = FILENAME - * LoggerTest.java - * - *@author Everett Anderson - * - *************************************************/ -package tests.netsvcs.Logger; - -import JACE.SOCK_SAP.*; -import java.io.*; -import java.net.*; -import JACE.OS.*; -import netsvcs.Logger.LogRecord; - -/** - * - * <p><h2>DESCRIPTION</h2> - * - * <blockquote> - * 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. - * </blockquote> - * - * @see netsvcs.Logger.ServerLoggingAcceptor, netsvcs.Logger.LogRecord - */ -public class LoggerTest { - - /** Command line: <hostname> [<port>] - * - * Creates a "hello world" log message and sends it to the server logging service. - * If no command line arguments are given, it uses ACE.DEFAULT_SERVER_PORT, and the - * current machine for the service location. - * - */ - public static void main(String args[]) - { - if (args.length < 1) { - System.err.println("Use: LoggerTest <host name> [<port>]"); - System.exit(0); - } - - // 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 { - - // Get a transmission system from the socket - OutputStream os = cli_stream.socket().getOutputStream(); - DataOutputStream dos = new DataOutputStream(os); - - // Send it - record.streamOutTo(dos); - - // Close the socket - cli_stream.close(); - - } catch (IOException ie) { - - ACE.ERROR("IOException, loop: " + ie); - return; - } - } -}; - - - - - - - - - - diff --git a/java/tests/netsvcs/Naming/ClientTest.java b/java/tests/netsvcs/Naming/ClientTest.java deleted file mode 100644 index c1189fecd7f..00000000000 --- a/java/tests/netsvcs/Naming/ClientTest.java +++ /dev/null @@ -1,117 +0,0 @@ -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")); - - res = proxy.resolve("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); - } - } - - } - -}; - |