You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2012/05/16 20:50:31 UTC
[8/44] git commit: Convert TestNG to Spock
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/78597564
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/78597564
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/78597564
Branch: refs/heads/master
Commit: 7859756445f38dd354230d977cdf458fec426597
Parents: b907711
Author: Howard M. Lewis Ship <hl...@gmail.com>
Authored: Tue May 8 17:01:35 2012 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Wed May 16 11:50:14 2012 -0700
----------------------------------------------------------------------
.../services/NonParallelExecutorSpec.groovy | 58 +++++++++
.../internal/services/NonParallelExecutorTest.java | 93 ---------------
2 files changed, 58 insertions(+), 93 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/78597564/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/NonParallelExecutorSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/NonParallelExecutorSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/NonParallelExecutorSpec.groovy
new file mode 100644
index 0000000..4d79462
--- /dev/null
+++ b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/NonParallelExecutorSpec.groovy
@@ -0,0 +1,58 @@
+package org.apache.tapestry5.ioc.internal.services
+
+import org.apache.tapestry5.ioc.Invokable
+import org.apache.tapestry5.ioc.Registry
+import org.apache.tapestry5.ioc.RegistryBuilder
+import org.apache.tapestry5.ioc.services.ParallelExecutor
+import spock.lang.AutoCleanup
+import spock.lang.Shared
+import spock.lang.Specification
+
+class NonParallelExecutorSpec extends Specification {
+
+ @Shared
+ @AutoCleanup("shutdown")
+ private Registry registry
+
+ @Shared
+ private ParallelExecutor executor
+
+ def setupSpec() {
+ registry = new RegistryBuilder().add(NonParallelModule).build()
+
+ executor = registry.getService ParallelExecutor
+ }
+
+ def "passing an Invokable will immediately invoke()"() {
+
+ Invokable inv = Mock()
+
+ when:
+
+ def actual = executor.invoke(String, inv)
+
+ then:
+
+ actual == "value"
+
+ 1 * inv.invoke() >> "value"
+ }
+
+ def "A returned Future object is a simple wrapper around the result"() {
+ Invokable inv = Mock()
+
+ when:
+
+ def future = executor.invoke(inv)
+
+ then:
+
+ 1 * inv.invoke() >> "right now"
+
+ !future.cancel(false)
+ !future.cancelled
+ future.done
+ future.get() == "right now"
+ future.get(0, null) == "right now"
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/78597564/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/NonParallelExecutorTest.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/NonParallelExecutorTest.java b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/NonParallelExecutorTest.java
deleted file mode 100644
index ef0a406..0000000
--- a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/NonParallelExecutorTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-// Copyright 2009 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.internal.services;
-
-import org.apache.tapestry5.ioc.Invokable;
-import org.apache.tapestry5.ioc.Registry;
-import org.apache.tapestry5.ioc.RegistryBuilder;
-import org.apache.tapestry5.ioc.services.ParallelExecutor;
-import org.apache.tapestry5.ioc.test.TestBase;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import java.util.concurrent.Future;
-
-public class NonParallelExecutorTest extends TestBase
-{
- private Registry registry;
-
- private ParallelExecutor executor;
-
- @BeforeClass
- public void setup()
- {
- RegistryBuilder builder = new RegistryBuilder();
- builder.add(NonParallelModule.class);
-
- registry = builder.build();
- executor = registry.getService(ParallelExecutor.class);
- }
-
- @AfterClass
- public void cleanup()
- {
- registry.shutdown();
-
- registry = null;
- executor = null;
- }
-
- @Test
- public void invoke_proxy()
- {
- Invokable<String> inv = newMock(Invokable.class);
-
- String value = "invokable-value";
-
- expect(inv.invoke()).andReturn(value);
-
- replay();
-
- assertSame(executor.invoke(String.class, inv), value);
-
- verify();
- }
-
- @Test
- public void invoke_with_future() throws Exception
- {
- Invokable<String> inv = newMock(Invokable.class);
-
- String value = "invokable-value";
-
- expect(inv.invoke()).andReturn(value);
-
- replay();
-
- Future<String> future = executor.invoke(inv);
-
- assertFalse(future.cancel(true));
- assertFalse(future.isCancelled());
- assertTrue(future.isDone());
- assertSame(future.get(), value);
- assertSame(future.get(0, null), value);
-
- verify();
-
- }
-}
-
-