- Import your simple AMP project into Eclipse if you have not already done so, using the instructions in the tutorial Alfresco SDK with Eclipse as your guide.
There are two distributions of JRebel can that be installed at this point. You can choose to install a command line version, or a version integrated with your IDE. You will see how to run the command-line version of JRebel in this tutorial.
- If you do not already have JRebel installed, visit the official website and download the current stable version of JRebel. You will also need to obtain an activation key from ZeroTurnaround.
- Once downloaded, unzip JRebel into a suitable location, and then run bin/activate-gui.sh. In the dialog displayed, copy your activation key and then complete the registration.
You now need to make an addition to your MAVEN_OPTS
environment variable. Modify
your MAVEN_OPTS variable to include the following
additional option -javaagent:/path/to/jrebel/jrebel.jar.
Important: You will need to modify this option so that it reflects the actual location on your specific system where the jrebel.jar file is installed to.
Change into the simple-module-project directory and type the
following command to build and run your project:
mvn clean install -Pamp-to-war,radAttention: Note the use of the rad profile, which is used for Rapid Application Development.Attention: If you have correctly installed JRebel, and configured your MAVEN_OPTS correctly, you will see a number of JRebel monitoring messages in the terminal window.
- Once the application has fully started you can display http://localhost:8080/alfresco/service/index. This will provide validation that Alfresco is running.
- Load the file src/test/java/org/alfresco/demoamp/test/DemoComponentTest.java into an editor of your choice.
- Now you will introduce a deliberate error into the test code, and re-run the test. In the DemoComponentTest.java source code, locate the testGetCompanyHome() method.
Locate the following line of code:
assertEquals("Company Home", companyHomeName);
Change the code to the following:
assertEquals("Company Hotel", companyHomeName);
This will cause the test to fail when it is re-run.
Run the test.
After a short interval the test will fail.
- Change the code back to remove the error. Save your changes.
Re-run the test.
The test will run very quickly (without any reloading of the application server).