Some refactoring and added some JUnit tests
This commit is contained in:
parent
d107cd504c
commit
24c4fac26d
13 changed files with 168 additions and 100 deletions
49
test/zutil/net/ws/rest/RestHttpPageTest.java
Executable file
49
test/zutil/net/ws/rest/RestHttpPageTest.java
Executable file
|
|
@ -0,0 +1,49 @@
|
|||
package zutil.net.ws.rest;
|
||||
|
||||
import org.junit.Test;
|
||||
import zutil.net.ws.WSInterface;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Ziver on 2016-09-27.
|
||||
*/
|
||||
public class RestHttpPageTest {
|
||||
|
||||
public static class TestClass implements WSInterface{
|
||||
public String hello(){
|
||||
return "hello world";
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noInput() throws Throwable {
|
||||
RestHttpPage rest = new RestHttpPage(new TestClass());
|
||||
|
||||
HashMap<String,String> input = new HashMap<>();
|
||||
String output = rest.execute("hello", input);
|
||||
assertEquals("\"hello world\"\n", output);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static class TestEchoClass implements WSInterface{
|
||||
public String echo(@WSParamName("input") String input){
|
||||
return "echo: "+input;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void oneInput() throws Throwable {
|
||||
RestHttpPage rest = new RestHttpPage(new TestEchoClass());
|
||||
|
||||
HashMap<String,String> input = new HashMap<>();
|
||||
input.put("input", "test input");
|
||||
String output = rest.execute("echo", input);
|
||||
assertEquals("\"echo: test input\"\n", output);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue