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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -38,10 +38,6 @@ import zutil.parser.wsdl.WSDLWriter;
|
|||
public class SOAPTest {
|
||||
/************************* TEST CASES ************************/
|
||||
public static void main(String[] args){
|
||||
new SOAPTest();
|
||||
}
|
||||
|
||||
public SOAPTest(){
|
||||
WebServiceDef wsDef = new WebServiceDef( MainSOAPClass.class );
|
||||
SOAPHttpPage soap = new SOAPHttpPage( wsDef );
|
||||
|
||||
|
|
@ -84,7 +80,7 @@ public class SOAPTest {
|
|||
public static class SpecialReturnClass extends WSReturnObject{
|
||||
@WSValueName(value="otherValue1")
|
||||
public String param1 = "otherValue1";
|
||||
@WSValueName("otherValue2")
|
||||
@WSValueName("otherName2")
|
||||
public String param2 = "otherValue2";
|
||||
public byte[] b = new byte[]{0x12, 0x23};
|
||||
public InnerClass inner = new InnerClass();
|
||||
|
|
@ -147,7 +143,7 @@ public class SOAPTest {
|
|||
@WSParamDocumentation("void method documentation")
|
||||
public void voidMethod (){ }
|
||||
|
||||
@WSDisabled()
|
||||
@WSIgnore()
|
||||
public void disabledMethod(){ }
|
||||
protected void protectedMethod(){ }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue