package net.xoetrope.data.test;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import junit.framework.TestCase;
import net.xoetrope.data.XDataSource;
import net.xoetrope.xui.XProject;
import net.xoetrope.xui.XProjectManager;
import net.xoetrope.xui.data.XModel;
/**
* <p>Title: Xui</p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) Xoetrope Ltd., 1998-2003</p>
* <p>Company: Xoetrope Ltd.</p>
* @author not attributable
* @version 1.0
*/
public class TestXDataSource extends TestCase
{
XProject currentProject;
public TestXDataSource( XProject project )
{
currentProject = project;
}
public void testCreateDataSource()
{
//FileInputStream fis = null;
BufferedReader isr = null;
XDataSource dataSource = null;
try {
isr = currentProject.getBufferedReader( "datasets.xml", null );
dataSource = new XDataSource( currentProject );
dataSource.read( isr );
}
catch ( Exception ex ) {
ex.printStackTrace();
}
/* End of setup */
XModel model = (XModel)XProjectManager.getModel().get( "base/coldroom/families" );
int numChildren = model.getNumChildren();
this.assertTrue( numChildren==3 );
for ( int i=0; i< numChildren; i++ ){
model.get( i ).get();
System.out.println( model.get( i ).getId() + ":" + model.get( i ).get() );
}
try {
FileOutputStream fos = new FileOutputStream( "C:\\cvs\\Xui\\Resource\\configres\\datasets.xml" );
OutputStreamWriter osw = new OutputStreamWriter( fos, "UTF8" );
BufferedWriter bw = new BufferedWriter( osw );
dataSource.write( bw );
}
catch ( IOException ex1 ) {
ex1.printStackTrace();
}
}
}