package com.ricebridge.xmlman.in.test;
import com.ricebridge.xmlman.*;
import com.ricebridge.xmlman.in.*;
import org.jostraca.util.*;
import junit.framework.*;
import junit.textui.*;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.parsers.SAXParser;
import java.util.*;
import java.io.*;
public class AttributeTest extends TestCase {
public AttributeTest( String pAttribute ) {
super( pAttribute );
}
public static TestSuite suite() {
return new TestSuite( AttributeTest.class );
}
public static void main( String[] pArgs ) {
TestRunner.run( suite() );
}
private static ArrayList sRecordSpecList = new ArrayList();
private static ArrayList sRecordDataList = new ArrayList();
static {
sRecordSpecList.add( new RecordSpec( "/root/foo", new String[] { "@name", "@bar", "que" } ) );
sRecordDataList.add( ListUtil.make( new String[] { "foo", "", "q1" },
new String[] { "foobar", "yes", "" },
new String[] { "barfoo", "", "" },
new String[] { "quebarfoo", "", "" },
new String[] { "lastfoo", "", "" } ) );
sRecordSpecList.add( new RecordSpec( "//foo", new String[] { "@name", "@bar", "que" } ) );
sRecordDataList.add( ListUtil.make( new String[] { "foo", "", "q1" },
new String[] { "foobar", "yes", "" },
new String[] { "barfoo", "", "" },
new String[] { "quebarfoo", "", "" },
new String[] { "lastfoo", "", "" } ) );
sRecordSpecList.add( new RecordSpec( "//foo[@bar='yes']", new String[] { "@name" } ) );
sRecordDataList.add( ListUtil.make( new String[] { "foobar" } ) );
sRecordSpecList.add( new RecordSpec( "//foo[@bar]", new String[] { "@name" } ) );
sRecordDataList.add( ListUtil.make( new String[] { "foobar" } ) );
sRecordSpecList.add( new RecordSpec( "//foo[not(@bar)]", new String[] { "@name" } ) );
sRecordDataList.add( ListUtil.make( new String[] { "foo" },
new String[] { "barfoo" },
new String[] { "quebarfoo" },
new String[] { "lastfoo" } ) );
sRecordSpecList.add( new RecordSpec( "//foo[@bar and @name]", new String[] { "@name" } ) );
sRecordDataList.add( ListUtil.make( new String[] { "foobar" } ) );
sRecordSpecList.add( new RecordSpec( "//foo[@name='lastfoo']", new String[] { "@name", "baz[1]/@name" } ) );
sRecordDataList.add( ListUtil.make( new String[] { "lastfoo", "baz1" } ) );
sRecordSpecList.add( new RecordSpec( "//foo[@name='lastfoo']", new String[] { "@name", "baz[2]/@name" } ) );
sRecordDataList.add( ListUtil.make( new String[] { "lastfoo", "baz2" } ) );
sRecordSpecList.add( new RecordSpec( "//foo[@name='lastfoo']", new String[] { "@name", "baz/@name" } ) );
sRecordDataList.add( ListUtil.make( new String[] { "lastfoo", "baz2" } ) );
sRecordSpecList.add( new RecordSpec( "//foo[bar]", new String[] { "@name" } ) );
sRecordDataList.add( ListUtil.make( new String[] { "barfoo" },
new String[] { "quebarfoo" }
) );
sRecordSpecList.add( new RecordSpec( "//foo[not(bar)]", new String[] { "@name" } ) );
sRecordDataList.add( ListUtil.make( new String[] { "foo" },
new String[] { "foobar" },
new String[] { "lastfoo" } ) );
sRecordSpecList.add( new RecordSpec( "//foo[bar and que]", new String[] { "@name" } ) );
sRecordDataList.add( ListUtil.make( new String[] { "quebarfoo" } ) );
sRecordSpecList.add( new RecordSpec( "//foo[@name='lastfoo']", new String[] { "@name",
"baz[bat]/@name",
"baz[bat]/noo[nam]/@name",
"baz[bat]/noo/@name",
"baz/noo/@name",
".//baz[bat]/@name",
".//baz[bat]//noo[nam]/@name",
".//baz[bat]//noo/@name",
".//baz//noo/@name",
"//baz[bat]/@name",
"//baz[bat]//noo[nam]/@name",
"//baz[bat]//noo/@name",
"//baz//noo/@name"
} ) );
sRecordDataList.add( ListUtil.make( new String[] { "lastfoo", "baz2", "noo1", "noo1", "noo1",
"baz2", "noo1", "noo1", "noo1",
"baz2", "noo1", "noo1", "noo1"
} ) );
}
public void testVariable() throws Exception {
TestUtil.testRecords( "com/ricebridge/xmlman/in/test/attribute.xml", sRecordSpecList, sRecordDataList, this );
}
}