You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@etch.apache.org by sc...@apache.org on 2008/12/01 15:42:58 UTC
svn commit: r722085 - in /incubator/etch/trunk/binding-java/runtime/src:
main/java/etch/bindings/java/transport/PlainMailbox.java
test/java/etch/bindings/java/transport/TestPlainMailbox.java
Author: sccomer
Date: Mon Dec 1 06:42:58 2008
New Revision: 722085
URL: http://svn.apache.org/viewvc?rev=722085&view=rev
Log:
java unit test for fix for ETCH-8.
Modified:
incubator/etch/trunk/binding-java/runtime/src/main/java/etch/bindings/java/transport/PlainMailbox.java
incubator/etch/trunk/binding-java/runtime/src/test/java/etch/bindings/java/transport/TestPlainMailbox.java
Modified: incubator/etch/trunk/binding-java/runtime/src/main/java/etch/bindings/java/transport/PlainMailbox.java
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-java/runtime/src/main/java/etch/bindings/java/transport/PlainMailbox.java?rev=722085&r1=722084&r2=722085&view=diff
==============================================================================
--- incubator/etch/trunk/binding-java/runtime/src/main/java/etch/bindings/java/transport/PlainMailbox.java (original)
+++ incubator/etch/trunk/binding-java/runtime/src/main/java/etch/bindings/java/transport/PlainMailbox.java Mon Dec 1 06:42:58 2008
@@ -149,7 +149,7 @@
public void registerNotify( Notify newNotify, Object newState, int maxDelay )
{
if (newNotify == null)
- throw new NullPointerException( "notify == null" );
+ throw new NullPointerException( "newNotify == null" );
if (maxDelay < 0)
throw new IllegalArgumentException( "maxDelay < 0" );
@@ -180,7 +180,7 @@
public void unregisterNotify( Notify oldNotify )
{
if (oldNotify == null)
- throw new NullPointerException( "notify == null" );
+ throw new NullPointerException( "oldNotify == null" );
if (this.notify == null)
return;
@@ -188,7 +188,7 @@
synchronized (queue)
{
if (oldNotify != this.notify)
- throw new IllegalStateException( "notify != this.notify" );
+ throw new IllegalStateException( "oldNotify != this.notify" );
if (alarmSet)
{
Modified: incubator/etch/trunk/binding-java/runtime/src/test/java/etch/bindings/java/transport/TestPlainMailbox.java
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-java/runtime/src/test/java/etch/bindings/java/transport/TestPlainMailbox.java?rev=722085&r1=722084&r2=722085&view=diff
==============================================================================
--- incubator/etch/trunk/binding-java/runtime/src/test/java/etch/bindings/java/transport/TestPlainMailbox.java (original)
+++ incubator/etch/trunk/binding-java/runtime/src/test/java/etch/bindings/java/transport/TestPlainMailbox.java Mon Dec 1 06:42:58 2008
@@ -41,8 +41,9 @@
public class TestPlainMailbox
{
private final MyMailboxManager mmgr = new MyMailboxManager();
-
+
private final MyNotify notify = new MyNotify();
+ private final MyNotify notify1 = new MyNotify();
/** @throws Exception */
@Test
@@ -396,6 +397,112 @@
mb.message( alice_who, foo_msg );
notify.checkMailboxStatus( true, mb, state, false );
}
+
+ /** @throws Exception */
+ @Test( expected = NullPointerException.class )
+ public void reg1() throws Exception
+ {
+ // notify == null
+ PlainMailbox mb = new PlainMailbox( mmgr, 1L );
+ mb.registerNotify( null, null, 0 );
+ }
+
+ /** @throws Exception */
+ @Test( expected = IllegalArgumentException.class )
+ public void reg2() throws Exception
+ {
+ // maxDelay < 0
+ PlainMailbox mb = new PlainMailbox( mmgr, 1L );
+ mb.registerNotify( notify, null, -1 );
+ }
+
+ /** @throws Exception */
+ @Test
+ public void reg3() throws Exception
+ {
+ PlainMailbox mb = new PlainMailbox( mmgr, 1L );
+ mb.registerNotify( notify, null, 0 );
+ }
+
+ /** @throws Exception */
+ @Test( expected = IllegalStateException.class )
+ public void reg4() throws Exception
+ {
+ // this.notify != null
+ PlainMailbox mb = new PlainMailbox( mmgr, 1L );
+ mb.registerNotify( notify, null, 0 );
+ mb.registerNotify( notify, null, 0 );
+ }
+
+ /** @throws Exception */
+ @Test( expected = IllegalStateException.class )
+ public void reg5() throws Exception
+ {
+ // this.notify != null
+ PlainMailbox mb = new PlainMailbox( mmgr, 1L );
+ mb.registerNotify( notify, null, 0 );
+ mb.registerNotify( notify1, null, 0 );
+ }
+
+ /** @throws Exception */
+ @Test
+ public void unreg1() throws Exception
+ {
+ PlainMailbox mb = new PlainMailbox( mmgr, 1L );
+ mb.unregisterNotify( notify );
+ }
+
+ /** @throws Exception */
+ @Test
+ public void unreg2() throws Exception
+ {
+ PlainMailbox mb = new PlainMailbox( mmgr, 1L );
+ mb.registerNotify( notify, null, 0 );
+ mb.unregisterNotify( notify );
+ }
+
+ /** @throws Exception */
+ @Test
+ public void unreg3() throws Exception
+ {
+ PlainMailbox mb = new PlainMailbox( mmgr, 1L );
+ mb.registerNotify( notify, null, 0 );
+ mb.unregisterNotify( notify );
+ mb.unregisterNotify( notify );
+ mb.unregisterNotify( notify1 );
+ }
+
+ /** @throws Exception */
+ @Test
+ public void unreg4() throws Exception
+ {
+ PlainMailbox mb = new PlainMailbox( mmgr, 1L );
+ mb.registerNotify( notify, null, 0 );
+ mb.unregisterNotify( notify );
+ mb.registerNotify( notify, null, 0 );
+ mb.unregisterNotify( notify );
+ mb.registerNotify( notify1, null, 0 );
+ mb.unregisterNotify( notify1 );
+ }
+
+ /** @throws Exception */
+ @Test( expected = IllegalStateException.class )
+ public void unreg5() throws Exception
+ {
+ // notify != this.notify
+ PlainMailbox mb = new PlainMailbox( mmgr, 1L );
+ mb.registerNotify( notify, null, 0 );
+ mb.unregisterNotify( notify1 );
+ }
+
+ /** @throws Exception */
+ @Test
+ public void unreg6() throws Exception
+ {
+ PlainMailbox mb = new PlainMailbox( mmgr, 1L );
+ mb.registerNotify( notify, null, 30 );
+ mb.unregisterNotify( notify );
+ }
///////////////////
// HELPFUL STUFF //
@@ -485,7 +592,6 @@
}
/** */
- @SuppressWarnings("hiding")
static class MyNotify implements Notify
{
public void mailboxStatus( Mailbox mb, Object state, boolean closed )