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/02 23:38:21 UTC

svn commit: r722646 - in /incubator/etch/trunk/binding-csharp/runtime/src: main/csharp/Etch/Util/ test/csharp/ test/csharp/Etch/Support/ test/csharp/Etch/Util/

Author: sccomer
Date: Tue Dec  2 14:38:21 2008
New Revision: 722646

URL: http://svn.apache.org/viewvc?rev=722646&view=rev
Log:
change the exception thrown by AbstractStartable for already started and is not started to Exception from ThreadInterruptedException.

change NullReferenceException thrown by AlarmManager when listener is null to ArgumentNullException.

shell of unit test for AlarmManager.

Added:
    incubator/etch/trunk/binding-csharp/runtime/src/test/csharp/Etch/Util/TestAlarmManager.cs   (with props)
Modified:
    incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Etch/Util/AbstractStartable.cs
    incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Etch/Util/AlarmManager.cs
    incubator/etch/trunk/binding-csharp/runtime/src/test/csharp/Etch/Support/TestTodoManager.cs
    incubator/etch/trunk/binding-csharp/runtime/src/test/csharp/EtchTestProj.csproj

Modified: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Etch/Util/AbstractStartable.cs
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Etch/Util/AbstractStartable.cs?rev=722646&r1=722645&r2=722646&view=diff
==============================================================================
--- incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Etch/Util/AbstractStartable.cs (original)
+++ incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Etch/Util/AbstractStartable.cs Tue Dec  2 14:38:21 2008
@@ -28,7 +28,7 @@
         public void Start()
         {
             if (IsStarted())
-                throw new Exception("Is already started");
+                throw new Exception("is already started");
 
             try
             {
@@ -79,7 +79,7 @@
         public void CheckIsStarted()
         {
             if (!IsStarted())
-                throw new System.Threading.ThreadInterruptedException("is not started");
+                throw new Exception("is not started");
         }
 
         /// <summary>

Modified: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Etch/Util/AlarmManager.cs
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Etch/Util/AlarmManager.cs?rev=722646&r1=722645&r2=722646&view=diff
==============================================================================
--- incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Etch/Util/AlarmManager.cs (original)
+++ incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Etch/Util/AlarmManager.cs Tue Dec  2 14:38:21 2008
@@ -178,7 +178,7 @@
         public void Add(AlarmListener listener, Object state, int delay)
         {
             if (listener == null)
-                throw new NullReferenceException("listener == null");
+                throw new ArgumentNullException("listener == null");
 
             if (delay <= 0)
                 throw new ArgumentException("delay <= 0");

Modified: incubator/etch/trunk/binding-csharp/runtime/src/test/csharp/Etch/Support/TestTodoManager.cs
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-csharp/runtime/src/test/csharp/Etch/Support/TestTodoManager.cs?rev=722646&r1=722645&r2=722646&view=diff
==============================================================================
--- incubator/etch/trunk/binding-csharp/runtime/src/test/csharp/Etch/Support/TestTodoManager.cs (original)
+++ incubator/etch/trunk/binding-csharp/runtime/src/test/csharp/Etch/Support/TestTodoManager.cs Tue Dec  2 14:38:21 2008
@@ -39,7 +39,7 @@
         }
 
         [Test]
-        [ExpectedException(typeof(ThreadInterruptedException))]
+        [ExpectedException(typeof(Exception))]
         public void TestManagerNotStarted()
         {
             TodoManager mgr = new TodoManager( 50, 10, 1, 5, 5000, 1 );
@@ -47,7 +47,7 @@
         }
 
         [Test]
-        [ExpectedException( typeof( ThreadInterruptedException ) )]
+        [ExpectedException( typeof( Exception ) )]
         public void TestShutDown()
         {
             TodoManager mgr = TodoManager.GetTodoManager();

Added: incubator/etch/trunk/binding-csharp/runtime/src/test/csharp/Etch/Util/TestAlarmManager.cs
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-csharp/runtime/src/test/csharp/Etch/Util/TestAlarmManager.cs?rev=722646&view=auto
==============================================================================
--- incubator/etch/trunk/binding-csharp/runtime/src/test/csharp/Etch/Util/TestAlarmManager.cs (added)
+++ incubator/etch/trunk/binding-csharp/runtime/src/test/csharp/Etch/Util/TestAlarmManager.cs Tue Dec  2 14:38:21 2008
@@ -0,0 +1,65 @@
+// $Id$
+// 
+// Copyright 2007-2008 Cisco Systems Inc.
+// 
+// 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.
+
+using System;
+using System.Threading;
+using NUnit.Framework;
+
+namespace Etch.Util
+{
+    [TestFixture]
+    public class TestAlarmManager
+    {
+        private const int Q1 = 30;
+        private const int Q2 = 60;
+
+        [Test]
+        public void start1()
+        {
+        }
+
+        [Test]
+        public void start2()
+        {
+        }
+
+        [Test]
+        public void start3()
+        {
+        }
+    }
+
+    class MyAlarmListener: AlarmListener
+    {
+        public MyAlarmListener( int delay )
+        {
+            this.delay = delay;
+        }
+
+        public int delay;
+
+        public bool wake;
+
+        public object state;
+
+        public int Wakeup(AlarmManager manager, object state, long due)
+        {
+            wake = true;
+            this.state = state;
+            return delay;
+        }
+    }
+}

Propchange: incubator/etch/trunk/binding-csharp/runtime/src/test/csharp/Etch/Util/TestAlarmManager.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/etch/trunk/binding-csharp/runtime/src/test/csharp/Etch/Util/TestAlarmManager.cs
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: incubator/etch/trunk/binding-csharp/runtime/src/test/csharp/EtchTestProj.csproj
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-csharp/runtime/src/test/csharp/EtchTestProj.csproj?rev=722646&r1=722645&r2=722646&view=diff
==============================================================================
--- incubator/etch/trunk/binding-csharp/runtime/src/test/csharp/EtchTestProj.csproj (original)
+++ incubator/etch/trunk/binding-csharp/runtime/src/test/csharp/EtchTestProj.csproj Tue Dec  2 14:38:21 2008
@@ -73,6 +73,7 @@
     <Compile Include="Etch\Transport\TestMessagizer.cs" />
     <Compile Include="Etch\Transport\TestPlainMailbox.cs" />
     <Compile Include="Etch\Transport\TestPlainMailboxManager.cs" />
+    <Compile Include="Etch\Util\TestAlarmManager.cs" />
     <Compile Include="Etch\Util\TestCharIterator.cs" />
     <Compile Include="Etch\Util\TestCircularQueue.cs" />
     <Compile Include="Etch\Util\TestDateSerializer.cs" />