tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject [40/44] git commit: Start converting tests from TestNG to Spock
Date Wed, 16 May 2012 18:50:32 GMT
Start converting tests from 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/c776b88f
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/c776b88f
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/c776b88f

Branch: refs/heads/master
Commit: c776b88f12962b708c28ac5ee6f63b65d8cc3a1f
Parents: 4c4b369
Author: Howard M. Lewis Ship <hlship@gmail.com>
Authored: Sun Apr 15 05:45:20 2012 -0700
Committer: Howard M. Lewis Ship <hlship@apache.org>
Committed: Wed May 16 11:49:40 2012 -0700

----------------------------------------------------------------------
 tapestry-ioc/build.gradle                          |    4 +
 .../apache/tapestry/ioc/IOCSpecification.groovy    |   25 +++++++
 .../ioc/services/PeriodicExecutorSpec.groovy       |   30 ++++++++
 .../ioc/services/PeriodicExecutorTests.groovy      |   53 ---------------
 .../services/SystemEnvSymbolProviderSpec.groovy    |   21 ++++++
 .../services/SystemEnvSymbolProviderTest.groovy    |   38 ----------
 6 files changed, 80 insertions(+), 91 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/c776b88f/tapestry-ioc/build.gradle
----------------------------------------------------------------------
diff --git a/tapestry-ioc/build.gradle b/tapestry-ioc/build.gradle
index 576bfe9..136a937 100644
--- a/tapestry-ioc/build.gradle
+++ b/tapestry-ioc/build.gradle
@@ -16,10 +16,14 @@ dependencies {
   compile "log4j:log4j:1.2.14"
   compile "org.slf4j:slf4j-log4j12:1.6.1"
 
+  testCompile "org.spockframework:spock-core:$spockVersion"
+
   provided "org.testng:testng:$testngVersion", { transitive = false }
 }
 
 test {
+  useJUnit()
+  useTestNG()
   // Override the master build.gradle
   systemProperties.remove("tapestry.service-reloading-enabled")
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/c776b88f/tapestry-ioc/src/test/groovy/org/apache/tapestry/ioc/IOCSpecification.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry/ioc/IOCSpecification.groovy
b/tapestry-ioc/src/test/groovy/org/apache/tapestry/ioc/IOCSpecification.groovy
new file mode 100644
index 0000000..8265954
--- /dev/null
+++ b/tapestry-ioc/src/test/groovy/org/apache/tapestry/ioc/IOCSpecification.groovy
@@ -0,0 +1,25 @@
+package org.apache.tapestry.ioc
+
+import org.apache.tapestry5.ioc.Registry
+import org.apache.tapestry5.ioc.RegistryBuilder
+import spock.lang.AutoCleanup
+import spock.lang.Specification
+
+abstract class IOCSpecification extends Specification {
+
+    @AutoCleanup("shutdown")
+    protected Registry registry;
+
+    protected final void buildRegistry(Class... moduleClasses) {
+
+        registry =
+            new RegistryBuilder().add(moduleClasses).build()
+    }
+
+    /** Any unrecognized methods are evaluated against the registry. */
+    def methodMissing(String name, args) {
+        registry."$name"(*args)
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/c776b88f/tapestry-ioc/src/test/groovy/org/apache/tapestry/ioc/services/PeriodicExecutorSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry/ioc/services/PeriodicExecutorSpec.groovy
b/tapestry-ioc/src/test/groovy/org/apache/tapestry/ioc/services/PeriodicExecutorSpec.groovy
new file mode 100644
index 0000000..0cfeff8
--- /dev/null
+++ b/tapestry-ioc/src/test/groovy/org/apache/tapestry/ioc/services/PeriodicExecutorSpec.groovy
@@ -0,0 +1,30 @@
+package org.apache.tapestry.ioc.services
+
+import org.apache.tapestry.ioc.IOCSpecification
+import org.apache.tapestry5.ioc.services.cron.IntervalSchedule
+import org.apache.tapestry5.ioc.services.cron.PeriodicExecutor
+
+import java.util.concurrent.CountDownLatch
+import java.util.concurrent.TimeUnit
+
+class PeriodicExecutorSpec extends IOCSpecification {
+
+    def "execution intervals"() {
+
+        buildRegistry()
+
+        def countDownLatch = new CountDownLatch(5);
+
+        def schedule = new IntervalSchedule(10)
+
+        def job = getService(PeriodicExecutor).addJob(schedule, "count incrementer", { countDownLatch.countDown();
})
+
+        countDownLatch.await 30, TimeUnit.SECONDS
+
+        cleanup:
+
+        job && job.cancel()
+
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/c776b88f/tapestry-ioc/src/test/groovy/org/apache/tapestry/ioc/services/PeriodicExecutorTests.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry/ioc/services/PeriodicExecutorTests.groovy
b/tapestry-ioc/src/test/groovy/org/apache/tapestry/ioc/services/PeriodicExecutorTests.groovy
deleted file mode 100644
index ba7cb70..0000000
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry/ioc/services/PeriodicExecutorTests.groovy
+++ /dev/null
@@ -1,53 +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.tapestry.ioc.services
-
-import java.util.concurrent.CountDownLatch
-import java.util.concurrent.TimeUnit
-import org.apache.tapestry5.ioc.Registry
-import org.apache.tapestry5.ioc.services.cron.IntervalSchedule
-import org.apache.tapestry5.ioc.services.cron.PeriodicExecutor
-import org.apache.tapestry5.ioc.services.cron.PeriodicJob
-import org.apache.tapestry5.ioc.test.IOCTestCase
-import org.testng.annotations.Test
-
-/**
- * @since 5.3
- */
-class PeriodicExecutorTests extends IOCTestCase
-{
-
-    @Test
-    void execution_intervals()
-    {
-        Registry r = buildRegistry()
-
-        def countDownLatch = new CountDownLatch(5);
-
-        def schedule = new IntervalSchedule(10)
-
-        PeriodicJob job = r.getService(PeriodicExecutor.class).addJob(schedule, "count incrementer",
{ countDownLatch.countDown(); })
-
-        countDownLatch.await 30, TimeUnit.SECONDS
-
-        assertEquals countDownLatch.getCount(), 0
-
-        job.cancel()
-
-        r.shutdown()
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/c776b88f/tapestry-ioc/src/test/groovy/org/apache/tapestry/ioc/services/SystemEnvSymbolProviderSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry/ioc/services/SystemEnvSymbolProviderSpec.groovy
b/tapestry-ioc/src/test/groovy/org/apache/tapestry/ioc/services/SystemEnvSymbolProviderSpec.groovy
new file mode 100644
index 0000000..a81d20d
--- /dev/null
+++ b/tapestry-ioc/src/test/groovy/org/apache/tapestry/ioc/services/SystemEnvSymbolProviderSpec.groovy
@@ -0,0 +1,21 @@
+package org.apache.tapestry.ioc.services
+
+import org.apache.tapestry5.ioc.internal.services.SystemEnvSymbolProvider
+import org.apache.tapestry5.ioc.services.SymbolProvider
+import spock.lang.Specification
+
+class SystemEnvSymbolProviderSpec extends Specification {
+
+    SymbolProvider provider = new SystemEnvSymbolProvider()
+
+    def "key exists"() {
+        expect:
+        provider.valueForSymbol("env.home") == System.getenv("HOME")
+    }
+
+    def "key missing"() {
+        expect: provider.valueForSymbol("env.does-not-exist") == null
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/c776b88f/tapestry-ioc/src/test/groovy/org/apache/tapestry/ioc/services/SystemEnvSymbolProviderTest.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry/ioc/services/SystemEnvSymbolProviderTest.groovy
b/tapestry-ioc/src/test/groovy/org/apache/tapestry/ioc/services/SystemEnvSymbolProviderTest.groovy
deleted file mode 100644
index 8ffba43..0000000
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry/ioc/services/SystemEnvSymbolProviderTest.groovy
+++ /dev/null
@@ -1,38 +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.tapestry.ioc.services
-
-import org.apache.tapestry5.ioc.internal.services.SystemEnvSymbolProvider
-import org.apache.tapestry5.ioc.services.SymbolProvider
-import org.apache.tapestry5.ioc.test.IOCTestCase
-import org.testng.annotations.Test
-
-class SystemEnvSymbolProviderTest extends IOCTestCase
-{
-
-    SymbolProvider provider = new SystemEnvSymbolProvider()
-
-    @Test
-    void key_exists()
-    {
-        assert provider.valueForSymbol("env.home") == System.getenv("HOME")
-    }
-
-    @Test
-    void key_missing()
-    {
-        assert provider.valueForSymbol("env.does-not-exist") == null
-    }
-}


Mime
View raw message