At line 1 changed 1 line. |
[AppFuse], by default, is configured to be an [Eclipse|http://www.eclipse.org] project. When you run __ant new -Dapp.name=''yourApp'' -Ddb.name=''yourDatabase''__ you will get the .project and .classpath files to start your project with. However, you will need to make a few easy setting changes in Eclipse (particularly to run [Ant|http://jakarta.apache.org/ant]). This tutorial shows you how to setup Eclipse to develop your AppFuse project. |
[AppFuse], by default, is configured to be an [Eclipse|http://www.eclipse.org] project. When you run __ant new__ to create a new project, you will get the .project and .classpath files to start your project with. However, you will need to make a few easy setting changes in Eclipse (particularly to run [Ant|http://jakarta.apache.org/ant]). This tutorial shows you how to setup Eclipse to develop your AppFuse project. |
At line 30 added 8 lines. |
Next, add the __catalina-ant.jar__ (from $CATALINA_HOME/server/lib) to the ant classpath. Then in the property tab, add __tomcatTasks.properties__ (in lib/ant-contrib) file as a global properties file. |
|
Lastly, still in Ant - Runtime - Properties tab, add the global property "tomcat.home" with a value of your CATALINA_HOME environment variable. |
|
Below is a screenshot of what your Ant Runtime classpath should look like after the above modifications: |
|
[ant-runtime.png] |
|
At line 38 changed 1 line. |
At this point, you should see something similar to the screenshot below. |
Now if you run the "compile" target and then refresh the project (right-click on project → Refresh) you shouldn't see any errors in the "Problems" pane. You should now be able to compile and create classes as you normally would. Sometimes when my imports aren't resolving correctly in Eclipse, I do have to run Project → Clean in Eclipse. |
At line 40 changed 3 lines. |
[ant-targets.png] |
|
__WARNING:__ If you're using the internal version of Ant, you may get an error message like the one below: |
%%note __NOTE:__ If you're using the internal version of Ant, you may get an error message like the one below: |
At line 47 changed 1 line. |
}}} |
}}}%% |
At line 51 changed 2 lines. |
!!Run JUnit Tests in Eclipse [#6] |
It's also possible to run your JUnit tests in Eclipse. I should note that if you're running an ActionTest, you'll need to execute "ant deploy-test-war" and then start Tomcat before running them. To configure Eclipse to run AppFuse's JUnit Tests, all you need to do is define a J2EE_HOME variable. To do this, go to Window → Preferences → Java → Classpath Variables. Add a new variable called J2EE_HOME and point it to the location where you have the [J2EE SDK|http://java.sun.com/j2ee/download.html#sdk] installed. AppFuse already has its classpath configured (in the .classpath file) to include J2EE_HOME/lib/j2ee.jar. |
At this point, you should see something similar to the screenshot below. |
At line 54 changed 1 line. |
Also, before running any JUnit Tests in Eclipse, you need to run "ant test-all" from the command line. After you have successfully done so, in Eclipse open a test you'd like to run (i.e. UserDaoTest) and go to Run → Debug As → JUnit Test. If this doesn't work, make sure you have AppFuse 1.0.1+ |
[ant-targets.png] |
At line 56 changed 2 lines. |
!!Tips for Debugging and UI Editing [#7] |
For debugging, I use the [Tomcat Plugin|http://www.sysdeo.com/eclipse/tomcatPlugin.html] in Eclipse and set breakpoints. For little changes, I use "ant deploy-web" which only takes a couple of seconds. For truly minor tweaks, it's sometimes easier to edit the file in Tomcat's webapps folder. For major design changes, I usually run the app, view source on a page and save it to a "sandbox" folder in the same directory as my project. Then I do a find/replace and change all "/appfuse/" references to "../web/". This allows me to change CSS and JS files and just refresh the file in the sandbox. |
!!Run JUnit Tests in Eclipse [#5] |
It's also possible to run your JUnit tests in Eclipse. But before running them, you need to run the "war" target. After this target completes, refresh your project. |
At line 64 added 1 line. |
After you have successfully done so, in Eclipse open a test you'd like to run (i.e. UserDaoTest) and go to Run → Debug As → JUnit Test. Note that you may have to run the "db-load" target before you run your tests every so often. I did have the following method in the Base*TestCase class for each layer, but this caused DBUnit to reload the database before every test in a Test class. Removing it reduces the execution time of "test-all" by more than 30 seconds. |
At line 66 added 21 lines. |
[{Java2HtmlPlugin |
|
protected void setUp() throws Exception { |
DataSource ds = (DataSource) ctx.getBean("dataSource"); |
IDatabaseConnection conn = new DatabaseConnection(ds.getConnection()); |
IDataSet dataSet = |
new XmlDataSet(new FileInputStream("metadata/sql/sample-data.xml")); |
// clear table and insert only sample data |
DatabaseOperation.CLEAN_INSERT.execute(conn, dataSet); |
conn.close(); |
} |
}] |
|
If the instructions above don't work for running JUnit tests in Eclipse, I suggest just using the command line - i.e. __ant test-dao -Dtestcase=UserDAO__. Running tests from the command line ''always'' works. ;-) |
|
!!Tips for Debugging and UI Editing [#6] |
For debugging, I use the [Tomcat Plugin|http://www.sysdeo.com/eclipse/tomcatplugin] in Eclipse and set breakpoints. To make the breakpoints work you will need to indicate your source-path using the Eclipse menu {{Window->Preferences}}, select {{Tomcat}}, then {{Source Path}}. |
|
For little changes, I use "ant deploy-web" which only takes a couple of seconds. For truly minor tweaks, it's sometimes easier to edit the file in Tomcat's webapps folder. For major design changes, I usually run the app, view source on a page and save it to a "sandbox" folder in the same directory as my project. Then I do a find/replace and change all "/appfuse/" references to "../web/". This allows me to change CSS and JS files and just refresh the file in the sandbox. |
|
|