📄 regression.java
字号:
n++; if (! tv.isAnon()) error(test, n);
n++; if (! m.contains(tv, RDF.type, RDF.Alt)) error(test,n);
uri = "http://aldabaran/foo";
n++; tv = m.createAlt(uri);
n++; if (! tv.getURI().equals(uri)) error(test, n);
n++; if (! m.contains(tv, RDF.type, RDF.Alt)) error(test,n);
} catch (Exception e) {
error(test, n, e);
}
try {
Seq tv;
n = 520;
n++; tv = m.createSeq();
n++; if (! tv.isAnon()) error(test, n);
n++; if (! m.contains(tv, RDF.type, RDF.Seq)) error(test,n);
uri = "http://aldabaran/foo";
n++; tv = m.createSeq(uri);
n++; if (! tv.getURI().equals(uri)) error(test, n);
n++; if (! m.contains(tv, RDF.type, RDF.Seq)) error(test,n);
} catch (Exception e) {
error(test, n, e);
}
}
} catch (Exception e) {
logger.error( "test " + test + "[" + n + "]", e );
errors = true;
}
// System.out.println("End of " + test);
}
/** Test model add and contains methods
* @param m the model implementation under test
*/
public void test3(Model m) {
String test = "Test3";
int n = 0;
try {
boolean tvBoolean = true;
byte tvByte = 1;
short tvShort = 2;
int tvInt = -1;
long tvLong = -2;
char tvChar = '!';
float tvFloat = (float) 123.456;
double tvDouble = -123.456;
String tvString = "test string";
String lang = "en";
LitTestObj tvObject = new LitTestObj(12345);
Literal tvLiteral = m.createLiteral("test string 2");
Resource tvResource = m.createResource();
Resource subject = m.createResource();
// System.out.println("Beginning " + test);
try {
n=100;
n++; m.add(subject, RDF.value, tvResource);
n++; if (! m.contains(subject,RDF.value,tvResource))
error(test,n);
} catch (Exception e) {
error(test, n, e);
}
try {
n=110;
n++; m.add(subject, RDF.value, tvLiteral);
n++; if (! m.contains(subject,RDF.value,tvLiteral))
error(test,n);
} catch (Exception e) {
error(test, n, e);
}
try {
n=120;
n++; m.add(subject, RDF.value, tvByte);
n++; if (! m.contains(subject,RDF.value,tvByte))
error(test,n);
} catch (Exception e) {
error(test, n, e);
}
try {
n=130;
n++; m.add(subject, RDF.value, tvShort);
n++; if (! m.contains(subject,RDF.value,tvShort))
error(test,n);
} catch (Exception e) {
error(test, n, e);
}
try {
n=140;
n++; m.add(subject, RDF.value, tvInt);
n++; if (! m.contains(subject,RDF.value,tvInt))
error(test,n);
} catch (Exception e) {
error(test, n, e);
}
try {
n=150;
n++; m.add(subject, RDF.value, tvLong);
n++; if (! m.contains(subject,RDF.value,tvLong))
error(test,n);
} catch (Exception e) {
error(test, n, e);
}
try {
n=160;
n++; m.add(subject, RDF.value, tvChar);
n++; if (! m.contains(subject,RDF.value,tvChar))
error(test,n);
} catch (Exception e) {
error(test, n, e);
}
try {
n=170;
n++; m.add(subject, RDF.value, tvFloat);
n++; if (! m.contains(subject,RDF.value,tvFloat))
error(test,n);
} catch (Exception e) {
error(test, n, e);
}
try {
n=180;
n++; m.add(subject, RDF.value, tvDouble);
n++; if (! m.contains(subject,RDF.value,tvDouble))
error(test,n);
} catch (Exception e) {
error(test, n, e);
}
try {
n=190;
n++; m.add(subject, RDF.value, tvObject);
n++; if (! m.contains(subject,RDF.value,tvObject))
error(test,n);
} catch (Exception e) {
error(test, n, e);
}
try {
n=200;
n++; m.add(subject, RDF.value, tvString);
n++; if (! m.contains(subject,RDF.value,tvString))
error(test, n);
n++; if ( m.contains(subject, RDF.value, tvString, lang))
error(test,n);
n++; m.add(subject, RDF.value, tvString, lang);
n++; if (! m.contains(subject, RDF.value, tvString, lang))
error(test,n);
} catch (Exception e) {
error(test, n, e);
}
try {
n=210;
n++; tvLiteral = m.createLiteral(n);
n++; Statement stmt = m.createStatement(subject,
RDF.value, tvLiteral);
n++; m.add(stmt);
n++; if (! m.contains(stmt))
error(test,n);
n++; long size = m.size();
n++; m.add(stmt);
n++; if (! (m.size() == size)) error(test,n);
n++; if (! m.contains(subject, RDF.value)) error(test,n);
n++; if ( m.contains(subject, RDF.subject)) error(test,n);
} catch (Exception e) {
error(test, n, e);
}
} catch (Exception e) {
logger.error( "test " + test + "[" + n + "]", e );
errors = true;
}
// System.out.println("End of " + test);
}
/** Test model get methods
* @param m the model implementation under test
*/
public void test4(Model m) {
String test = "Test4";
int n = 0;
try {
// System.out.println("Beginning " + test);
try {
Resource r;
n = 110;
String uri = "http://aldabaran.hpl.hp.com/rdf/test4/a"
+ Integer.toString(n);
n++; r = m.getResource(uri);
n++; if (! r.getURI().equals(uri)) error(test,n);
} catch (Exception e) {
error(test, n, e);
}
try {
Resource r;
n = 120;
String uri = "http://aldabaran.hpl.hp.com/rdf/test4/a"
+ Integer.toString(n);
n++; r = m.getResource(uri, new ResTestObjF());
n++; if (! r.getURI().equals(uri)) error(test,n);
} catch (Exception e) {
error(test, n, e);
}
try {
Property p;
n = 130;
String uri = "http://aldabaran.hpl.hp.com/rdf/test4/a"
+ Integer.toString(n);
n++; p = m.getProperty(uri);
n++; if (! p.getURI().equals(uri)) error(test,n);
} catch (Exception e) {
error(test, n, e);
}
try {
Property p;
n = 140;
String ns = "http://aldabaran.hpl.hp.com/rdf/test4/"
+ Integer.toString(n) + "/";
String ln = "foo";
n++; p = m.getProperty(ns, ln);
n++; if (! p.getURI().equals(ns+ln)) error(test,n);
} catch (Exception e) {
error(test, n, e);
}
try {
Bag c;
n = 150;
String uri = "http://aldabaran.hpl.hp.com/rdf/test4/"
+ Integer.toString(n);
n++; m.createBag(uri);
n++; c = m.getBag(uri);
n++; if (! c.getURI().equals(uri)) error(test,n);
n++; if (! m.contains(c, RDF.type, RDF.Bag)) error(test,n);
} catch (Exception e) {
error(test, n, e);
}
try {
Alt c;
n = 160;
String uri = "http://aldabaran.hpl.hp.com/rdf/test4/"
+ Integer.toString(n);
n++; m.createAlt(uri);
n++; c = m.getAlt(uri); c = m.getAlt( m.getResource( uri ));
n++; if (! c.getURI().equals(uri)) error(test,n);
n++; if (! m.contains(c, RDF.type, RDF.Alt)) error(test,n);
} catch (Exception e) {
error(test, n, e);
}
try {
Seq c;
n = 170;
String uri = "http://aldabaran.hpl.hp.com/rdf/test4/"
+ Integer.toString(n);
n++; m.createSeq(uri);
n++; c = m.getSeq(uri);
n++; if (! c.getURI().equals(uri)) error(test,n);
n++; if (! m.contains(c, RDF.type, RDF.Seq)) error(test,n);
} catch (Exception e) {
error(test, n, e);
}
} catch (Exception e) {
logger.error( "test " + test + "[" + n + "]", e );
errors = true;
}
// System.out.println("End of " + test);
}
/** Empty the passed in model
* @param m the model implementation under test
*/
public void test5(Model m) {
String test = "Test5";
int n = 0;
try {
StmtIterator iter;
// System.out.println("Beginning " + test);
try {
n=100;
n++; iter = m.listStatements();
while (iter.hasNext()) {
iter.nextStatement();
n++; iter.remove();
}
n++; iter.close();
n++; if (! (m.size()==0)) error(test,999);
} catch (Exception e) {
error(test, n, e);
}
} catch (Exception e) {
logger.error( "test " + test + "[" + n + "]", e );
}
// System.out.println("End of " + test);
}
/** test model list methods
* @param m the model implementation under test
*/
public void test6(Model m) {
String test = "Test6";
int n = 0;
int num = 5;
int numStatements;
// System.out.println("Beginning " + test);
Resource subject[] = new Resource[num];
Property predicate[] = new Property[num];
Statement stmts[] = new Statement[num*num];
String suri = "http://aldabaran/test6/s";
String puri = "http://aldabaran/test6/";
try {
for (int i = 0; i<num; i++) {
subject[i] = m.createResource(suri + Integer.toString(i));
predicate[i] = m.createProperty(puri + Integer.toString(i),
"p");
}
n = 50;
if (m.size() != 0) error(test, n);
for (int i=0; i<num; i++) {
for (int j=0; j<num; j++) {
Statement stmt = m.createStatement(subject[i], predicate[j],
m.createLiteral(i*num+j));
m.add(stmt);
m.add(stmt);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -