groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [groovy] 01/17: fix unintended illegal access
Date Fri, 19 Apr 2019 01:43:42 GMT
This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch GROOVY_2_5_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit c599d10fbc24d052e7952197885b255e8ba5c2f8
Author: Paul King <paulk@asert.com.au>
AuthorDate: Wed Apr 17 09:32:23 2019 +1000

    fix unintended illegal access
---
 src/test/groovy/bugs/Groovy8764Bug.groovy          |  12 +-
 src/test/groovy/util/ObjectGraphBuilderTest.groovy | 788 ++++++++++-----------
 .../groovy/ast/CodeVisitorSupportTest.groovy       |   4 +-
 .../powerassert/AssertionRenderingTest.groovy      |  12 +-
 .../runtime/powerassert/EvaluationTest.groovy      |   2 +-
 5 files changed, 412 insertions(+), 406 deletions(-)

diff --git a/src/test/groovy/bugs/Groovy8764Bug.groovy b/src/test/groovy/bugs/Groovy8764Bug.groovy
index 5a842f2..a3589b4 100644
--- a/src/test/groovy/bugs/Groovy8764Bug.groovy
+++ b/src/test/groovy/bugs/Groovy8764Bug.groovy
@@ -45,8 +45,9 @@ class Groovy8764Bug extends GroovyTestCase {
     void testDgmMethodInClosureInInnerClass() {
         if (System.getProperty('java.specification.version') < '1.8') return
         assertScript '''
-        import groovy.transform.*
-        import java.util.function.Function
+            import groovy.transform.*
+            import java.util.function.Function
+            import static groovy.test.GroovyAssert.isAtLeastJdk
 
             @CompileStatic
             class Outer {
@@ -63,7 +64,12 @@ class Groovy8764Bug extends GroovyTestCase {
 
             def oi = new Outer.Inner()
             assert !oi.test(0)
-            assert oi.test(1).value == 1
+            if (isAtLeastJdk('9.0')) {
+                assert oi.test(1).get() == 1
+            } else {
+                // confirm accessing private field okay on older JDK versions
+                assert oi.test(1).value == 1
+            }
         '''
     }
 }
diff --git a/src/test/groovy/util/ObjectGraphBuilderTest.groovy b/src/test/groovy/util/ObjectGraphBuilderTest.groovy
index 44f594a..3ba08fd 100644
--- a/src/test/groovy/util/ObjectGraphBuilderTest.groovy
+++ b/src/test/groovy/util/ObjectGraphBuilderTest.groovy
@@ -1,395 +1,395 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-package groovy.util
-
-class ObjectGraphBuilderTest extends GroovyTestCase {
-   ObjectGraphBuilder builder
-   ObjectGraphBuilder reflectionBuilder
-
-   void testCompany() {
-      def expected = new Company( name: 'ACME', employees: [] )
-      def actual = builder.company( name: 'ACME', employees: [] )
-      assert actual != null
-      //assert actual.class == Company
-      assert actual.name == expected.name
-      assert actual.address == expected.address
-      assert actual.employees == expected.employees
-   }
-
-   void testCompanyAndAddress() {
-      def expectedAddress = new Address( line1: '123 Groovy Rd', zip: 12345, state: 'JV'
)
-      def expectedCompany = new Company( name: 'ACME', employees: [], address: expectedAddress
)
-      def actualCompany = builder.company( name: 'ACME', employees: [] ) {
-         address( line1: '123 Groovy Rd', zip: 12345, state: 'JV' )
-      }
-      assert actualCompany != null
-      //assert actualCompany.class == Company
-      assert actualCompany.name == expectedCompany.name
-      assert actualCompany.employees == expectedCompany.employees
-      def actualAddress = actualCompany.address
-      assert actualAddress != null
-      //assert actualAddress.class == Address
-      assert actualAddress.line1 == expectedAddress.line1
-      assert actualAddress.line2 == expectedAddress.line2
-      assert actualAddress.zip == expectedAddress.zip
-      assert actualAddress.state == expectedAddress.state
-   }
-
-   void testCompanyAndEmployeeAndAddress() {
-      def expectedAddress = new Address( line1: '123 Groovy Rd', zip: 12345, state: 'JV'
)
-      def expectedEmployee = new Employee( name: 'Duke', employeeId: 1, address: expectedAddress
)
-      def expectedCompany = new Company( name: 'ACME' )
-      def actualCompany = builder.company( name: 'ACME', employees: [] ) {
-         employee(  name: 'Duke', employeeId: 1 ) {
-            address( line1: '123 Groovy Rd', zip: 12345, state: 'JV' )
-         }
-      }
-      assert actualCompany != null
-      //assert actualCompany.class == Company
-      assert actualCompany.name == expectedCompany.name
-      assert actualCompany.employees.size() == 1
-      def actualEmployee = actualCompany.employees[0]
-      //assert actualEmployee.class == Employee
-      assert actualEmployee.name == expectedEmployee.name
-      assert actualEmployee.employeeId == expectedEmployee.employeeId
-      def actualAddress = actualEmployee.address
-      assert actualAddress != null
-      //assert actualAddress.class == Address
-      assert actualAddress.line1 == expectedAddress.line1
-      assert actualAddress.line2 == expectedAddress.line2
-      assert actualAddress.zip == expectedAddress.zip
-      assert actualAddress.state == expectedAddress.state
-   }
-
-   void testCompanyAndEmployeeSameAddress() {
-      def expectedAddress = new Address( line1: '123 Groovy Rd', zip: 12345, state: 'JV'
)
-      def expectedEmployee = new Employee( name: 'Duke', employeeId: 1, address: expectedAddress
)
-      def expectedCompany = new Company( name: 'ACME' )
-      def actualCompany = builder.company( name: 'ACME', employees: [] ) {
-         address( id: 'a1', line1: '123 Groovy Rd', zip: 12345, state: 'JV' )
-         employee(  name: 'Duke', employeeId: 1, address: a1 )
-      }
-      assert actualCompany != null
-      //assert actualCompany.class == Company
-      assert actualCompany.name == expectedCompany.name
-      assert actualCompany.employees.size() == 1
-      def actualEmployee = actualCompany.employees[0]
-      //assert actualEmployee.class == Employee
-      assert actualEmployee.name == expectedEmployee.name
-      assert actualEmployee.employeeId == expectedEmployee.employeeId
-      assert actualCompany.address == actualEmployee.address
-   }
-
-   void testCompanyAndEmployeeSameAddressWithRef() {
-      def expectedAddress = new Address( line1: '123 Groovy Rd', zip: 12345, state: 'JV'
)
-      def expectedEmployee = new Employee( name: 'Duke', employeeId: 1, address: expectedAddress
)
-      def expectedCompany = new Company( name: 'ACME' )
-      def actualCompany = builder.company( name: 'ACME', employees: [] ) {
-         address( id: 'a1', line1: '123 Groovy Rd', zip: 12345, state: 'JV' )
-         employee(  name: 'Duke', employeeId: 1 ){
-            address( refId: 'a1' )
-         }
-      }
-      assert actualCompany != null
-      //assert actualCompany.class == Company
-      assert actualCompany.name == expectedCompany.name
-      assert actualCompany.employees.size() == 1
-      def actualEmployee = actualCompany.employees[0]
-      //assert actualEmployee.class == Employee
-      assert actualEmployee.name == expectedEmployee.name
-      assert actualEmployee.employeeId == expectedEmployee.employeeId
-      assert actualCompany.address == actualEmployee.address
-      assert actualEmployee.company == actualCompany
-   }
-
-   void testCompanyAndManyEmployees() {
-      def actualCompany = builder.company( name: 'ACME', employees: [] ) {
-         3.times {
-            employee(  name: "Duke $it", employeeId: it )
-         }
-      }
-      assert actualCompany != null
-      assert actualCompany.employees.size() == 3
-      3.times {
-         assert actualCompany.employees[it].name == "Duke $it"
-      }
-      //assert actualCompany.employees*.getClass() == [Employee,Employee,Employee]
-   }
-
-   void testStringfiedIdentifierResolver() {
-      builder.identifierResolver = "uid"
-      def company = builder.company( name: 'ACME', employees: [], uid: 'acme' )
-      assert company != null
-      assert builder.acme != null
-      assert builder.acme == company
-   }
-
-   void testStringfiedReferenceResolver() {
-      builder.referenceResolver = "ref_id"
-      def company = builder.company( name: 'ACME', employees: [] ) {
-         address( line1: '123 Groovy Rd', zip: 12345, state: 'JV', id: 'a1' )
-         employee(  name: 'Duke', employeeId: 1, id: 'e1' ) {
-            address( ref_id: 'a1' )
-         }
-      }
-      assert company != null
-      assert company.employees.size() == 1
-      assert builder.e1 == company.employees[0]
-      assert builder.a1 == company.address
-      assert builder.a1 == builder.e1.address
-   }
-
-   void testReferenceResolver() {
-      def company = builder.company( name: 'ACME', employees: [] ) {
-         address( line1: '123 Groovy Rd', zip: 12345, state: 'JV', id: 'a1' )
-         employee(  name: 'Duke', employeeId: 1, id: 'e1' ) {
-            address( refId: 'a1' )
-         }
-      }
-      assert company != null
-      assert company.employees.size() == 1
-      assert builder.e1 == company.employees[0]
-      assert builder.a1 == company.address
-      assert builder.a1 == builder.e1.address
-   }
-
-   void testReferenceResolver_referenceIsLiveObject() {
-      def company = builder.company( name: 'ACME', employees: [] ) {
-         address( line1: '123 Groovy Rd', zip: 12345, state: 'JV', id: 'a1' )
-         employee(  name: 'Duke', employeeId: 1, id: 'e1' ) {
-            address( refId: a1 )
-         }
-      }
-      assert company != null
-      assert company.employees.size() == 1
-      assert builder.e1 == company.employees[0]
-      assert builder.a1 == company.address
-      assert builder.a1 == builder.e1.address
-   }
-
-   void testDirectReference() {
-      def company = builder.company( name: 'ACME', employees: [] ) {
-         address( line1: '123 Groovy Rd', zip: 12345, state: 'JV', id: 'a1' )
-         employee(  name: 'Duke', employeeId: 1, id: 'e1' ) {
-            address( a1 )
-         }
-      }
-      assert company != null
-      assert company.employees.size() == 1
-      assert builder.e1 == company.employees[0]
-      assert builder.a1 == company.address
-      assert builder.a1 == builder.e1.address
-   }
-
-   void testLazyReferences() {
-      def company = builder.company( name: 'ACME', employees: [] ) {
-         employee(  name: 'Duke', employeeId: 1, id: 'e1' ) {
-            address( refId: 'a1' )
-         }
-         address( line1: '123 Groovy Rd', zip: 12345, state: 'JV', id: 'a1' )
-      }
-      assert company != null
-      assert company.employees.size() == 1
-      assert builder.e1 == company.employees[0]
-      assert builder.a1 == company.address
-      assert builder.a1 == builder.e1.address
-   }
-
-   void testReflectionCompany() {
-      def expected = new ReflectionCompany( name: 'ACME' )
-      def actual = reflectionBuilder.reflectionCompany( name: 'ACME' )
-      assert actual != null
-      assert actual.name == expected.name
-   }
-
-   void testReflectionCompanyAndAddress() {
-      def expectedAddress = new Address( line1: '123 Groovy Rd', zip: 12345, state: 'JV'
)
-      def expectedCompany = new ReflectionCompany( name: 'ACME', addr: expectedAddress )
-      def actualCompany = reflectionBuilder.reflectionCompany( name: 'ACME' ) {
-         addr( line1: '123 Groovy Rd', zip: 12345, state: 'JV' )
-      }
-      assert actualCompany != null
-      assert actualCompany.name == expectedCompany.name
-      def actualAddress = actualCompany.addr
-      assert actualAddress != null
-      assert actualAddress.line1 == expectedAddress.line1
-      assert actualAddress.line2 == expectedAddress.line2
-      assert actualAddress.zip == expectedAddress.zip
-      assert actualAddress.state == expectedAddress.state
-   }
-
-    void testReflectionCompanyAddressAndEmployees() {
-      def expectedAddress = new Address( line1: '123 Groovy Rd', zip: 12345, state: 'JV'
)
-      def expectedCompany = new ReflectionCompany( name: 'ACME', addr: expectedAddress )
-      def expectedDirector = new Employee( name: 'Duke', employeeId: 1, address: expectedAddress
)
-      def expectedFinancialController = new Employee( name: 'Craig', employeeId: 2, address:
expectedAddress )
-      def expectedDrone0 = new Employee( name: 'Drone0', employeeId: 3, address: expectedAddress
)
-      def expectedDrone1 = new Employee( name: 'Drone1', employeeId: 4, address: expectedAddress
)
-
-      def actualCompany = reflectionBuilder.reflectionCompany( name: 'ACME', drones: [] )
{
-         addr( id: 'a1', line1: '123 Groovy Rd', zip: 12345, state: 'JV' )
-         director(  name: expectedDirector.name, employeeId: expectedDirector.employeeId
){
-            address( refId: 'a1' )
-         }
-         financialController(  name: expectedFinancialController.name, employeeId: expectedFinancialController.employeeId
){
-            address( refId: 'a1' )
-         }
-         drones(  name: expectedDrone0.name, employeeId: expectedDrone0.employeeId ){
-            address( refId: 'a1' )
-         }
-         drones(  name: expectedDrone1.name, employeeId: expectedDrone1.employeeId ){
-            address( refId: 'a1' )
-         }
-      }
-      
-      assert actualCompany != null
-      assert actualCompany.name == expectedCompany.name
-      def actualAddress = actualCompany.addr
-      assert actualAddress != null
-      assert actualAddress.line1 == expectedAddress.line1
-      assert actualAddress.line2 == expectedAddress.line2
-      assert actualAddress.zip == expectedAddress.zip
-      assert actualAddress.state == expectedAddress.state
-
-      assert actualCompany.director != null
-      assert actualCompany.director.name == expectedDirector.name
-      assert actualCompany.director.employeeId == expectedDirector.employeeId
-      assert actualCompany.director.address.line1 == expectedAddress.line1
-
-      assert actualCompany.financialController != null
-      assert actualCompany.financialController.name == expectedFinancialController.name
-      assert actualCompany.financialController.employeeId == expectedFinancialController.employeeId
-      assert actualCompany.financialController.address.line1 == expectedAddress.line1
-
-      assert actualCompany.drones != null
-      assert actualCompany.drones.size == 2
-      assert actualCompany.drones[0].name == expectedDrone0.name
-      assert actualCompany.drones[0].employeeId == expectedDrone0.employeeId
-      assert actualCompany.drones[0].address != null
-      assert actualCompany.drones[0].address.line1 == expectedAddress.line1
-      assert actualCompany.drones[1].name == expectedDrone1.name
-      assert actualCompany.drones[1].address != null
-      assert actualCompany.drones[1].employeeId == expectedDrone1.employeeId
-      assert actualCompany.drones[1].address.line1 == expectedAddress.line1
-   }
-
-   void testPlural() {
-       def dracula = builder.person(name: 'Dracula') {
-           allergy(name: 'garlic', reaction: 'moderate burns')
-           allergy(name: 'cross', reaction: 'aversion')
-           allergy(name: 'wood stake', reaction: 'death')
-           allergy(name: 'sunlight', reaction: 'burst into flames')
-           petMonkey(name: 'La-la')
-           petMonkey(name: 'Ampersand')
-       }
-
-       assert dracula.allergies.size() == 4
-       assert dracula.petMonkeys.size() == 2
-   }
-
-   void testCompanyAndEmployeeAndAddressUsingBeanFactory() {
-      def expectedAddress = new Address( line1: '123 Groovy Rd', zip: 12345, state: 'JV'
)
-      def expectedEmployee = new Employee( name: 'Duke', employeeId: 1, address: expectedAddress
)
-      def expectedCompany = new Company( name: 'ACME' )
-      def actualCompany = builder.bean(new Company(), name: 'ACME', employees: [] ) {
-         bean(Employee, name: 'Duke', employeeId: 1 ) {
-            bean(Address, line1: '123 Groovy Rd', zip: 12345, state: 'JV' )
-         }
-      }
-      assert actualCompany != null
-      // assert actualCompany.class == Company
-      assert actualCompany.name == expectedCompany.name
-      assert actualCompany.employees.size() == 1
-      def actualEmployee = actualCompany.employees[0]
-      // assert actualEmployee.class == Employee
-      assert actualEmployee.name == expectedEmployee.name
-      assert actualEmployee.employeeId == expectedEmployee.employeeId
-      def actualAddress = actualEmployee.address
-      assert actualAddress != null
-      // assert actualAddress.class == Address
-      assert actualAddress.line1 == expectedAddress.line1
-      assert actualAddress.line2 == expectedAddress.line2
-      assert actualAddress.zip == expectedAddress.zip
-      assert actualAddress.state == expectedAddress.state
-   }
-
-   void setUp() {
-      builder = new ObjectGraphBuilder()
-      builder.classNameResolver = "groovy.util"
-      reflectionBuilder = new ObjectGraphBuilder()
-      reflectionBuilder.classNameResolver = [ name: 'reflection', root: "groovy.util" ]
-   }
-}
-
-class Company {
-   String name
-   Address address
-   List employees = []
-
-   String toString() { "Company=[name:${name}, address:${address}, employees:${employees}]"
}
-}
-
-class Address {
-   String line1
-   String line2
-   int zip
-   String state
-
-   String toString() { "Address=[line1:${line1}, line2:${line2}, zip:${zip}, state:${state}]"
}
-}
-
-class Employee {
-   String name
-   int employeeId
-   Address address
-   Company company
-
-   String toString() { "Employee=[name:${name}, employeeId:${employeeId}, address:${address},
company:${company.name}]" }
-}
-
-class ReflectionCompany {
-   String name
-   Address addr
-   Employee director
-   Employee financialController
-   List<Employee> drones
-
-   String toString() { "Company=[name:${name}, address:${address}, director:${md}, financialController:${cio},
drones:${drones}]" }
-}
-
-class Person {
-    String name
-    List allergies = []
-    List petMonkeys = []
-
-    String toString() { "Person=[name:${name}, allergies:${allergies}, petMonkeys:${petMonkeys}]"
}
-}
-
-class Allergy {
-    String name
-    String reaction
-
-    String toString() { "Allergy=[name:${name}, reaction:${reaction}]" }
-}
-
-class PetMonkey {
-    String name
-
-    String toString() { "PetMonkey=[name:${name}]" }
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package groovy.util
+
+class ObjectGraphBuilderTest extends GroovyTestCase {
+   ObjectGraphBuilder builder
+   ObjectGraphBuilder reflectionBuilder
+
+   void testCompany() {
+      def expected = new Company( name: 'ACME', employees: [] )
+      def actual = builder.company( name: 'ACME', employees: [] )
+      assert actual != null
+      //assert actual.class == Company
+      assert actual.name == expected.name
+      assert actual.address == expected.address
+      assert actual.employees == expected.employees
+   }
+
+   void testCompanyAndAddress() {
+      def expectedAddress = new Address( line1: '123 Groovy Rd', zip: 12345, state: 'JV'
)
+      def expectedCompany = new Company( name: 'ACME', employees: [], address: expectedAddress
)
+      def actualCompany = builder.company( name: 'ACME', employees: [] ) {
+         address( line1: '123 Groovy Rd', zip: 12345, state: 'JV' )
+      }
+      assert actualCompany != null
+      //assert actualCompany.class == Company
+      assert actualCompany.name == expectedCompany.name
+      assert actualCompany.employees == expectedCompany.employees
+      def actualAddress = actualCompany.address
+      assert actualAddress != null
+      //assert actualAddress.class == Address
+      assert actualAddress.line1 == expectedAddress.line1
+      assert actualAddress.line2 == expectedAddress.line2
+      assert actualAddress.zip == expectedAddress.zip
+      assert actualAddress.state == expectedAddress.state
+   }
+
+   void testCompanyAndEmployeeAndAddress() {
+      def expectedAddress = new Address( line1: '123 Groovy Rd', zip: 12345, state: 'JV'
)
+      def expectedEmployee = new Employee( name: 'Duke', employeeId: 1, address: expectedAddress
)
+      def expectedCompany = new Company( name: 'ACME' )
+      def actualCompany = builder.company( name: 'ACME', employees: [] ) {
+         employee(  name: 'Duke', employeeId: 1 ) {
+            address( line1: '123 Groovy Rd', zip: 12345, state: 'JV' )
+         }
+      }
+      assert actualCompany != null
+      //assert actualCompany.class == Company
+      assert actualCompany.name == expectedCompany.name
+      assert actualCompany.employees.size() == 1
+      def actualEmployee = actualCompany.employees[0]
+      //assert actualEmployee.class == Employee
+      assert actualEmployee.name == expectedEmployee.name
+      assert actualEmployee.employeeId == expectedEmployee.employeeId
+      def actualAddress = actualEmployee.address
+      assert actualAddress != null
+      //assert actualAddress.class == Address
+      assert actualAddress.line1 == expectedAddress.line1
+      assert actualAddress.line2 == expectedAddress.line2
+      assert actualAddress.zip == expectedAddress.zip
+      assert actualAddress.state == expectedAddress.state
+   }
+
+   void testCompanyAndEmployeeSameAddress() {
+      def expectedAddress = new Address( line1: '123 Groovy Rd', zip: 12345, state: 'JV'
)
+      def expectedEmployee = new Employee( name: 'Duke', employeeId: 1, address: expectedAddress
)
+      def expectedCompany = new Company( name: 'ACME' )
+      def actualCompany = builder.company( name: 'ACME', employees: [] ) {
+         address( id: 'a1', line1: '123 Groovy Rd', zip: 12345, state: 'JV' )
+         employee(  name: 'Duke', employeeId: 1, address: a1 )
+      }
+      assert actualCompany != null
+      //assert actualCompany.class == Company
+      assert actualCompany.name == expectedCompany.name
+      assert actualCompany.employees.size() == 1
+      def actualEmployee = actualCompany.employees[0]
+      //assert actualEmployee.class == Employee
+      assert actualEmployee.name == expectedEmployee.name
+      assert actualEmployee.employeeId == expectedEmployee.employeeId
+      assert actualCompany.address == actualEmployee.address
+   }
+
+   void testCompanyAndEmployeeSameAddressWithRef() {
+      def expectedAddress = new Address( line1: '123 Groovy Rd', zip: 12345, state: 'JV'
)
+      def expectedEmployee = new Employee( name: 'Duke', employeeId: 1, address: expectedAddress
)
+      def expectedCompany = new Company( name: 'ACME' )
+      def actualCompany = builder.company( name: 'ACME', employees: [] ) {
+         address( id: 'a1', line1: '123 Groovy Rd', zip: 12345, state: 'JV' )
+         employee(  name: 'Duke', employeeId: 1 ){
+            address( refId: 'a1' )
+         }
+      }
+      assert actualCompany != null
+      //assert actualCompany.class == Company
+      assert actualCompany.name == expectedCompany.name
+      assert actualCompany.employees.size() == 1
+      def actualEmployee = actualCompany.employees[0]
+      //assert actualEmployee.class == Employee
+      assert actualEmployee.name == expectedEmployee.name
+      assert actualEmployee.employeeId == expectedEmployee.employeeId
+      assert actualCompany.address == actualEmployee.address
+      assert actualEmployee.company == actualCompany
+   }
+
+   void testCompanyAndManyEmployees() {
+      def actualCompany = builder.company( name: 'ACME', employees: [] ) {
+         3.times {
+            employee(  name: "Duke $it", employeeId: it )
+         }
+      }
+      assert actualCompany != null
+      assert actualCompany.employees.size() == 3
+      3.times {
+         assert actualCompany.employees[it].name == "Duke $it"
+      }
+      //assert actualCompany.employees*.getClass() == [Employee,Employee,Employee]
+   }
+
+   void testStringfiedIdentifierResolver() {
+      builder.identifierResolver = "uid"
+      def company = builder.company( name: 'ACME', employees: [], uid: 'acme' )
+      assert company != null
+      assert builder.acme != null
+      assert builder.acme == company
+   }
+
+   void testStringfiedReferenceResolver() {
+      builder.referenceResolver = "ref_id"
+      def company = builder.company( name: 'ACME', employees: [] ) {
+         address( line1: '123 Groovy Rd', zip: 12345, state: 'JV', id: 'a1' )
+         employee(  name: 'Duke', employeeId: 1, id: 'e1' ) {
+            address( ref_id: 'a1' )
+         }
+      }
+      assert company != null
+      assert company.employees.size() == 1
+      assert builder.e1 == company.employees[0]
+      assert builder.a1 == company.address
+      assert builder.a1 == builder.e1.address
+   }
+
+   void testReferenceResolver() {
+      def company = builder.company( name: 'ACME', employees: [] ) {
+         address( line1: '123 Groovy Rd', zip: 12345, state: 'JV', id: 'a1' )
+         employee(  name: 'Duke', employeeId: 1, id: 'e1' ) {
+            address( refId: 'a1' )
+         }
+      }
+      assert company != null
+      assert company.employees.size() == 1
+      assert builder.e1 == company.employees[0]
+      assert builder.a1 == company.address
+      assert builder.a1 == builder.e1.address
+   }
+
+   void testReferenceResolver_referenceIsLiveObject() {
+      def company = builder.company( name: 'ACME', employees: [] ) {
+         address( line1: '123 Groovy Rd', zip: 12345, state: 'JV', id: 'a1' )
+         employee(  name: 'Duke', employeeId: 1, id: 'e1' ) {
+            address( refId: a1 )
+         }
+      }
+      assert company != null
+      assert company.employees.size() == 1
+      assert builder.e1 == company.employees[0]
+      assert builder.a1 == company.address
+      assert builder.a1 == builder.e1.address
+   }
+
+   void testDirectReference() {
+      def company = builder.company( name: 'ACME', employees: [] ) {
+         address( line1: '123 Groovy Rd', zip: 12345, state: 'JV', id: 'a1' )
+         employee(  name: 'Duke', employeeId: 1, id: 'e1' ) {
+            address( a1 )
+         }
+      }
+      assert company != null
+      assert company.employees.size() == 1
+      assert builder.e1 == company.employees[0]
+      assert builder.a1 == company.address
+      assert builder.a1 == builder.e1.address
+   }
+
+   void testLazyReferences() {
+      def company = builder.company( name: 'ACME', employees: [] ) {
+         employee(  name: 'Duke', employeeId: 1, id: 'e1' ) {
+            address( refId: 'a1' )
+         }
+         address( line1: '123 Groovy Rd', zip: 12345, state: 'JV', id: 'a1' )
+      }
+      assert company != null
+      assert company.employees.size() == 1
+      assert builder.e1 == company.employees[0]
+      assert builder.a1 == company.address
+      assert builder.a1 == builder.e1.address
+   }
+
+   void testReflectionCompany() {
+      def expected = new ReflectionCompany( name: 'ACME' )
+      def actual = reflectionBuilder.reflectionCompany( name: 'ACME' )
+      assert actual != null
+      assert actual.name == expected.name
+   }
+
+   void testReflectionCompanyAndAddress() {
+      def expectedAddress = new Address( line1: '123 Groovy Rd', zip: 12345, state: 'JV'
)
+      def expectedCompany = new ReflectionCompany( name: 'ACME', addr: expectedAddress )
+      def actualCompany = reflectionBuilder.reflectionCompany( name: 'ACME' ) {
+         addr( line1: '123 Groovy Rd', zip: 12345, state: 'JV' )
+      }
+      assert actualCompany != null
+      assert actualCompany.name == expectedCompany.name
+      def actualAddress = actualCompany.addr
+      assert actualAddress != null
+      assert actualAddress.line1 == expectedAddress.line1
+      assert actualAddress.line2 == expectedAddress.line2
+      assert actualAddress.zip == expectedAddress.zip
+      assert actualAddress.state == expectedAddress.state
+   }
+
+    void testReflectionCompanyAddressAndEmployees() {
+      def expectedAddress = new Address( line1: '123 Groovy Rd', zip: 12345, state: 'JV'
)
+      def expectedCompany = new ReflectionCompany( name: 'ACME', addr: expectedAddress )
+      def expectedDirector = new Employee( name: 'Duke', employeeId: 1, address: expectedAddress
)
+      def expectedFinancialController = new Employee( name: 'Craig', employeeId: 2, address:
expectedAddress )
+      def expectedDrone0 = new Employee( name: 'Drone0', employeeId: 3, address: expectedAddress
)
+      def expectedDrone1 = new Employee( name: 'Drone1', employeeId: 4, address: expectedAddress
)
+
+      def actualCompany = reflectionBuilder.reflectionCompany( name: 'ACME', drones: [] )
{
+         addr( id: 'a1', line1: '123 Groovy Rd', zip: 12345, state: 'JV' )
+         director(  name: expectedDirector.name, employeeId: expectedDirector.employeeId
){
+            address( refId: 'a1' )
+         }
+         financialController(  name: expectedFinancialController.name, employeeId: expectedFinancialController.employeeId
){
+            address( refId: 'a1' )
+         }
+         drones(  name: expectedDrone0.name, employeeId: expectedDrone0.employeeId ){
+            address( refId: 'a1' )
+         }
+         drones(  name: expectedDrone1.name, employeeId: expectedDrone1.employeeId ){
+            address( refId: 'a1' )
+         }
+      }
+      
+      assert actualCompany != null
+      assert actualCompany.name == expectedCompany.name
+      def actualAddress = actualCompany.addr
+      assert actualAddress != null
+      assert actualAddress.line1 == expectedAddress.line1
+      assert actualAddress.line2 == expectedAddress.line2
+      assert actualAddress.zip == expectedAddress.zip
+      assert actualAddress.state == expectedAddress.state
+
+      assert actualCompany.director != null
+      assert actualCompany.director.name == expectedDirector.name
+      assert actualCompany.director.employeeId == expectedDirector.employeeId
+      assert actualCompany.director.address.line1 == expectedAddress.line1
+
+      assert actualCompany.financialController != null
+      assert actualCompany.financialController.name == expectedFinancialController.name
+      assert actualCompany.financialController.employeeId == expectedFinancialController.employeeId
+      assert actualCompany.financialController.address.line1 == expectedAddress.line1
+
+      assert actualCompany.drones != null
+      assert actualCompany.drones.size() == 2
+      assert actualCompany.drones[0].name == expectedDrone0.name
+      assert actualCompany.drones[0].employeeId == expectedDrone0.employeeId
+      assert actualCompany.drones[0].address != null
+      assert actualCompany.drones[0].address.line1 == expectedAddress.line1
+      assert actualCompany.drones[1].name == expectedDrone1.name
+      assert actualCompany.drones[1].address != null
+      assert actualCompany.drones[1].employeeId == expectedDrone1.employeeId
+      assert actualCompany.drones[1].address.line1 == expectedAddress.line1
+   }
+
+   void testPlural() {
+       def dracula = builder.person(name: 'Dracula') {
+           allergy(name: 'garlic', reaction: 'moderate burns')
+           allergy(name: 'cross', reaction: 'aversion')
+           allergy(name: 'wood stake', reaction: 'death')
+           allergy(name: 'sunlight', reaction: 'burst into flames')
+           petMonkey(name: 'La-la')
+           petMonkey(name: 'Ampersand')
+       }
+
+       assert dracula.allergies.size() == 4
+       assert dracula.petMonkeys.size() == 2
+   }
+
+   void testCompanyAndEmployeeAndAddressUsingBeanFactory() {
+      def expectedAddress = new Address( line1: '123 Groovy Rd', zip: 12345, state: 'JV'
)
+      def expectedEmployee = new Employee( name: 'Duke', employeeId: 1, address: expectedAddress
)
+      def expectedCompany = new Company( name: 'ACME' )
+      def actualCompany = builder.bean(new Company(), name: 'ACME', employees: [] ) {
+         bean(Employee, name: 'Duke', employeeId: 1 ) {
+            bean(Address, line1: '123 Groovy Rd', zip: 12345, state: 'JV' )
+         }
+      }
+      assert actualCompany != null
+      // assert actualCompany.class == Company
+      assert actualCompany.name == expectedCompany.name
+      assert actualCompany.employees.size() == 1
+      def actualEmployee = actualCompany.employees[0]
+      // assert actualEmployee.class == Employee
+      assert actualEmployee.name == expectedEmployee.name
+      assert actualEmployee.employeeId == expectedEmployee.employeeId
+      def actualAddress = actualEmployee.address
+      assert actualAddress != null
+      // assert actualAddress.class == Address
+      assert actualAddress.line1 == expectedAddress.line1
+      assert actualAddress.line2 == expectedAddress.line2
+      assert actualAddress.zip == expectedAddress.zip
+      assert actualAddress.state == expectedAddress.state
+   }
+
+   void setUp() {
+      builder = new ObjectGraphBuilder()
+      builder.classNameResolver = "groovy.util"
+      reflectionBuilder = new ObjectGraphBuilder()
+      reflectionBuilder.classNameResolver = [ name: 'reflection', root: "groovy.util" ]
+   }
+}
+
+class Company {
+   String name
+   Address address
+   List employees = []
+
+   String toString() { "Company=[name:${name}, address:${address}, employees:${employees}]"
}
+}
+
+class Address {
+   String line1
+   String line2
+   int zip
+   String state
+
+   String toString() { "Address=[line1:${line1}, line2:${line2}, zip:${zip}, state:${state}]"
}
+}
+
+class Employee {
+   String name
+   int employeeId
+   Address address
+   Company company
+
+   String toString() { "Employee=[name:${name}, employeeId:${employeeId}, address:${address},
company:${company.name}]" }
+}
+
+class ReflectionCompany {
+   String name
+   Address addr
+   Employee director
+   Employee financialController
+   List<Employee> drones
+
+   String toString() { "Company=[name:${name}, address:${address}, director:${md}, financialController:${cio},
drones:${drones}]" }
+}
+
+class Person {
+    String name
+    List allergies = []
+    List petMonkeys = []
+
+    String toString() { "Person=[name:${name}, allergies:${allergies}, petMonkeys:${petMonkeys}]"
}
+}
+
+class Allergy {
+    String name
+    String reaction
+
+    String toString() { "Allergy=[name:${name}, reaction:${reaction}]" }
+}
+
+class PetMonkey {
+    String name
+
+    String toString() { "PetMonkey=[name:${name}]" }
 }
diff --git a/src/test/org/codehaus/groovy/ast/CodeVisitorSupportTest.groovy b/src/test/org/codehaus/groovy/ast/CodeVisitorSupportTest.groovy
index e3843eb..b9cc2e3 100644
--- a/src/test/org/codehaus/groovy/ast/CodeVisitorSupportTest.groovy
+++ b/src/test/org/codehaus/groovy/ast/CodeVisitorSupportTest.groovy
@@ -42,7 +42,7 @@ class CodeVisitorSupportTest extends GroovyTestCase {
         assert visitor.history[2] == BooleanExpression
         assert visitor.history[3] == BlockStatement
         assert visitor.history[4] == BlockStatement
-        assert visitor.history.size == 5
+        assert visitor.history.size() == 5
     }
 
     void testEmptyStatementsOnIfElse() {
@@ -57,7 +57,7 @@ class CodeVisitorSupportTest extends GroovyTestCase {
         assert visitor.history[2] == BooleanExpression
         assert visitor.history[3] == BlockStatement
         assert visitor.history[4] == EmptyStatement
-        assert visitor.history.size == 5
+        assert visitor.history.size() == 5
     }
 
     void testTryCatchFinally() {
diff --git a/src/test/org/codehaus/groovy/runtime/powerassert/AssertionRenderingTest.groovy
b/src/test/org/codehaus/groovy/runtime/powerassert/AssertionRenderingTest.groovy
index 60983fd..37e4f7a 100644
--- a/src/test/org/codehaus/groovy/runtime/powerassert/AssertionRenderingTest.groovy
+++ b/src/test/org/codehaus/groovy/runtime/powerassert/AssertionRenderingTest.groovy
@@ -340,14 +340,14 @@ assert (a..<b) == null
 
     void testPropertyExpression() {
         isRendered """
-assert a.size == null
-       | |    |
-       | 1    false
-       [9]
+assert a.bytes == null
+       | |     |
+       | [65]  false
+       'A'
 
         """, {
-            def a = [9]
-            assert a.size == null
+            def a = 'A'
+            assert a.bytes == null
         }
 
         isRendered """
diff --git a/src/test/org/codehaus/groovy/runtime/powerassert/EvaluationTest.groovy b/src/test/org/codehaus/groovy/runtime/powerassert/EvaluationTest.groovy
index cec4851..467dacc 100644
--- a/src/test/org/codehaus/groovy/runtime/powerassert/EvaluationTest.groovy
+++ b/src/test/org/codehaus/groovy/runtime/powerassert/EvaluationTest.groovy
@@ -156,7 +156,7 @@ class EvaluationTest extends GroovyTestCase {
     }
 
     void testPropertyExpression() {
-        assert [1,2,3].size == 3
+        assert 'A'.bytes == [65] as byte[]
         assert (new Properties().next.next.next.x = 10) == 10
         assert Integer.MIN_VALUE < Integer.MAX_VALUE
     }


Mime
View raw message