View
 

80legsprocesstest

Page history last edited by 80legs 1 year, 6 months ago

Table of Contents


 

Overview


80legsprocesstest.jar is a stand alone testing application to help you test your 80app.  You create a few files that contain page contents and the details about the page that you want to simulate and your jar is dynamically loaded by 80legsprocesstest and tested just like it will be used during a live job.

 

Downloading and Getting Started


  1. Download the latest 80legsProcessTest.jar from the download page of the code repository.  Remember where you save it (for this example, we will call it /data/80legsprocesstest.jar)
  2. Output the jar from your WebAnalysis project (for this example, we will call it /data/customcode.jar)
  3. (Optional) To prepare a page to test, first get the page contents:
    1. Open the page you want to test in a browser.
    2. Right-click and get the page source.
    3. Copy the contents of the page source into a new file (for this example, we will use /data/pagecontents.bin)
  4. (Optional) Prepare the parameter file that contains the information you want in your simulation (for this example, we will call the file /data/pageinfo.txt).  Add the following lines to the file:
    1. URL=<url of page>
    2. STATUS=<status string>  (e.g. 404 or 200)
    3. HEADER=<key>,<value>  (e.g., User-Agent,Mozilla/5.0 (compatible; 80bot/0.71; http://www.80legs.com/spider.html;) Gecko/2008032620) (repeats for each header you want to simulate)
  5. (Optional) Prepare any data you need to pass to your custom WebAnalysis.deserializeData() function (for this example, we will call it /data/customdata.bin)

 

Testing your WebAnalysis jar


  1. Open a new shell or command prompt (it should work in Windows, Linux, or Mac).
  2. Run the test:  java -Xmx256m -jar <80legs-process-test-jar> <test-jar-fileName> <optional-doc-info-fileName> <optional-doc-contents-fileName> <optional-data-fileName>
    1. Using our example filenames, this would be:  java -Xmx256m -jar /data/80legsprocesstest.jar /data/customcode.jar /data/pageinfo.txt /data/pagecontents.bin /data/customdata.bin (the last 3 arguments are optional)
    2. If you just want to see if your jar has the correct signatures without testing your functionality on real page contents use: java -Xmx256m -jar /data/80legsprocesstest.jar /data/customcode.jar
  3. The results that you return from your WebAnalysis.processDocument() function will be printed two ways:
    1. It will try to create a string from your returned byte[] and print it.  It is not necessary to have your resulting byte[] be a String, but since it is a common use case we try to print it that way.
    2. It will print the individual bytes returned from your function.
  4. Repeat as necessary to debug your code.
  5. When you are happy with the results, go ahead and upload it and try it out in the sandbox.

 

Testing your WebAnalysis jar WITH Live Server Security


If you are using 3rd party code (such as an XML parser) in your WebAnalysis JAR, you will probably have to test your code using the 80legs security policy.  If your code produces security-related exceptions, you may have to alter the 3rd party code in order to use it on the 80legs platform.

  1. Download this java.policy file, and place it in the same directory as 80legsProcessTest_0.83h.jar and your WebAnalysis JAR file.
  2. The java.policy file contains 2 lines that start with 'grant codeBase "file:/C:/test/'.  You will need to change 'C:/test/' on both of these lines to be the directory where your JAR files and the policy file are located.
  3. The java.policy file also contains a reference to '80legsProcessTest_0.83h.jar'.  You will need to change this text to match the name of the 80legsProcessTest JAR that you are using.
  4. Run the 80legsProcessTest (from the directory above) using this command:  java -Djava.security.manager -Djava.security.policy="java.policy" -jar 80legsProcessTest_x.xxx.jar <test-jar-fileName> <optional-doc-info-fileName> <optional-doc-contents-fileName> <optional-data-fileName>

Comments (0)

You don't have permission to comment on this page.