You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nutch.apache.org by Apache Wiki <wi...@apache.org> on 2008/07/17 23:12:40 UTC

[Nutch Wiki] Update of "WritingPluginExample-0.9" by PatrickMarkiewicz

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Nutch Wiki" for change notification.

The following page has been changed by PatrickMarkiewicz:
http://wiki.apache.org/nutch/WritingPluginExample-0%2e9

------------------------------------------------------------------------------
  
  == Unit testing ==
  
- We'll need to create two files for unit testing:  a page we'll do the testing against, and a class to do the testing with.  Again, let's assume your plug in directory is [!YourCheckoutDir]/src/plugin and that your test plugin is under directory.  Create directory recommended/data, and under it make a new file called recommended.html
+ We'll need to create two files for unit testing:  a page we'll do the testing against, and a class to do the testing with.  Again, let's assume your plugin directory is [!YourCheckoutDir]/src/plugin and that your test plugin is under that directory.  Create directory recommended/data, and under it make a new file called recommended.html
  
  {{{
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
@@ -392, +392 @@

  
  As you can see, this code first parses the document, looks for the '''Recommended''' item in the object contentMeta - which we saved on RecommendedParser - and verifies that it's set to value '''recommended-content'''.  
  
+ Now add some lines to the build.xml file located in [!YourCheckoutDir]/src/plugin/recommended directory, so that at a minimum its contents are:
+ {{{
+ <?xml version="1.0"?>
+ 
+ <project name="recommended" default="jar">
+ 
+   <import file="../build-plugin.xml"/>
+ 
+   <!-- for junit test -->
+   <mkdir dir="${build.test}/data"/>
+   <copy file="data/recommended.html" todir="${build.test}/data"/>
+ 
+ </project>
+ }}}
+ These lines will copy the test data to the proper directory for testing.
+ 
  To run the test case, simply move back to your plugin's root directory and execute
  
  {{{