22 |
* -------------------------------------------------------------------------- |
* -------------------------------------------------------------------------- |
23 |
*/ |
*/ |
24 |
using System; |
using System; |
25 |
|
using System.Xml; |
26 |
using System.IO; |
using System.IO; |
27 |
|
using DotGNU.XmlRpc.Serialization.Formatters; |
28 |
|
|
29 |
namespace DotGNU.XmlRpc |
namespace DotGNU.XmlRpc |
30 |
{ |
{ |
34 |
{ |
{ |
35 |
public XmlRpcTester( string fileName ) |
public XmlRpcTester( string fileName ) |
36 |
{ |
{ |
37 |
|
MethodCallFormatter call = new MethodCallFormatter(); |
38 |
|
|
39 |
|
// Turn the xmlrpc stream into a XmlRpcMethod Object |
40 |
Console.Out.WriteLine( "Running test: {0}", fileName ); |
Console.Out.WriteLine( "Running test: {0}", fileName ); |
41 |
FileInfo fi = new System.IO.FileInfo( fileName ); |
FileStream fs = new FileStream( fileName, FileMode.Open ); |
42 |
StreamReader sr = fi.OpenText(); |
XmlRpcMethod method = (XmlRpcMethod)call.Deserialize( fs ); |
43 |
string buff = sr.ReadToEnd(); |
Console.Out.WriteLine( method ); |
44 |
XmlRpcReader reader = new XmlRpcReader( buff ); |
|
45 |
|
// Now convert it back using the c# serialization mechanism |
46 |
|
MemoryStream ms = new MemoryStream(); |
47 |
|
call.Serialize( ms, method ); |
48 |
|
ms.Seek( 0, 0 ); |
49 |
|
StreamReader sr = new StreamReader( ms ); |
50 |
|
Console.Out.WriteLine( sr.ReadToEnd() ); |
51 |
|
|
52 |
|
// Create and fire a bogus response |
53 |
|
XmlRpcResponse resp = new XmlRpcResponse(); |
54 |
|
int i = 1234567890; |
55 |
|
resp.Add( i ); |
56 |
|
|
57 |
|
MethodResponseFormatter response = new MethodResponseFormatter(); |
58 |
|
ms = new MemoryStream(); |
59 |
|
response.Serialize( ms, resp ); |
60 |
|
StreamReader sr2 = new StreamReader( ms ); |
61 |
|
ms.Seek( 0, 0 ); |
62 |
|
Console.Out.WriteLine( sr2.ReadToEnd() ); |
63 |
|
|
64 |
|
// Convert the response back into an XmlRpcResponse object |
65 |
|
ms.Seek( 0, 0 ); |
66 |
|
XmlRpcResponse r = (XmlRpcResponse)response.Deserialize( ms ); |
67 |
|
Console.Out.WriteLine( r ); |
68 |
} |
} |
69 |
|
|
70 |
public static void Main( string[] args ) |
public static void Main( string[] args ) |