You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2012/05/16 20:50:32 UTC

[31/44] git commit: Explain use of propertyMissing(), and streamline the cloneViaSerialize method

Explain use of propertyMissing(), and streamline the cloneViaSerialize method


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/5c907785
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/5c907785
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/5c907785

Branch: refs/heads/master
Commit: 5c90778538d85b3068787e0717697b52925db2fa
Parents: 829a846
Author: Howard M. Lewis Ship <hl...@gmail.com>
Authored: Thu Apr 19 16:16:55 2012 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Wed May 16 11:49:41 2012 -0700

----------------------------------------------------------------------
 .../services/cron/CronExpressionSpec.groovy        |   10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/5c907785/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/cron/CronExpressionSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/cron/CronExpressionSpec.groovy b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/cron/CronExpressionSpec.groovy
index 0bd058a..bafc09c 100644
--- a/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/cron/CronExpressionSpec.groovy
+++ b/tapestry-ioc/src/test/groovy/org/apache/tapestry5/ioc/internal/services/cron/CronExpressionSpec.groovy
@@ -9,11 +9,10 @@ import java.text.ParseException
 @Unroll
 class CronExpressionSpec extends Specification {
 
-
+  // This allows the any of the constants defined on Calendar to be used
+  // without qualification.
   def propertyMissing(String name) { Calendar[name] }
 
-
-
   def "isSatisfiedBy(#year, #month, #day, #hour, #minute, #second ) should be #satisfied for expression '#expr'"() {
 
     def cal = Calendar.getInstance();
@@ -41,11 +40,8 @@ class CronExpressionSpec extends Specification {
 
   def cloneViaSerialize(obj) {
     ByteArrayOutputStream baos = new ByteArrayOutputStream()
-    ObjectOutputStream oos = new ObjectOutputStream(baos)
-
-    oos.writeObject(obj)
 
-    oos.close()
+    baos.withObjectOutputStream { it.writeObject(obj) }
 
     ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray())
     ObjectInputStream ois = new ObjectInputStream(bais)