001: /*
002: (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003: All rights reserved - see end of file.
004: $Id: NewRegression.java,v 1.17 2008/01/02 12:07:04 andy_seaborne Exp $
005: */
006:
007: package com.hp.hpl.jena.regression;
008:
009: import junit.framework.TestSuite;
010:
011: import com.hp.hpl.jena.rdf.model.test.ModelTestBase;
012:
013: public class NewRegression extends ModelTestBase {
014: public NewRegression(String name) {
015: super (name);
016: }
017:
018: public static TestSuite suite() {
019: TestSuite result = new TestSuite(NewRegression.class);
020: result.addTest(NewRegressionLiterals.suite());
021: result.addTest(NewRegressionResources.suite());
022: result.addTest(NewRegressionStatements.suite());
023: result.addTest(NewRegressionContainers.suite());
024: result.addTest(NewRegressionAddAndContains.suite());
025: result.addTest(NewRegressionGet.suite());
026: result.addTest(NewRegressionObjects.suite());
027: result.addTest(NewRegressionStatements.suite());
028: result.addTest(NewRegressionAddModel.suite());
029: result.addTest(NewRegressionListSubjects.suite());
030: result.addTest(NewRegressionSelector.suite());
031: result.addTest(NewRegressionSeq.suite());
032: result.addTest(NewRegressionSet.suite());
033: result.addTest(NewRegressionResourceMethods.suite());
034: result.addTest(NewRegressionStatementMethods.suite());
035: result.addTest(NewRegressionBagMethods.suite());
036: result.addTest(NewRegressionAltMethods.suite());
037: result.addTest(NewRegressionSeqMethods.suite());
038: return result;
039: }
040:
041: public void testNothing() {
042: }
043:
044: }
045:
046: // /** test load from xml file
047: // * @param m the model implementation under test
048: // */
049: // public void test18(Model m) {
050: // String test = "Test18";
051: // if (test.equals( test )) return;
052: // String testURI = "http://aldabaran.hpl.hp.com/rdftest/test18/";
053: // String subject1 = testURI + "1";
054: // String object1 =
055: // "<foo bar=\"bar\"><bar>abc<foobar/>def<>'"&</bar></foo>";
056: // String RDFSchemaURI = "http://lists.w3.org/Archives/Public/www-archive/"
057: // + "2001Sep/att-0064/00-rdfschema.rdf";
058: // int n = 0;
059: //
060: // try {
061: // System.out.println("Beginning " + test);
062: // m.read(ResourceReader.getInputStream("modules/rdf/rdfschema.html"),
063: // RDFSchemaURI);
064: // n++; if (m.size() != 124) error(test, n);
065: // // n++; m.write(new PrintWriter(System.out));
066: //
067: // StmtIterator iter = m.listStatements();
068: // while (iter.hasNext()) {
069: // iter.nextStatement();
070: // iter.remove();
071: // }
072: //
073: // m.read(ResourceReader.getInputStream("modules/rdf/embeddedxml.xml"), "");
074: // n++;
075: // /* I'd like to test for the exactly correct value here, but can't since the
076: // * exactly correct value is not defined.
077: // if (! m.contains(m.createResource(subject1),
078: // RDF.value, object1)) error(test, n++);
079: // * So instead lets do some rough checks its right */
080: // String xml = m.getResource(subject1)
081: // .getRequiredProperty(RDF.value)
082: // .getString();
083: // n++; if ( xml.indexOf("<") == -1) error(test, n);
084: // n++; if ( xml.indexOf(">") == -1) error(test, n);
085: // n++; if ( xml.indexOf("&") == -1) error(test, n);
086: // n++; if ((xml.indexOf("'bar'") == -1) &&
087: // (xml.indexOf("\"bar\"") == -1)) error(test, n);
088: //
089: // m.createResource()
090: // .addProperty(RDF.value, "can't loose");
091: // // m.write(new PrintWriter(System.out));
092: //
093: // iter = m.listStatements();
094: // while (iter.hasNext()) {
095: // iter.nextStatement();
096: // iter.remove();
097: // }
098: // n++;
099: // m.read(ResourceReader.getInputStream("modules/rdf/testcollection.rdf"), "");
100: // if (m.size() != 24) error(test, (int) m.size());
101: //
102: // iter = m.listStatements();
103: // while (iter.hasNext()) {
104: // iter.nextStatement();
105: // iter.remove();
106: // }
107: //
108: // try {
109: // m.read(System.getProperty("com.hp.hpl.jena.regression.testURL",
110: // RDFSchemaURI));
111: // // n++; m.write(new PrintWriter(System.out));
112: // n++; if ((m.size() != 124) && (m.size() != 125)) {
113: // System.out.println("size = " + m.size());
114: // error(test, n);
115: // }
116: // if (! m.contains(RDF.Property, RDF.type, RDFS.Class))
117: // error(test, n);
118: // } catch (JenaException rdfx) {
119: // Throwable th = rdfx.getCause();
120: // if ( th instanceof NoRouteToHostException
121: // || th instanceof UnknownHostException
122: // || th instanceof IOException
123: // || th instanceof ConnectException) {
124: // logger.warn( "Cannot access public internet- part of test not executed" );
125: // } else {
126: // throw rdfx;
127: // }
128: // }
129: //
130: // } catch (Exception e) {
131: // logger.error( "test " + test + "[" + n + "]", e );
132: // errors = true;
133: // }
134: //// System.out.println("End of " + test);
135: // }
136: //
137: // /** test moving things between models
138: // * @param m the model implementation under test
139: // */
140: // public void test19(Model m1, Model m2) {
141: // String test = "Test19";
142: // int n = 0;
143: //
144: // try {
145: // Statement stmt;
146: // StmtIterator sIter;
147: //// System.out.println("Beginning " + test);
148: //
149: // try {
150: // n=100;
151: // Resource r11 = m1.createResource();
152: // Resource r12 = m2.createResource(new ResTestObjF());
153: // long size1 = m1.size();
154: // long size2 = m2.size();
155: //
156: // r11.addProperty(RDF.value, 1);
157: // n++; if (! (m1.size() == ++size1)) error(test, n);
158: // n++; if (! (m2.size() == size2)) error(test,n);
159: //
160: // stmt = m2.createStatement(r11, RDF.value, r12);
161: // n++; if (! (stmt.getSubject().getModel() == m2)) error(test,n);
162: // n++; if (! (stmt.getResource().getModel() == m2)) error(test,n);
163: //
164: // m1.add(stmt);
165: // n++; if (! (m1.size() == ++size1)) error(test, n);
166: // n++; if (! (m2.size() == size2)) error(test,n);
167: //
168: // sIter = m1.listStatements(
169: // new SimpleSelector(r11, RDF.value, r12));
170: // n++; if (! sIter.hasNext()) error(test, n);
171: // n++; stmt = sIter.nextStatement();
172: // n++; if (! (stmt.getSubject().getModel() == m1)) error(test,n);
173: // n++; if (! (stmt.getResource().getModel() == m1)) error(test,n);
174: // sIter.close();
175: //
176: //
177: // } catch (Exception e) {
178: // error(test, n, e);
179: // }
180: // } catch (Exception e) {
181: // logger.error( "test " + test + "[" + n + "]", e );
182: // errors = true;
183: // }
184: //// System.out.println("End of " + test);
185: // }
186: //
187: // /** Empty the passed in model
188: // * @param m the model implementation under test
189: // */
190: // public void test20(Model m) {
191: // String test = "Test20";
192: // int n = 0;
193: //
194: // try {
195: //// System.out.println("Beginning " + test);
196: // Statement s1 = null;
197: // Statement s2 = null;
198: //
199: // try {
200: // n=100;
201: // n++; s1 = m.createStatement(m.createResource(),
202: // RDF.type,
203: // RDFS.Class);
204: // n++; if (s1.isReified()) error(test,n);
205: // n++; m.add(s1);
206: // n++; if (s1.isReified()) error(test,n);
207: // n++; s2 = m.createStatement(m.createResource(),
208: // RDF.type,
209: // RDFS.Class);
210: // n++; if (s2.isReified()) error(test,n);
211: // n++; m.add(s2);
212: // n++; if (s2.isReified()) error(test,n);
213: ///*
214: // n++; m.add(s1, RDF.value, new LiteralImpl("foo"));
215: // n++; if (!s1.isReified()) error(test,n);
216: //
217: // n++; m.add(s1, RDF.value, s2);
218: // n++; if (!s2.isReified()) error(test,n);
219: // */
220: // } catch (Exception e) {
221: // error(test, n, e);
222: // }
223: // } catch (Exception e) {
224: // logger.error( "test " + test + "[" + n + "]", e );
225: // errors = true;
226: // }
227: //// System.out.println("End of " + test);
228: // }
229: //
230: // /** Testing for miscellaneous bugs
231: // * @param m the model implementation under test
232: // */
233: // public void test97(Model m) {
234: // String test = "Test97";
235: // int n = 0;
236: //
237: // try {
238: //
239: //// System.out.println("Beginning " + test);
240: //
241: // /*
242: // the _null_ argument to LiteralImpl was preserved only for backward
243: // compatability. It was be logged and has now become an exception.
244: // (Brian and Chris had a discussion about this and agreed).
245: // */
246: // // Node.nullLiteralsGenerateWarnings();
247: // try
248: // {
249: // n=100; m.query(new SimpleSelector(null,
250: // null,
251: // new LiteralImpl( Node.createLiteral( null, "", false ), (ModelCom) m)));
252: // error( test, n );
253: // }
254: // catch (NullPointerException e)
255: // {}
256: // try
257: // {
258: // n=101; m.query(new SimpleSelector(null,
259: // null,
260: // new LiteralImpl( Node.createLiteral( null, "en", false ), (ModelCom) m)));
261: // error( test, n );
262: // }
263: // catch (NullPointerException e)
264: // {}
265: // // end of nullLiteralsGenerateWarnings code
266: //
267: // n=102;
268: // StmtIterator iter
269: // = m.listStatements(new SimpleSelector(null,
270: // null,
271: // (String) null));
272: // while (iter.hasNext()) {
273: // RDFNode o = iter.nextStatement().getObject();
274: // }
275: //
276: // n=103;
277: // iter = m.listStatements(new SimpleSelector(null,
278: // null,
279: // (Object) null));
280: // while (iter.hasNext()) {
281: // RDFNode o = iter.nextStatement().getObject();
282: // }
283: //
284: // } catch (Exception e) {
285: // error(test, n, e);
286: // }
287: //// System.out.println("End of " + test);
288: // }
289: //
290: // /** Empty the passed in model
291: // * @param m the model implementation under test
292: // */
293: // public void test99(Model m) {
294: // String test = "Test5";
295: // int n = 0;
296: //
297: // try {
298: // StmtIterator iter;
299: //// System.out.println("Beginning " + test);
300: //
301: // try {
302: // n=100;
303: // n++; iter = m.listStatements();
304: // while (iter.hasNext()) {
305: // iter.nextStatement();
306: // n++; iter.remove();
307: // }
308: // n++; iter.close();
309: // n++; if (! (m.size()==0)) error(test,999);
310: // } catch (Exception e) {
311: // error(test, n, e);
312: // }
313: // } catch (Exception e) {
314: // logger.error( "test " + test + "[" + n + "]", e );
315: // errors = true;
316: // }
317: //// System.out.println("End of " + test);
318: // }
319: //
320:
321: /*
322: * (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
323: * All rights reserved.
324: *
325: * Redistribution and use in source and binary forms, with or without
326: * modification, are permitted provided that the following conditions
327: * are met:
328: * 1. Redistributions of source code must retain the above copyright
329: * notice, this list of conditions and the following disclaimer.
330: * 2. Redistributions in binary form must reproduce the above copyright
331: * notice, this list of conditions and the following disclaimer in the
332: * documentation and/or other materials provided with the distribution.
333: * 3. The name of the author may not be used to endorse or promote products
334: * derived from this software without specific prior written permission.
335: *
336: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
337: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
338: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
339: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
340: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
341: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
342: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
343: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
344: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
345: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
346: */
|