Running grails test-app command from grails web console plugin - grails

I have installed the grails web plugin. I can now browse to :
localhost:8080/myappname/console
And I can see the console displayed over there. I have bunch of test-cases written for application. I wish I can test my app from this web console.
Is it possible to do so? I'm very new to grails.
Thanks in advance.

Short answer no. The grails console is meant to write groovy code that interacts with your running application. Your running application does not include your test cases or the grails command line by default.
Long answer sort of. Provided you have all of your projects source code available somewhere in the file system where your application is running, you could call an external process to run test-app and return the result to the user. Here are some docs on running external processes in groovy: http://groovy.codehaus.org/Executing+External+Processes+From+Groovy. I suppose you could also package you application somehow to make this work, but I think doing that would be fairly complex.
I am not sure this is a good use case for the console plugin over all. Hope this helps

Related

Web app reload issue in Groovy/Grails Tool Suite

I have ggts-bundle bundle 3.6.1 64 bit with JDK 7 (jdk1.7.0_67) on Win7 64bit.
I have grails home setup as GRAILS_HOME and grails version grails-2.4.3.
When i create a new action/method in the controller class in the tool suite and hit save and refresh the browser, it doesn't reload the changes in the application.
I even modified BuildConfig.groovy and added the following
grails.reload.enabled = true
I also tried with grails -reloading run-app
Nothing seem to reload the changes, I have to stop the server and restart it and then
it reflects the changes.
I am sure there's something i can do to have it reload the app.
I read online and tried other suggestion in questions on stackoverflow before i posted this.
Any suggestions.
Did you end up getting a solution to this?
I've just tried this out in GGTS and it looks like there is no problem.
Version: 3.6.3.RELEASE
Build Id: 201411281415
Platform: Eclipse Luna SR1 (4.4.1)
OS: Win7 64bit
I'm working on a plain vanilla (unmodified) install with default settings.
Using a simple Grails project, with a simple HelloController.groovy and a couple of GSPs... corresponding to two methods inside the controller. Launch the server...
Tried out two scenarios to see what happened, back in the IDE...
modify some simple output text in one of the GSPs, save, refresh the browser... yep, no problem, the change shows up
modify the HelloController.groovy to tell one of the methods to use a different GSP, save, refresh the browser... again, no problems, the change is reflected.
Note. I did have to wait a few seconds in scenario 2 for the IDE to notice the change and to recompile
Perhaps try updating your instance of GGTS to the latest release to see if that makes a difference?
Hope this helps.

Sling Testing Tools Selector configuration

AEM 5.6.1
I am trying to run some server side testing using the sling testing tools. I have deployed the junit.core bundle and I can navigate to the JUnitServlet at /system/sling/junit/
When I hit this url there are tests visible from multiple bundles, I don't want to run the adobe ones but I can't figure out how to filter package names past the period using the url.
e.g
Available tests:
com.adobe.stuff
com.my.stuff
I tried:
/system/sling/junit/com/ <--works but isn't detailed enough
/system/sling/junit/com.my <-- breaks unsurprisingly
/system/sling/junit/com%2Emy <-- also breaks with 501
Is there an expected way of doing this? I couldn't find any documentation about this and the javadoc didn't really help either.
/system/sling/junit/com.my.html should work - you are right that the /system/sling/junit servlet should make this more explicit. There are examples of running such tests from proxy JUnit tests in the Sling codebase, see SlingServerSideTest for example.

Grails: Provide a library to an external groovy script

what I have:
an external GroovyScript using the apache-commons-io library
and a working grails application
In the existing grails-application there are different external scripts (as of now only perl-scripts) which are executed async with grails (using the execute-Method).
Now I got an GroovyScript which I want to run the same way as I run the PerlScripts.
At the moment the script has the commons-io-library in a lib-folder. It works fine.
So my question is: How do I provide the groovy-script with the commons-io-library from grails in a smooth and neat way? Do I have to provide the path within the command which is executed via the execute-Method
e.g.:
groovy -cp=path/to/grailshome/lib.jar scripfile.groovy
this won't really work if I deploy the grailsapplication to the tomcat in the current production-environment as the libs from grails are in a different path.
Putting the script into the src/groovy folder of grails would probably work, but that's not the way I want it. The script needs to be standalone.
I'm really stuck as I'm not really versed with the technical details of and groovy grails.
Even suggestions and ideas how this can be accomplished are enough.
I hope you understand the question, thanks in advance
Is this a situation where using Grapes and putting:
#Grab( 'commons-io:commons-io:2.1' )
At the top of your groovy script would help?
If you are running this as a war, then this might work:
String path = grailsApplication.parentContext
.getResource( 'WEB-INF/lib/commons-io-1.4.jar' )
.file
.absolutePath

Possible to deploy WAR via Dreamweaver CS5?

I use Dreamweaver heavily for modifying Liferay templates (Velocity files), and then have to run Apache Ant from Command Prompt to deploy the WAR to Tomcat . Is there anyway I can streamline this process so I can save/deploy straight from Dreamweaver?
I tried to setup a site and specify Tomcat as the local server, but obviously Dreamweaver just tries to push the raw file and does deploy the WAR.. Is there some sort of extension or way I can call Apache Ant from Dreamweaver?
Thanks!
I've not seen such an extension, you can search for one at the Adobe Exchange: http://www.adobe.com/go/exchange , however if there isn't one already available, which I suspect there isn't, it would be possible to write one of your own. The following links are for the extending Dreamweaver, and Dreamweaver extensibility APIs:
http://help.adobe.com/en_US/dreamweaver/cs/extend/index.html
http://help.adobe.com/en_US/dreamweaver/cs/apiref/index.html
In this particular case, I believe that you'd need to use an undocumented API call to communicate with an external process (in your case Ant), such as DWfile.runCommandLine() or MM.runCommandLine(). Paul Boon found these and blogged about them and a couple of others here:
http://communitymx.com/blog/index.cfm?newsid=179&blogger=35

grails: where can utility code be placed, that doesn't cause a container restart?

I'm wondering where utility code can be placed, that doesn't cause a restart of container. Updating controllers doesn't cause a container restart & the updated code is available to run (great), but I wanted a more general library/utility place for my utility code.
Putting the code in /utils or in src/groovy does cause a restart on save, at least using Intellij, but I imagine this is the same regardless of where Grails is developed.
Perhaps you have some general info/insights on how Grails does this -- includes new code but doesn't need to restart the container, if that's only special to controllers?
(v. 1.3.7)
You're out of luck out of the box unless you want to use 2.0. The alternative is to turn off auto-reloading and add in something like jrebel. See this blog for details.

Resources