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/21 19:28:19 UTC
[9/9] Refactor all the tapestry-ioc Spock specifications into the
ioc.specs package Convert some package-private classes and constructors to
public
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a1bef869/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/InternalUtilsSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/InternalUtilsSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/InternalUtilsSpec.groovy
deleted file mode 100644
index 66fa20f..0000000
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/InternalUtilsSpec.groovy
+++ /dev/null
@@ -1,607 +0,0 @@
-package org.apache.tapestry5.ioc.util
-
-import org.apache.tapestry5.func.F
-import org.apache.tapestry5.func.Predicate
-import org.apache.tapestry5.ioc.annotations.Inject
-import org.apache.tapestry5.ioc.def.ServiceDef
-import org.apache.tapestry5.ioc.def.ServiceDef2
-import org.apache.tapestry5.ioc.internal.QuietOperationTracker
-import org.apache.tapestry5.ioc.services.Builtin
-import org.apache.tapestry5.ioc.services.Coercion
-import org.apache.tapestry5.ioc.services.SymbolSource
-import spock.lang.Shared
-import spock.lang.Specification
-import spock.lang.Unroll
-
-import java.lang.reflect.Method
-
-import org.apache.tapestry5.ioc.*
-import org.apache.tapestry5.ioc.internal.util.*
-
-class InternalUtilsSpec extends Specification {
-
- private static class PrivateInnerClass {
-
- public PrivateInnerClass() {
- }
- }
-
- static class PublicInnerClass {
-
- protected PublicInnerClass() {
- }
- }
-
- @Shared
- def tracker = new QuietOperationTracker();
-
-
- @Unroll
- def "asString(): #desc"() {
-
- when:
-
- Method m = clazz.getMethod(methodName, * paramTypes)
-
- then:
-
- InternalUtils.asString(m) == expected
-
- where:
-
- clazz | methodName | paramTypes | expected | desc
- Object | "toString" | [] | "java.lang.Object.toString()" | "method with no arguments"
- Collections | "sort" | [List, Comparator] | "java.util.Collections.sort(List, Comparator)" | "method with multiple argments"
- Object | "wait" | [long] | "java.lang.Object.wait(long)" | "method with primitive argument"
- Arrays | "sort" | [int[]] | "java.util.Arrays.sort(int[])" | "method with primitive array argument"
- Arrays | "sort" | [Object[]] | "java.util.Arrays.sort(Object[])" | "method with object array argument"
- }
-
- @Unroll
- def "size(): #desc"() {
- expect:
-
- InternalUtils.size(array as Object[]) == expected
-
- where:
-
- array | expected | desc
- [] | 0 | "empty array"
- null | 0 | "null is size 0"
- [1, 2, 3] | 3 | "non-empty array"
- }
-
- @Unroll
- def "stripMemberName('#input') should be '#expected'"() {
- expect:
-
- InternalUtils.stripMemberName(input) == expected
-
- where:
-
- input | expected
- "simple" | "simple"
- "_name" | "name"
- '$name' | "name"
- '__$ruby_style_' | "ruby_style"
- '$_$__$__$_$____$_$_$_$$name' | "name"
- "foo_" | "foo"
- "_foo_" | "foo"
- }
-
- def "invalid input to stripMemberName() is an exception"() {
- when:
-
- InternalUtils.stripMemberName("!foo")
-
- then:
-
- IllegalArgumentException e = thrown()
-
- e.message == "Input '!foo' is not a valid Java identifier."
- }
-
- def "toList(Enumeration) is a sorted list"() {
- when:
-
- def e = Collections.enumeration(["wilma", "fred", "barney"])
-
- then:
-
- InternalUtils.toList(e) == ["barney", "fred", "wilma"]
- }
-
- @Unroll
- def "join(): #desc"() {
- expect:
-
- InternalUtils.join(list) == expected
-
- where:
-
- list | expected | desc
- ["barney"] | "barney" | "single value"
- ["fred", "barney", "wilma"] | "fred, barney, wilma" | "multiple values"
- ["fred", "barney", "", "wilma"] | "fred, barney, (blank), wilma" | "empty string converted to '(blank)'"
- }
-
- @Unroll
- def "joinSorted(): #desc"() {
- InternalUtils.joinSorted(list) == expected
-
- where:
-
- list | expected | desc
- null | "(none)" | "null list is '(none)'"
- [] | "(none)" | "empty list is '(none)'"
- ["barney"] | "barney" | "single value"
- ["fred", "barney", "wilma"] | "barney, fred, wilma" | "multiple values"
- ["fred", "barney", "", "wilma"] | "(blank), barney, fred, wilma" | "empty string converted to '(blank)'"
- }
-
- @Unroll
- def "capitalize('#input') is '#expected'"() {
- expect:
-
- InternalUtils.capitalize(input) == expected
-
- where:
-
- input | expected
- "hello" | "Hello"
- "Goodbye" | "Goodbye"
- "" | ""
- "a" | "A"
- "A" | "A"
- }
-
- def "locationOf(Object)"() {
- Locatable locatable = Mock()
- Location l = Mock()
-
- expect:
-
- InternalUtils.locationOf(null) == null
- InternalUtils.locationOf("La! La!") == null
-
- InternalUtils.locationOf(l).is(l)
-
- when:
-
- def actual = InternalUtils.locationOf(locatable)
-
- then:
-
- _ * locatable.location >> l
-
- actual.is(l)
- }
-
- @Unroll
- def "sortedKeys(): #desc"() {
- expect:
-
- InternalUtils.sortedKeys(map) == expected
-
- where:
-
- map | expected | desc
- null | [] | "null map"
- [:] | [] | "empty map"
- ["fred": "flintstone", "barney": "rubble"] | ["barney", "fred"] | "standard map"
- }
-
- @Unroll
- def "get(Map,Object): #desc"() {
- expect:
-
- InternalUtils.get(map, key) == expected
-
- where:
-
- map | key | expected | desc
- null | null | null | "null key and map"
- null | "foo" | null | "null map"
- ["fred": "flintstone"] | "fred" | "flintstone" | "real map and key"
- ["fred": "flintstone"] | "barney" | null | "real map with missing key"
- }
-
- def "reverseIterator(List)"() {
- when:
-
- def i = InternalUtils.reverseIterator(["a", "b", "c"])
-
- then:
-
- i.hasNext()
- i.next() == "c"
-
- i.hasNext()
- i.next() == "b"
-
- i.hasNext()
- i.next() == "a"
-
- !i.hasNext()
- }
-
- def "remove() not supported by reverse Iterator"() {
- def i = InternalUtils.reverseIterator(["a", "b", "c"])
-
- when:
-
- i.remove()
-
- then:
-
- thrown(UnsupportedOperationException)
- }
-
- @Unroll
- def "lastTerm(): #desc"() {
- expect:
-
- InternalUtils.lastTerm(input) == expected
-
- where:
-
- input | expected | desc
- "simple" | "simple" | "single term"
- "fee.fie.foe.fum" | "fum" | "dotted name sequence"
- }
-
- def "simple value passed to lastTerm() returns the exact input value"() {
- def input = "simple"
-
- expect:
-
- InternalUtils.lastTerm(input).is(input)
- }
-
- def "addToMapList()"() {
- def map = [:]
-
- when:
-
- InternalUtils.addToMapList(map, "fred", 1)
-
- then:
-
- map == ["fred": [1]]
-
- when:
-
- InternalUtils.addToMapList(map, "fred", 2)
-
- then:
-
- map == ["fred": [1, 2]]
- }
-
- def "validateMarkerAnnotation()"() {
-
- when:
-
- InternalUtils.validateMarkerAnnotation(Inject)
-
- then:
-
- noExceptionThrown()
-
- when:
-
- InternalUtils.validateMarkerAnnotations([Inject, NotRetainedRuntime] as Class[])
-
- then:
-
- IllegalArgumentException e = thrown()
-
- e.message == "Marker annotation class org.apache.tapestry5.ioc.internal.util.NotRetainedRuntime is not valid because it is not visible at runtime. Add a @Retention(RetentionPolicy.RUNTIME) to the class."
- }
-
- def "close(Closable) for null does nothing"() {
- when:
- InternalUtils.close(null)
-
- then:
- noExceptionThrown()
- }
-
- def "close(Closable) for success case"() {
- Closeable c = Mock()
-
- when:
-
- InternalUtils.close(c)
-
- then:
-
- 1 * c.close()
- }
-
- def "close(Closable) ignores exceptions"() {
- Closeable c = Mock()
-
- when:
-
- InternalUtils.close(c)
-
- then:
-
- 1 * c.close() >> {
- throw new IOException("ignored")
- }
- }
-
- def "constructor with Tapestry @Inject annotation"() {
- when:
-
- def c = InternalUtils.findAutobuildConstructor(InjectoBean)
-
- then:
-
- c.parameterTypes == [String]
- }
-
- def "constructor with javax @Inject annotation"() {
- when:
-
- def c = InternalUtils.findAutobuildConstructor(JavaxInjectBean)
-
- then:
-
- c.parameterTypes == [String]
- }
-
- def "too many autobuild constructors"() {
- when:
-
- InternalUtils.findAutobuildConstructor(TooManyAutobuildConstructorsBean)
-
- then:
-
- IllegalArgumentException e = thrown()
-
- e.message == "Too many autobuild constructors found: use either @org.apache.tapestry5.ioc.annotations.Inject or @javax.inject.Inject annotation to mark a single constructor for autobuilding."
- }
-
- def "validateConstructorForAutobuild(): ensure check that the class itself is public"() {
- def cons = PrivateInnerClass.constructors[0]
-
- when:
-
- InternalUtils.validateConstructorForAutobuild(cons)
-
- then:
-
- IllegalArgumentException e = thrown()
-
- e.message == "Class ${PrivateInnerClass.name} is not a public class and may not be autobuilt."
- }
-
- def "validateConstructorForAutobuild(): ensure check that constructor is public"() {
- def cons = PublicInnerClass.declaredConstructors[0]
-
- when:
-
- InternalUtils.validateConstructorForAutobuild(cons)
-
- then:
-
- IllegalArgumentException e = thrown()
-
- e.message == "Constructor protected ${PublicInnerClass.name}() is not public and may not be used for autobuilding an instance of the class. " +
- "You should make the constructor public, or mark an alternate public constructor with the @Inject annotation."
- }
-
- def "@Inject service annotation on a field"() {
- ObjectLocator ol = Mock()
- def target = new FieldInjectionViaInjectService()
- Runnable fred = Mock()
-
- when:
-
- InternalUtils.injectIntoFields(target, ol, null, tracker)
-
- then:
-
- target.fred.is(fred)
-
- 1 * ol.getService("FredService", Runnable) >> fred
- }
-
- def "@javax.annotations.Inject / @Named annotation on field"() {
- ObjectLocator ol = Mock()
- def target = new FieldInjectionViaJavaxNamed()
- Runnable fred = Mock()
-
- when:
-
- InternalUtils.injectIntoFields(target, ol, null, tracker)
-
- then:
-
- target.fred.is(fred)
-
- 1 * ol.getService("BarneyService", Runnable) >> fred
- }
-
- def "@Inject annotation on field"() {
- ObjectLocator ol = Mock()
- def target = new FieldInjectionViaInject()
- SymbolSource source = Mock()
- InjectionResources resources = Mock()
-
- when:
-
- InternalUtils.injectIntoFields(target, ol, resources, tracker)
-
- then:
-
- target.symbolSource.is(source)
-
- 1 * resources.findResource(SymbolSource, SymbolSource) >> null
- 1 * ol.getObject(SymbolSource, _) >> { type, ap ->
- assert ap.getAnnotation(Builtin) != null
-
- return source
- }
- }
-
- def "@javax.annotation.Inject annotation on field"() {
- ObjectLocator ol = Mock()
- def target = new FieldInjectionViaJavaxInject()
- SymbolSource source = Mock()
- InjectionResources resources = Mock()
-
- when:
-
- InternalUtils.injectIntoFields(target, ol, resources, tracker)
-
- then:
-
- target.symbolSource.is(source)
-
- 1 * resources.findResource(SymbolSource, SymbolSource) >> null
- 1 * ol.getObject(SymbolSource, _) >> { type, ap ->
- assert ap.getAnnotation(Builtin) != null
-
- return source
- }
- }
-
- def "check handling of exception while injecting into a field"() {
- ObjectLocator ol = Mock()
- def target = new FieldInjectionViaInjectService()
-
- when:
-
- InternalUtils.injectIntoFields(target, ol, null, tracker)
-
- then:
-
- Exception e = thrown()
-
- 1 * ol.getService("FredService", Runnable) >> "NotTheRightType"
-
- e.message.contains "Unable to set field 'fred' of <FieldInjectionViaInjectService> to NotTheRightType"
- }
-
- @Unroll
- def "keys(Map): #desc"() {
- expect:
-
- InternalUtils.keys(map) == (expected as Set)
-
- where:
-
- map | expected | desc
- null | [] | "null map"
- [:] | [] | "empty map"
- ["fred": "flintstone", "barney": "rubble"] | ["fred", "barney"] | "non-empty map"
- }
-
- @Unroll
- def "size(Collection): #desc"() {
- expect:
-
- InternalUtils.size(coll) == expected
-
- where:
-
- coll | expected | desc
- null | 0 | "null collection"
- [] | 0 | "empty collection"
- [1, 2, 3] | 3 | "non-empty collection"
- }
-
- def "toServiceDef2() delegates most methods to ServiceDef instance"() {
- ServiceDef delegate = Mock()
- ServiceBuilderResources resources = Mock()
- ObjectCreator creator = Mock()
- def serviceId = "fred"
- def markers = [] as Set
-
- ServiceDef2 sd = InternalUtils.toServiceDef2(delegate)
-
- when:
-
- def actual = sd.createServiceCreator(resources)
-
- then:
-
- actual.is creator
-
- 1 * delegate.createServiceCreator(resources) >> creator
-
-
- when:
-
- actual = sd.getServiceId()
-
- then:
- actual.is serviceId
-
- 1 * delegate.serviceId >> serviceId
-
- when:
-
- actual = sd.markers
-
- then:
-
- actual.is markers
- 1 * delegate.markers >> markers
-
-
- when:
-
- actual = sd.serviceInterface
-
- then:
-
- actual == Runnable
- 1 * delegate.serviceInterface >> Runnable
-
- when:
-
- actual = sd.serviceScope
-
- then:
-
- actual == ScopeConstants.PERTHREAD
- 1 * delegate.serviceScope >> ScopeConstants.PERTHREAD
-
- when:
-
- actual = sd.eagerLoad
-
- then:
-
- actual == true
- 1 * delegate.eagerLoad >> true
-
- expect:
-
- !sd.preventDecoration
- }
-
- def "matchAndSort()"() {
- def pred = { !it.startsWith(".") } as Predicate
-
- expect:
-
- InternalUtils.matchAndSort(["Fred", "Barney", "..", ".hidden", "Wilma"], pred) == ["Barney", "Fred", "Wilma"]
- }
-
- def "toMapper(Coercion)"() {
- def coercion = { it.toUpperCase() } as Coercion
-
- def flow = F.flow("Mary", "had", "a", "little", "lamb")
-
- expect:
-
- flow.map(InternalUtils.toMapper(coercion)).toList() == ["MARY", "HAD", "A", "LITTLE", "LAMB"]
- }
-}
-
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a1bef869/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
deleted file mode 100644
index e6da101..0000000
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/LocationImplSpec.groovy
+++ /dev/null
@@ -1,89 +0,0 @@
-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/a1bef869/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/MessageFormatterImplSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/MessageFormatterImplSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/MessageFormatterImplSpec.groovy
deleted file mode 100644
index c8e8a46..0000000
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/MessageFormatterImplSpec.groovy
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.apache.tapestry5.ioc.util
-
-import org.apache.tapestry5.ioc.internal.util.MessageFormatterImpl
-import spock.lang.Specification
-import spock.lang.Unroll
-
-class MessageFormatterImplSpec extends Specification {
-
- @Unroll
- def "standard formatting: #desc"() {
-
- def mf = new MessageFormatterImpl(format, null)
-
- expect:
-
- mf.format(* args) == expected
-
- where:
-
- format | args | expected | desc
-
- "Tapestry is %s." | ["cool"] | "Tapestry is cool." | "simple substition"
- "Tapestry release #%d." | [5] | "Tapestry release #5." | "numeric conversion"
- "%s is %s at version %d." | ["Tapestry", "cool", 5] | "Tapestry is cool at version 5." | "multiple conversions"
- "%s failed: %s" | ["Something", new RuntimeException("bad wolf")] | "Something failed: bad wolf" | "expansion of exception message"
- "%s failed: %s" | ["Another", new NullPointerException()] | "Another failed: java.lang.NullPointerException" | "expansion of exception without message is exception class name"
- }
-}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a1bef869/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/MessagesImplSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/MessagesImplSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/MessagesImplSpec.groovy
deleted file mode 100644
index 8d51c68..0000000
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/MessagesImplSpec.groovy
+++ /dev/null
@@ -1,76 +0,0 @@
-package org.apache.tapestry5.ioc.util
-
-import org.apache.tapestry5.ioc.Messages
-import org.apache.tapestry5.ioc.internal.util.MessagesImpl
-import org.apache.tapestry5.ioc.internal.util.TargetMessages
-import spock.lang.Shared
-import spock.lang.Specification
-import spock.lang.Unroll
-
-class MessagesImplSpec extends Specification {
-
- @Shared
- Messages messages = MessagesImpl.forClass(TargetMessages)
-
- @Unroll
- def "contains key: #desc"() {
-
- expect:
-
- messages.contains(key) == expectation
-
- where:
-
- key | expectation | desc
- "no-args" | true | "base case"
- "xyzzyz" | false | "key not present"
- "No-Args" | true | "case insensitive"
- }
-
- @Unroll
- def "get message from catalog: #desc"() {
- expect:
-
- messages.get(key) == expectation
-
- where:
-
- key | expectation | desc
-
- "no-args" | "No arguments." | "base case"
- "something-failed" | "Something failed: %s" | "does not attempt to expand conversions"
- "No-Args" | "No arguments." | "access is case insensitive"
- "does-not-exist" | "[[missing key: does-not-exist]]" | "fake value supplied for missing key"
- }
-
- @Unroll
- def "format message:#desc"() {
- expect:
-
- messages.format(key, value) == expectation
-
- where:
-
- key | value | expectation | desc
- "result" | "good" | "The result is 'good'." | "standard"
- "Result" | "best" | "The result is 'best'." | "lookup is case insensitive"
- "does-not-exist" | "xyzzyz" | "[[missing key: does-not-exist]]" | "fake value supplied for missing key"
- }
-
- def "access a MesageFormatter to format content"() {
- def mf = messages.getFormatter("result")
-
- expect:
-
- mf.format("cool") == "The result is 'cool'."
- }
-
- def "MessageFormatters are cached"() {
- def mf1 = messages.getFormatter("result")
- def mf2 = messages.getFormatter("result")
-
- expect:
-
- mf1.is(mf2)
- }
-}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a1bef869/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/OneShotLockSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/OneShotLockSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/OneShotLockSpec.groovy
deleted file mode 100644
index 5c45193..0000000
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/OneShotLockSpec.groovy
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.apache.tapestry5.ioc.util
-
-import org.apache.tapestry5.ioc.internal.util.OneShotLockSubject
-import spock.lang.Specification
-
-class OneShotLockSpec extends Specification {
-
- def subject = new OneShotLockSubject()
-
- def "may only invoke locked method once"() {
- subject.go()
- subject.done()
-
-
- when:
-
- subject.go()
-
- then:
-
- IllegalStateException e = thrown()
-
- e.message.contains "${subject.class.name}.go("
- e.message.contains "may no longer be invoked"
- }
-
- def "the method that locks is itself checked"() {
-
- subject.go()
- subject.done()
-
- when:
-
- subject.done()
-
- then:
-
- IllegalStateException e = thrown()
-
- e.message.contains "${subject.class.name}.done("
- }
-}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a1bef869/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/OrdererSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/OrdererSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/OrdererSpec.groovy
deleted file mode 100644
index 317913a..0000000
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/OrdererSpec.groovy
+++ /dev/null
@@ -1,285 +0,0 @@
-package org.apache.tapestry5.ioc.util
-
-import org.apache.tapestry5.ioc.Orderable
-import org.apache.tapestry5.ioc.internal.util.Orderer
-import org.apache.tapestry5.ioc.internal.util.UtilMessages
-import org.slf4j.Logger
-import spock.lang.Specification
-
-class OrdererSpec extends Specification {
-
- Logger logger = Mock()
-
- def "the order of the values is unchanged when there are no dependencies"() {
-
- def orderer = new Orderer(logger)
-
- when:
-
- orderer.with {
- add "fred", "FRED"
- add "barney", "BARNEY"
- add "wilma", "WILMA"
- add "betty", "BETTY"
- }
-
- then:
-
- orderer.ordered == ["FRED", "BARNEY", "WILMA", "BETTY"]
- }
-
- def "an override can change order and value"() {
- def orderer = new Orderer(logger)
-
- when:
-
- orderer.with {
- add "fred", "FRED"
- add "barney", "BARNEY"
- add "wilma", "WILMA"
- add "betty", "BETTY"
-
- override "barney", "Mr. Rubble", "before:*"
- }
-
- then:
-
- orderer.ordered == ["Mr. Rubble", "FRED", "WILMA", "BETTY"]
- }
-
- def "an override must match a previously added id"() {
- def orderer = new Orderer(logger)
-
- when:
-
- orderer.with {
- add "fred", "FRED"
- add "barney", "BARNEY"
- add "wilma", "WILMA"
- add "betty", "BETTY"
-
- override "bambam", "Mr. Rubble JR.", "before:*"
- }
-
- then:
-
- IllegalArgumentException e = thrown()
-
- e.message == "Override for object 'bambam' is invalid as it does not match an existing object."
- }
-
- def "a missing constraint type is logged as a warning"() {
-
- def orderer = new Orderer(logger)
-
- when:
-
- orderer.with {
- add "fred", "FRED"
- add "barney", "BARNEY", "fred"
- add "wilma", "WILMA"
- add "betty", "BETTY"
- }
-
- then:
-
- logger.warn(UtilMessages.constraintFormat("fred", "barney"))
-
- orderer.ordered == ["FRED", "BARNEY", "WILMA", "BETTY"]
- }
-
- def "an unknown constraint type is logged as a warning"() {
- def orderer = new Orderer(logger)
-
- when:
-
- orderer.with {
- add "fred", "FRED"
- add "barney", "BARNEY", "nearby:fred"
- add "wilma", "WILMA"
- add "betty", "BETTY"
- }
-
- then:
-
- logger.warn(UtilMessages.constraintFormat("nearby:fred", "barney"))
-
- orderer.ordered == ["FRED", "BARNEY", "WILMA", "BETTY"]
- }
-
- def "null values are not included in the result"() {
- def orderer = new Orderer(logger)
-
- when:
-
- orderer.with {
- add "fred", "FRED"
- add "barney", "BARNEY"
- add "zippo", null
- add "wilma", "WILMA"
- add "groucho", null
- add "betty", "BETTY"
- }
-
- then:
-
- orderer.ordered == ["FRED", "BARNEY", "WILMA", "BETTY"]
- }
-
- def "duplicate ids are ignored"() {
- def orderer = new Orderer(logger)
-
- orderer.with {
- add "fred", "FRED"
- add "barney", "BARNEY"
- add "wilma", "WILMA"
- }
-
- when:
-
- orderer.add("Fred", "Fred 2")
-
- then:
-
- // Notice it uses the previously added id, whose case is considered canonical
- logger.warn(UtilMessages.duplicateOrderer("fred"))
-
- when:
-
- orderer.add "betty", "BETTY"
-
- then:
-
- orderer.ordered == ["FRED", "BARNEY", "WILMA", "BETTY"]
- }
-
- def "the special before:* moves the value to the front of the list"() {
- def orderer = new Orderer(logger)
-
- when:
-
- orderer.with {
- add "fred", "FRED"
- add "barney", "BARNEY", "before:*"
- add "wilma", "WILMA"
- add "betty", "BETTY"
- }
-
- then:
-
- orderer.ordered == ["BARNEY", "FRED", "WILMA", "BETTY"]
- }
-
- def "the special after:* moves the value to the end of the list"() {
- def orderer = new Orderer(logger)
-
- when:
-
- orderer.with {
- add "fred", "FRED"
- add "barney", "BARNEY", "after:*"
- add "wilma", "WILMA"
- add "betty", "BETTY"
- }
-
- then:
-
- // A number of factors can twiddle the order of the other elements, so we just check the last
- orderer.ordered[3] == "BARNEY"
- }
-
- def "use lists of pre-requisites (after:)"() {
-
- def orderer = new Orderer(logger)
-
- when:
-
- orderer.with {
- add "fred", "FRED", "after:wilma"
- add "barney", "BARNEY", "after:fred,betty"
- add "wilma", "WILMA"
- add "betty", "BETTY"
- }
-
- then:
-
- orderer.ordered == ["WILMA", "FRED", "BETTY", "BARNEY"]
- }
-
- def "use both pre- and post-requisites (before: and after:)"() {
-
- def orderer = new Orderer(logger)
-
- when:
-
- orderer.with {
- add "fred", "FRED", "after:wilma"
- add "barney", "BARNEY", "after:fred,betty"
- add "wilma", "WILMA"
- add "betty", "BETTY", "before:wilma"
- }
-
- then:
-
- orderer.ordered == ["BETTY", "WILMA", "FRED", "BARNEY"]
- }
-
- def "pre- and post-requisites are case-insensitive"() {
- def orderer = new Orderer(logger)
-
- when:
-
- orderer.with {
- add "fred", "FRED", "after:WILMA"
- add "barney", "BARNEY", "after:fred,BETTY"
- add "wilma", "WILMA"
- add "betty", "BETTY", "before:Wilma"
- }
-
- then:
-
- orderer.ordered == ["BETTY", "WILMA", "FRED", "BARNEY"]
- }
-
- def "dependency cycles are identified and logged as warnings"() {
-
- def orderer = new Orderer(logger)
-
- when:
-
- orderer.with {
- add "fred", "FRED", "after:wilma"
- add "barney", "BARNEY", "after:fred,betty"
- add "wilma", "WILMA"
- add "betty", "BETTY", "before:Wilma", "after:barney"
- }
-
- def ordered = orderer.ordered
-
- then:
-
- 1 * logger.warn("Unable to add 'barney' as a dependency of 'betty', as that forms a dependency cycle ('betty' depends on itself via 'barney'). The dependency has been ignored.")
-
-
- ordered == ["BETTY", "WILMA", "FRED", "BARNEY"]
- }
-
- def "Orderable has a useful toString()"() {
-
- when:
-
- def simple = new Orderable("simple", "SIMPLE")
-
- then:
-
- simple.toString() == "Orderable[simple SIMPLE]"
-
- when:
-
- def complex = new Orderable("complex", "COMPLEX", "after:foo", "before:bar")
-
- then:
-
- complex.toString() == "Orderable[complex after:foo before:bar COMPLEX]"
- }
-}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a1bef869/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/URLChangeTrackerSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/URLChangeTrackerSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/URLChangeTrackerSpec.groovy
deleted file mode 100644
index ad2c28e..0000000
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/util/URLChangeTrackerSpec.groovy
+++ /dev/null
@@ -1,187 +0,0 @@
-package org.apache.tapestry5.ioc.util
-
-import org.apache.tapestry5.ioc.internal.services.ClasspathURLConverterImpl
-import org.apache.tapestry5.ioc.internal.util.URLChangeTracker
-import org.apache.tapestry5.ioc.services.ClasspathURLConverter
-import spock.lang.Shared
-import spock.lang.Specification
-
-class URLChangeTrackerSpec extends Specification {
-
- @Shared
- ClasspathURLConverter converter = new ClasspathURLConverterImpl()
-
- def tracker = new URLChangeTracker(converter)
-
- def "new instance does not contain changes"() {
- expect:
-
- !tracker.containsChanges()
- }
-
- def "adding a null URL returns 0"() {
-
- expect:
- tracker.add(null) == 0l
- }
-
- def touch(file) {
-
- def initial = file.lastModified()
- def index = 0
-
- while (true) {
-
- file.lastModified = System.currentTimeMillis()
-
- if (file.lastModified() != initial) { return }
-
- Thread.sleep(50 * 2 ^ index++)
- }
- }
-
- def "add a file, touch it, and ensure that the change is noticed"() {
- def f = newFile()
-
- when:
-
- tracker.add(f.toURL())
-
- then:
-
- // one for the file, one for its directory
-
- tracker.trackedFileCount() == 2
- !tracker.containsChanges()
-
- when:
-
- touch(f)
-
- then:
-
- tracker.containsChanges()
- }
-
- def File newFile() {
- File.createTempFile("changetracker0", ".tmp")
- }
-
- def "creating a new file in an existing tracker folder is a change"() {
-
- def first = newFile()
- def dir = first.getParentFile()
-
- when:
-
- tracker.add(first.toURL())
-
- then:
-
- !tracker.containsChanges()
-
- when:
-
- def initial = dir.lastModified()
- def index = 0
-
- while (true) {
- newFile()
-
- if (dir.lastModified() != initial) { break; }
- Thread.sleep(50 * 2 ^ index++)
- }
-
- then:
-
- tracker.containsChanges()
- }
-
- def "non-file URLs are ignored"() {
-
- when:
-
- tracker.add(new URL("http://google.com"))
-
- then:
-
- tracker.trackedFileCount() == 0
- }
-
- def "caching of URLs and timestamps"() {
-
- def file = newFile()
- def url = file.toURL()
-
- def initial = tracker.add(url)
-
- when:
-
- touch(file)
-
- then:
-
- tracker.add(url) == initial
-
- tracker.containsChanges()
-
- when:
-
- tracker.clear()
-
- then:
-
- tracker.add(url) != initial
- }
-
- def "deleting a file shows as changes"() {
- def file = newFile()
- def url = file.toURL()
-
- when:
-
- def initial = tracker.add(url)
-
- then:
-
- initial > 0
- !tracker.containsChanges()
-
- when:
-
- file.delete()
-
- then:
-
- tracker.containsChanges()
- }
-
- def "can track changes at a 1-second granularity (rather than millisecond)"() {
- tracker = new URLChangeTracker(converter, true, true)
-
- def file = newFile()
-
- when:
-
- long initial = tracker.add(file.toURL())
-
- then:
-
- initial % 1000 == 0
-
- when:
-
- Thread.sleep 1500
-
- touch(file)
-
- then:
-
- tracker.containsChanges()
-
- def updated = tracker.add(file.toURL())
-
- updated % 1000 == 0
- updated != initial
- }
-}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a1bef869/tapestry-ioc/src/test/groovy/org/apache/tapestry5/util/ExceptionUtilsSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/util/ExceptionUtilsSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/util/ExceptionUtilsSpec.groovy
deleted file mode 100644
index 1bc4796..0000000
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/util/ExceptionUtilsSpec.groovy
+++ /dev/null
@@ -1,53 +0,0 @@
-package org.apache.tapestry5.util
-
-import org.apache.tapestry5.ioc.internal.services.PropertyAccessImpl
-import org.apache.tapestry5.ioc.internal.util.TapestryException
-import org.apache.tapestry5.ioc.util.ExceptionUtils
-import org.apache.tapestry5.ioc.util.ExceptionWrapper
-import spock.lang.Shared
-import spock.lang.Specification
-
-class ExceptionUtilsSpec extends Specification {
-
- @Shared
- def access = new PropertyAccessImpl()
-
- def "find cause with match"() {
- when:
- def inner = new TapestryException("foo", null)
- def outer = new RuntimeException(inner)
-
- then:
-
- ExceptionUtils.findCause(outer, TapestryException).is(inner)
- ExceptionUtils.findCause(outer, TapestryException, access).is(inner)
- }
-
- def "find cause with no match"() {
-
- when:
-
- def re = new RuntimeException("No cause for you.")
-
- then:
-
- ExceptionUtils.findCause(re, TapestryException) == null
- ExceptionUtils.findCause(re, TapestryException, access) == null
- }
-
- def "find a hidden exception"() {
- when:
-
- def inner = new RuntimeException()
- def outer = new ExceptionWrapper(inner)
-
- then:
-
- // TAP5-1639: The old code can't find inner
- ExceptionUtils.findCause(outer, RuntimeException) == null
-
- // The new reflection-based on can:
-
- ExceptionUtils.findCause(outer, RuntimeException, access).is(inner)
- }
-}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a1bef869/tapestry-ioc/src/test/groovy/org/apache/tapestry5/util/StackSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/util/StackSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/util/StackSpec.groovy
deleted file mode 100644
index d5f17b8..0000000
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/util/StackSpec.groovy
+++ /dev/null
@@ -1,113 +0,0 @@
-package org.apache.tapestry5.util
-
-import org.apache.tapestry5.ioc.util.Stack
-import spock.lang.Specification
-
-class StackSpec extends Specification {
-
- def stack = new Stack()
-
- def "peek in empty stack is failure"() {
-
- when:
-
- stack.peek()
-
- then:
-
- IllegalStateException e = thrown()
-
- e.message == "Stack is empty."
- }
-
- def "pop in empty stack is failure"() {
-
- when:
-
- stack.pop()
-
- then:
-
- IllegalStateException e = thrown()
-
- e.message == "Stack is empty."
- }
-
- def "simple stack operations"() {
-
- def fred = "fred"
- def barney = "barney"
-
- expect:
-
- stack.empty
-
- when:
-
- stack.push fred
-
- then:
-
- stack.peek().is(fred)
- !stack.empty
-
- when:
-
- stack.push barney
-
- then:
-
- stack.peek().is(barney)
-
- stack.toString() == "Stack[barney, fred]"
-
- stack.depth == 2
-
- stack.snapshot.equals([fred, barney])
-
- when:
-
- def popped = stack.pop()
-
- then:
-
- popped.is barney
- stack.peek().is(fred)
- !stack.empty
-
- when:
-
- popped = stack.pop()
-
- then:
-
- popped.is fred
- stack.empty
- }
-
- def "force the expansion of the inner data"() {
-
- def limit = 1000
-
- when:
-
- limit.times { stack.push it }
-
- then:
-
- limit.downto(1) { stack.pop() == it - 1}
- }
-
- def "clear the stack"() {
-
- 10.times { stack.push it }
-
- when:
-
- stack.clear()
-
- then:
-
- stack.empty
- }
-}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a1bef869/tapestry-ioc/src/test/groovy/org/apache/tapestry5/util/StrategyRegistrySpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/util/StrategyRegistrySpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/util/StrategyRegistrySpec.groovy
deleted file mode 100644
index 30ca282..0000000
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/util/StrategyRegistrySpec.groovy
+++ /dev/null
@@ -1,148 +0,0 @@
-package org.apache.tapestry5.util
-
-import org.apache.tapestry5.ioc.util.StrategyRegistry
-import org.apache.tapestry5.ioc.util.UnknownValueException
-import spock.lang.Specification
-
-class StrategyRegistrySpec extends Specification {
-
- def "check exception when an adaptor is not found"() {
- Runnable r1 = Mock()
- Runnable r2 = Mock()
-
- StrategyRegistry reg = StrategyRegistry.newInstance(Runnable, [
- (List): r1,
- (Map): r2
- ])
-
- when:
-
- reg.get(Set)
-
- then:
-
- UnknownValueException e = thrown()
-
- e.message == "No adapter from type java.util.Set to type java.lang.Runnable is available."
- e.availableValues.toString() == "AvailableValues[registered types: interface java.util.List, interface java.util.Map]"
-
- }
-
- def "access to types registered"() {
- Runnable r1 = Mock()
- Runnable r2 = Mock()
-
- when:
-
- StrategyRegistry sr = StrategyRegistry.newInstance(Runnable, [
- (List): r1,
- (Map): r2
- ])
-
- then:
-
- sr.types.size == 2
- sr.types.containsAll(List, Map)
- }
-
- def "locate an adapter based on interface inheritance"() {
-
- Runnable r1 = Mock()
- Runnable r2 = Mock()
-
- when:
-
- StrategyRegistry sr = StrategyRegistry.newInstance(Runnable, [
- (List): r1,
- (Map): r2
- ])
-
- def arrayListAdapter = sr.get(ArrayList)
-
- then:
-
- arrayListAdapter.is r1
-
- when:
-
- def adapter2 = sr.get(ArrayList)
-
- then:
-
- adapter2.is r1
-
- when:
-
- sr.clearCache()
-
- def adapter3 = sr.get(ArrayList)
-
- then:
-
- adapter3.is r1
- }
-
- def "the registration map passed to the constructor is copied"() {
-
- Runnable r1 = Mock()
- Runnable r2 = Mock()
-
- def registrations = [
- (List): r1,
- (Map): r2
- ]
-
- when:
-
- StrategyRegistry sr = StrategyRegistry.newInstance(Runnable, registrations)
-
- registrations.clear()
-
- then:
-
- sr.get(ArrayList).is(r1)
- }
-
- def "adapter found from an instance"() {
-
- Runnable r1 = Mock()
- Runnable r2 = Mock()
-
- when:
-
- StrategyRegistry sr = StrategyRegistry.newInstance(Runnable, [
- (List): r1,
- (Map): r2
- ])
-
- then:
-
- sr.getByInstance([]).is(r1)
- sr.getByInstance([:]).is(r2)
-
- when:
-
- sr.clearCache()
-
- then:
-
- sr.getByInstance([]).is(r1)
- }
-
- def "null instances matches against void.class"() {
-
- Runnable r1 = Mock()
- Runnable r2 = Mock()
-
- when:
-
- def sr = StrategyRegistry.newInstance(Runnable, [
- (void): r1,
- (Map): r2])
-
-
- then:
-
- sr.getByInstance(null).is(r1)
- }
-}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a1bef869/tapestry-ioc/src/test/groovy/org/apache/tapestry5/util/StringToEnumCoercionSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/util/StringToEnumCoercionSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/util/StringToEnumCoercionSpec.groovy
deleted file mode 100644
index 26c617b..0000000
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/util/StringToEnumCoercionSpec.groovy
+++ /dev/null
@@ -1,52 +0,0 @@
-package org.apache.tapestry5.util
-
-import spock.lang.Specification
-
-
-class StringToEnumCoercionSpec extends Specification {
-
- def "searches are case-insensitive"() {
- def coercion = new StringToEnumCoercion(Stooge)
-
- expect:
-
- coercion.coerce("moe").is(Stooge.MOE)
- coercion.coerce("MOE").is(Stooge.MOE)
- coercion.coerce("CURLY_Joe").is(Stooge.CURLY_JOE)
- }
-
- def "blank input returns null"() {
- def coercion = new StringToEnumCoercion(Stooge)
-
- expect:
-
- coercion.coerce("") == null
- coercion.coerce("\t\n") == null
- }
-
- def "enum value can be found by an added alias"() {
- def coercion = new StringToEnumCoercion(Stooge)
-
- coercion.addAlias("shemp", Stooge.CURLY_JOE)
-
- expect:
-
- coercion.coerce("curly_joe").is(Stooge.CURLY_JOE)
- coercion.coerce("shemp").is(Stooge.CURLY_JOE)
- coercion.coerce("Shemp").is(Stooge.CURLY_JOE)
- }
-
- def "a failed search by name throws an exception"() {
- def coercion = new StringToEnumCoercion(Stooge)
-
- when:
-
- coercion.coerce("shemp")
-
- then:
-
- RuntimeException e = thrown()
-
- e.message == /Input 'shemp' does not identify a value from enumerated type ${Stooge.name}./
- }
-}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a1bef869/tapestry-ioc/src/test/groovy/org/apache/tapestry5/util/TimeIntervalSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/util/TimeIntervalSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/util/TimeIntervalSpec.groovy
deleted file mode 100644
index b6f8720..0000000
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/util/TimeIntervalSpec.groovy
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.apache.tapestry5.util
-
-import org.apache.tapestry5.ioc.util.TimeInterval
-import spock.lang.Specification
-import spock.lang.Unroll
-
-class TimeIntervalSpec extends Specification {
-
- @Unroll
- def "constructor usage '#input' parses to #milliseconds ms and '#units'"() {
- when:
-
- TimeInterval ti = new TimeInterval(input)
-
- then:
-
- ti.milliseconds() == milliseconds
- ti.toString() == "TimeInterval[$units]"
-
- ti.toDescription() == description
-
- where:
-
- input | milliseconds | units | description
-
- "30 s" | 30000 | "30000 ms" | "30s"
- "1h 30m" | 90 * 60 * 1000 | "5400000 ms" | "1h 30m"
- "2d" | 2 * 24 * 60 * 60 * 1000 | "172800000 ms" | "2d"
- "23ms" | 23 | "23 ms" | "23ms"
- "62s" | 62 * 1000 | "62000 ms" | "1m 2s"
- }
-
- def "invalid units"() {
-
- when:
-
- TimeInterval.parseMilliseconds "30s 500mz"
-
- then:
-
- RuntimeException e = thrown()
-
- e.message == "Unknown time interval unit 'mz' (in '30s 500mz'). Defined units: d, h, m, ms, s, y."
- }
-
- def "unrecognized input"() {
-
- when:
-
- TimeInterval.parseMilliseconds "30s z 500ms"
-
- then:
-
- RuntimeException e = thrown()
-
- e.message.contains "Unexpected string 'z'"
- }
-
- def "unrecognized input at end"() {
-
- when:
-
- TimeInterval.parseMilliseconds "30s 500ms xyz"
-
- then:
-
- RuntimeException e = thrown()
-
- e.message.contains "Unexpected string 'xyz'"
- }
-
-}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a1bef869/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/MasterModule.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/MasterModule.java b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/MasterModule.java
index 654a733..1c392dc 100644
--- a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/MasterModule.java
+++ b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/MasterModule.java
@@ -17,10 +17,10 @@ package org.apache.tapestry5.ioc;
import org.apache.tapestry5.ioc.annotations.SubModule;
/**
- * Used by {@link org.apache.tapestry5.ioc.RegistryBuilderSpec}.
+ * Used by {@link ioc.specs.RegistryBuilderSpec}.
*/
@SubModule(
- { FredModule.class, BarneyModule.class })
+ {FredModule.class, BarneyModule.class})
public final class MasterModule
{
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a1bef869/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/Square.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/Square.java b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/Square.java
index 3cd7c88..fd7a5ff 100644
--- a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/Square.java
+++ b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/Square.java
@@ -15,7 +15,7 @@
package org.apache.tapestry5.ioc;
/**
- * Used by {@link org.apache.tapestry5.ioc.RegistryBuilderSpec}.
+ * Used by {@link ioc.specs.RegistryBuilderSpec}.
*/
public interface Square
{
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a1bef869/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ExtraPublicConstructorsModule.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ExtraPublicConstructorsModule.java b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ExtraPublicConstructorsModule.java
index c262a64..0d7a8d2 100644
--- a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ExtraPublicConstructorsModule.java
+++ b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ExtraPublicConstructorsModule.java
@@ -18,7 +18,7 @@ import org.apache.tapestry5.ioc.MappedConfiguration;
import org.apache.tapestry5.ioc.services.SymbolSource;
/**
- * Used by {@link org.apache.tapestry5.ioc.internal.ModuleImplSpec}.
+ * Used by {@link ioc.specs.ModuleImplSpec}.
*/
public class ExtraPublicConstructorsModule
{
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a1bef869/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ModuleImplTestModule.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ModuleImplTestModule.java b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ModuleImplTestModule.java
index 36c513c..16e8320 100644
--- a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ModuleImplTestModule.java
+++ b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ModuleImplTestModule.java
@@ -18,7 +18,7 @@ import org.apache.tapestry5.ioc.ServiceResources;
import org.apache.tapestry5.ioc.annotations.InjectService;
/**
- * Module class used by {@link ModuleImplSpec}.
+ * Module class used by {@link ioc.specs.ModuleImplSpec}.
*/
public class ModuleImplTestModule
{
@@ -52,7 +52,7 @@ public class ModuleImplTestModule
}
public FoeService buildRecursiveFoe(@InjectService("RecursiveFoe")
- FoeService self)
+ FoeService self)
{
// While constructing self, we invoke a method on self.
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a1bef869/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/PrivateConstructorModule.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/PrivateConstructorModule.java b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/PrivateConstructorModule.java
index e9a231a..2fc257f 100644
--- a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/PrivateConstructorModule.java
+++ b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/PrivateConstructorModule.java
@@ -16,7 +16,7 @@ package org.apache.tapestry5.ioc.internal;
/**
- * Used by {@link org.apache.tapestry5.ioc.RegistryConstructionAndRuntimeErrorsSpec}.
+ * Used by {@link ioc.specs.RegistryConstructionAndRuntimeErrorsSpec}.
*/
public class PrivateConstructorModule
{
@@ -24,5 +24,8 @@ public class PrivateConstructorModule
{
}
- public Runnable buildTrigger() { return null; }
+ public Runnable buildTrigger()
+ {
+ return null;
+ }
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a1bef869/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ServiceBuilderMethodFixture.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ServiceBuilderMethodFixture.java b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ServiceBuilderMethodFixture.java
index f67ebdc..5e2d0bd 100644
--- a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ServiceBuilderMethodFixture.java
+++ b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ServiceBuilderMethodFixture.java
@@ -26,7 +26,7 @@ import java.util.Collection;
import java.util.List;
/**
- * Used by {@link org.apache.tapestry5.ioc.internal.ServiceBuilderMethodInvokerSpec}.
+ * Used by {@link ioc.specs.ServiceBuilderMethodInvokerSpec}.
*/
public class ServiceBuilderMethodFixture extends Assert
{
@@ -77,17 +77,16 @@ public class ServiceBuilderMethodFixture extends Assert
}
public FieService build_injected(@InjectService("Foe")
- FoeService foe)
+ FoeService foe)
{
assertSame(expectedFoe, foe);
return fie;
}
-
public FieService build_named_injected(@Named("Foe")
- FoeService foe)
+ FoeService foe)
{
assertSame(expectedFoe, foe);
@@ -115,9 +114,11 @@ public class ServiceBuilderMethodFixture extends Assert
return fie;
}
- /** Before 5.2, an @Inject was necessary here. Now we're testing that it no longer is necessary. */
+ /**
+ * Before 5.2, an @Inject was necessary here. Now we're testing that it no longer is necessary.
+ */
public FieService build_with_forced_injection(@Value("Injected")
- String string)
+ String string)
{
assertEquals(string, expectedString);
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a1bef869/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/Bar.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/Bar.java b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/Bar.java
index 53f8d5c..472c7eb 100644
--- a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/Bar.java
+++ b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/Bar.java
@@ -1,7 +1,7 @@
package org.apache.tapestry5.ioc.internal.util;
/**
- * Used by {@link org.apache.tapestry5.ioc.util.InheritanceSearchSpec}.
+ * Used by {@link ioc.specs.InheritanceSearchSpec}.
*/
public interface Bar
{
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a1bef869/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/BarImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/BarImpl.java b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/BarImpl.java
index a741ad7..3451819 100644
--- a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/BarImpl.java
+++ b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/BarImpl.java
@@ -2,7 +2,7 @@ package org.apache.tapestry5.ioc.internal.util;
/**
- * Used by {@link org.apache.tapestry5.ioc.util.InheritanceSearchSpec}.
+ * Used by {@link ioc.specs.InheritanceSearchSpec}.
*/
public class BarImpl implements Bar
{
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a1bef869/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/Foo.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/Foo.java b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/Foo.java
index 6898469..e41a9c7 100644
--- a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/Foo.java
+++ b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/Foo.java
@@ -2,7 +2,7 @@ package org.apache.tapestry5.ioc.internal.util;
/**
- * Used by {@link org.apache.tapestry5.ioc.util.InheritanceSearchSpec}.
+ * Used by {@link ioc.specs.InheritanceSearchSpec}.
*/
public interface Foo extends Bar
{
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a1bef869/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/FooBar.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/FooBar.java b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/FooBar.java
index ba0a9b3..497d389 100644
--- a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/FooBar.java
+++ b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/FooBar.java
@@ -2,7 +2,7 @@ package org.apache.tapestry5.ioc.internal.util;
/**
- * Used by {@link org.apache.tapestry5.ioc.util.InheritanceSearchSpec}.
+ * Used by {@link ioc.specs.InheritanceSearchSpec}.
*/
public interface FooBar extends Foo, Bar
{
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a1bef869/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/FooBarImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/FooBarImpl.java b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/FooBarImpl.java
index 4bb033e..c54f201 100644
--- a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/FooBarImpl.java
+++ b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/FooBarImpl.java
@@ -2,7 +2,7 @@ package org.apache.tapestry5.ioc.internal.util;
/**
- * Used by {@link org.apache.tapestry5.ioc.util.InheritanceSearchSpec}.
+ * Used by {@link ioc.specs.InheritanceSearchSpec}.
*/
public class FooBarImpl extends FooImpl implements Bar, FooBar
{
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a1bef869/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/FooImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/FooImpl.java b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/FooImpl.java
index 94d74c8..241e4b3 100644
--- a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/FooImpl.java
+++ b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/FooImpl.java
@@ -1,7 +1,7 @@
package org.apache.tapestry5.ioc.internal.util;
/**
- * Used by {@link org.apache.tapestry5.ioc.util.InheritanceSearchSpec}.
+ * Used by {@link ioc.specs.InheritanceSearchSpec}.
*/
public class FooImpl extends BarImpl implements Foo
{
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a1bef869/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/TargetMessages.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/TargetMessages.java b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/TargetMessages.java
index ea1edc1..dced51e 100644
--- a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/TargetMessages.java
+++ b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/util/TargetMessages.java
@@ -1,7 +1,7 @@
package org.apache.tapestry5.ioc.internal.util;
/**
- * Used with {@link org.apache.tapestry5.ioc.util.MessagesImplSpec}.
+ * Used with {@link ioc.specs.MessagesImplSpec}.
*/
public class TargetMessages
{
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a1bef869/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/util/IdAllocatorSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/util/IdAllocatorSpec.groovy b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/util/IdAllocatorSpec.groovy
deleted file mode 100644
index 5802da7..0000000
--- a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/util/IdAllocatorSpec.groovy
+++ /dev/null
@@ -1,163 +0,0 @@
-package org.apache.tapestry5.ioc.util
-
-import spock.lang.Specification
-
-
-class IdAllocatorSpec extends Specification {
-
- def "id is not allocated until it is allocated"() {
- when:
-
- IdAllocator a = new IdAllocator()
-
- then:
-
- !a.isAllocated("name")
-
- when:
-
- def actual = a.allocateId("name")
-
- then:
-
- actual == "name"
- a.isAllocated("name")
- }
-
- def "repeatedly allocated ids are uniqued with a suffix"() {
-
- IdAllocator a = new IdAllocator()
-
- a.allocateId("name")
-
- expect:
-
- 10.times {
-
- def expected = "name_$it"
-
- assert !a.isAllocated(expected)
-
- assert a.allocateId("name") == expected
- }
- }
-
- def "access to allocated ids"() {
- IdAllocator a = new IdAllocator()
-
- when:
-
- a.allocateId("name")
-
- then:
-
- a.allocatedIds == ["name"]
-
- when:
-
- a.allocateId("name")
-
- then:
-
- a.allocatedIds == ["name", "name_0"]
- }
-
- def "allocation using a namespace"() {
-
- IdAllocator a = new IdAllocator("_NS")
-
- expect:
-
- a.allocateId("name") == "name_NS"
-
- a.allocateId("name") == "name_NS_0"
-
- // This is current behavior, but is probably something
- // that could be improved.
-
- a.allocateId("name_NS") == "name_NS_NS"
-
- a.allocateId("name_NS") == "name_NS_NS_0"
- }
-
- def "degenerate id allocation"() {
- IdAllocator a = new IdAllocator()
-
- expect:
-
- a.allocateId("d_1") == "d_1"
- a.allocateId("d") == "d"
- a.allocateId("d") == "d_0"
- a.allocateId("d") == "d_2"
-
- a.allocateId("d") == "d_3"
-
- // It's a collision, so a unique number is appended.
- a.allocateId("d_1") == "d_1_0"
- }
-
- def "degenerate id allocation (with a namespace)"() {
-
- IdAllocator a = new IdAllocator("_NS")
-
- expect:
-
- a.allocateId("d_1") == "d_1_NS"
-
- a.allocateId("d") == "d_NS"
- a.allocateId("d") == "d_NS_0"
- a.allocateId("d") == "d_NS_1"
- a.allocateId("d") == "d_NS_2"
- a.allocateId("d") == "d_NS_3"
-
- a.allocateId("d_1") == "d_1_NS_0"
-
- // This is very degenerate, and maybe something that needs fixing.
-
- a.allocateId("d_1_NS") == "d_1_NS_NS"
- }
-
- def "clearing an allocator forgets prior ids"() {
- when:
-
- IdAllocator a = new IdAllocator()
-
-
- then:
-
- a.allocateId("foo") == "foo"
- a.allocateId("foo") == "foo_0"
-
- when:
-
- a.clear()
-
- then:
-
- a.allocateId("foo") == "foo"
- a.allocateId("foo") == "foo_0"
- }
-
- def "cloning an id allocator does not share data with the new allocator"() {
-
- when:
-
- IdAllocator a = new IdAllocator();
-
- then:
-
- a.allocateId("foo") == "foo"
- a.allocateId("foo") == "foo_0"
-
- when:
-
- IdAllocator b = a.clone()
-
- then:
-
- ["bar", "baz", "foo", "foo"].each {
- assert a.allocateId(it) == b.allocateId(it)
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a1bef869/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/util/LocalizedNamesGeneratorSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/util/LocalizedNamesGeneratorSpec.groovy b/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/util/LocalizedNamesGeneratorSpec.groovy
deleted file mode 100644
index 95a6cb0..0000000
--- a/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/util/LocalizedNamesGeneratorSpec.groovy
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.apache.tapestry5.ioc.util
-
-import spock.lang.Specification
-import spock.lang.Unroll
-
-
-class LocalizedNamesGeneratorSpec extends Specification {
-
- @Unroll
- def "Localized names for #path and #locale are '#expected'"() {
-
- when:
-
- LocalizedNameGenerator g = new LocalizedNameGenerator(path, locale)
-
- then:
-
- expected.tokenize().each {
- assert g.hasNext()
- assert g.next() == it
- }
-
- !g.hasNext()
-
- where:
-
- path | locale | expected
-
- "basic.test" | Locale.US | "basic_en_US.test basic_en.test basic.test"
- "noCountry.zap" | Locale.FRENCH | "noCountry_fr.zap noCountry.zap"
- "fred.foo" | new Locale("en", "", "GEEK") | "fred_en__GEEK.foo fred_en.foo fred.foo"
- "context:/blah" | Locale.FRENCH | "context:/blah_fr context:/blah"
- "context:/blah" | new Locale("fr", "", "GEEK") | "context:/blah_fr__GEEK context:/blah_fr context:/blah"
-
- // The double-underscore is correct, it's a kind of placeholder for the null country. JDK1.3 always converts the locale to upper case. JDK 1.4
- // does not. To keep this test happyt, we selected an all-uppercase locale.
-
- }
-}