Skip to Content.
Sympa Menu

notify-dpml - r1248 - in trunk/main/util/job/impl/src: main/net/dpml/job/impl test/net/dpml/job test/net/dpml/job/impl

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: r1248 - in trunk/main/util/job/impl/src: main/net/dpml/job/impl test/net/dpml/job test/net/dpml/job/impl
  • Date: Wed, 22 Mar 2006 19:31:32 +0100

Author: mcconnell
Date: 2006-03-22 19:31:21 +0100 (Wed, 22 Mar 2006)
New Revision: 1248

Added:
trunk/main/util/job/impl/src/test/net/dpml/job/impl/
trunk/main/util/job/impl/src/test/net/dpml/job/impl/FIFOTestCase.java
Modified:
trunk/main/util/job/impl/src/main/net/dpml/job/impl/FIFO.java
Log:
testcaseshousekeeping


Modified: trunk/main/util/job/impl/src/main/net/dpml/job/impl/FIFO.java
===================================================================
--- trunk/main/util/job/impl/src/main/net/dpml/job/impl/FIFO.java
2006-03-22 18:18:03 UTC (rev 1247)
+++ trunk/main/util/job/impl/src/main/net/dpml/job/impl/FIFO.java
2006-03-22 18:31:21 UTC (rev 1248)
@@ -30,11 +30,17 @@
{
private ArrayList m_queue;

+ /**
+ * Creation of a new FIFO queue.
+ */
FIFO()
{
m_queue = new ArrayList();
}

+ /**
+ * Clear the queue.
+ */
void clear()
{
synchronized( this )
@@ -43,6 +49,9 @@
}
}

+ /**
+ * Add an object to the queue.
+ */
void put( Object obj )
{
synchronized( this )
@@ -52,6 +61,11 @@
}
}

+ /**
+ * Get the first object entered in the queue.
+ * @return the first object
+ * @exception InterruptedException if interrupted
+ */
Object get() throws InterruptedException
{
synchronized( this )
@@ -64,6 +78,10 @@
}
}

+ /**
+ * Get the number of objects on the queue.
+ * @return the number of objects
+ */
int size()
{
synchronized( this )

Added: trunk/main/util/job/impl/src/test/net/dpml/job/impl/FIFOTestCase.java
===================================================================
--- trunk/main/util/job/impl/src/test/net/dpml/job/impl/FIFOTestCase.java
2006-03-22 18:18:03 UTC (rev 1247)
+++ trunk/main/util/job/impl/src/test/net/dpml/job/impl/FIFOTestCase.java
2006-03-22 18:31:21 UTC (rev 1248)
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2006 Stephen J. McConnell.
+ *
+ * Licensed 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 net.dpml.job.impl;
+
+import junit.framework.TestCase;
+
+/**
+ * FIFO list validation.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class FIFOTestCase extends TestCase
+{
+ /**
+ * Test the FIFO inital size.
+ * @exception Exception if an error occurs
+ */
+ public void testFIFO() throws Exception
+ {
+ FIFO fifo = new FIFO();
+ assertEquals( "size", 0, fifo.size() );
+ Object a = new Object();
+ Object b = new Object();
+ Object c = new Object();
+ fifo.put( a );
+ fifo.put( b );
+ fifo.put( c );
+ assertEquals( "size", 3, fifo.size() );
+ fifo.clear();
+ assertEquals( "size", 0, fifo.size() );
+ }
+
+ /**
+ * Test the FIFO semantics.
+ * @exception Exception if an error occurs
+ */
+ public void testFIFOSemantics() throws Exception
+ {
+ FIFO fifo = new FIFO();
+ Object a = new Object();
+ Object b = new Object();
+ Object c = new Object();
+ fifo.put( a );
+ fifo.put( b );
+ fifo.put( c );
+ Object first = fifo.get();
+ assertEquals( "first", a, first );
+ assertEquals( "size", 2, fifo.size() );
+ Object second = fifo.get();
+ assertEquals( "second", b, second );
+ assertEquals( "size", 1, fifo.size() );
+ Object third = fifo.get();
+ assertEquals( "third", c, third );
+ assertEquals( "size", 0, fifo.size() );
+ }
+
+}




  • r1248 - in trunk/main/util/job/impl/src: main/net/dpml/job/impl test/net/dpml/job test/net/dpml/job/impl, mcconnell at BerliOS, 03/22/2006

Archive powered by MHonArc 2.6.24.

Top of Page