home | career | drupal | java | mac | mysql | perl | scala | uml | unix

Groovy example source code file (Groovy3403Bug.groovy)

This example Groovy source code file (Groovy3403Bug.groovy) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Groovy tags/keywords

groovy3403bug, groovy3403bug, groovytestcase, helper3403, helper3403, main3403, main3403, stubfor, stubfor

The Groovy Groovy3403Bug.groovy source code

package groovy.bugs

import groovy.mock.interceptor.StubFor

class Groovy3403Bug extends GroovyTestCase {

    void testStubIssueForStaticMethodsDueToCallSiteCachingWhenUsing2Stubs() {
        def stub1 = new StubFor(Main3403)
        stub1.demand.test() {
            return "stubbed call made - 1"

        def ot = new Helper3403()

        stub1.use {
            assert ot.doTest() == "stubbed call made - 1"

        def stub2 = new StubFor(Main3403)
        stub2.demand.test() {
            return "stubbed call made - 2"

        // the following stubbed call is on stub2 and its demand count should be separate.
        // Currently due to caching of MockProxyMetaClass, it gets counted towards stub1 demands 
        // and throws "End of demands" exception
        stub2.use {
            assert ot.doTest() == "stubbed call made - 2"

class Main3403 {
   static test(){
       println "original call made"

class Helper3403 {
    def doTest() {

Other Groovy examples (source code examples)

Here is a short list of links related to this Groovy Groovy3403Bug.groovy source code file:

new blog posts


Copyright 1998-2014 Alvin Alexander, alvinalexander.com
All Rights Reserved.