Updated Branches:
  refs/heads/master a5b066c24 -> 0cf6562f4

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/0cf6562f
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/0cf6562f
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/0cf6562f

Branch: refs/heads/master
Commit: 0cf6562f4ae1209f9d5feb91a0bd4f919feee83e
Parents: fb18dd4
Author: Howard M. Lewis Ship <[email protected]>
Authored: Mon Jun 18 17:15:29 2012 -0700
Committer: Howard M. Lewis Ship <[email protected]>
Committed: Mon Jun 18 17:15:29 2012 -0700

----------------------------------------------------------------------
 .../tapestry5/ioc/util/LocationImplSpec.groovy     |   89 +++++++++++++
 .../ioc/internal/util/LocationImplTest.java        |  100 ---------------
 2 files changed, 89 insertions(+), 100 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0cf6562f/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/LocationImplSpec.groovy
----------------------------------------------------------------------
diff --git 
a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/LocationImplSpec.groovy
 
b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/LocationImplSpec.groovy
new file mode 100644
index 0000000..e6da101
--- /dev/null
+++ 
b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/LocationImplSpec.groovy
@@ -0,0 +1,89 @@
+package org.apache.tapestry5.ioc.util
+
+import org.apache.tapestry5.ioc.internal.util.ClasspathResource
+import org.apache.tapestry5.ioc.internal.util.LocationImpl
+import spock.lang.Shared
+import spock.lang.Specification
+
+class LocationImplSpec extends Specification {
+
+  @Shared
+  def random = new Random()
+
+  @Shared
+  def resource = new ClasspathResource("/foo/Bar.xml")
+
+  def "toString() with all three parameters"() {
+    def line = random.nextInt()
+    def column = random.nextInt()
+
+    when:
+
+    def location = new LocationImpl(resource, line, column)
+
+    then:
+
+    location.resource.is(resource)
+    location.line == line
+    location.column == column
+
+    location.toString() == "$resource, line $line, column $column"
+  }
+
+  def "toString() with unknown column"() {
+    def line = random.nextInt()
+
+    when:
+
+    def location = new LocationImpl(resource, line)
+
+    then:
+
+    location.resource.is(resource)
+    location.line == line
+    location.toString() == "$resource, line $line"
+  }
+
+  def "unknown line and column"() {
+    when:
+
+    def location = new LocationImpl(resource,)
+
+    then:
+
+    location.resource.is(resource)
+    location.toString() == resource.toString()
+  }
+
+  def "equality"() {
+
+    when:
+
+    def l1 = new LocationImpl(resource, 22, 7)
+    def l2 = new LocationImpl(resource, 22, 7)
+    def l3 = new LocationImpl(null, 22, 7)
+    def l4 = new LocationImpl(resource, 99, 7)
+    def l5 = new LocationImpl(resource, 22, 99)
+    def l6 = new LocationImpl(new ClasspathResource("/baz/Biff.txt"), 22, 7)
+
+    then:
+
+    l1 == l1
+    l1 != null
+
+    l1 == l2
+    l2.hashCode() == l1.hashCode()
+
+    l3 != l1
+    l3.hashCode() != l1.hashCode()
+
+    l4 != l1
+    l4.hashCode() != l1.hashCode()
+
+    l5 != l1
+    l5.hashCode() != l1.hashCode()
+
+    l6 != l1
+    l6.hashCode() != l1.hashCode()
+  }
+}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0cf6562f/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/LocationImplTest.java
----------------------------------------------------------------------
diff --git 
a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/LocationImplTest.java
 
b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/LocationImplTest.java
deleted file mode 100644
index 492fddc..0000000
--- 
a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/LocationImplTest.java
+++ /dev/null
@@ -1,100 +0,0 @@
-// Copyright 2006, 2007 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.util;
-
-import org.apache.tapestry5.ioc.Location;
-import org.apache.tapestry5.ioc.Resource;
-import org.apache.tapestry5.ioc.test.IOCTestCase;
-import org.testng.annotations.Test;
-
-import java.util.Random;
-
-public class LocationImplTest extends IOCTestCase
-{
-    private final Random random = new Random();
-
-    private final Resource resource = new ClasspathResource("/foo/Bar.xml");
-
-    @Test
-    public void all_three_parameters()
-    {
-
-        int line = random.nextInt();
-        int column = random.nextInt();
-
-        Location l = new LocationImpl(resource, line, column);
-
-        assertSame(l.getResource(), resource);
-        assertEquals(l.getLine(), line);
-        assertEquals(l.getColumn(), column);
-
-        assertEquals(l.toString(), String.format("%s, line %d, column %d", 
resource, line, column));
-    }
-
-    @Test
-    public void unknown_column()
-    {
-        int line = random.nextInt();
-
-        Location l = new LocationImpl(resource, line);
-
-        assertSame(l.getResource(), resource);
-        assertEquals(l.getLine(), line);
-        assertEquals(l.getColumn(), -1);
-
-        assertEquals(l.toString(), String.format("%s, line %d", resource, 
line));
-    }
-
-    @Test
-    public void unknown_line_and_column()
-    {
-        Location l = new LocationImpl(resource);
-
-        assertSame(l.getResource(), resource);
-        assertEquals(l.getLine(), -1);
-        assertEquals(l.getColumn(), -1);
-
-        assertEquals(l.toString(), resource.toString());
-    }
-
-    @Test
-    public void equality()
-    {
-        Location l1 = new LocationImpl(resource, 22, 7);
-        Location l2 = new LocationImpl(resource, 22, 7);
-        Location l3 = new LocationImpl(null, 22, 7);
-        Location l4 = new LocationImpl(resource, 99, 7);
-        Location l5 = new LocationImpl(resource, 22, 99);
-        Location l6 = new LocationImpl(new ClasspathResource("/baz/Biff.txt"), 
22, 7);
-
-        assertEquals(l1, l1);
-        assertFalse(l1.equals(null));
-
-        assertEquals(l1, l2);
-        assertEquals(l2.hashCode(), l1.hashCode());
-
-        assertFalse(l3.equals(l1));
-        assertFalse(l3.hashCode() == l1.hashCode());
-
-        assertFalse(l4.equals(l1));
-        assertFalse(l4.hashCode() == l1.hashCode());
-
-        assertFalse(l5.equals(l1));
-        assertFalse(l5.hashCode() == l1.hashCode());
-
-        assertFalse(l6.equals(l1));
-        assertFalse(l6.hashCode() == l1.hashCode());
-    }
-}

Reply via email to