Steve Taylor wrote:
> Hi,
> 
> This is probably down to my inexperience with coding Java and
> learning
> the BASE API but with regards to testing the plugin during development,
> do I have to use the GUI to run the plugin each time or
> are there any tricks/hints people can recommend so I can test the
> plugin, say from the command line? For example, a typical cycle for me is:
> 
> 1) Write some plugin code
> 2) Compile it
> 3) Restart Tomcat for plugin code to take effect
> 4) Login again
> 5) Find experiment/bioassay
> 6) Run plugin
> 7) Check to see if code does what I think it should!

I recognise this pattern... We often have to do the same thing when 
testing our own plug-ins or changes in the core.

I have a few tips:

1)
If you have compiled your plug-in into a JAR file and placed it outside 
Tomcat's classpath (that is, NOT in the www/WEB-INF/lib) directory, you 
can replace 3, 4 and 5 with:

 From the Administrate -> Plugins -> Definitions list select your 
plug-in by marking the checkbox and then click the Unload button. The 
next time you run your plug-in the new code will be used. You can have 
the plug-in list open in a separate window, so you don't have to move 
between the list and the experiment.

(Just came up with the idea that we could use the timestamp of the JAR 
file to implement automatic unload... I'll try to include it in the 2.4 
relase.)

2)
It is possible for you create a test program that can be invoked from 
the command line. This will be easier if you have separated the code 
that does the actual work from the plug-in specific code. Check the code 
for the ZipFileUnpacker for a real example:
http://base.thep.lu.se/browser/trunk/src/plugins/core/net/sf/basedb/plugins/ZipFileUnpacker.java

The test program could then look something like:

   // Create SessionControl and log in to BASE
   // User and password can probably be hardcoded

   // Find your data/experiment/bioassay
   // Use hardcoded ID for simplest code or do a query by name

   MyPlugin p = new MyPlugin();
   p.doTheWork(DbControl, BioAssaySet, anotherParam, anotherOption)

   // display results -- or use web interface to check it out
   // clean up and exit

This setup should work well as long as you only use it locally and 
already has data to test it with. If you need to test on any server 
where you don't know if there is any data or not it is going to be harder.

Check for example the (brand new) test program for the
BioAssaySetExporter at 
http://base.thep.lu.se/browser/trunk/src/test/TestBioAsssaySetExporter.java

It creates an experiment, raw data sets, etc. and does some analysis 
before the actual testing of the exporter can take place. Afterwards it 
has to clean up everything it has created to leave the database as it 
was before the test.

/Nicklas


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
basedb-devel mailing list
basedb-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/basedb-devel

Reply via email to