01: package net.xoetrope.data.test;
02:
03: import java.io.BufferedReader;
04: import java.io.BufferedWriter;
05: import java.io.FileInputStream;
06: import java.io.FileOutputStream;
07: import java.io.IOException;
08: import java.io.OutputStreamWriter;
09:
10: import junit.framework.TestCase;
11: import net.xoetrope.data.XDataSource;
12: import net.xoetrope.xui.XProjectManager;
13: import net.xoetrope.xui.XResourceManager;
14: import net.xoetrope.xui.data.XModel;
15:
16: /**
17: * <p>Title: Xui</p>
18: * <p>Description: </p>
19: * <p>Copyright: Copyright (c) Xoetrope Ltd., 1998-2003</p>
20: * <p>Company: Xoetrope Ltd.</p>
21: * @author not attributable
22: * @version 1.0
23: */
24:
25: public class TestXDataSource extends TestCase {
26: public TestXDataSource() {
27: }
28:
29: public void testCreateDataSource() {
30: FileInputStream fis = null;
31: BufferedReader isr = null;
32: XDataSource dataSource = null;
33: try {
34: isr = XResourceManager.getBufferedReader("datasets.xml",
35: null);
36: dataSource = new XDataSource();
37: dataSource.read(isr);
38: } catch (Exception ex) {
39: ex.printStackTrace();
40: }
41: /* End of setup */
42:
43: XModel model = (XModel) XProjectManager.getModel().get(
44: "base/coldroom/families");
45: int numChildren = model.getNumChildren();
46: this .assertTrue(numChildren == 3);
47: for (int i = 0; i < numChildren; i++) {
48: model.get(i).get();
49: System.out.println(model.get(i).getId() + ":"
50: + model.get(i).get());
51: }
52:
53: try {
54: FileOutputStream fos = new FileOutputStream(
55: "C:\\cvs\\Xui\\Resource\\configres\\datasets.xml");
56: OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF8");
57: BufferedWriter bw = new BufferedWriter(osw);
58: dataSource.write(bw);
59: } catch (IOException ex1) {
60: ex1.printStackTrace();
61: }
62: }
63: }
|