UserInfo
1 import java.util.ArrayList;
2
3 public class UserInfo {
4 private ArrayList list;
5
6 private int id;
7
8 private String name;
9
10 public int getId() {
11 return id;
12 }
13
14 public void setId(int id) {
15 this.id = id;
16 }
17
18 public String getName() {
19 return name;
20 }
21
22 public void setName(String name) {
23 this.name = name;
24 }
25
26 public ArrayList getList() {
27 return list;
28 }
29
30 public void setList(ArrayList list) {
31 this.list = list;
32 }
33 }
34
GetObject
1
2
3 import java.util.ArrayList;
4 import javax.jws.WebMethod;
5 import javax.jws.WebService;
6 import javax.jws.soap.SOAPBinding;
7
8 @WebService(targetNamespace = "http://jdk.study.hermit.org/testobject")
9 @SOAPBinding(style = SOAPBinding.Style.RPC)
10 public class GetObject {
11 @WebMethod
12 public UserInfo getUserInfo(String name) {
13 UserInfo user = new UserInfo();
14 ArrayList<String> list =new ArrayList<String>();
15 list.add("123");
16 list.add("456");
17 list.add("789");
18 user.setList(list);
19 user.setId(1);
20 user.setName(name);
21 return user;
22 }
23
24 }
TestObject
1 package test;
2
3 import static org.junit.Assert.*;
4 import org.hermit.study.jdk.testobject.GetObject;
5 import org.hermit.study.jdk.testobject.GetObjectService;
6 import org.hermit.study.jdk.testobject.UserInfo;
7 import org.junit.Test;
8
9 public class TestObject {
10 @Test
11 public void getObject() {
12 GetObjectService service = new GetObjectService();
13 GetObject obj = service.getGetObjectPort();
14 UserInfo user = obj.getUserInfo("hermit");
15 assertNotNull(user.getId());
16 assertNotNull(user.getList());
17 assertEquals(user.getList().size(),3);
18 assertEquals(user.getList().get(0),"123");
19 assertEquals(user.getList().get(1),"456");
20 assertEquals(user.getList().get(2),"789");
21 assertEquals("hermit", user.getName());
22 }
23 }
测试通过
可见对象内的list是可以传递过来的。。。。。。。。。
posted on 2007-01-31 14:13
交口称赞 阅读(2922)
评论(8) 编辑 收藏 所属分类:
Java6