Last active
August 29, 2015 14:01
-
-
Save aaronzirbes/1e9dffc5459c61eb7839 to your computer and use it in GitHub Desktop.
Fix for this: https://jira.grails.org/browse/GRAILS-10661
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.zirbes.grails.functional.remote | |
import grails.util.BuildSettingsHolder | |
import groovyx.remote.transport.http.HttpTransport | |
/** | |
* Adds null safe grails specific convenient no arg constructor. | |
* https://jira.grails.org/browse/GRAILS-10661 | |
*/ | |
class RemoteControl extends groovyx.remote.client.RemoteControl { | |
static public final RECEIVER_PATH = 'grails-remote-control' | |
RemoteControl() { | |
super( | |
new HttpTransport( | |
getNullSafeFunctionalTestReceiverAddress(), | |
Thread.currentThread().contextClassLoader | |
), | |
Thread.currentThread().contextClassLoader | |
) | |
} | |
private static String getNullSafeFunctionalTestReceiverAddress() { | |
String base = getNullSafeFunctionalTestBaseUrl() | |
if (!base) { | |
throw new IllegalStateException('Cannot get receiver address for functional testing as functional test ' + | |
'base URL is not set. Are you calling this from a functional test?') | |
} | |
return base.endsWith('/') ? base + RECEIVER_PATH : base + '/' + RECEIVER_PATH | |
} | |
private static String getNullSafeFunctionalTestBaseUrl() { | |
String base = BuildSettingsHolder.settings?.functionalTestBaseUrl | |
if (!base || base == 'null') { base = '' } | |
return base | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment