|
Groovy example source code file (Groovy3139Bug.groovy)
The Groovy Groovy3139Bug.groovy source codepackage groovy.bugs import groovy.mock.interceptor.StubFor class Groovy3139Bug extends GroovyTestCase { void testStubbingIssueDueToCachingWhenUsing2Stubs() { def urlStub1 = new StubFor(URL) urlStub1.demand.openConnection {""} urlStub1.use { def get = new Get2(url: "http://localhost") def result = get.text } def urlStub2 = new StubFor(URL) // the following stubbed call is on urlStub2 and its demand cound should be separate. // Currently due to caching of MockProxyMetaClass, it gets counted towards urlStub1 demands // and throws "End of demands" exception urlStub2.demand.openConnection {""} urlStub2.use { def get = new Get2(url: "http://localhost") def result = get.text } } } class Get2{ String url String getText() { def aUrl = new URL(toString()) def conn = aUrl.openConnection() return "DUMMY" } String toString(){ return url } } Other Groovy examples (source code examples)Here is a short list of links related to this Groovy Groovy3139Bug.groovy source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.