Giter VIP home page Giter VIP logo

grails-remote-control's Introduction

The Grails remote-control plugin allows you to execute code inside a remote Grails application. The typical use case for this is for functional testing where you are testing an application inside a separate JVM and therefore do not have easy access to the application runtime. If you can access the application runtime environment then you can do things like change service parameter values, create and delete domain data and so forth.

The plugin uses the Groovy Remote Control library.

This plugin requires Grails 2.0.0 and will not work on earlier versions

An Example

The Test

We have written an application and now want to write some functional tests. In these tests we need to create some test data. This might look something like…

class MyFunctionalTest extends GroovyTestCase {
        
    def testIt() {
        def person = new Person(name: "Me")
        person.save(flush: true)
        
        // Somehow make some HTTP request and test that person is in the DB
            
        person.delete(flush: true)
    }
        
}

That will work if we are running our tests in the same JVM as the running application, which is the default behaviour…

grails test-app functional:

However, it won't work if your tests ARE NOT in the same JVM, as is the case with testing against a WAR deployment…

grails test-app functional: -war

This is going to fail because in the JVM that is running the tests there is no Grails application (the WAR is run in a forked JVM to be closer to a production like environment).

Existing Solutions

The most common existing workaround for this problem is to write a special controller that you call via HTTP in your functional tests to do the setup/teardown. This will work, but requires effort and is inherently fragile.

Using a remote control

The remote control plugin solves this problem by allowing you to define closures to be executed in the application you are testing. This is best illustrated by rewriting the above test…

import grails.plugin.remotecontrol.RemoteControl
    
class MyFunctionalTest extends GroovyTestCase {
        
    def remote = new RemoteControl()
    
    def testIt() {
        def id = remote {
            def person = new Person(name: "Me")
            person.save()
            person.id
        }
            
        // Somehow make some HTTP request and test that person is in the DB
            
        remote {
            Person.get(id).delete()
        }
    }
}

This test will now working when testing agains a WAR or a local version. The closures passed to remote are sent over HTTP to the running application and executed there, so it doesn't matter where the application is.

Chaining

Closures can be chained, with the return value of the previous closure being passed as an argument to the next closure in the chain. This is done on the server side, so it's ok for a closure to return a non serialisable value to be given to the next one. An example use for this would be reusing a closure to fetch some value, and then using another closure to process it.

import grails.plugin.remotecontrol.RemoteControl
    
class MyFunctionalTest extends GroovyTestCase {
        
    def remote = new RemoteControl()
        
    def getPerson = { id -> Person.get(id) }
        
    def modifyPerson(id, Closure modifications) {
        // pass the result of the getPerson command to the 
        // given modifications command
        remote.exec(getPerson.curry(id), modifications) 
    }
        
    def testIt() {
        def id = remote {
            def person = new Person(name: "Me")
            person.save()
            person.id
        }
            
        // Somehow make some HTTP request and test that person is in the DB
            
        // Change the name
        modifyPerson(id) { 
            it.setName("New Name")
            it.save(flush: true)
            null // return must be serialisable
        }
        
        // Somehow make some HTTP request and test that the person's name has changed
        
        // Cleanup
        modifyPerson(id) {
            it.delete()
        }
    }
}

A more concise example of how values are passed to the next command in the chain would be…

assert remote.exec({ 1 }, { it + 1 }, { it + 1 }) == 3

Context

The Groovy Remote Control library establishes a command context that is shared for all commands in a given chain.

This plugin prepoluates the context with two variables:

  • ctx - The main application context
  • app - The grails application object

This allows you to access beans (such as services) from commands…

remote.exec { ctx.someService.doSomeServiceStuff() }
Populating The Context

You can also set values in the context. This is sometimes useful when using a command chain where an initial command sets up some context.

def getPersonWithId = { person = Person.get(it) }
def doubleAge = { person.age *= 2 }
def savePerson = { person.save(flush: true) }
    
def doubleAgeOfPersonWithId(id) {
    remote.exec(getPersonWithId.curry(id), doubleAge, savePerson)
}
    
doubleAgeOfPersonWithId(10)

More Examples

To see some more usage examples of a remote control, see the demonstration test case in the project.

Testing Remote Apps

Let's say that we want to functionally test our application on different flavours of application server and we have our app deployed on three different app servers at the following URLs:

If we have the remote-control plugin installed and have written our tests to use it, we could simply run:

grails test-app functional: -baseUrl=http://appsrv1.test.my.org/myapp
grails test-app functional: -baseUrl=http://appsrv2.test.my.org/myapp
grails test-app functional: -baseUrl=http://appsrv3.test.my.org/myapp

Which will execute the tests against that remote instance.

Security

By default, the servlet that accepts remote commands is only configured when the application is started in the test environment. This means that it is not possible to use a remote with a production application out of the box.

However, if you do want to enable the remote control servlet that accepts commands in an environment other than production you can set remoteControl.enabled to true in the application config for that environment.

Testing applications with catch-all URL Mappings

Your remote control will not work if you have a catch-all URL mapping, e.g.

class UrlMappings {
	static mappings = {
		"/**"(controller:'boss')
	}
}

You will see groovyx.remote.RemoteControlException: Error sending command chain. The fix is to add the following line to URL Mappings:

static excludes = ['/grails-remote-control']

Your URL mappings should now look like:

class UrlMappings {
	static excludes = ['/grails-remote-control']
	static mappings = {
		"/**"(controller:'boss')
	}
}

grails-remote-control's People

Contributors

alxndrsn avatar double16 avatar hauner avatar ldaley avatar stokito avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

grails-remote-control's Issues

Does not work in Grails V2.3.7?

Hi,

I'm trying out the remote control plugin and have created a simple functional test as follows:

class SampleSpec extends GebSpec {

  def remote = new RemoteControl()

  def "sample specification"() {

    when:
    def id = remote {
      def field = new Field(label: "Remote Control", id: 0)
      field.save flush: true
      field.id
    }

    then:
    true

  }

However, I keep getting the following error when running my function tests using the remote control plugin groovyx.remote.RemoteControlException: Error sending command chain to 'http://localhost:8080null/grails-remote-control' at groovyx.remote.transport.http.HttpTransport.send(HttpTransport.groovy:65) at groovyx.remote.client.RemoteControl.sendCommandChain(RemoteControl.groovy:114) at groovyx.remote.client.RemoteControl.exec(RemoteControl.groovy:73) at groovyx.remote.client.RemoteControl.exec(RemoteControl.groovy:67) at groovyx.remote.client.RemoteControl.call(RemoteControl.groovy:81)

I noticed that there were some open issues that looked similar and am wondering if the issue I am facing is a known issue? Is there any work around available? Thanks.

Fix/add installation documentation

The documentation over at grails.org is wrong (at least for Grails 2.5.6):

  1. install-plugin is deprecated, one should add

    plugins {
                ...
    	test ":remote-control:2.0"
    }
    
  2. Dependency compile "org.grails.plugins:remote-control:2.0" does not resolve, and is in fact unnecessary (cf. my question on SO).

Please fix the documentation on grails.org and mirror the instructions here in the project README.

Doesn't work for geb tests if app context is '/'

remote-control does not work in Geb tests if app context is set to ROOT.

With the following set in application.properties:

app.context=/

I receive this exception:

| Failure:  setup can be loaded via a remote closure(wsmocker.RemoteConfigLoadSpec)
|  groovyx.remote.RemoteControlException: Error sending command chain to 'http://localhost:8080//grails-remote-control'
    at groovyx.remote.transport.http.HttpTransport.send(HttpTransport.groovy:65)
    at groovyx.remote.client.RemoteControl.sendCommandChain(RemoteControl.groovy:114)
    at groovyx.remote.client.RemoteControl.exec(RemoteControl.groovy:73)
    at groovyx.remote.client.RemoteControl.exec(RemoteControl.groovy:67)
    at wsmocker.RemoteConfigLoadSpec.setup can be loaded via a remote closure(RemoteConfigLoadSpec.groovy:25)
Caused by: java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:8080//grails-remote-control
    at groovyx.remote.transport.http.HttpTransport.send_closure1(HttpTransport.groovy:62)
    at groovyx.remote.transport.http.HttpTransport.send(HttpTransport.groovy:53)
    ... 4 more

To work around the bug, remove the app.context config from application.properties and instead put the following in grails-app/conf/Config.groovy:

grails.app.context = '/'
environments {
    test {
        grails.app.context = 'workaround'
    }
}

remote control not available when using catch-all URL mapping

Not sure if this is grails-remote-control's fault, but with a catch-all URL mapping like so:

class UrlMappings {
    static mappings = {
        "/**"(controller:'boss')
    }
}

I get the following exception:

|  groovyx.remote.RemoteControlException: Error sending command chain to 'http://localhost:8080/wsmocker/grails-remote-control'
    at groovyx.remote.transport.http.HttpTransport.send(HttpTransport.groovy:65)
    at groovyx.remote.client.RemoteControl.sendCommandChain(RemoteControl.groovy:114)
    at groovyx.remote.client.RemoteControl.exec(RemoteControl.groovy:73)
    at groovyx.remote.client.RemoteControl.exec(RemoteControl.groovy:67)
    at wsmocker.RemoteConfigLoadSpec.setup can be loaded via a remote closure(RemoteConfigLoadSpec.groovy:25)
Caused by: java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:8080/wsmocker/grails-remote-control
    at groovyx.remote.transport.http.HttpTransport.send_closure1(HttpTransport.groovy:62)
    at groovyx.remote.transport.http.HttpTransport.send(HttpTransport.groovy:53)
    ... 4 more

The fix is to add the following line to URL Mappings:

static excludes = ['/grails-remote-control']

so it looks like this:

class UrlMappings {
    static excludes = ['/grails-remote-control']
    static mappings = {
        "/**"(controller:'boss')
    }
}

Again, I'm not sure if this can be fixed in grails-remote-control, but I think it's worth mentioning as the excludes options is not mentioned in the grails documentation, and it could be tricky to figure this out.

NullPointerException in RemoteControlServlet.doExecute(RemoteControlServlet.groovy:30)

I'm seeing a NullPointerException whenever I make an exec() call. As far as I can tell, the calls are successful. However, I'm guessing that the error means something, not that I have seen any immediate side effects.

I'm using a custom grails environment (ie not "test"), have set remoteControl.enabled = true, and basically everything seems to be working.

The stack trace is:
[http-nio-8080-exec-3] ERROR agent.SpringLoadedPreProcessor - Unexpected problem transforming call sites
java.lang.NullPointerException
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
at groovyx.remote.server.CommandInvoker.defineClass(CommandInvoker.groovy:73)
at groovyx.remote.server.CommandInvoker.instantiate(CommandInvoker.groovy:57)
at groovyx.remote.server.CommandInvoker.invokeAgainst(CommandInvoker.groovy:37)
at groovyx.remote.server.CommandChainInvoker.invokeAgainst(CommandChainInvoker.groovy:37)
at groovyx.remote.server.Receiver.invokeCommandChain(Receiver.groovy:129)
at groovyx.remote.server.Receiver.execute(Receiver.groovy:125)
at groovyx.remote.transport.http.RemoteControlServlet.doExecute(RemoteControlServlet.groovy:74)
at grails.plugin.remotecontrol.RemoteControlServlet.doExecute(RemoteControlServlet.groovy:30)
at groovyx.remote.transport.http.RemoteControlServlet.doPost(RemoteControlServlet.groovy:39)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)

Not working where server has self-signed cert

Where target url is https , and the cert is self signed, exception occurs:

groovyx.remote.RemoteControlException: Error sending command chain to 'https://www.staging.on.dolicloud.com/grails-remote-control'
at groovyx.remote.transport.http.HttpTransport.send(HttpTransport.groovy:65)
at groovyx.remote.client.RemoteControl.sendCommandChain(RemoteControl.groovy:114)
at groovyx.remote.client.RemoteControl.exec(RemoteControl.groovy:73)
at groovyx.remote.client.RemoteControl.exec(RemoteControl.groovy:67)
at groovyx.remote.client.RemoteControl.call(RemoteControl.groovy:81)
at AdminSpec.login(AdminSpec.groovy:18)
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at groovyx.remote.transport.http.HttpTransport.send_closure1(HttpTransport.groovy:61)
at groovyx.remote.transport.http.HttpTransport.send(HttpTransport.groovy:53)
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:268)

baseUrl doesn't work.

Hi,

When I executed command
grails test-app functional: -baseUrl="http://mysampleurl",
I got following errors:

|Loading Grails 2.3.7
|Configuring classpath
.
|Environment set to test
...............................................................................
|Server stopped
Error |
Fatal error running tests: No signature of method: static java.lang.System.setProperty() is applicable for argument types: (java.lang.String, java.lang.Boolean) values: [geb.build.baseUrl, true]
Possible solutions: setProperty(java.lang.String, java.lang.String), getProperty(java.lang.String), getProperty(java.lang.String, java.lang.String), hasProperty(java.lang.String), getProperties(), getProperties() (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
groovy.lang.MissingMethodException: No signature of method: static java.lang.System.setProperty() is applicable for argument types: (java.lang.String, java.lang.Boolean) values: [geb.build.baseUrl, true]
Possible solutions: setProperty(java.lang.String, java.lang.String), getProperty(java.lang.String), getProperty(java.lang.String, java.lang.String), hasProperty(java.lang.String), getProperties(), getProperties()
    at _Events$_run_closure8.doCall(_Events.groovy:131)
    at _GrailsTest_groovy$_run_closure1.doCall(_GrailsTest_groovy:102)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
    at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
    at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at TestApp$_run_closure1.doCall(TestApp.groovy:32)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
    at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
    at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
    at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
    at gant.Gant.withBuildListeners(Gant.groovy:427)
    at gant.Gant.this$2$withBuildListeners(Gant.groovy)
    at gant.Gant$this$2$withBuildListeners$0.callCurrent(Unknown Source)
    at gant.Gant.dispatch(Gant.groovy:415)
    at gant.Gant.this$2$dispatch(Gant.groovy)
    at gant.Gant.invokeMethod(Gant.groovy)
    at gant.Gant.executeTargets(Gant.groovy:591)
    at gant.Gant.executeTargets(Gant.groovy:590)

Error |
Fatal error running tests: No signature of method: static java.lang.System.setProperty() is applicable for argument types: (java.lang.String, java.lang.Boolean) values: [geb.build.baseUrl, true]
Possible solutions: setProperty(java.lang.String, java.lang.String), getProperty(java.lang.String), getProperty(java.lang.String, java.lang.String), hasProperty(java.lang.String), getProperties(), getProperties()
.Tests FAILED 
|
 - view reports in C:\sampleProject\target\test-reports
Error |
Error executing script TestApp: groovy.lang.MissingMethodException: No signature of method: static java.lang.System.setProperty() is applicable for argument types: (java.lang.String, java.lang.Boolean) values: [geb.build.baseUrl, true]
Possible solutions: setProperty(java.lang.String, java.lang.String), getProperty(java.lang.String), getProperty(java.lang.String, java.lang.String), hasProperty(java.lang.String), getProperties(), getProperties() (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
groovy.lang.MissingMethodException: No signature of method: static java.lang.System.setProperty() is applicable for argument types: (java.lang.String, java.lang.Boolean) values: [geb.build.baseUrl, true]
Possible solutions: setProperty(java.lang.String, java.lang.String), getProperty(java.lang.String), getProperty(java.lang.String, java.lang.String), hasProperty(java.lang.String), getProperties(), getProperties()
    at _Events$_run_closure8.doCall(_Events.groovy:131)
    at _GrailsTest_groovy$_run_closure1.doCall(_GrailsTest_groovy:102)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
    at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
    at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at TestApp$_run_closure1.doCall(TestApp.groovy:32)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
    at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
    at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
    at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
    at gant.Gant.withBuildListeners(Gant.groovy:427)
    at gant.Gant.this$2$withBuildListeners(Gant.groovy)
    at gant.Gant$this$2$withBuildListeners$0.callCurrent(Unknown Source)
    at gant.Gant.dispatch(Gant.groovy:415)
    at gant.Gant.this$2$dispatch(Gant.groovy)
    at gant.Gant.invokeMethod(Gant.groovy)
    at gant.Gant.executeTargets(Gant.groovy:591)
    at gant.Gant.executeTargets(Gant.groovy:590)

Error |
Error executing script TestApp: groovy.lang.MissingMethodException: No signature of method: static java.lang.System.setProperty() is applicable for argument types: (java.lang.String, java.lang.Boolean) values: [geb.build.baseUrl, true]
Possible solutions: setProperty(java.lang.String, java.lang.String), getProperty(java.lang.String), getProperty(java.lang.String, java.lang.String), hasProperty(java.lang.String), getProperties(), getProperties()

How do I pass in the baseUrl correctly ?
Thanks.

Please publish version 1.5

Latest version of this plugin available in grails plugins repository is 1.4, but this version doesn't work with grails 2.4.0 because ApplicationHolder has been removed.

This has been fixed already in the code, so the only thing left to be done is to release this new version.

Compatibility Grails V2.5.0

Hi,

I would like to know if the plugin remote-control v2.0 is compatible with grails v2.5.0?

Because I'm upgrading my grails project from v2.4.4 to v2.5.0 and when i run the functional test I get this error for all my tests:

screenshot from 2015-05-04 09 41 19

I try to fix it by updating all my plugins but it didn't fix it

dependencies {
        // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
        runtime 'mysql:mysql-connector-java:5.1.35'
        runtime 'org.elasticsearch:elasticsearch:1.5.2'
        compile 'com.cloudinary:cloudinary:1.0.14'
        compile "org.apache.commons:commons-math3:3.5"
        compile "com.javadocmd:simplelatlng:1.3.0"
        compile "com.logentries:logentries-appender:1.1.30"
        compile "com.cloudbees.thirdparty:zendesk-java-client:0.2.4"
        runtime 'com.spatial4j:spatial4j:0.4.1'
        compile 'com.vividsolutions:jts:1.13'
        compile 'com.github.javafaker:javafaker:0.5'
        compile 'com.codahale.metrics:metrics-graphite:3.0.2'
        compile 'io.jsonwebtoken:jjwt:0.4'

    }

    plugins {
        // plugins for the build system only
        build ':tomcat:8.0.21'

        // plugins for the compile step
        compile ':cache:1.1.8'
        compile ":rest:0.8"
        compile ":bcrypt:1.0"
        compile ":asynchronous-mail:1.2"
        compile ':quartz:1.0.2'
        compile ":joda-time:1.5"
        compile ":build-test-data:2.4.0"
        compile ":spring-events:1.2"
        compile ":remote-control:2.0"
        compile ":build-info:1.2.8"

        // plugins needed at runtime but not for compilation
        runtime ":hibernate4:4.3.8.1"
        runtime ":database-migration:1.4.0"

        runtime ":cors:1.1.6"
        // compile ":redis-hibernate-cache:1.0"

        compile ":rest-client-builder:2.1.1"

        test ":plastic-criteria:1.5.1"
        compile ":yammer-metrics:3.0.1-2"

        compile ":redis-hibernate-cache:1.0", {
            excludes "logback-classic"
        }
        compile ":redis-flexible-cache:0.3.4"
        compile ":cache-headers:1.1.7"


        // Uncomment these (or add new ones) to enable additional resources capabilities
        //runtime ":zipped-resources:1.0.1"
        //runtime ":cached-resources:1.1"
        //runtime ":yui-minify-resources:0.1.5"
    }

Thanks for your help

Edit:

i tried with:
grails test-app functional:
grails test-app functional: -baseUrl=http://localhost:8080/
grails test-app functional: -baseUrl=http://localhost:8080

Edit2: the functional tests were running fine with grails 2.4.4 and remote-control 2.0

Always the same errors

fix remote execution syntax in docs

The docs show various examples of remote execution such as

        def id = remote {
            def person = new Person(name: "Me")
            person.save()
            person.id
        }

But as far as I can tell this doesn't work and remote.exec should be used instead, e.g.

        def id = remote.exec {
            def person = new Person(name: "Me")
            person.save()
            person.id
        }

groovyx.remote.RemoteControlException when using the "-war" option

I cannot run my tests when using the war option:

grails -Dgeb.env=phantomjs test-app -war -functional

It causes:

groovyx.remote.RemoteControlException: Error sending command chain to 'http://localhost:8080/insoft-fw/grails-remote-control'
    at groovyx.remote.transport.http.HttpTransport.send(HttpTransport.groovy:65)
    at groovyx.remote.client.RemoteControl.sendCommandChain(RemoteControl.groovy:114)
    at groovyx.remote.client.RemoteControl.exec(RemoteControl.groovy:73)
    at groovyx.remote.client.RemoteControl.exec(RemoteControl.groovy:67)
    at br.com.insoft4.fw.security.LoginSpec.setupSpec(LoginSpec.groovy:18)
Caused by: java.io.FileNotFoundException: http://localhost:8080/insoft-fw/grails-remote-control
    at groovyx.remote.transport.http.HttpTransport.send_closure1(HttpTransport.groovy:62)
    at groovyx.remote.transport.http.HttpTransport.send(HttpTransport.groovy:53)
    ... 4 more

Running without the war option executes with success.

command chained exception

Hi,

I am using this plugin and trying to access message bundles.

Below is the stacktrace I get. Is there something am I missing? Also, we are using spring-security-LDAP

groovyx.remote.RemoteControlException: Error sending command chain to 'http://localhost:8080/******/grails-remote-control'
[test] at groovyx.remote.transport.http.HttpTransport.send(HttpTransport.groovy:65)
[test] at groovyx.remote.client.RemoteControl.sendCommandChain(RemoteControl.groovy:114)
[test] at groovyx.remote.client.RemoteControl.exec(RemoteControl.groovy:73)
[test] at groovyx.remote.client.RemoteControl.exec(RemoteControl.groovy:67)
[test] at cgw.login.AbstractCGWGebSpec.msg(AbstractCGWGebSpec.groovy:35)
[test] at cgw.login.AbstractCGWGebSpec.Login to cgw application(AbstractCGWGebSpec.groovy:25)
[test] Caused by: java.io.StreamCorruptedException: invalid stream header: 3C68746D
[test] at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:782)
[test] at java.io.ObjectInputStream.(ObjectInputStream.java:279)
[test] at groovyx.remote.util.ClassLoaderConfigurableObjectInputStream.(ClassLoaderConfigurableObjectInputStream.groovy:26)
[test] at groovyx.remote.Result.readFrom(Result.groovy:150)
[test] at groovyx.remote.transport.http.HttpTransport.send_closure1(HttpTransport.groovy:62)
[test] at groovyx.remote.transport.http.HttpTransport.send(HttpTransport.groovy:53)

Regards
Lalit

Unable to work with remotes

Hi,

I have my application war deployed on a remote staging server. The war file was build with the following command grails -Dgrails.env=staging war

In my Config.groovy, I've specified

environments {
  staging {
    remoteControl.enabled = true
  }
}

In my GebConfig, I've specified the baseUrl to my remote. An example as follows:

baseUrl = 'http://example.example.net/' //example only

However, when I run grails test-app functional:, remote control does not setup my database correctly. Testing it with curl as described here, shows that the endpoint is not exposed. Can you please advise how I can resolve this? Thanks.

Regards,
John

How install remote-control plugin?

In Buildconfig.groovy under plugins section
test ":remote-control:............"

Is it the correct way to install the plugin?
In the documentation page is said to use the deprecated intall-plugin.

Can't get Remote Control to work on separate war

I have functional tests set up that use the grails remote control plugin. Everything works fine when I run everything together. However, when I try to run the test against a separate war file I get a 404 on the grails-remote-control end point. I have "static excludes = ['/grails-remote-control']" setup in my UrlMappings file and I also have "remoteControl.enabled = true" in my config for every environment.

I traced it through to see where it was failing and it appears to be hitting "throw new FileNotFoundException(sm.getString("defaultServlet.missingResource",requestUri));" in DefaultServlet.java. This gets thrown if it can't find the resource in the Servlet Context cache. No idea why this is different to success case though...

Any ideas what I might be doing wrong here?

I'm using Grails 2.4.4 and Remote Control 2.0.

Error when deploying an app including this plugin on JBoss AS

org.codehaus.groovy.modules.remote:remote-transport-http:0.5 plugin dependency has a transitive dependency to javax.servlet:servlet-api.

servlet-api is already provided by Grails runtime (as provided dependency).

This dependency should be excluded in BuildConfig.groovy.

grails 2.4.x use of org.codehaus.groovy.grails.commons.ApplicationHolder

..../plugins/remote-control-1.4/src/groovy/grails/plugin/remotecontrol/RemoteControlServlet.groovy: 21: unable to resolve class org.codehaus.groovy.grails.commons.ApplicationHolder
@ line 21, column 1.
import org.codehaus.groovy.grails.commons.ApplicationHolder
^
1 error

org.codehaus.groovy.grails.commons.ApplicationHolder was removed from grails 2.4.

Use with Grails 2.4.4 and Groovy 2.4 can't find the closure

I'm using Grails 2.4.4, a Gradle build with the cradle-grails-plugin, and Groovy 2.4 (non-standard, I know). The remote control plugin is failing because it can't find the closure. I think this is related to http://jira.codehaus.org/browse/GROOVY-5351 because of the closure naming. I see in https://github.com/alkemist/remote-control a commit was made to address this.

Can you release a new remote-control and grails-remote-control to include the fix?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.