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
[6/44] git commit: Update Groovy formatting and reformat existing code
Update Groovy formatting and reformat existing code
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/6ba605f4
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/6ba605f4
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/6ba605f4
Branch: refs/heads/master
Commit: 6ba605f4b2a2aa06175d47cea209b186a8ba199f
Parents: e57bd92
Author: Howard M. Lewis Ship <hl...@gmail.com>
Authored: Mon May 14 11:33:49 2012 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Wed May 16 11:50:14 2012 -0700
----------------------------------------------------------------------
.../apache/tapestry5/ioc/BaseLocatableSpec.groovy | 29 +-
.../org/apache/tapestry5/ioc/EagerLoadSpec.groovy | 19 +-
.../tapestry5/ioc/ManifestProcessingSpec.groovy | 6 +-
.../tapestry5/ioc/ModuleInstantiationSpec.groovy | 1 +
.../ioc/OrderedConstraintBuilderSpec.groovy | 30 +-
.../tapestry5/ioc/RegistryBuilderSpec.groovy | 94 ++--
.../org/apache/tapestry5/ioc/ReloadSpec.groovy | 454 +++++++-------
.../ioc/internal/LazyAdvisorImplSpec.groovy | 6 +-
.../ioc/internal/LoggingDecoratorImplSpec.groovy | 3 +
.../AspectInterceptorBuilderImplSpec.groovy | 2 +
.../ioc/internal/services/BridgeBuilderSpec.groovy | 4 +
.../internal/services/ChainBuilderImplSpec.groovy | 1 +
.../services/ExceptionAnalyzerImplSpec.groovy | 13 +-
.../services/FilterMethodAnalyzerSpec.groovy | 7 +-
.../services/MasterObjectProviderImplSpec.groovy | 3 +-
.../internal/services/MethodIteratorSpec.groovy | 4 +
.../internal/services/MethodSignatureSpec.groovy | 1 +
.../internal/services/ParallelExecutorSpec.groovy | 1 +
.../ioc/internal/services/ToString.groovy | 1 +
.../ioc/services/PeriodicExecutorSpec.groovy | 18 +-
.../services/SystemEnvSymbolProviderSpec.groovy | 16 +-
.../tapestry5/util/StringToEnumCoercionSpec.groovy | 65 +--
22 files changed, 394 insertions(+), 384 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6ba605f4/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/BaseLocatableSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/BaseLocatableSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/BaseLocatableSpec.groovy
index 7dcc0a5..9344b13 100644
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/BaseLocatableSpec.groovy
+++ b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/BaseLocatableSpec.groovy
@@ -3,30 +3,31 @@ package org.apache.tapestry5.ioc
import spock.lang.Specification
class LocatableFixture extends BaseLocatable {
- LocatableFixture(Location location) {
- super(location)
- }
+
+ LocatableFixture(Location location) {
+ super(location)
+ }
}
class BaseLocatableSpec extends Specification {
- def "location property is readable"() {
- Location location = Mock()
+ def "location property is readable"() {
+ Location location = Mock()
- Locatable locatable = new LocatableFixture(location)
+ Locatable locatable = new LocatableFixture(location)
- expect:
+ expect:
- locatable.location.is location
- }
+ locatable.location.is location
+ }
- def "location may be null"() {
- Locatable locatable = new LocatableFixture(null);
+ def "location may be null"() {
+ Locatable locatable = new LocatableFixture(null);
- expect:
+ expect:
- locatable.location == null
- }
+ locatable.location == null
+ }
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6ba605f4/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/EagerLoadSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/EagerLoadSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/EagerLoadSpec.groovy
index a04bd61..7175751 100644
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/EagerLoadSpec.groovy
+++ b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/EagerLoadSpec.groovy
@@ -2,20 +2,19 @@ package org.apache.tapestry5.ioc
class EagerLoadSpec extends AbstractRegistrySpecification {
- def "proxied service does eager load"()
- {
- expect:
+ def "proxied service does eager load"() {
+ expect:
- EagerProxyReloadModule.eagerLoadServiceDidLoad == false
+ EagerProxyReloadModule.eagerLoadServiceDidLoad == false
- when:
+ when:
- buildRegistry EagerProxyReloadModule
+ buildRegistry EagerProxyReloadModule
- performRegistryStartup()
+ performRegistryStartup()
- then:
+ then:
- EagerProxyReloadModule.eagerLoadServiceDidLoad == true
- }
+ EagerProxyReloadModule.eagerLoadServiceDidLoad == true
+ }
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6ba605f4/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/ManifestProcessingSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/ManifestProcessingSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/ManifestProcessingSpec.groovy
index 51b0949..d466772 100644
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/ManifestProcessingSpec.groovy
+++ b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/ManifestProcessingSpec.groovy
@@ -11,9 +11,9 @@ class ManifestProcessingSpec extends Specification {
expect:
- // This is more to verify the module execution environment
- fakejar.exists()
- fakejar.isDirectory()
+ // This is more to verify the module execution environment
+ fakejar.exists()
+ fakejar.isDirectory()
when:
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6ba605f4/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/ModuleInstantiationSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/ModuleInstantiationSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/ModuleInstantiationSpec.groovy
index 67c2fb3..4b5f40b 100644
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/ModuleInstantiationSpec.groovy
+++ b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/ModuleInstantiationSpec.groovy
@@ -2,6 +2,7 @@ package org.apache.tapestry5.ioc
class ModuleInstantiationSpec extends AbstractRegistrySpecification {
+
def setup() {
StaticModule.reset()
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6ba605f4/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/OrderedConstraintBuilderSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/OrderedConstraintBuilderSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/OrderedConstraintBuilderSpec.groovy
index 02ea9ae..18c0cbe 100644
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/OrderedConstraintBuilderSpec.groovy
+++ b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/OrderedConstraintBuilderSpec.groovy
@@ -4,27 +4,27 @@ import spock.lang.Specification
class OrderedConstraintBuilderSpec extends Specification {
- /** Any unrecognized methods are evaluated against {@link OrderConstraintBuilder}. */
- def methodMissing(String name, args) {
- OrderConstraintBuilder."$name"(* args)
- }
+ /** Any unrecognized methods are evaluated against {@link OrderConstraintBuilder}. */
+ def methodMissing(String name, args) {
+ OrderConstraintBuilder."$name"(* args)
+ }
- def "constraint ordering"() {
- expect:
+ def "constraint ordering"() {
+ expect:
- constraint.build() == values
+ constraint.build() == values
- where:
+ where:
- constraint || values
+ constraint || values
- after("A") || ["after:A"]
- afterAll() || ["after:*"]
- before("B") || ["before:B"]
- beforeAll() || ["before:*"]
+ after("A") || ["after:A"]
+ afterAll() || ["after:*"]
+ before("B") || ["before:B"]
+ beforeAll() || ["before:*"]
- before("A").after("B") || ["before:A", "after:B"]
- }
+ before("A").after("B") || ["before:A", "after:B"]
+ }
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6ba605f4/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/RegistryBuilderSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/RegistryBuilderSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/RegistryBuilderSpec.groovy
index 98db472..fd3acad 100644
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/RegistryBuilderSpec.groovy
+++ b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/RegistryBuilderSpec.groovy
@@ -8,88 +8,88 @@ import spock.lang.Specification
class RegistryBuilderSpec extends Specification {
- def "@SubModule annotation is honored"() {
- when:
+ def "@SubModule annotation is honored"() {
+ when:
- Registry r = new RegistryBuilder().add(MasterModule).build()
+ Registry r = new RegistryBuilder().add(MasterModule).build()
- def service = r.getService("UnorderedNames", NameListHolder)
+ def service = r.getService("UnorderedNames", NameListHolder)
- then:
+ then:
- service.names == ["Beta", "Gamma", "UnorderedNames"]
+ service.names == ["Beta", "Gamma", "UnorderedNames"]
- cleanup:
+ cleanup:
- r.shutdown()
- }
+ r.shutdown()
+ }
- def "adding modules by name, in comma seperated list, as from a manifest"() {
- when:
+ def "adding modules by name, in comma seperated list, as from a manifest"() {
+ when:
- RegistryBuilder builder = new RegistryBuilder()
+ RegistryBuilder builder = new RegistryBuilder()
- IOCUtilities.addModulesInList builder,
- "${FredModule.class.name}, ${BarneyModule.class.name}, ${RegistryBuilderTestModule.class.name}"
+ IOCUtilities.addModulesInList builder,
+ "${FredModule.class.name}, ${BarneyModule.class.name}, ${RegistryBuilderTestModule.class.name}"
- Registry registry = builder.build()
+ Registry registry = builder.build()
- Square service = registry.getService(Square)
+ Square service = registry.getService(Square)
- then:
+ then:
- service.square(4) == 16
+ service.square(4) == 16
- service.toString() == "<Proxy for Square(${Square.class.name})>"
+ service.toString() == "<Proxy for Square(${Square.class.name})>"
- cleanup:
+ cleanup:
- registry.shutdown()
- }
+ registry.shutdown()
+ }
- def "exercise RegistryBuilder.buildAndStartupRegistry()"() {
- when:
+ def "exercise RegistryBuilder.buildAndStartupRegistry()"() {
+ when:
- Registry r = RegistryBuilder.buildAndStartupRegistry(MasterModule);
+ Registry r = RegistryBuilder.buildAndStartupRegistry(MasterModule);
- NameListHolder service = r.getService("UnorderedNames", NameListHolder);
+ NameListHolder service = r.getService("UnorderedNames", NameListHolder);
- then:
+ then:
- service.names == ["Beta", "Gamma", "UnorderedNames"]
+ service.names == ["Beta", "Gamma", "UnorderedNames"]
- cleanup:
+ cleanup:
- r.shutdown();
- }
+ r.shutdown();
+ }
- def "use explicit ModuleDef with buildAndStartupRegistry()"() {
- when:
+ def "use explicit ModuleDef with buildAndStartupRegistry()"() {
+ when:
- Logger logger = LoggerFactory.getLogger(getClass());
+ Logger logger = LoggerFactory.getLogger(getClass());
- ModuleDef module = new DefaultModuleDefImpl(ServiceBuilderModule,
- logger, null);
+ ModuleDef module = new DefaultModuleDefImpl(ServiceBuilderModule,
+ logger, null);
- Registry r = RegistryBuilder.buildAndStartupRegistry(module, MasterModule);
+ Registry r = RegistryBuilder.buildAndStartupRegistry(module, MasterModule);
- NameListHolder nameListHolder = r.getService("UnorderedNames", NameListHolder);
+ NameListHolder nameListHolder = r.getService("UnorderedNames", NameListHolder);
- then:
+ then:
- nameListHolder.names == ["Beta", "Gamma", "UnorderedNames"]
+ nameListHolder.names == ["Beta", "Gamma", "UnorderedNames"]
- when:
+ when:
- Greeter greeter = r.getService("Greeter", Greeter)
+ Greeter greeter = r.getService("Greeter", Greeter)
- then:
+ then:
- greeter.greeting == "Greetings from service Greeter."
+ greeter.greeting == "Greetings from service Greeter."
- cleanup:
+ cleanup:
- r.shutdown();
+ r.shutdown();
- }
+ }
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6ba605f4/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/ReloadSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/ReloadSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/ReloadSpec.groovy
index 763df6d..6838d81 100644
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/ReloadSpec.groovy
+++ b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/ReloadSpec.groovy
@@ -11,391 +11,391 @@ import static org.apache.tapestry5.internal.plastic.asm.Opcodes.*
class ReloadSpec extends Specification {
- private static final String PACKAGE = "com.example";
+ private static final String PACKAGE = "com.example";
- private static final String CLASS = PACKAGE + ".ReloadableServiceImpl";
+ private static final String CLASS = PACKAGE + ".ReloadableServiceImpl";
- private static final String BASE_CLASS = PACKAGE + ".BaseReloadableServiceImpl";
+ private static final String BASE_CLASS = PACKAGE + ".BaseReloadableServiceImpl";
- @AutoCleanup("shutdown")
- Registry registry
+ @AutoCleanup("shutdown")
+ Registry registry
- @AutoCleanup("deleteDir")
- File classesDir
+ @AutoCleanup("deleteDir")
+ File classesDir
- ClassLoader classLoader
+ ClassLoader classLoader
- File classFile;
+ File classFile;
- def createRegistry() {
- registry = new RegistryBuilder(classLoader).add(ReloadModule).build()
- }
+ def createRegistry() {
+ registry = new RegistryBuilder(classLoader).add(ReloadModule).build()
+ }
- /** Any unrecognized methods are evaluated against the registry. */
- def methodMissing(String name, args) {
- registry."$name"(* args)
- }
+ /** Any unrecognized methods are evaluated against the registry. */
+ def methodMissing(String name, args) {
+ registry."$name"(* args)
+ }
- def setup() {
- def uid = UUID.randomUUID().toString()
+ def setup() {
+ def uid = UUID.randomUUID().toString()
- classesDir = new File(System.getProperty("java.io.tmpdir"), uid)
+ classesDir = new File(System.getProperty("java.io.tmpdir"), uid)
- def classesURL = new URL("file:" + classesDir.getCanonicalPath() + "/")
+ def classesURL = new URL("file:" + classesDir.getCanonicalPath() + "/")
- classLoader = new URLClassLoader([classesURL] as URL[],
- Thread.currentThread().contextClassLoader)
+ classLoader = new URLClassLoader([classesURL] as URL[],
+ Thread.currentThread().contextClassLoader)
- classFile = new File(classesDir, PlasticInternalUtils.toClassPath(CLASS))
- }
-
- def createImplementationClass(String status) {
- createImplementationClass CLASS, status
- }
+ classFile = new File(classesDir, PlasticInternalUtils.toClassPath(CLASS))
+ }
- def createImplementationClass(String className, String status) {
+ def createImplementationClass(String status) {
+ createImplementationClass CLASS, status
+ }
- String internalName = PlasticInternalUtils.toInternalName className
+ def createImplementationClass(String className, String status) {
- createClassWriter(internalName, "java/lang/Object", ACC_PUBLIC).with {
+ String internalName = PlasticInternalUtils.toInternalName className
- // Add default constructor
+ createClassWriter(internalName, "java/lang/Object", ACC_PUBLIC).with {
- visitMethod(ACC_PUBLIC, "<init>", "()V", null, null).with {
- visitCode()
- visitVarInsn ALOAD, 0
- visitMethodInsn INVOKESPECIAL, "java/lang/Object", "<init>", "()V"
- visitInsn RETURN
- visitMaxs 1, 1
- visitEnd()
- }
+ // Add default constructor
+ visitMethod(ACC_PUBLIC, "<init>", "()V", null, null).with {
+ visitCode()
+ visitVarInsn ALOAD, 0
+ visitMethodInsn INVOKESPECIAL, "java/lang/Object", "<init>", "()V"
+ visitInsn RETURN
+ visitMaxs 1, 1
+ visitEnd()
+ }
- visitMethod(ACC_PUBLIC, "getStatus", "()Ljava/lang/String;", null, null).with {
- visitCode()
- visitLdcInsn status
- visitInsn ARETURN
- visitMaxs 1, 1
- visitEnd()
- }
- visitEnd()
+ visitMethod(ACC_PUBLIC, "getStatus", "()Ljava/lang/String;", null, null).with {
+ visitCode()
+ visitLdcInsn status
+ visitInsn ARETURN
+ visitMaxs 1, 1
+ visitEnd()
+ }
- writeBytecode it, internalName
- }
+ visitEnd()
+ writeBytecode it, internalName
}
- def createClassWriter(String internalName, String baseClassInternalName, int classModifiers) {
- ClassWriter cw = new ClassWriter(0);
+ }
- cw.visit V1_5, classModifiers, internalName, null,
- baseClassInternalName, [
- PlasticInternalUtils.toInternalName(ReloadableService.name)
- ] as String[]
+ def createClassWriter(String internalName, String baseClassInternalName, int classModifiers) {
+ ClassWriter cw = new ClassWriter(0);
+ cw.visit V1_5, classModifiers, internalName, null,
+ baseClassInternalName, [
+ PlasticInternalUtils.toInternalName(ReloadableService.name)
+ ] as String[]
- return cw
- }
+ return cw
+ }
- def writeBytecode(ClassWriter cw, String internalName) {
- byte[] bytecode = cw.toByteArray();
- writeBytecode(bytecode, pathForInternalName(internalName))
- }
+ def writeBytecode(ClassWriter cw, String internalName) {
+ byte[] bytecode = cw.toByteArray();
- def writeBytecode(byte[] bytecode, String path) {
- File file = new File(path)
+ writeBytecode(bytecode, pathForInternalName(internalName))
+ }
- file.parentFile.mkdirs()
+ def writeBytecode(byte[] bytecode, String path) {
+ File file = new File(path)
- file.withOutputStream { it.write bytecode }
- }
+ file.parentFile.mkdirs()
+ file.withOutputStream { it.write bytecode }
+ }
- def pathForInternalName(String internalName) {
- return String.format("%s/%s.class",
- classesDir.getAbsolutePath(),
- internalName)
- }
- def update() {
- getService(UpdateListenerHub).fireCheckForUpdates()
- }
+ def pathForInternalName(String internalName) {
+ return String.format("%s/%s.class",
+ classesDir.getAbsolutePath(),
+ internalName)
+ }
- def "reload a service implementation"() {
+ def update() {
+ getService(UpdateListenerHub).fireCheckForUpdates()
+ }
- when:
+ def "reload a service implementation"() {
- createImplementationClass "initial"
+ when:
- createRegistry()
+ createImplementationClass "initial"
- ReloadableService reloadable = getService(ReloadableService);
+ createRegistry()
- update()
+ ReloadableService reloadable = getService(ReloadableService);
- then:
+ update()
- reloadable.status == "initial"
+ then:
- when:
+ reloadable.status == "initial"
- update()
+ when:
- touch classFile
+ update()
- createImplementationClass "updated"
+ touch classFile
- then:
+ createImplementationClass "updated"
- // Changes do not take effect until after update check
+ then:
- reloadable.status == "initial"
+ // Changes do not take effect until after update check
- when:
+ reloadable.status == "initial"
- update()
+ when:
- then:
+ update()
- reloadable.status == "updated"
- }
+ then:
- def "reload a base class"() {
+ reloadable.status == "updated"
+ }
- setup:
+ def "reload a base class"() {
- def baseClassInternalName = PlasticInternalUtils.toInternalName BASE_CLASS
- def internalName = PlasticInternalUtils.toInternalName CLASS
+ setup:
- createImplementationClass BASE_CLASS, "initial from base"
+ def baseClassInternalName = PlasticInternalUtils.toInternalName BASE_CLASS
+ def internalName = PlasticInternalUtils.toInternalName CLASS
- createClassWriter(internalName, baseClassInternalName, ACC_PUBLIC).with {
+ createImplementationClass BASE_CLASS, "initial from base"
- visitMethod(ACC_PUBLIC, "<init>", "()V", null, null).with {
- visitCode()
- visitVarInsn ALOAD, 0
- visitMethodInsn INVOKESPECIAL, baseClassInternalName, "<init>", "()V"
- visitInsn RETURN
- visitMaxs 1, 1
- visitEnd()
- }
+ createClassWriter(internalName, baseClassInternalName, ACC_PUBLIC).with {
- visitEnd()
+ visitMethod(ACC_PUBLIC, "<init>", "()V", null, null).with {
+ visitCode()
+ visitVarInsn ALOAD, 0
+ visitMethodInsn INVOKESPECIAL, baseClassInternalName, "<init>", "()V"
+ visitInsn RETURN
+ visitMaxs 1, 1
+ visitEnd()
+ }
- writeBytecode it, internalName
- }
+ visitEnd()
- createRegistry()
+ writeBytecode it, internalName
+ }
- when:
+ createRegistry()
- ReloadableService reloadable = getService(ReloadableService)
+ when:
- update()
+ ReloadableService reloadable = getService(ReloadableService)
- then:
+ update()
- reloadable.status == "initial from base"
+ then:
- when:
+ reloadable.status == "initial from base"
- touch(new File(pathForInternalName(baseClassInternalName)))
+ when:
- createImplementationClass BASE_CLASS, "updated from base"
+ touch(new File(pathForInternalName(baseClassInternalName)))
- update()
+ createImplementationClass BASE_CLASS, "updated from base"
- then:
+ update()
- reloadable.status == "updated from base"
- }
+ then:
- def "deleting an implementation class results in a runtime exception when reloading"() {
+ reloadable.status == "updated from base"
+ }
- when:
+ def "deleting an implementation class results in a runtime exception when reloading"() {
- createImplementationClass "before delete"
+ when:
- createRegistry()
+ createImplementationClass "before delete"
- ReloadableService reloadable = getService ReloadableService
+ createRegistry()
- then:
+ ReloadableService reloadable = getService ReloadableService
- reloadable.status == "before delete"
+ then:
- assert classFile.exists()
+ reloadable.status == "before delete"
- when:
+ assert classFile.exists()
- classFile.delete()
+ when:
- update()
+ classFile.delete()
- reloadable.getStatus()
+ update()
- then:
+ reloadable.getStatus()
- RuntimeException e = thrown()
+ then:
- e.message.contains "Unable to reload class $CLASS"
- }
+ RuntimeException e = thrown()
+ e.message.contains "Unable to reload class $CLASS"
+ }
- def "reload a proxy object"() {
- when:
- createImplementationClass "initial proxy"
+ def "reload a proxy object"() {
+ when:
- createRegistry()
+ createImplementationClass "initial proxy"
- def clazz = classLoader.loadClass CLASS
+ createRegistry()
- ReloadableService reloadable = proxy(ReloadableService, clazz)
+ def clazz = classLoader.loadClass CLASS
- then:
+ ReloadableService reloadable = proxy(ReloadableService, clazz)
- reloadable.status == "initial proxy"
+ then:
- when:
+ reloadable.status == "initial proxy"
- touch classFile
+ when:
- createImplementationClass "updated proxy"
+ touch classFile
- update()
+ createImplementationClass "updated proxy"
- then:
+ update()
- reloadable.status == "updated proxy"
+ then:
- when:
+ reloadable.status == "updated proxy"
- touch classFile
+ when:
- createImplementationClass "re-updated proxy"
+ touch classFile
- update()
+ createImplementationClass "re-updated proxy"
- then:
+ update()
- reloadable.status == "re-updated proxy"
- }
+ then:
- def "check exception message for invalid service implementation (lacking a public constructor)"() {
+ reloadable.status == "re-updated proxy"
+ }
- when:
+ def "check exception message for invalid service implementation (lacking a public constructor)"() {
- createImplementationClass "initial"
+ when:
- createRegistry()
+ createImplementationClass "initial"
- ReloadableService reloadable = getService ReloadableService
+ createRegistry()
- touch classFile
+ ReloadableService reloadable = getService ReloadableService
- createInvalidImplementationClass()
+ touch classFile
- update()
+ createInvalidImplementationClass()
- reloadable.getStatus()
+ update()
- then:
+ reloadable.getStatus()
- Exception e = thrown()
+ then:
- e.message == "Service implementation class com.example.ReloadableServiceImpl does not have a suitable public constructor."
- }
+ Exception e = thrown()
- def "ensure ReloadAware services are notified when services are reloaded"() {
+ e.message == "Service implementation class com.example.ReloadableServiceImpl does not have a suitable public constructor."
+ }
- when:
+ def "ensure ReloadAware services are notified when services are reloaded"() {
- registry = new RegistryBuilder().add(ReloadAwareModule).build()
+ when:
- then:
+ registry = new RegistryBuilder().add(ReloadAwareModule).build()
- ReloadAwareModule.counterInstantiations == 0
- ReloadAwareModule.counterReloads == 0
+ then:
- when:
+ ReloadAwareModule.counterInstantiations == 0
+ ReloadAwareModule.counterReloads == 0
- Counter counter = proxy(Counter, CounterImpl)
+ when:
- then:
+ Counter counter = proxy(Counter, CounterImpl)
- ReloadAwareModule.counterInstantiations == 0
+ then:
- expect:
+ ReloadAwareModule.counterInstantiations == 0
- counter.increment() == 1
- counter.increment() == 2
+ expect:
- ReloadAwareModule.counterInstantiations == 1
+ counter.increment() == 1
+ counter.increment() == 2
- when:
+ ReloadAwareModule.counterInstantiations == 1
- def classURL = CounterImpl.getResource("CounterImpl.class")
- def classFile = new File(classURL.toURI())
+ when:
- touch classFile
+ def classURL = CounterImpl.getResource("CounterImpl.class")
+ def classFile = new File(classURL.toURI())
- update()
+ touch classFile
- // Check that the internal state has reset
+ update()
- assert counter.increment() == 1
+ // Check that the internal state has reset
- then:
+ assert counter.increment() == 1
- ReloadAwareModule.counterInstantiations == 2
- ReloadAwareModule.counterReloads == 1
- }
+ then:
+
+ ReloadAwareModule.counterInstantiations == 2
+ ReloadAwareModule.counterReloads == 1
+ }
- def createInvalidImplementationClass() {
- def internalName = PlasticInternalUtils.toInternalName CLASS
+ def createInvalidImplementationClass() {
+ def internalName = PlasticInternalUtils.toInternalName CLASS
- createClassWriter(internalName, "java/lang/Object", ACC_PUBLIC).with {
+ createClassWriter(internalName, "java/lang/Object", ACC_PUBLIC).with {
- visitMethod(ACC_PROTECTED, "<init>", "()V", null, null).with {
- visitVarInsn ALOAD, 0
- visitMethodInsn INVOKESPECIAL, "java/lang/Object", "<init>", "()V"
- visitInsn RETURN
- visitMaxs 1, 1
- visitEnd()
- }
+ visitMethod(ACC_PROTECTED, "<init>", "()V", null, null).with {
+ visitVarInsn ALOAD, 0
+ visitMethodInsn INVOKESPECIAL, "java/lang/Object", "<init>", "()V"
+ visitInsn RETURN
+ visitMaxs 1, 1
+ visitEnd()
+ }
- visitEnd()
+ visitEnd()
- writeBytecode it, internalName
- }
+ writeBytecode it, internalName
}
+ }
- def touch(File f) {
- long startModified = f.lastModified();
+ def touch(File f) {
+ long startModified = f.lastModified();
- int index = 0;
+ int index = 0;
- while (true) {
- f.setLastModified System.currentTimeMillis()
+ while (true) {
+ f.setLastModified System.currentTimeMillis()
- long newModified = f.lastModified()
+ long newModified = f.lastModified()
- if (newModified != startModified) {
- return;
- }
+ if (newModified != startModified) {
+ return;
+ }
- // Sleep an ever increasing amount, to ensure that the filesystem
- // catches the change to the file. The Ubuntu CI Server appears
- // to need longer waits.
+ // Sleep an ever increasing amount, to ensure that the filesystem
+ // catches the change to the file. The Ubuntu CI Server appears
+ // to need longer waits.
- Thread.sleep 50 * (2 ^ index++)
- }
+ Thread.sleep 50 * (2 ^ index++)
}
+ }
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6ba605f4/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/LazyAdvisorImplSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/LazyAdvisorImplSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/LazyAdvisorImplSpec.groovy
index a37d05b..d68d845 100644
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/LazyAdvisorImplSpec.groovy
+++ b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/LazyAdvisorImplSpec.groovy
@@ -8,8 +8,8 @@ import org.apache.tapestry5.ioc.services.LazyAdvisor
import java.sql.SQLException
-public interface LazyService
-{
+public interface LazyService {
+
void notLazyBecauseVoid();
String notLazyBecauseOfReturnValue();
@@ -112,7 +112,7 @@ class LazyAdvisorImplSpec extends AbstractSharedRegistrySpecification {
0 * _
}
- def "the @NotLazy annotation prevents laziness" () {
+ def "the @NotLazy annotation prevents laziness"() {
Greeter greeter = Mock()
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6ba605f4/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/LoggingDecoratorImplSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/LoggingDecoratorImplSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/LoggingDecoratorImplSpec.groovy
index f37d5b5..2d77d9a 100644
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/LoggingDecoratorImplSpec.groovy
+++ b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/LoggingDecoratorImplSpec.groovy
@@ -6,10 +6,12 @@ import org.slf4j.Logger
import org.xml.sax.SAXParseException
interface AdderService {
+
long add(long operand1, long operand2);
}
interface ExceptionService {
+
void parse() throws SAXParseException;
}
@@ -151,6 +153,7 @@ class LoggingDecoratorImplSpec extends AbstractSharedRegistrySpecification {
// delegate through, so we can't implement ToStringService as a Mock
ToStringService delegate = new ToStringService() {
+
String toString() { "FROM DELEGATE" }
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6ba605f4/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/AspectInterceptorBuilderImplSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/AspectInterceptorBuilderImplSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/AspectInterceptorBuilderImplSpec.groovy
index b58ecb8..9722cea 100644
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/AspectInterceptorBuilderImplSpec.groovy
+++ b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/AspectInterceptorBuilderImplSpec.groovy
@@ -9,12 +9,14 @@ import spock.lang.Shared
interface Subject {
+
void advised();
void notAdvised();
}
interface ArraysSubject {
+
String[] operation(String[] inputs);
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6ba605f4/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/BridgeBuilderSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/BridgeBuilderSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/BridgeBuilderSpec.groovy
index 2b65ace..a62299e 100644
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/BridgeBuilderSpec.groovy
+++ b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/BridgeBuilderSpec.groovy
@@ -59,10 +59,12 @@ class BridgeBuilderSpec extends AbstractSharedRegistrySpecification {
Logger logger = Mock()
ToStringService service = new ToStringService() {
+
String toString() { "Service" }
}
ToStringFilter filter = new ToStringFilter() {
+
String toString(ToStringService s) {
s.toString().toUpperCase()
}
@@ -127,6 +129,7 @@ class BridgeBuilderSpec extends AbstractSharedRegistrySpecification {
Logger logger = Mock()
MiddleFilter mf = new MiddleFilter() {
+
@Override
void execute(int count, char ch, MiddleService service, StringBuilder buffer) {
service.execute(count, ch, buffer)
@@ -138,6 +141,7 @@ class BridgeBuilderSpec extends AbstractSharedRegistrySpecification {
}
MiddleService ms = new MiddleService() {
+
@Override
void execute(int count, char ch, StringBuilder buffer) {
count.times() { buffer.append ch }
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6ba605f4/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/ChainBuilderImplSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/ChainBuilderImplSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/ChainBuilderImplSpec.groovy
index febcc9e..9c41bda 100644
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/ChainBuilderImplSpec.groovy
+++ b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/ChainBuilderImplSpec.groovy
@@ -4,6 +4,7 @@ import org.apache.tapestry5.ioc.AbstractSharedRegistrySpecification
import org.apache.tapestry5.ioc.services.ChainBuilder
interface ChainCommand {
+
void run();
int workInt(int input);
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6ba605f4/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/ExceptionAnalyzerImplSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/ExceptionAnalyzerImplSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/ExceptionAnalyzerImplSpec.groovy
index 4133e74..5970946 100644
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/ExceptionAnalyzerImplSpec.groovy
+++ b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/ExceptionAnalyzerImplSpec.groovy
@@ -5,22 +5,21 @@ import org.apache.tapestry5.ioc.Location
import org.apache.tapestry5.ioc.internal.util.TapestryException
import org.apache.tapestry5.ioc.services.ExceptionAnalyzer
-class WriteOnlyPropertyException extends Exception
-{
+class WriteOnlyPropertyException extends Exception {
+
private String code;
- public String getCode()
- {
+ public String getCode() {
return code;
}
- public void setFaultCode(int code)
- {
+ public void setFaultCode(int code) {
this.code = String.format("%04d", code);
}
}
class SelfCausedException extends RuntimeException {
+
SelfCausedException(String message) {
super(message);
}
@@ -186,7 +185,7 @@ class ExceptionAnalyzerImplSpec extends AbstractSharedRegistrySpecification {
def ei = ea.exceptionInfos[0]
ei.propertyNames.contains("code")
- ! ei.propertyNames.contains("faultCode")
+ !ei.propertyNames.contains("faultCode")
ei.getProperty("code") == "0099"
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6ba605f4/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
index 6114b4b..93afb73 100644
--- 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
@@ -12,7 +12,6 @@ class FilterMethodAnalyzerSpec extends Specification {
@Unroll
def "position of delegate parameter for #filterMethod should be #position"() {
-
def analyzer = new FilterMethodAnalyzer(SampleService)
expect:
@@ -24,11 +23,11 @@ class FilterMethodAnalyzerSpec extends Specification {
methodName | position
"simpleMatch" | 0
"mismatchParameterCount" | -1
- "mismatchReturnType" | -1
+ "mismatchReturnType" | -1
"missingServiceInterface" | -1
"complexMatch" | 2
- mainMethod = find SampleService, methodName
- filterMethod = find SampleFilter, methodName
+ mainMethod = find SampleService, methodName
+ filterMethod = find SampleFilter, methodName
}
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6ba605f4/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/MasterObjectProviderImplSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/MasterObjectProviderImplSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/MasterObjectProviderImplSpec.groovy
index 98fa0a9..73ba4c5 100644
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/MasterObjectProviderImplSpec.groovy
+++ b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/MasterObjectProviderImplSpec.groovy
@@ -78,8 +78,7 @@ class MasterObjectProviderImplSpec extends Specification {
0 * _
}
- def "no match for a required search delegates to the ObjectLocator.getService(Class)"()
- {
+ def "no match for a required search delegates to the ObjectLocator.getService(Class)"() {
ObjectProvider prov1 = Mock()
ObjectProvider prov2 = Mock()
AnnotationProvider ap = Mock()
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6ba605f4/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/MethodIteratorSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/MethodIteratorSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/MethodIteratorSpec.groovy
index 5bbf397..13142ac 100644
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/MethodIteratorSpec.groovy
+++ b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/MethodIteratorSpec.groovy
@@ -4,10 +4,12 @@ import spock.lang.Specification
import spock.lang.Unroll
interface Play extends Runnable {
+
void jump()
}
interface Runnable2 {
+
void run()
}
@@ -16,10 +18,12 @@ interface Runnable3 extends Runnable, Runnable2 {
}
interface Openable {
+
public void open();
}
interface OpenableWithError {
+
public void open() throws IOException;
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6ba605f4/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/MethodSignatureSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/MethodSignatureSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/MethodSignatureSpec.groovy
index 96134d9..a84788a 100644
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/MethodSignatureSpec.groovy
+++ b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/MethodSignatureSpec.groovy
@@ -7,6 +7,7 @@ import java.lang.reflect.Method
import java.sql.SQLException
class MethodSignatureSpec extends Specification {
+
def MethodSignature find(Class sourceClass, String methodName) {
Method match = sourceClass.methods.find { it.name == methodName }
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6ba605f4/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/ParallelExecutorSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/ParallelExecutorSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/ParallelExecutorSpec.groovy
index 4ba10a6..4819fda 100644
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/ParallelExecutorSpec.groovy
+++ b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/ParallelExecutorSpec.groovy
@@ -83,6 +83,7 @@ class ParallelExecutorSpec extends AbstractSharedRegistrySpecification {
def "exception inside the Invokable is rethrown by the thunk"() {
def inv = new Invokable() {
+
Object invoke() { throw new RuntimeException("Future failure!")}
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6ba605f4/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/ToString.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/ToString.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/ToString.groovy
index f2b0301..f1b8854 100644
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/ToString.groovy
+++ b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/ToString.groovy
@@ -2,5 +2,6 @@ package org.apache.tapestry5.ioc.internal.services
/** An interface that includes toString() */
interface ToString {
+
String toString();
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6ba605f4/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/services/PeriodicExecutorSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/services/PeriodicExecutorSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/services/PeriodicExecutorSpec.groovy
index 993c6b6..a9ec916 100644
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/services/PeriodicExecutorSpec.groovy
+++ b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/services/PeriodicExecutorSpec.groovy
@@ -9,22 +9,22 @@ import java.util.concurrent.TimeUnit
class PeriodicExecutorSpec extends AbstractRegistrySpecification {
- def "execution intervals"() {
+ def "execution intervals"() {
- buildRegistry()
+ buildRegistry()
- def countDownLatch = new CountDownLatch(5);
+ def countDownLatch = new CountDownLatch(5);
- def schedule = new IntervalSchedule(10)
+ def schedule = new IntervalSchedule(10)
- def job = getService(PeriodicExecutor).addJob(schedule, "count incrementer", { countDownLatch.countDown(); })
+ def job = getService(PeriodicExecutor).addJob(schedule, "count incrementer", { countDownLatch.countDown(); })
- countDownLatch.await 30, TimeUnit.SECONDS
+ countDownLatch.await 30, TimeUnit.SECONDS
- cleanup:
+ cleanup:
- job && job.cancel()
+ job && job.cancel()
- }
+ }
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6ba605f4/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/services/SystemEnvSymbolProviderSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/services/SystemEnvSymbolProviderSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/services/SystemEnvSymbolProviderSpec.groovy
index b308f5d..9b24ec1 100644
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/services/SystemEnvSymbolProviderSpec.groovy
+++ b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/services/SystemEnvSymbolProviderSpec.groovy
@@ -5,16 +5,16 @@ import spock.lang.Specification
class SystemEnvSymbolProviderSpec extends Specification {
- SymbolProvider provider = new SystemEnvSymbolProvider()
+ SymbolProvider provider = new SystemEnvSymbolProvider()
- def "key exists"() {
- expect:
- provider.valueForSymbol("env.home") == System.getenv("HOME")
- }
+ def "key exists"() {
+ expect:
+ provider.valueForSymbol("env.home") == System.getenv("HOME")
+ }
- def "key missing"() {
- expect: provider.valueForSymbol("env.does-not-exist") == null
+ def "key missing"() {
+ expect: provider.valueForSymbol("env.does-not-exist") == null
- }
+ }
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6ba605f4/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
index d7ddd79..26c617b 100644
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/util/StringToEnumCoercionSpec.groovy
+++ b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/util/StringToEnumCoercionSpec.groovy
@@ -3,55 +3,50 @@ package org.apache.tapestry5.util
import spock.lang.Specification
-class StringToEnumCoercionSpec extends Specification
-{
+class StringToEnumCoercionSpec extends Specification {
- def "searches are case-insensitive"()
- {
- def coercion = new StringToEnumCoercion(Stooge)
+ def "searches are case-insensitive"() {
+ def coercion = new StringToEnumCoercion(Stooge)
- expect:
+ expect:
- coercion.coerce("moe").is(Stooge.MOE)
- coercion.coerce("MOE").is(Stooge.MOE)
- coercion.coerce("CURLY_Joe").is(Stooge.CURLY_JOE)
- }
+ 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)
+ def "blank input returns null"() {
+ def coercion = new StringToEnumCoercion(Stooge)
- expect:
+ expect:
- coercion.coerce("") == null
- coercion.coerce("\t\n") == null
- }
+ coercion.coerce("") == null
+ coercion.coerce("\t\n") == null
+ }
- def "enum value can be found by an added alias"()
- {
- def coercion = new StringToEnumCoercion(Stooge)
+ def "enum value can be found by an added alias"() {
+ def coercion = new StringToEnumCoercion(Stooge)
- coercion.addAlias("shemp", Stooge.CURLY_JOE)
+ coercion.addAlias("shemp", Stooge.CURLY_JOE)
- expect:
+ expect:
- coercion.coerce("curly_joe").is(Stooge.CURLY_JOE)
- coercion.coerce("shemp").is(Stooge.CURLY_JOE)
- coercion.coerce("Shemp").is(Stooge.CURLY_JOE)
- }
+ 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)
+ def "a failed search by name throws an exception"() {
+ def coercion = new StringToEnumCoercion(Stooge)
- when:
+ when:
- coercion.coerce("shemp")
+ coercion.coerce("shemp")
- then:
+ then:
- RuntimeException e = thrown()
+ RuntimeException e = thrown()
- e.message == /Input 'shemp' does not identify a value from enumerated type ${Stooge.name}./
- }
+ e.message == /Input 'shemp' does not identify a value from enumerated type ${Stooge.name}./
+ }
}