Groovy
  1. Groovy
  2. GROOVY-3720

MockFor and StubFor call unsupported method in ProxyGenerator for creation of instances of Abstract classes

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.7-beta-1
    • Fix Version/s: 1.6.5, 1.7-beta-2
    • Component/s: None
    • Labels:
      None
    • Environment:
      Windows XP Professional Version 5.1.2600 Service Pack 2 Build 2600

      Description

      public abstract class MyNode {

      }

      @Test
      public void testCreateStubNode()

      { def stubNodeContext = new StubFor(MyNode) assertNotNull(stubNodeContext.proxyInstance()) }

      @Test
      public void testCreateStubNodeDelegate()

      { def stubNodeContext = new StubFor(MyNode) assertNotNull(stubNodeContext.proxyDelegateInstance()) }

      @Test
      public void testCreateMockNode()

      { def mockNodeContext = new MockFor(MyNode) assertNotNull(mockNodeContext.proxyInstance()) }

      @Test
      public void testCreateMockNodeDelegate()

      { def mockNodeContext = new MockFor(MyNode) assertNotNull(mockNodeContext.proxyDelegateInstance()) }

      In any case (and with a non-empty Abstract class such as import javax.media.j3d.Node) the result is:

      groovy.lang.MissingMethodException: No signature of method: groovy.util.ProxyGenerator.instantiateAggregateFromBaseClass() is applicable for argument types: (java.lang.Class, null) values: [class MyNode, null]

      Which appears to be absolutely true: the ProxyGenerator only has these 3 method signatures, none of which have the Class as the 1st argument (save the single parameter version)...

      instantiateAggregateFromBaseClass(Class)
      instantiateAggregateFromBaseClass(Map, Class)
      instantiateAggregateFromBaseClass(Closure, Class)

        Activity

        Geoff Sindel created issue -
        Hide
        Roshan Dawrani added a comment - - edited

        An additional test case below, which must also go through after the fix:

        import groovy.mock.interceptor.*
        
        class AnotherNodeTest extends GroovyTestCase {
        
        	void testCreateStubNode() {
        		def stubNodeContext = new StubFor(AnotherNode) 
        		assertNotNull stubNodeContext.proxyInstance()
        	}
        
            void testCreateStubNodeDelegate() {
                def stubNodeContext = new StubFor(AnotherNode) 
                assertNotNull stubNodeContext.proxyDelegateInstance()
            }
            
            void testCreateMockNode() {
                def mockNodeContext = new MockFor(AnotherNode) 
        
                assertNotNull mockNodeContext.proxyInstance()
                assertNotNull mockNodeContext.proxyDelegateInstance()
            }
        
            void testCreateMockNodeDelegate() {
                def mockNodeContext = new MockFor(AnotherNode) 
        
                assertNotNull mockNodeContext.proxyInstance()
                assertNotNull mockNodeContext.proxyDelegateInstance()
            }
        }
        
        abstract class BaseNode {
            abstract m1()
        }
        abstract class AnotherNode extends BaseNode {
        	abstract m2()
        }
        
        Show
        Roshan Dawrani added a comment - - edited An additional test case below, which must also go through after the fix: import groovy.mock.interceptor.* class AnotherNodeTest extends GroovyTestCase { void testCreateStubNode() { def stubNodeContext = new StubFor(AnotherNode) assertNotNull stubNodeContext.proxyInstance() } void testCreateStubNodeDelegate() { def stubNodeContext = new StubFor(AnotherNode) assertNotNull stubNodeContext.proxyDelegateInstance() } void testCreateMockNode() { def mockNodeContext = new MockFor(AnotherNode) assertNotNull mockNodeContext.proxyInstance() assertNotNull mockNodeContext.proxyDelegateInstance() } void testCreateMockNodeDelegate() { def mockNodeContext = new MockFor(AnotherNode) assertNotNull mockNodeContext.proxyInstance() assertNotNull mockNodeContext.proxyDelegateInstance() } } abstract class BaseNode { abstract m1() } abstract class AnotherNode extends BaseNode { abstract m2() }
        Roshan Dawrani made changes -
        Field Original Value New Value
        Assignee Roshan Dawrani [ roshandawrani ]
        Hide
        Roshan Dawrani added a comment -

        Fixed.

        Show
        Roshan Dawrani added a comment - Fixed.
        Roshan Dawrani made changes -
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 1.6.5 [ 15539 ]
        Fix Version/s 1.7-beta-2 [ 15540 ]
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Mark Thomas made changes -
        Workflow jira [ 12732703 ] Default workflow, editable Closed status [ 12744541 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12973650 ] Default workflow, editable Closed status [ 12980808 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        20h 45m 1 Roshan Dawrani 02/Sep/09 13:04
        Resolved Resolved Closed Closed
        43d 5h 10m 1 Paul King 15/Oct/09 18:15

          People

          • Assignee:
            Roshan Dawrani
            Reporter:
            Geoff Sindel
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development