/*
* Name: BasicUnitTest
* Author: Richard Rodger
* Release: 0.3
*
* Copyright (c) 2002 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.unit.test;
/* Import << */
import org.jostraca.unit.BasicUnit;
import org.jostraca.unit.UnitOrigin;
import org.jostraca.unit.BasicUnitOrigin;
import org.jostraca.util.Standard;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
import java.util.Hashtable;
/* Import >> */
/** <b>Description:</b><br>
* Test cases for DateUtil.
*/
public class BasicUnitTest extends TestCase {
/* Test Framework << */
public BasicUnitTest( String pName ) {
super( pName );
}
public static TestSuite suite() {
return new TestSuite( BasicUnitTest.class );
}
public static void main( String[] pArgs ) {
TestRunner.run( suite() );
}
/* Test Framework >> */
/* Public Methods << */
public void testCreate() {
String t01 = "t01";
String s01 = "s01";
String c01 = "c01";
BasicUnit bu01 = new BasicUnit( t01, s01, c01 );
assertEquals( t01, bu01.getType() );
assertEquals( s01, bu01.getSection() );
assertEquals( c01, bu01.getContent() );
try {
bu01 = new BasicUnit( null, s01, c01 );
fail();
} catch( IllegalArgumentException iae ) {}
try {
bu01 = new BasicUnit( t01, null, c01 );
fail();
} catch( IllegalArgumentException iae ) {}
UnitOrigin uo = new BasicUnitOrigin();
bu01 = new BasicUnit( t01, s01, c01, uo );
assertEquals( uo, bu01.getOrigin() );
try {
bu01 = new BasicUnit( t01, s01, c01, null );
fail();
} catch( IllegalArgumentException iae ) {}
Hashtable ht = new Hashtable();
bu01 = new BasicUnit( t01, s01, c01, uo, ht );
assertEquals( ht, bu01.getAttributes() );
try {
bu01 = new BasicUnit( t01, s01, c01, uo, null );
fail();
} catch( IllegalArgumentException iae ) {}
}
public void testEmpty() {
String t01 = "t01";
String s01 = "s01";
String c01 = "c01";
BasicUnit bu01 = new BasicUnit( t01, s01, c01 );
UnitOrigin uo = bu01.getOrigin();
assertEquals( Standard.UNKNOWN, uo.getReference() );
Hashtable ht = bu01.getAttributes();
assertEquals( 0, bu01.getAttributes().size() );
BasicUnit bu02 = new BasicUnit( t01, c01, uo );
assertEquals( t01, bu02.getType() );
assertEquals( c01, bu02.getContent() );
assertEquals( Standard.EMPTY, bu02.getSection() );
assertEquals( uo, bu02.getOrigin() );
}
/* Public Methods >> */
}