01: package com.xoetrope.service.test;
02:
03: import junit.framework.TestCase;
04: import net.xoetrope.optional.data.XOptionalDataSource;
05: import net.xoetrope.optional.service.XRouteManager;
06: import net.xoetrope.optional.service.XServiceModelNode;
07: import net.xoetrope.xui.XProjectManager;
08: import net.xoetrope.xui.data.XModel;
09:
10: /**
11: * <p>Copyright (c) Xoetrope Ltd. 2001-2004</p>
12: * $Revision: 1.2 $
13: */
14: public class AvailabilityTest extends TestCase {
15: String defaultURLStr = "http://localhost:8080/xserviceservletError";
16:
17: public AvailabilityTest() {
18: XProjectManager.getCurrentProject().setStartupFile(
19: "xlib.properties");
20: readDataSource();
21: }
22:
23: public void testModelService() {
24: XRouteManager routeMgr = (XRouteManager) XProjectManager
25: .getCurrentProject().getObject("Routes");
26: XServiceModelNode node = new XServiceModelNode();
27:
28: try {
29: node = (XServiceModelNode) XModel.getInstance().get(
30: "calcArea64");
31: node.setAttribValue(0, "a");
32: node.setAttribValue(1, "b");
33: node.setAttribValue(2, "c");
34: Object result = node.get();
35: assertTrue(new Double(result.toString()).doubleValue() == 101.64);
36: } catch (Exception ex) {
37: ex.printStackTrace();
38: }
39: }
40:
41: public void testFallback() {
42: try {
43: XServiceModelNode node = (XServiceModelNode) XModel
44: .getInstance().get("getNameError");
45: Object result = node.get();
46: assertTrue(new Double(result.toString()).doubleValue() == 101.64);
47: } catch (Exception ex) {
48: ex.printStackTrace();
49: }
50:
51: }
52:
53: /**
54: * Read the model
55: * @param f the frame
56: */
57: private void readDataSource() {
58: String startupFile;
59: XOptionalDataSource modelDataSource;
60: try {
61: modelDataSource = new XOptionalDataSource();
62: } catch (Exception ex2) {
63: return;
64: }
65:
66: try {
67: String fileName = XProjectManager.getCurrentProject()
68: .getStartupParam("ModelData");
69: modelDataSource.read(XProjectManager.getCurrentProject()
70: .getBufferedReader(fileName, "UTF8"));
71: } catch (Exception ex) {
72: ex.printStackTrace();
73: }
74:
75: assertTrue(XModel.getInstance().getNumChildren() > 0);
76: }
77:
78: }
|