Convert TestNG to Spock

Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/8912f060
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/8912f060
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/8912f060

Branch: refs/heads/master
Commit: 8912f0608154c9d33dbce31376db29d7140c3a40
Parents: 17f0c48
Author: Howard M. Lewis Ship <[email protected]>
Authored: Mon Jun 11 15:16:20 2012 -0700
Committer: Howard M. Lewis Ship <[email protected]>
Committed: Mon Jun 11 15:16:20 2012 -0700

----------------------------------------------------------------------
 .../tapestry5/ioc/services/CronScheduleSpec.groovy |   27 +++++++++
 .../ioc/services/cron/CronScheduleTest.java        |   45 ---------------
 2 files changed, 27 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/8912f060/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/services/CronScheduleSpec.groovy
----------------------------------------------------------------------
diff --git 
a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/services/CronScheduleSpec.groovy
 
b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/services/CronScheduleSpec.groovy
new file mode 100644
index 0000000..927e0c7
--- /dev/null
+++ 
b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/services/CronScheduleSpec.groovy
@@ -0,0 +1,27 @@
+package org.apache.tapestry5.ioc.services
+
+import org.apache.tapestry5.ioc.AbstractSharedRegistrySpecification
+import org.apache.tapestry5.ioc.services.cron.CronSchedule
+import org.apache.tapestry5.ioc.services.cron.PeriodicExecutor
+
+import java.util.concurrent.CountDownLatch
+import java.util.concurrent.TimeUnit
+
+class CronScheduleSpec extends AbstractSharedRegistrySpecification {
+
+  def "add a job and ensure that it executes"() {
+    def latch = new CountDownLatch(5)
+
+    def executor = getService PeriodicExecutor
+
+    executor.addJob(new CronSchedule("0/1 * * * * ?"), "Test", { 
latch.countDown() })
+
+    when:
+
+    latch.await(30, TimeUnit.SECONDS)
+
+    then:
+
+    latch.count == 0
+  }
+}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/8912f060/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/services/cron/CronScheduleTest.java
----------------------------------------------------------------------
diff --git 
a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/services/cron/CronScheduleTest.java
 
b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/services/cron/CronScheduleTest.java
deleted file mode 100644
index 037bfef..0000000
--- 
a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/services/cron/CronScheduleTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2011 The Apache Software Foundation
-//
-// 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 org.apache.tapestry5.ioc.services.cron;
-
-import org.apache.tapestry5.ioc.internal.IOCInternalTestCase;
-import org.testng.annotations.Test;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-public class CronScheduleTest extends IOCInternalTestCase
-{
-
-    @Test
-    public void schedule() throws InterruptedException
-    {
-        final CountDownLatch countDownLatch = new CountDownLatch(5);
-
-        final PeriodicExecutor executor = getService(PeriodicExecutor.class);
-
-        executor.addJob(new CronSchedule("0/1 * * * * ?"), "Test", new 
Runnable()
-        {
-            public void run()
-            {
-                countDownLatch.countDown();
-            }
-        });
-
-        countDownLatch.await(30, TimeUnit.SECONDS);
-
-        assertEquals(countDownLatch.getCount(), 0);
-    }
-}

Reply via email to