01: package com.xoetrope.service.test;
02:
03: import net.xoetrope.optional.service.XRouteManager;
04: import net.xoetrope.optional.service.XServiceModelNode;
05: import net.xoetrope.xui.data.XModel;
06: import net.xoetrope.xui.XProjectManager;
07:
08: /**
09: * Test the unreliable service servelt to see that it returns the expected errors
10: * <p>Copyright (c) Xoetrope Ltd. 2001-2004</p>
11: * $Revision: 1.2 $
12: */
13: public class XUnreliableServiceTest extends XServiceTest {
14: public XUnreliableServiceTest() {
15: super ();
16: defaultURLStr = "http://localhost:8080/xunreliableservlet";
17: }
18:
19: /*
20: public void testServer()
21: {
22: XServiceModelNode node = new XServiceModelNode();
23: XHttpClientServiceProxy s = new XHttpClientServiceProxy();
24: s.setUrl( defaultURLStr );
25: s.setRouteName( "remote" );
26: String[] argNames = { "reliability" };
27: node.setupService( "getName", s, argNames );
28: // A normal request
29: node.setAttribValue( 0, Integer.toString( XUnreliableServiceServlet.RELIABLE ).toString());
30: Object result = node.get();
31: assertTrue( result.toString().compareTo( CalcTestService.class.getName()) == 0 );
32: int responseLength = result.toString().length();
33: node.setAttribValue( 0, Integer.toString( XUnreliableServiceServlet.PARTIAL_RESPONSE ).toString());
34: Object partialResult = node.get();
35: assertTrue( partialResult.toString().length() == responseLength / 2 );
36: // Finish up with a reliable request to reset the reliability flag
37: node.setAttribValue( 0, Integer.toString( XUnreliableServiceServlet.RELIABLE ).toString());
38: result = node.get();
39: assertTrue( result.toString().compareTo( CalcTestService.class.getName()) == 0 );
40: }*/
41:
42: public void testMultiRouteService() {
43: assertTrue(XModel.getInstance().getNumChildren() > 0);
44:
45: XServiceModelNode node = new XServiceModelNode();
46: try {
47: XRouteManager routeMgr = (XRouteManager) XProjectManager
48: .getCurrentProject().getObject("Routes");
49: node.setupService("getName64", routeMgr.getRoute(
50: "redundantRoute",
51: "com.xoetrope.service.test.CalcTestService"), null);
52: Object result = node.get();
53: assertTrue(result != null);
54: assertTrue(result.toString().compareTo(
55: CalcTestService.GET_NAME_64) == 0);
56: } catch (Exception e) {
57: e.printStackTrace();
58: }
59: }
60: }
|