/*
* Name: SimpleDataObjectReaderTest
* Authors: Richard Rodger
* Release: 0.3
*
* Copyright (C) 2001 Richard Rodger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
// package
package org.jostraca.resource.test;
/* Import << */
import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
import org.jostraca.resource.SimpleDataObject;
import org.jostraca.resource.SimpleDataObjectReader;
import org.jostraca.util.FileUtil;
/* Import >> */
/** <b>Description:</b><br>
* Test cases for org.jostraca.resource.SimpleDataObject
*/
public class SimpleDataObjectReaderTest extends TestCase {
public SimpleDataObjectReaderTest( String pName ) {
super( pName );
}
public static TestSuite suite() {
return new TestSuite( SimpleDataObjectReaderTest.class );
}
public static void main( String[] pArgs ) {
TestRunner.run( suite() );
}
public void testNameOnly() throws Exception {
String input = ""
+"\nPerson"
+"\nFirstName String"
+"\nSecondName String"
+"\nSalary int"
+"\n;"
+"\nCompany"
+"\nName String"
+"\nAddress String"
+"\n;\n "
;
FileUtil.writeFile("simpledataobjectschmematest.txt", input);
SimpleDataObject[] sdos = SimpleDataObjectReader.read( "simpledataobjectschmematest.txt" );
SimpleDataObject person = sdos[0];
SimpleDataObject company = sdos[1];
assertEquals( "Person", person.getName() );
assertEquals( "Company", company.getName() );
assertTrue( person.nextField() );
assertEquals( "FirstName", person.getFieldName() );
assertEquals( "String", person.getFieldType() );
assertTrue( person.nextField() );
assertEquals( "SecondName", person.getFieldName() );
assertEquals( "String", person.getFieldType() );
assertTrue( person.nextField() );
assertEquals( "Salary", person.getFieldName() );
assertEquals( "int", person.getFieldType() );
assertEquals( "false", ""+person.nextField() );
assertEquals( "true", ""+person.nextField() );
assertTrue( company.nextField() );
assertEquals( "Name", company.getFieldName() );
assertEquals( "String", company.getFieldType() );
assertTrue( company.nextField() );
assertEquals( "Address", company.getFieldName() );
assertEquals( "String", company.getFieldType() );
assertEquals( "false", ""+company.nextField() );
assertTrue( company.nextField() );
}
}