STest.java [test/service_tests] Revision: 48e524ffd9fcbfb36876707cdff3423aae1df8e9 Date: Wed Apr 20 16:33:25 MDT 2016
package service_tests;
import csip.test.ServiceTest2;
import java.io.File;
import java.util.Properties;
import org.codehaus.jettison.json.JSONArray;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
/**
*
* @author od
*/
public class STest {
@Rule
public TestName name = new TestName();
private void run() throws Exception {
String testFolder = new File(getClass().getCanonicalName().replace('.', '/')).getParent();
JSONArray r = ServiceTest2.run(new Properties(), "test/" + testFolder + "/" + name.getMethodName() + ".json");
Assert.assertTrue(r.getJSONObject(0).getInt("successful") == 1);
}
/*
1. Run a service against an endpoint.
2. If successful, store the response in 'tests/service_tests'
3. Name it : <servicepath>__<name>.json
Example:
The service response is 'alfafa.json' and ran
successfully against
http://csip.engr.colostate.edu/csip-erosion/m/weps/1.3
store this response as
tests/service_tests/m_weps_1_3__alfalfa.json
- replace '/' with '_'
- replace '.' with '_'
- separate both parts with '__'
4. Add a new JUnit test for this service to this file:
@Test public void m_weps_1_3__alfalfa() throws Exception {
run();
}
The test method name and the name of the json file
(without the extension) must match!
This is it!
*/
@Test public void m_nutrient_slp_1_0__moderate() throws Exception { run(); }
@Test public void m_ipmscoresfull_1_0_1__getfull() throws Exception { run(); }
@Test public void m_pestlosspot_1_0__test_1() throws Exception { run(); }
@Test public void m_pestipmscoresfull_1_0__test_1() throws Exception { run(); }
@Test public void m_pestmigtechsfull_1_0__test_1() throws Exception { run(); }
@Test public void m_pesticide_practice_score_1_0__test_1() throws Exception { run(); }
@Test public void m_sednutpractscoresfull_1_0__test_1() throws Exception { run(); }
// .. more here
}