You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2012/05/16 20:50:32 UTC
[26/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/fc2bf6fa
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/fc2bf6fa
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/fc2bf6fa
Branch: refs/heads/master
Commit: fc2bf6faef0dc5574022d0e73761930bf2d815a0
Parents: 1df00a3
Author: Howard M. Lewis Ship <hl...@gmail.com>
Authored: Fri May 4 14:29:26 2012 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Wed May 16 11:50:13 2012 -0700
----------------------------------------------------------------------
.../services/FilterMethodAnalyzerSpec.groovy | 34 +++++++
.../services/FilterMethodAnalyzerTest.java | 75 ---------------
2 files changed, 34 insertions(+), 75 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/fc2bf6fa/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/FilterMethodAnalyzerSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/FilterMethodAnalyzerSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/FilterMethodAnalyzerSpec.groovy
new file mode 100644
index 0000000..6114b4b
--- /dev/null
+++ b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/FilterMethodAnalyzerSpec.groovy
@@ -0,0 +1,34 @@
+package org.apache.tapestry5.ioc.internal.services
+
+import spock.lang.Specification
+import spock.lang.Unroll
+
+
+class FilterMethodAnalyzerSpec extends Specification {
+
+ def find(clazz, name) {
+ new MethodSignature(clazz.methods.find { it.name == name })
+ }
+
+ @Unroll
+ def "position of delegate parameter for #filterMethod should be #position"() {
+
+ def analyzer = new FilterMethodAnalyzer(SampleService)
+
+ expect:
+
+ analyzer.findServiceInterfacePosition(mainMethod, filterMethod) == position
+
+ where:
+
+ methodName | position
+ "simpleMatch" | 0
+ "mismatchParameterCount" | -1
+ "mismatchReturnType" | -1
+ "missingServiceInterface" | -1
+ "complexMatch" | 2
+
+ mainMethod = find SampleService, methodName
+ filterMethod = find SampleFilter, methodName
+ }
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/fc2bf6fa/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/FilterMethodAnalyzerTest.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/FilterMethodAnalyzerTest.java b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/FilterMethodAnalyzerTest.java
deleted file mode 100644
index 2ffa82e..0000000
--- a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/FilterMethodAnalyzerTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright 2006, 2012 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.internal.IOCInternalTestCase;
-import org.testng.annotations.Test;
-
-import java.lang.reflect.Method;
-
-public class FilterMethodAnalyzerTest extends IOCInternalTestCase
-{
- private MethodSignature find(Class target, String name)
- {
- Method method = findMethod(target, name);
-
- return new MethodSignature(method);
- }
-
- private void assertPosition(String methodName, int expected)
- {
- FilterMethodAnalyzer a = new FilterMethodAnalyzer(SampleService.class);
-
- MethodSignature ms = find(SampleService.class, methodName);
- MethodSignature fms = find(SampleFilter.class, methodName);
-
- assertEquals(expected, a.findServiceInterfacePosition(ms, fms));
- }
-
- private void assertMismatch(String methodName)
- {
- assertPosition(methodName, -1);
- }
-
- @Test
- public void simple_match()
- {
- assertPosition("simpleMatch", 0);
- }
-
- @Test
- public void mismatched_parameter_count()
- {
- assertMismatch("mismatchParameterCount");
- }
-
- @Test
- public void mismatch_on_method_return_type()
- {
- assertMismatch("mismatchReturnType");
- }
-
- @Test
- public void service_interface_not_in_filter_method_signature()
- {
- assertMismatch("missingServiceInterface");
- }
-
- @Test
- public void match_with_multiple_parameters()
- {
- assertPosition("complexMatch", 2);
- }
-}