How do I run unit tests against Akka Actors using Ant? - scala

I am in a project environment where Apache Ant is used exclusively to build, test, and deploy production application. I do not have control or influence over this, and it will not change. (ie. I cannot just switch to SBT for this application.)
I have inherited a Scala 2.9.3 application that I am upgrading to Scala 2.12.4. I'm also adding SBT and IDE (Intelli-J) support for LOCAL development, build, testing purposes.
I have everything working building, testing, running locally using ANT, SBT, and the IDE. I'm using scalatest 2.12.3 for most unit tests. But I've run into a problem trying to integrate the Akka Test Kit : https://doc.akka.io/docs/akka/2.5/testing.html
I am unable to create an Ant taskdef for running the tests.
How do I run unit tests against Akka Actors using Ant?
I can provide source code, as needed.
But I don't know how that will help, so please be specific if you want/need to see something.
Thanks!

Related

Going through Spring Test Data Geode but #EnableGemFireMockObjects annotation is not found

I spent a long time trying to run the example tests from here and here.
The #EnableGemFireMockObjects annotation cannot be found and neither can
import org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects;
The example tests don't run. Presumably this is missing a Gradle dependency but I can't find a Gradle example in the documentation.
The Spring Test for Apache Geode project (STDG) should build just fine, by running (from the project root directory)...
$ gradlew clean build install
STDG can also be built with Maven, hence the inclusion of a pom.xml file, by running...
$ mvn clean install
NOTE: If you build with Maven first and then later switch to building with Gradle, make sure to remove the target/ directly before building with Gradle.
Additionally, if you setup your IDE (e.g. IJ or STS) with the STDG project, importing from either the Maven or Gradle project models, after building (compiling) the STDG project, you should be able to run the Unit or Integration Tests individually from your IDE as well.
The Maven or Gradle files will ensure that your (test-time) classpath(s) are correct.
As for using STDG outside of the STDG project itself (the tests in STDG are not there for example, but there to test the functionality of STDG itself), see:
Spring Boot for Apache Geode (SBDG): https://github.com/spring-projects/spring-boot-data-geode. Specifically see the auto-configuration module test suite where STDG is used quite extensively.
Spring Session for Apache Geode (SSDG) also extensively uses the STDG project now to test Spring Session functionality with Apache Geode or Pivotal GemFire as the provider: https://github.com/spring-projects/spring-session-data-geode.
Eventually, I will be retrofitting the SDG test suite to use STDG as well, replacing the old test framework inside SDG on which STDG was founded.
Finally...
I did a presentation on the STDG project at the SpringOne Platform 2017 conference, the code of which is here:
https://github.com/jxblum/simplifying-apache-geode-with-spring-data
Here is 1 such test class from that example project:
https://github.com/jxblum/simplifying-apache-geode-with-spring-data/blob/master/simplifying-apachegeode-testing-springdata-complete/src/test/java/example/app/tests/SpringApacheGeodeConfigurationUnitTests.java
I have not updated the project in quite awhile, but is still mostly applicable. Use SBDG and SSDG test suites as definitive examples for using STDG.
Hope this helps.
Per Javalibs I needed to add
implementation 'org.springframework.data:spring-data-geode-test:0.0.11.RELEASE'
to gradle.build dependencies group.

is it possible to run geb-spock test on eclipse IDE

Using the junit runner, is it possible to run geb-spock test like a normal spock tests?
It seems that a stock eclipse installation can't do it and couldn't find any eclipse plugin to add the functionality.
I'm trying this using eclipse-oxygen latest.
To run Geb-Spock tests like a normal Spock test. (I am thinking you mean without initializing a browser.) Just extends Specification instead of extends GebSpec. Spock uses jUnit as the default test runner. So a Eclipse plugin for jUnit should work with Spock.

Scala IDEA and activator build the same project separately

I'm using IntellIj IDEA + scala + play2 plugins to develop my Play! application.
I enabled 'Auto make' option on IDEA and after the build is finished in IDEA, and when I try to run the application in activator console, it does the another build process on the console.
How can I make these two environment to share the build environment?

Automate JUnit tests for functionality on the server in Eclipse?

I would have added some JUnit tests to an Eclipse project that test functionality on the server to an Eclipse web project.
I can run the web application from inside Eclipse on an external Tomcat server (Run As | Run on Server) and then run the JUnit tests also from inside Eclipse while the first is still up.
I understand that is should be possible to fully automate both steps as one by making use of a Jetty (instead of Tomcat) server that runs inside Eclipse and that could be booted e.g. in #BeforeClass (or earlier).
Does Eclipse support this kind of unit testing out-of-the-box. I am currently using Eclipse Java EE IDE for Web Developers (Version: Kepler Service Release 2).
Eclipse (and any other IDE for that matter) doesn't stop you from doing anything in unit tests. It doesn't really support much, either, which is the core of your problem: Eclipse won't start a server for your unit tests. The same is true for all other IDEs that I know of.
Instead, you need to read up on how to embed Jetty in a Java application (= your unit tests) so the first test can start the server. Use a lazy init pattern for this:
private static JettyManager jetty;
#Before public void startServer() {
if( null == jetty ) {
jetty = new JettyManager();
jetty.start();
}
}
You can use a JVM shutdown hook to cleanly stop the server.
I use the same pattern to create the database which should be used during the tests to make sure it's clean. For this, I embed an H2 database.
If you want more automation, look at Maven. It can run integration tests (including deploying the WAR before starting the tests). See http://www.benoitschweblin.com/2013/03/run-jetty-in-maven-life-cycle.html
With the Maven Cargo plugin, you can deploy to almost every J2EE container.
Or use Jenkins: http://programmaticponderings.wordpress.com/2013/11/13/building-a-deployment-pipeline-using-git-maven-jenkins-and-glassfish-part-2-of-2/

Testing #RooJavaBean class in Eclipse IDE with JUnit

I use Spring Roo to generate getters/setters.
When I update my class under test and then run JUnit tests from Eclipse IDE (STS), it does't see changes I have made.
For example:
java.lang.NoSuchMethodError: com.example.web.forms.UserRegistrationForm_Roo_JavaBean.ajc$interMethodDispatch1$com_datefitting_web_forms_UserRegistrationForm_Roo_JavaBean$com_example_web_forms_UserRegistrationForm$setName(Lcom/datefitting/web/forms/UserRegistrationForm;Ljava/lang/String;)V`
After running roo>perform tests everything runs fine even in IDE. In project settings there is AspectJ builder.
How to run JUnit tests of #RooJavaBean annotated class in IDE, without invoking mvn test or roo>perform tests?
Is the Roo shell open in STS while you are running? In order for your aspects to be recreated based on changes to the target types, the Roo shell must be running in the IDE. If it is running on the command line (from outside the IDE), STS will not be made aware that changes have been made to aspects and it will not be picked up in your project.