📄 abstracttestquery1.java
字号:
/*
(c) Copyright 2003, 2004, 2005, 2006, 2007 Hewlett-Packard Development Company, LP
[See end of file]
$Id: AbstractTestQuery1.java,v 1.8 2007/01/02 11:50:15 andy_seaborne Exp $
*/
package com.hp.hpl.jena.db.test;
import com.hp.hpl.jena.graph.*;
import com.hp.hpl.jena.graph.test.*;
import com.hp.hpl.jena.graph.query.*;
import com.hp.hpl.jena.shared.*;
import com.hp.hpl.jena.util.iterator.*;
import com.hp.hpl.jena.graph.impl.*;
import com.hp.hpl.jena.vocabulary.RDF;
import java.util.*;
import junit.framework.*;
/**
Abstract tests for graph query, parameterised on getGraph().
@author kers
*/
public abstract class AbstractTestQuery1 extends GraphTestBase
{
public AbstractTestQuery1(String name)
{ super(name); }
public static TestSuite suite()
{ return new TestSuite( AbstractTestQuery1.class ); }
public abstract Graph getGraph();
public abstract Graph getGraph( ReificationStyle style );
// in the stmt strings below, L indicates a long (object or predicate)
// L, if specifed, MUST precede the URI. for the object, a prefix of
// U indicates a reference (URI). otherwise, the object is considered
// a literal string. if the string begins with R, it is treated as
// a reified statement with 4 tokens, where the first is the URI that
// reifies the subsequent statement.
// the database has the following pattern.
protected String[] statementList = {
// metadata about properties
"Pname Pcard O1",
"Psex Pcard O1",
"Pdept Pcardmax O5",
"Pmgr Pcardmax O1",
"Ptitle Pcardmax O5",
"Pname Prange Oliteral",
"Psex Prange Oliteral",
"Pdept Prange Oliteral",
"Pmgr Prange Oresource",
"Ptitle Prange Oliteral",
"S1 Pname Omm",
"S1 Psex Omale",
"S1 Pdept Ojena",
"S1 Pdept Oapp",
"S1 Pmgr US4",
"S1 Ptitle Oboss",
"S2 Pname Obb",
"S2 Psex Omale",
"S2 Pdept Ogenesis",
"S2 Pdept Oapp",
"S2 Pmgr US4",
"S2 Ptitle Oboss",
"S3 Pname Ojb",
"S3 Psex Ofemale",
"S3 Pdept Oapp",
"S3 Pmgr US1",
"S3 Ptitle Oboss",
"S4 Pname Odick",
"S4 Psex Omale",
"S4 Pmgr Oshane",
"S4 Ptitle Obigboss",
"S5 Pname Okers",
"S5 Psex Omale",
"S5 Pdept Ojena",
"S5 Pdept Ordql",
"S5 Pmgr US1",
"S5 Ptitle Ogrunt",
"S6 Pname Ojjc",
"S6 Psex Omale",
"S6 Pdept Ojena",
"S6 Pdept Ordf",
"S6 Pdept Oowl",
"S6 Pmgr US1",
"S6 Ptitle Ogrunt",
"S7 Pname Oder",
"S7 Psex Omale",
"S7 Pdept Ojena",
"S7 Pdept Ordf",
"S7 Pdept Oowl",
"S7 Pmgr US1",
"S7 Ptitle Ogrunt",
"S7 Ptitle Oboss",
"S8 Pname Obmk",
"S8 Psex Omale",
"S8 Pdept Ojena",
"S8 Pdept Ordf",
"S8 Pmgr US1",
"S8 Ptitle Ogrunt",
"S8 Ptitle Oboss",
"S9 Pname Oas",
"S9 Psex Omale",
"S9 Pdept Ojena",
"S9 Pdept Ordf",
"S9 Pdept Ordql",
"S9 Pmgr US1",
"S9 Ptitle Ogrunt",
"S10 Pname Oian",
"S10 Psex Omale",
"S10 Pdept Ojena",
"S10 Pdept Oowl",
"S10 Pmgr US1",
"S10 Ptitle Ogrunt",
"S11 Pname Osteveb",
"S11 Psex Omale",
"S11 Pdept Oapp",
"S11 Pmgr US3",
"S11 Ptitle Ogrunt",
"S12 Pname Ostevec",
"S12 Psex Omale",
"S12 Pdept Oapp",
"S12 Pmgr US3",
"S12 Ptitle Ogrunt",
"S13 Pname Ocs",
"S13 Psex Omale",
"S13 Pdept Ojena",
"S13 Pdept Ogenesis",
"S13 Pmgr US2",
"S13 Ptitle Ogrunt",
"S14 Pname Ohk",
"S14 Psex Ofemale",
"S14 Pdept Oapp",
"S14 Pdept Ogenesis",
"S14 Pmgr US2",
"S14 Ptitle Ogrunt",
"S15 Pname Oks",
"S15 Psex Omale",
"S15 Pdept Oapp",
"S15 Pdept Ogenesis",
"S15 Pmgr US2",
"S16 Pname Owkw",
"S16 Psex Omale",
"S16 Pdept Ojena",
"S16 Pdept Oapp",
"S16 Pmgr US2",
"S16 Ptitle Ogrunt",
// reify the first few sets of statements
"N1 S1 Pname Omm",
"N2 S1 Psex Omale",
"N3 S1 Pdept Ojena",
"N4 S1 Pdept Oapp",
"N5 S1 Pmgr US4",
"N6 S1 Ptitle Oboss",
"N7 S2 Pname Obb",
"N8 S2 Psex Omale",
"N9 S2 Pdept Ogenesis",
"N10 S2 Pdept Oapp",
"N11 S2 Pmgr US4",
"N12 S2 Ptitle Oboss",
"N13 S3 Pname Ojb",
"N14 S3 Psex Ofemale",
"N15 S3 Pdept Oapp",
"N16 S3 Pmgr US1",
"N17 S3 Ptitle Oboss",
"N18 S4 Pname Odick",
"N19 S4 Psex Omale",
"N20 S4 Pmgr Oshane",
"N21 S4 Ptitle Obigboss",
"N22 S5 Pname Okers",
"N23 S5 Psex Omale",
"N24 S5 Pdept Ojena",
"N25 S5 Pdept Ordql",
"N26 S5 Pmgr US1",
"N27 S5 Ptitle Ogrunt",
};
public void setUp() throws Exception
{
super.setUp();
}
protected Graph standard()
{ return fetchGraph( ReificationStyle.Standard ); }
protected Graph convenient()
{ return fetchGraph( ReificationStyle.Convenient ); }
protected Graph fetchGraph( ReificationStyle style )
{ Graph s = getGraph( style );
loadGraph( s );
return s; }
protected void tearDown() throws Exception {
super.tearDown();
}
/**
The lots-of-dots prefix to use to make things long
*/
protected final String longPrefix = makeLongPrefix();
/**
Answer a string of 256 dots.
*/
private String makeLongPrefix()
{ StringBuffer sb = new StringBuffer( 256 );
for (int i = 0; i < 256; i += 1) sb.append( '.' );
return sb.toString(); }
protected Node makeResource ( String u )
{ return Node.createURI( expandLong( u ) ); }
protected Node makeObject ( String u ) {
boolean isRef = u.charAt(0) == 'U';
return
isRef ? makeResource( u.substring(1) )
: Node.createLiteral( new LiteralLabel( expandLong( u ) ) );
}
protected String expandLong( String s )
{ return s.charAt(0) == 'L' ? longPrefix + s.substring(1) : s; }
static int stmtCnt = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -