View Javadoc

1   package net.wotonomy.web.xml;
2   
3   
4   import java.io.Serializable;
5   import java.net.URL;
6   import java.util.Date;
7   
8   import junit.framework.TestCase;
9   
10  public class XMLRPCSelectorTest extends TestCase {
11  
12  	public XMLRPCSelectorTest(String name) {
13  		super(name);
14  	}
15  
16  	protected void setUp() throws Exception {
17  		super.setUp();
18  	}
19  
20  	protected void tearDown() throws Exception {
21  		super.tearDown();
22  	}
23  
24  	public static void testFoo(  )	{
25  		try
26  		{
27              // create url for server
28              URL url = new URL( "http://localhost:8080/xmlrpctest" );
29  
30              // set up selectors
31              XMLRPCSelector getFullName = 
32                  new XMLRPCSelector( "getFullName" );
33              XMLRPCSelector getCreateDate = 
34                  new XMLRPCSelector( "getCreateDate" );
35              XMLRPCSelector setCreateDate = 
36                  new XMLRPCSelector( "setCreateDate" );
37              XMLRPCSelector getChildList = 
38                  new XMLRPCSelector( "getChildList" );
39              XMLRPCSelector setChildList = 
40                  new XMLRPCSelector( "setChildList" );
41  
42              // fetch the full name
43              System.out.println( getFullName.invoke( url ) );
44  
45              // fetch the create date
46              System.out.println( getCreateDate.invoke( url ) );
47              // set date to current time
48              setCreateDate.invoke( url, new java.util.Date() );
49              // re-fetch the create date
50              System.out.println( getCreateDate.invoke( url ) );
51  
52              // fetch the child list
53              java.util.List childList = (java.util.List) getChildList.invoke( url );
54              System.out.println( childList );
55              // add a new child
56              childList.add( new MockSerializableObject(new Long(5),"John","Doe", new Date()) );
57              setChildList.invoke( url, childList );
58              // re-fetch the child list
59              System.out.println( getChildList.invoke( url ) );
60  		} 
61  		catch (Exception exc) 
62  		{
63              //exc.printStackTrace();
64  		}
65  	}
66  	
67  	public static class MockSerializableObject implements Serializable {
68  		public String firstname;
69  		public String lastname;
70  		public Long id;
71  		public Date aDate;
72  
73  		public MockSerializableObject(Long id, String firstname, String lastname, Date date) {
74  			super();
75  			aDate = date;
76  			this.firstname = firstname;
77  			this.id = id;
78  			this.lastname = lastname;
79  		}
80  		
81  	}
82  	
83  }