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/06/12 23:37:22 UTC

[2/5] 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/22d05b16
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/22d05b16
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/22d05b16

Branch: refs/heads/master
Commit: 22d05b1662cb902cda8fc8ffddbf1c7f068e8a69
Parents: cb55d1c
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Tue Jun 12 11:09:13 2012 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Tue Jun 12 11:09:13 2012 -0700

----------------------------------------------------------------------
 .../services/ResourceSymbolProviderSpec.groovy     |   31 +++++++++
 .../services/ResourceSymbolProviderTest.java       |   53 ---------------
 2 files changed, 31 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/22d05b16/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/ResourceSymbolProviderSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/ResourceSymbolProviderSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/ResourceSymbolProviderSpec.groovy
new file mode 100644
index 0000000..481dc68
--- /dev/null
+++ b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/ResourceSymbolProviderSpec.groovy
@@ -0,0 +1,31 @@
+package org.apache.tapestry5.ioc.internal.services
+
+import org.apache.tapestry5.ioc.Resource
+import spock.lang.Specification
+
+class ResourceSymbolProviderSpec extends Specification {
+
+  static final CONTENT = 'homer=simpson\r\nmonty=burns'
+
+  def "access to contents of stream"() {
+    Resource resource = Mock()
+
+    when:
+
+    ResourceSymbolProvider provider = new ResourceSymbolProvider(resource)
+
+    then:
+
+    1 * resource.openStream() >> { new ByteArrayInputStream(CONTENT.bytes) }
+
+    expect:
+
+    provider.valueForSymbol("homer") == "simpson"
+    provider.valueForSymbol("monty") == "burns"
+
+    provider.valueForSymbol("HOMER") == "simpson"
+
+    provider.valueForSymbol("marge") == null
+
+  }
+}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/22d05b16/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/ResourceSymbolProviderTest.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/ResourceSymbolProviderTest.java b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/ResourceSymbolProviderTest.java
deleted file mode 100644
index 587e6f7..0000000
--- a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/ResourceSymbolProviderTest.java
+++ /dev/null
@@ -1,53 +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.Resource;
-import org.apache.tapestry5.ioc.test.IOCTestCase;
-import org.testng.annotations.Test;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-
-public class ResourceSymbolProviderTest extends IOCTestCase
-{
-    private static final String CONTENT = "homer=simpson\r\nmonty=burns";
-
-    @Test
-    public void access() throws Exception
-    {
-        Resource resource = mockResource();
-
-        InputStream is = new ByteArrayInputStream(CONTENT.getBytes());
-
-        expect(resource.openStream()).andReturn(is);
-
-        replay();
-
-        ResourceSymbolProvider provider = new ResourceSymbolProvider(resource);
-
-        /* test general access */
-        assertEquals(provider.valueForSymbol("homer"), "simpson");
-        assertEquals(provider.valueForSymbol("monty"), "burns");
-
-        /* check for case-insensitivity */
-        assertEquals(provider.valueForSymbol("HOMER"), "simpson");
-
-        /* non-existent keys should return null */
-        assertNull(provider.valueForSymbol("marge"));
-
-        verify();
-    }
-}