KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > regression > Regression


1 /*
2     (c) Copyright 2001, 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
3     [See end of file]
4     $Id: Regression.java,v 1.20 2005/02/21 12:18:40 andy_seaborne Exp $
5  */

6
7 package com.hp.hpl.jena.regression;
8
9 import com.hp.hpl.jena.rdf.model.impl.*;
10 import com.hp.hpl.jena.rdf.model.*;
11
12 import com.hp.hpl.jena.vocabulary.*;
13 import com.hp.hpl.jena.shared.*;
14 import com.hp.hpl.jena.graph.*;
15
16 import java.net.*;
17 import java.util.*;
18 import java.io.*;
19
20 import org.apache.commons.logging.Log;
21 import org.apache.commons.logging.LogFactory;
22
23 /** A common set of regression tests.
24  *
25  * @author bwm
26  * @version Release='$Name: $' Revision='$Revision: 1.20 $' Date='$Date: 2005/02/21 12:18:40 $'
27  */

28 public class Regression extends Object JavaDoc {
29
30     protected boolean errors = false;
31
32     public static void doTest(Model m1, Model m2, Model m3, Model m4) {
33         (new Regression()).test(m1, m2, m3, m4);
34     }
35
36     protected static Log logger = LogFactory.getLog( Regression.class );
37
38     /** Run the whole batch of common tests on a model implementation
39      * @param m an instance of the model to be tested
40      */

41     public void test(Model m1, Model m2, Model m3, Model m4) {
42         try {
43             StmtIterator iter = m1.listStatements();
44             while (iter.hasNext()) {
45                 iter.nextStatement();
46                 iter.remove();
47             }
48
49             iter = m2.listStatements();
50             while (iter.hasNext()) {
51                 iter.nextStatement();
52                 iter.remove();
53             }
54
55             iter = m3.listStatements();
56             while (iter.hasNext()) {
57                 iter.nextStatement();
58                 iter.remove();
59             }
60
61             iter = m4.listStatements();
62             while (iter.hasNext()) {
63                 iter.nextStatement();
64                 iter.remove();
65             }
66         } catch (Exception JavaDoc e) {
67             System.out.println(e);
68             errors = true;
69         }
70
71         test1(m1);
72         test2(m1);
73         test3(m1);
74         test4(m1);
75         test5(m1); // leaves m empty if successful
76
test6(m1);
77         test7(m1,m2);
78         test8(m1);
79         test9(m2);
80         test10(m3);
81         test11(m1,m2);
82         test12(m1);
83         test13(m1);
84         test14(m1);
85         test15(m1);
86         test16(m1);
87         test17(m1);
88         test18(m4);
89         test19(m2,m3);
90 // test20(m4); reification is not working
91
test97(m4);
92  // test98(m1);
93
}
94
95     /** Test Literal creation methods
96      * @param m the model implementation under test
97      */

98     public void test1(Model m) {
99         Literal l;
100         String JavaDoc test = "Test1";
101         int n = 0;
102 // System.out.println("Beginning " + test);
103
try {
104             {
105                 n = 100;
106                 n++; if (! m.createLiteral(true).getBoolean()) error(test, n);
107                 n++; if ( m.createLiteral(false).getBoolean()) error(test, n);
108             }
109
110             {
111                 n = 200;
112                 byte tv = 0;
113
114                 l = m.createLiteral(tv);
115                 n++; if (l.getByte() != tv) error(test, n);
116                 n++; if (l.getShort() != tv) error(test, n);
117                 n++; if (l.getInt() != tv) error(test, n);
118                 n++; if (l.getLong() != tv) error(test, n);
119
120                 tv = -1;
121                 l = m.createLiteral(tv);
122                 n++; if (l.getByte() != tv) error(test, n);
123                 n++; if (l.getShort() != tv) error(test, n);
124                 n++; if (l.getInt() != tv) error(test, n);
125                 n++; if (l.getLong() != tv) error(test, n);
126
127                 tv = Byte.MIN_VALUE;
128                 l = m.createLiteral(tv);
129                 n++; if (l.getByte() != tv) error(test, n);
130                 n++; if (l.getShort() != tv) error(test, n);
131                 n++; if (l.getInt() != tv) error(test, n);
132                 n++; if (l.getLong() != tv) error(test, n);
133
134                 tv = Byte.MAX_VALUE;
135                 l = m.createLiteral(tv);
136                 n++; if (l.getByte() != tv) error(test, n);
137                 n++; if (l.getShort() != tv) error(test, n);
138                 n++; if (l.getInt() != tv) error(test, n);
139                 n++; if (l.getLong() != tv) error(test, n);
140             }
141
142             {
143                 n = 300;
144                 short tv;
145
146                 tv = 0;
147                 l = m.createLiteral(tv);
148                 n++; if (l.getByte() != tv) error(test, n);
149                 n++; if (l.getShort() != tv) error(test, n);
150                 n++; if (l.getInt() != tv) error(test, n);
151                 n++; if (l.getLong() != tv) error(test, n);
152
153                 tv = -1;
154                 l = m.createLiteral(tv);
155                 n++; if (l.getByte() != tv) error(test, n);
156                 n++; if (l.getShort() != tv) error(test, n);
157                 n++; if (l.getInt() != tv) error(test, n);
158                 n++; if (l.getLong() != tv) error(test, n);
159
160                 tv = Short.MIN_VALUE;
161                 l = m.createLiteral(tv);
162                 try {
163                     n++; if (l.getByte() != tv) error(test, n);
164             } catch (NumberFormatException JavaDoc e) {}
165                 n++; if (l.getShort() != tv) error(test, n);
166                 n++; if (l.getInt() != tv) error(test, n);
167                 n++; if (l.getLong() != tv) error(test, n);
168
169                 tv = Short.MAX_VALUE;
170                 l = m.createLiteral(tv);
171                 try {
172                     n++; if (l.getByte() != tv) error(test, n);
173             } catch (NumberFormatException JavaDoc e) {}
174                 n++; if (l.getShort() != tv) error(test, n);
175                 n++; if (l.getInt() != tv) error(test, n);
176                 n++; if (l.getLong() != tv) error(test, n);
177             }
178
179             {
180                 n = 400;
181                 int tv;
182
183                 tv = 0;
184                 l = m.createLiteral(tv);
185                 n++; if (l.getByte() != tv) error(test, n);
186                 n++; if (l.getShort() != tv) error(test, n);
187                 n++; if (l.getInt() != tv) error(test, n);
188                 n++; if (l.getLong() != tv) error(test, n);
189
190                 tv = -1;
191                 l = m.createLiteral(tv);
192                 n++; if (l.getByte() != tv) error(test, n);
193                 n++; if (l.getShort() != tv) error(test, n);
194                 n++; if (l.getInt() != tv) error(test, n);
195                 n++; if (l.getLong() != tv) error(test, n);
196
197                 tv = Integer.MIN_VALUE;
198                 l = m.createLiteral(tv);
199                 try {
200                     n++; if (l.getByte() != tv) error(test, n);
201             } catch (NumberFormatException JavaDoc e) {}
202                 try {
203                     n++; if (l.getShort() != tv) error(test, n);
204             } catch (NumberFormatException JavaDoc e) {}
205                 n++; if (l.getInt() != tv) error(test, n);
206                 n++; if (l.getLong() != tv) error(test, n);
207
208                 tv = Integer.MAX_VALUE;
209                 l = m.createLiteral(tv);
210                 try {
211                     n++; if (l.getByte() != tv) error(test, n);
212             } catch (NumberFormatException JavaDoc e) {}
213                 try {
214                     n++; if (l.getShort() != tv) error(test, n);
215             } catch (NumberFormatException JavaDoc e) {}
216                 n++; if (l.getInt() != tv) error(test, n);
217                 n++; if (l.getLong() != tv) error(test, n);
218             }
219
220             {
221                 n = 500;
222                 long tv;
223
224                 tv = 0;
225                 l = m.createLiteral(tv);
226                 n++; if (l.getByte() != tv) error(test, n);
227                 n++; if (l.getShort() != tv) error(test, n);
228                 n++; if (l.getInt() != tv) error(test, n);
229                 n++; if (l.getLong() != tv) error(test, n);
230
231                 tv = -1;
232                 l = m.createLiteral(tv);
233                 n++; if (l.getByte() != tv) error(test, n);
234                 n++; if (l.getShort() != tv) error(test, n);
235                 n++; if (l.getInt() != tv) error(test, n);
236                 n++; if (l.getLong() != tv) error(test, n);
237
238                 tv = Long.MIN_VALUE;
239                 l = m.createLiteral(tv);
240                 try {
241                     n++; if (l.getByte() != tv) error(test, n);
242             } catch (NumberFormatException JavaDoc e) {}
243                 try {
244                     n++; if (l.getShort() != tv) error(test, n);
245             } catch (NumberFormatException JavaDoc e) {}
246                 try {
247                     n++; if (l.getInt() != tv) error(test, n);
248             } catch (NumberFormatException JavaDoc e) {}
249                 n++; if (l.getLong() != tv) error(test, n);
250
251                 tv = Long.MAX_VALUE;
252                 l = m.createLiteral(tv);
253                 try {
254                     n++; if (l.getByte() != tv) error(test, n);
255             } catch (NumberFormatException JavaDoc e) {}
256                 try {
257                     n++; if (l.getShort() != tv) error(test, n);
258             } catch (NumberFormatException JavaDoc e) {}
259                 try {
260                     n++; if (l.getInt() != tv) error(test, n);
261             } catch (NumberFormatException JavaDoc e) {}
262                 n++; if (l.getLong() != tv) error(test, n);
263             }
264
265             {
266                 float tv;
267                 float maxerror = (float) 0.00005;
268                 n = 600;
269
270                 tv = (float) 0.0;
271                 l = m.createLiteral(tv);
272                 n++; if (java.lang.Math.abs(l.getFloat() - tv) >= maxerror) error(test, n);
273
274                 tv = (float) -1.0;
275                 l = m.createLiteral(tv);
276                 n++; if (java.lang.Math.abs(l.getFloat() - tv) >= maxerror) error(test, n);
277
278                 tv = (float) 12345.6789;
279                 l = m.createLiteral(tv);
280                 n++; if (java.lang.Math.abs(l.getFloat() - tv) >= maxerror) error(test, n);
281
282                 tv = Float.MAX_VALUE;
283                 l = m.createLiteral(tv);
284                 n++; if (java.lang.Math.abs(l.getFloat() - tv) >= maxerror) error(test, n);
285
286                 tv = Float.MIN_VALUE;
287                 l = m.createLiteral(tv);
288                 n++; if (java.lang.Math.abs(l.getFloat() - tv) >= maxerror) error(test, n);
289             }
290             {
291                 double tv;
292                 double maxerror = (double) 0.000000005;
293                 n = 700;
294
295                 tv = (double) 0.0;
296                 l = m.createLiteral(tv);
297                 n++; if (java.lang.Math.abs(l.getDouble() - tv) >= maxerror) error(test, n);
298
299                 tv = (double) -1.0;
300                 l = m.createLiteral(tv);
301                 n++; if (java.lang.Math.abs(l.getDouble() - tv) >= maxerror) error(test, n);
302
303                 tv = (double) 12345.67890;
304                 l = m.createLiteral(tv);
305                 n++; if (java.lang.Math.abs(l.getDouble() - tv) >= maxerror) error(test, n);
306
307                 tv = Double.MAX_VALUE;
308                 l = m.createLiteral(tv);
309                 n++; if (java.lang.Math.abs(l.getDouble() - tv) >= maxerror) error(test, n);
310
311                 tv = Double.MIN_VALUE;
312                 l = m.createLiteral(tv);
313                 n++; if (java.lang.Math.abs(l.getDouble() - tv) >= maxerror) error(test, n);
314             }
315
316             {
317                 char tv;
318                 n = 800;
319
320                 tv = 'A';
321                 n++; if (m.createLiteral(tv).getChar() != tv) error(test, n);
322
323                 tv = 'a';
324                 n++; if (m.createLiteral(tv).getChar() != tv) error(test, n);
325
326                 tv = '#';
327                 n++; if (m.createLiteral(tv).getChar() != tv) error(test, n);
328
329                 tv = '@';
330                 n++; if (m.createLiteral(tv).getChar() != tv) error(test, n);
331             }
332
333             {
334                 String JavaDoc language = "en";
335                 String JavaDoc tv;
336                 n = 900;
337
338                 tv = "";
339                 n++; if (! m.createLiteral(tv).getString()
340                                                 .equals(tv)) error(test, n);
341
342                 tv = "A test string";
343                 n++; if (! m.createLiteral(tv).getString()
344                                                   .equals(tv)) error(test, n);
345
346                 tv = "Another test string";
347                 n++; l = m.createLiteral(tv);
348                 n++; if (! l.getString().equals(tv)) error(test, n);
349                 n++; if (! (l.getLanguage().equals(""))) error(test,n);
350                 n++; l = m.createLiteral(tv, language);
351                 n++; if (! (l.getString().equals(tv)))error(test, n);
352                 n++; if (! (l.getLanguage().equals(language))) error(test,n);
353                 n++; if (! l.equals(m.createLiteral(tv, language)))
354                          error(test,n);
355                 n++; if ( l.equals(m.createLiteral(tv))) error(test,n);
356             }
357
358             {
359                 LitTestObj tv;
360                 LitTestObjF factory = new LitTestObjF();
361                 n = 1000;
362
363                 tv = new LitTestObj(0);
364                 n++; if (! m.createLiteral(tv).getObject(factory)
365                 .equals(tv)) error(test, n);
366
367                 tv = new LitTestObj(12345);
368                 n++; if (! m.createLiteral(tv).getObject(factory)
369                 .equals(tv)) error(test, n);
370
371                 tv = new LitTestObj(-67890);
372                 n++; if (! m.createLiteral(tv).getObject(factory)
373                 .equals(tv)) error(test, n);
374             }
375         } catch (Exception JavaDoc e) {
376             logger.error( "test " + test + "[" + n + "]", e );
377             errors = true;
378         }
379 // System.out.println("End of " + test);
380
}
381
382     /** Test Resource creation methods
383      * @param m the model implementation under test
384      */

385     public void test2(Model m) {
386         String JavaDoc test = "Test2";
387         int n = 0;
388         String JavaDoc uri;
389 // System.out.println("Beginning " + test);
390
try {
391             {
392                 Resource r;
393                 n = 100;
394
395                 try {
396                     n = 110;
397                     n++; r = m.createResource();
398                     n++; if (! r.isAnon()) error(test, n);
399                     n++; if (! (r.getURI() == null)) error(test, n);
400                     n++; if (! (r.getNameSpace() == null)) error(test, n);
401                     n++; if (! (r.getLocalName() == null)) error(test, n);
402                 } catch (JenaException e) {
403                     error(test, n, e);
404                 }
405
406                 try {
407                     n = 120;
408                     n++; r = m.createResource((String JavaDoc) null);
409                     n++; if (! r.isAnon()) error(test, n);
410                     n++; if (! (r.getURI() == null)) error(test, n);
411                 } catch (JenaException e) {
412                     error(test, n, e);
413                 }
414
415                 try {
416                     n = 140;
417                     uri = "http://aldabaran.hpl.hp.com/foo";
418                     n++; r = m.createResource(uri);
419                     n++; if (! r.getURI().equals(uri)) error(test, n);
420                 } catch (JenaException e) {
421                     error(test, n, e);
422                 }
423
424                 try {
425                     n = 150;
426                     n++; r = m.createResource(RDF.Property);
427                     n++; if (! r.isAnon()) error(test, n);
428                 } catch (JenaException e) {
429                     error(test, n, e);
430                 }
431
432                 try {
433                     n = 160;
434                     uri = "http://aldabaran.hpl.hp.com/foo";
435                     n++; r = m.createResource(uri, RDF.Property);
436                     n++; if (! r.getURI().equals(uri)) error(test, n);
437                 } catch (JenaException e) {
438                     error(test, n, e);
439                 }
440
441                 try {
442                     n = 170;
443                     n++; r = m.createResource(new ResTestObjF());
444                     n++; if (! r.isAnon()) error(test, n);
445                 } catch (JenaException e) {
446                     error(test, n, e);
447                 }
448
449                 try {
450                     n = 180;
451                     uri = "http://aldabaran.hpl.hp.com/foo";
452                     n++; r = m.createResource(uri, new ResTestObjF());
453                     n++; if (! r.getURI().equals(uri)) error(test, n);
454                 } catch (JenaException e) {
455                     error(test, n, e);
456                 }
457             }
458
459             {
460                 Property p;
461                 n = 200;
462
463                 try {
464                     n++; p = m.createProperty(null); error(test, n);
465                 } catch (InvalidPropertyURIException jx) {
466                     // as expected.
467

468                 }
469
470                 try {
471                     n++; p = m.createProperty("abc/def");
472                     n++; if (! p.getNameSpace().equals("abc/")) error(test, n);
473                     n++; if (! p.getLocalName().equals("def")) error(test, n);
474                     n++; if (! p.getURI().equals("abc/def")) error(test,n);
475                 } catch (JenaException e) {
476                     error(test, n, e);
477                 }
478
479                 try {
480                     n++; p = m.createProperty("abc/", "def");
481                     n++; if (! p.getNameSpace().equals("abc/")) error(test, n);
482                     n++; if (! p.getLocalName().equals("def")) error(test, n);
483                     n++; if (! p.getURI().equals("abc/def")) error(test,n);
484                 } catch (JenaException e) {
485                     error(test, n, e);
486                 }
487
488                 try {
489                     n++; p = m.createProperty(RDF.getURI() + "_345");
490                     n++; if (! p.getNameSpace().equals(RDF.getURI())) error(test, n);
491                     n++; if (! p.getLocalName().equals("_345")) error(test, n);
492                     n++; if (! p.getURI().equals(RDF.getURI() + "_345")) error(test,n);
493                 } catch (JenaException e) {
494                     error(test, n, e);
495                 }
496
497                 try {
498                     n++; p = m.createProperty(RDF.getURI(), "_345");
499                     n++; if (! p.getNameSpace().equals(RDF.getURI())) error(test, n);
500                     n++; if (! p.getLocalName().equals("_345")) error(test, n);
501                     n++; if (! p.getURI().equals(RDF.getURI() + "_345")) error(test,n);
502                 } catch (JenaException e) {
503                     error(test, n, e);
504                 }
505
506             }
507
508             {
509                 String JavaDoc subjURI = "http://aldabaran.hpl.hp.com/foo";
510                 String JavaDoc predURI = "http://aldabaran.hpl.hp.com/bar";
511                 Resource r = m.createResource(subjURI);
512                 Property p = m.createProperty(predURI);
513                 Statement s;
514
515                 n = 300;
516
517                 try {
518                     boolean tv = true;
519                     n=310;
520                     n++; s = m.createStatement(r, p, tv);
521                     n++; if (! s.getSubject().getURI().equals(subjURI))
522                     error(test,n);
523                     n++; if (! s.getPredicate().getURI().equals(predURI))
524                     error(test,n);
525                     n++; if (! s.getBoolean()) error(test,n);
526                 } catch (Exception JavaDoc e) {
527                     error(test, n, e);
528                 }
529
530                 try {
531                     byte tv = Byte.MAX_VALUE;
532                     n=320;
533                     n++; s = m.createStatement(r, p, tv);
534                     n++; if (! s.getSubject().getURI().equals(subjURI))
535                     error(test,n);
536                     n++; if (! s.getPredicate().getURI().equals(predURI))
537                     error(test,n);
538                     n++; if (! (s.getByte()==tv)) error(test,n);
539                 } catch (Exception JavaDoc e) {
540                     error(test, n, e);
541                 }
542
543                 try {
544                     short tv = Short.MAX_VALUE;
545                     n=330;
546                     n++; s = m.createStatement(r, p, tv);
547                     n++; if (! s.getSubject().getURI().equals(subjURI))
548                     error(test,n);
549                     n++; if (! s.getPredicate().getURI().equals(predURI))
550                     error(test,n);
551                     n++; if (! (s.getShort()== tv)) error(test,n);
552                 } catch (Exception JavaDoc e) {
553                     error(test, n, e);
554                 }
555
556                 try {
557                     int tv = Integer.MAX_VALUE;
558                     n=340;
559                     n++; s = m.createStatement(r, p, tv);
560                     n++; if (! s.getSubject().getURI().equals(subjURI))
561                     error(test,n);
562                     n++; if (! s.getPredicate().getURI().equals(predURI))
563                     error(test,n);
564                     n++; if (! (s.getInt()==tv)) error(test,n);
565                 } catch (Exception JavaDoc e) {
566                     error(test, n, e);
567                 }
568
569                 try {
570                     long tv = Long.MAX_VALUE;
571                     n=350;
572                     n++; s = m.createStatement(r, p, tv);
573                     n++; if (! s.getSubject().getURI().equals(subjURI))
574                     error(test,n);
575                     n++; if (! s.getPredicate().getURI().equals(predURI))
576                     error(test,n);
577                     n++; if (! (s.getLong()==tv)) error(test,n);
578                 } catch (Exception JavaDoc e) {
579                     error(test, n, e);
580                 }
581
582                 try {
583                     char tv = '$';
584                     n=360;
585                     n++; s = m.createStatement(r, p, tv);
586                     n++; if (! s.getSubject().getURI().equals(subjURI))
587                     error(test,n);
588                     n++; if (! s.getPredicate().getURI().equals(predURI))
589                     error(test,n);
590                     n++; if (! (s.getChar()==tv)) error(test,n);
591                 } catch (Exception JavaDoc e) {
592                     error(test, n, e);
593                 }
594
595                 try {
596                     float tv = (float) 123.456;
597                     n=370;
598                     n++; s = m.createStatement(r, p, tv);
599                     n++; if (! s.getSubject().getURI().equals(subjURI))
600                     error(test,n);
601                     n++; if (! s.getPredicate().getURI().equals(predURI))
602                     error(test,n);
603                     n++; if (! ((s.getFloat()-tv) < 0.0005)) error(test,n);
604                 } catch (Exception JavaDoc e) {
605                     error(test, n, e);
606                 }
607
608                 try {
609                     double tv = 12345.67890;
610                     n=380;
611                     n++; s = m.createStatement(r, p, tv);
612                     n++; if (! s.getSubject().getURI().equals(subjURI))
613                     error(test,n);
614                     n++; if (! s.getPredicate().getURI().equals(predURI))
615                     error(test,n);
616                     n++; if (! ((s.getDouble()-tv) < 0.0000005)) error(test,n);
617                 } catch (Exception JavaDoc e) {
618                     error(test, n, e);
619                 }
620
621                 try {
622                     String JavaDoc tv = "this is a test string";
623                     String JavaDoc lang = "en";
624                     n=390;
625                     n++; s = m.createStatement(r, p, tv);
626                     n++; if (! s.getSubject().getURI().equals(subjURI))
627                     error(test,n);
628                     n++; if (! s.getPredicate().getURI().equals(predURI))
629                     error(test,n);
630                     n++; if (! s.getString().equals(tv)) error(test,n);
631                   // n++; if (! s.getLiteral().equals(tv)) error(test,n);
632
n++; s = m.createStatement(r,p,tv,lang);
633                     n++; if (! s.getLanguage().equals(lang)) error(test,n);
634                 } catch (Exception JavaDoc e) {
635                     error(test, n, e);
636                 }
637
638                 try {
639                     LitTestObj tv = new LitTestObj(Long.MIN_VALUE);
640                     String JavaDoc lang = "fr";
641                     n=400;
642                     n++; s = m.createStatement(r, p, tv);
643                     n++; if (! s.getSubject().getURI().equals(subjURI))
644                             error(test,n);
645                     n++; if (! s.getPredicate().getURI().equals(predURI))
646                              error(test,n);
647                     n++; if (! s.getObject(new LitTestObjF()).equals(tv))
648                               error(test,n);
649                 } catch (Exception JavaDoc e) {
650                     error(test, n, e);
651                 }
652
653                 try {
654                     Resource tv = m.createResource();
655                     n=410;
656                     n++; s = m.createStatement(r, p, tv);
657                     n++; if (! s.getSubject().getURI().equals(subjURI))
658                     error(test,n);
659                     n++; if (! s.getPredicate().getURI().equals(predURI))
660                     error(test,n);
661                     n++; if (! s.getResource().equals(tv)) error(test,n);
662                 } catch (Exception JavaDoc e) {
663                     error(test, n, e);
664                 }
665
666                 try {
667                     Literal tv = m.createLiteral(true);
668                     n=420;
669                     n++; s = m.createStatement(r, p, tv);
670                     n++; if (! s.getSubject().getURI().equals(subjURI))
671                     error(test,n);
672                     n++; if (! s.getPredicate().getURI().equals(predURI))
673                     error(test,n);
674                     n++; if (! s.getBoolean()) error(test,n);
675                 } catch (Exception JavaDoc e) {
676                     error(test, n, e);
677                 }
678             }
679
680             {
681                 // test container creation
682

683                 try {
684                     Bag tv;
685                     n = 500;
686                     n++; tv = m.createBag();
687                     n++; if (! tv.isAnon()) error(test, n);
688                     n++; if (! m.contains(tv, RDF.type, RDF.Bag)) error(test,n);
689
690                     uri = "http://aldabaran/foo";
691                     n++; tv = m.createBag(uri);
692                     n++; if (! tv.getURI().equals(uri)) error(test, n);
693                     n++; if (! m.contains(tv, RDF.type, RDF.Bag)) error(test,n);
694                 } catch (Exception JavaDoc e) {
695                     error(test, n, e);
696                 }
697
698                 try {
699                     Alt tv;
700                     n = 510;
701                     n++; tv = m.createAlt();
702                     n++; if (! tv.isAnon()) error(test, n);
703                     n++; if (! m.contains(tv, RDF.type, RDF.Alt)) error(test,n);
704
705                     uri = "http://aldabaran/foo";
706                     n++; tv = m.createAlt(uri);
707                     n++; if (! tv.getURI().equals(uri)) error(test, n);
708                     n++; if (! m.contains(tv, RDF.type, RDF.Alt)) error(test,n);
709                 } catch (Exception JavaDoc e) {
710                     error(test, n, e);
711                 }
712
713                 try {
714                     Seq tv;
715                     n = 520;
716                     n++; tv = m.createSeq();
717                     n++; if (! tv.isAnon()) error(test, n);
718                     n++; if (! m.contains(tv, RDF.type, RDF.Seq)) error(test,n);
719
720                     uri = "http://aldabaran/foo";
721                     n++; tv = m.createSeq(uri);
722                     n++; if (! tv.getURI().equals(uri)) error(test, n);
723                     n++; if (! m.contains(tv, RDF.type, RDF.Seq)) error(test,n);
724                 } catch (Exception JavaDoc e) {
725                     error(test, n, e);
726                 }
727             }
728
729
730         } catch (Exception JavaDoc e) {
731             logger.error( "test " + test + "[" + n + "]", e );
732             errors = true;
733         }
734 // System.out.println("End of " + test);
735
}
736     /** Test model add and contains methods
737      * @param m the model implementation under test
738      */

739     public void test3(Model m) {
740         String JavaDoc test = "Test3";
741         int n = 0;
742
743         try {
744             boolean tvBoolean = true;
745             byte tvByte = 1;
746             short tvShort = 2;
747             int tvInt = -1;
748             long tvLong = -2;
749             char tvChar = '!';
750             float tvFloat = (float) 123.456;
751             double tvDouble = -123.456;
752             String JavaDoc tvString = "test string";
753             String JavaDoc lang = "en";
754             LitTestObj tvObject = new LitTestObj(12345);
755             Literal tvLiteral = m.createLiteral("test string 2");
756             Resource tvResource = m.createResource();
757             Resource subject = m.createResource();
758 // System.out.println("Beginning " + test);
759

760             try {
761                 n=100;
762                 n++; m.add(subject, RDF.value, tvResource);
763                 n++; if (! m.contains(subject,RDF.value,tvResource))
764                 error(test,n);
765             } catch (Exception JavaDoc e) {
766                 error(test, n, e);
767             }
768
769             try {
770                 n=110;
771                 n++; m.add(subject, RDF.value, tvLiteral);
772                 n++; if (! m.contains(subject,RDF.value,tvLiteral))
773                 error(test,n);
774             } catch (Exception JavaDoc e) {
775                 error(test, n, e);
776             }
777
778             try {
779                 n=120;
780                 n++; m.add(subject, RDF.value, tvByte);
781                 n++; if (! m.contains(subject,RDF.value,tvByte))
782                 error(test,n);
783             } catch (Exception JavaDoc e) {
784                 error(test, n, e);
785             }
786
787             try {
788                 n=130;
789                 n++; m.add(subject, RDF.value, tvShort);
790                 n++; if (! m.contains(subject,RDF.value,tvShort))
791                 error(test,n);
792             } catch (Exception JavaDoc e) {
793                 error(test, n, e);
794             }
795
796             try {
797                 n=140;
798                 n++; m.add(subject, RDF.value, tvInt);
799                 n++; if (! m.contains(subject,RDF.value,tvInt))
800                 error(test,n);
801             } catch (Exception JavaDoc e) {
802                 error(test, n, e);
803             }
804
805             try {
806                 n=150;
807                 n++; m.add(subject, RDF.value, tvLong);
808                 n++; if (! m.contains(subject,RDF.value,tvLong))
809                 error(test,n);
810             } catch (Exception JavaDoc e) {
811                 error(test, n, e);
812             }
813
814             try {
815                 n=160;
816                 n++; m.add(subject, RDF.value, tvChar);
817                 n++; if (! m.contains(subject,RDF.value,tvChar))
818                 error(test,n);
819             } catch (Exception JavaDoc e) {
820                 error(test, n, e);
821             }
822
823             try {
824                 n=170;
825                 n++; m.add(subject, RDF.value, tvFloat);
826                 n++; if (! m.contains(subject,RDF.value,tvFloat))
827                 error(test,n);
828             } catch (Exception JavaDoc e) {
829                 error(test, n, e);
830             }
831
832             try {
833                 n=180;
834                 n++; m.add(subject, RDF.value, tvDouble);
835                 n++; if (! m.contains(subject,RDF.value,tvDouble))
836                 error(test,n);
837             } catch (Exception JavaDoc e) {
838                 error(test, n, e);
839             }
840
841             try {
842                 n=190;
843                 n++; m.add(subject, RDF.value, tvObject);
844                 n++; if (! m.contains(subject,RDF.value,tvObject))
845                          error(test,n);
846             } catch (Exception JavaDoc e) {
847                 error(test, n, e);
848             }
849
850             try {
851                 n=200;
852                 n++; m.add(subject, RDF.value, tvString);
853                 n++; if (! m.contains(subject,RDF.value,tvString))
854                         error(test, n);
855                 n++; if ( m.contains(subject, RDF.value, tvString, lang))
856                         error(test,n);
857                 n++; m.add(subject, RDF.value, tvString, lang);
858                 n++; if (! m.contains(subject, RDF.value, tvString, lang))
859                         error(test,n);
860             } catch (Exception JavaDoc e) {
861                 error(test, n, e);
862             }
863
864             try {
865                 n=210;
866                 n++; tvLiteral = m.createLiteral(n);
867                 n++; Statement stmt = m.createStatement(subject,
868                 RDF.value, tvLiteral);
869                 n++; m.add(stmt);
870                 n++; if (! m.contains(stmt))
871                 error(test,n);
872                 n++; long size = m.size();
873                 n++; m.add(stmt);
874                 n++; if (! (m.size() == size)) error(test,n);
875                 n++; if (! m.contains(subject, RDF.value)) error(test,n);
876                 n++; if ( m.contains(subject, RDF.subject)) error(test,n);
877             } catch (Exception JavaDoc e) {
878                 error(test, n, e);
879             }
880         } catch (Exception JavaDoc e) {
881             logger.error( "test " + test + "[" + n + "]", e );
882             errors = true;
883         }
884 // System.out.println("End of " + test);
885
}
886
887     /** Test model get methods
888      * @param m the model implementation under test
889      */

890     public void test4(Model m) {
891         String JavaDoc test = "Test4";
892         int n = 0;
893
894         try {
895 // System.out.println("Beginning " + test);
896

897             try {
898                 Resource r;
899                 n = 110;
900                 String JavaDoc uri = "http://aldabaran.hpl.hp.com/rdf/test4/a"
901                 + Integer.toString(n);
902                 n++; r = m.getResource(uri);
903                 n++; if (! r.getURI().equals(uri)) error(test,n);
904             } catch (Exception JavaDoc e) {
905                 error(test, n, e);
906             }
907
908             try {
909                 Resource r;
910                 n = 120;
911                 String JavaDoc uri = "http://aldabaran.hpl.hp.com/rdf/test4/a"
912                 + Integer.toString(n);
913                 n++; r = m.getResource(uri, new ResTestObjF());
914                 n++; if (! r.getURI().equals(uri)) error(test,n);
915             } catch (Exception JavaDoc e) {
916                 error(test, n, e);
917             }
918
919             try {
920                 Property p;
921                 n = 130;
922                 String JavaDoc uri = "http://aldabaran.hpl.hp.com/rdf/test4/a"
923                 + Integer.toString(n);
924                 n++; p = m.getProperty(uri);
925                 n++; if (! p.getURI().equals(uri)) error(test,n);
926             } catch (Exception JavaDoc e) {
927                 error(test, n, e);
928             }
929
930             try {
931                 Property p;
932                 n = 140;
933                 String JavaDoc ns = "http://aldabaran.hpl.hp.com/rdf/test4/"
934                 + Integer.toString(n) + "/";
935                 String JavaDoc ln = "foo";
936                 n++; p = m.getProperty(ns, ln);
937                 n++; if (! p.getURI().equals(ns+ln)) error(test,n);
938             } catch (Exception JavaDoc e) {
939                 error(test, n, e);
940             }
941
942             try {
943                 Bag c;
944                 n = 150;
945                 String JavaDoc uri = "http://aldabaran.hpl.hp.com/rdf/test4/"
946                 + Integer.toString(n);
947                 n++; m.createBag(uri);
948                 n++; c = m.getBag(uri);
949                 n++; if (! c.getURI().equals(uri)) error(test,n);
950                 n++; if (! m.contains(c, RDF.type, RDF.Bag)) error(test,n);
951             } catch (Exception JavaDoc e) {
952                 error(test, n, e);
953             }
954
955             try {
956                 Alt c;
957                 n = 160;
958                 String JavaDoc uri = "http://aldabaran.hpl.hp.com/rdf/test4/"
959                 + Integer.toString(n);
960                 n++; m.createAlt(uri);
961                 n++; c = m.getAlt(uri); c = m.getAlt( m.getResource( uri ));
962                 n++; if (! c.getURI().equals(uri)) error(test,n);
963                 n++; if (! m.contains(c, RDF.type, RDF.Alt)) error(test,n);
964             } catch (Exception JavaDoc e) {
965                 error(test, n, e);
966             }
967
968             try {
969                 Seq c;
970                 n = 170;
971                 String JavaDoc uri = "http://aldabaran.hpl.hp.com/rdf/test4/"
972                 + Integer.toString(n);
973                 n++; m.createSeq(uri);
974                 n++; c = m.getSeq(uri);
975                 n++; if (! c.getURI().equals(uri)) error(test,n);
976                 n++; if (! m.contains(c, RDF.type, RDF.Seq)) error(test,n);
977             } catch (Exception JavaDoc e) {
978                 error(test, n, e);
979             }
980         } catch (Exception JavaDoc e) {
981             logger.error( "test " + test + "[" + n + "]", e );
982             errors = true;
983         }
984 // System.out.println("End of " + test);
985
}
986
987     /** Empty the passed in model
988      * @param m the model implementation under test
989      */

990     public void test5(Model m) {
991         String JavaDoc test = "Test5";
992         int n = 0;
993
994         try {
995             StmtIterator iter;
996 // System.out.println("Beginning " + test);
997

998             try {
999                 n=100;
1000                n++; iter = m.listStatements();
1001                while (iter.hasNext()) {
1002                    iter.nextStatement();
1003                    n++; iter.remove();
1004                }
1005                n++; iter.close();
1006                n++; if (! (m.size()==0)) error(test,999);
1007            } catch (Exception JavaDoc e) {
1008                error(test, n, e);
1009            }
1010        } catch (Exception JavaDoc e) {
1011            logger.error( "test " + test + "[" + n + "]", e );
1012        }
1013// System.out.println("End of " + test);
1014
}
1015
1016    /** test model list methods
1017     * @param m the model implementation under test
1018     */

1019    public void test6(Model m) {
1020        String JavaDoc test = "Test6";
1021        int n = 0;
1022        int num = 5;
1023        int numStatements;
1024
1025
1026// System.out.println("Beginning " + test);
1027

1028
1029        Resource subject[] = new Resource[num];
1030        Property predicate[] = new Property[num];
1031        Statement stmts[] = new Statement[num*num];
1032
1033        String JavaDoc suri = "http://aldabaran/test6/s";
1034        String JavaDoc puri = "http://aldabaran/test6/";
1035
1036        try {
1037
1038            for (int i = 0; i<num; i++) {
1039                subject[i] = m.createResource(suri + Integer.toString(i));
1040                predicate[i] = m.createProperty(puri + Integer.toString(i),
1041                "p");
1042            }
1043
1044            n = 50;
1045            if (m.size() != 0) error(test, n);
1046
1047            for (int i=0; i<num; i++) {
1048                for (int j=0; j<num; j++) {
1049                    Statement stmt = m.createStatement(subject[i], predicate[j],
1050                                                      m.createLiteral(i*num+j));
1051                    m.add(stmt);
1052                    m.add(stmt);
1053                    stmts[i*num+j] = stmt;
1054                }
1055            }
1056
1057            int numStmts = num*num;
1058            boolean stmtf[] = new boolean[numStmts];
1059            boolean subjf[] = new boolean[num];
1060            boolean predf[] = new boolean[num];
1061
1062            n = 100;
1063            n++; if (m.size() != numStmts) error(test, n);
1064            for (int i=0; i<numStmts; i++) {
1065                stmtf[i] = false;
1066            }
1067            for (int i=0; i<num; i++) {
1068                subjf[i] = false;
1069                predf[i] = false;
1070            }
1071
1072            boolean found = false;
1073            ResIterator rIter = m.listSubjects();
1074            while (rIter.hasNext()) {
1075                Resource subj = rIter.nextResource();
1076                found = false;
1077                for (int i=0; i<num; i++) {
1078                    if (subj.equals(subject[i])) {
1079                        found = true;
1080                        if (subjf[i]) error(test, 110);
1081                        subjf[i] = true;
1082                    }
1083                }
1084                if (! found) error(test, 120);
1085            }
1086            for (int i=0; i<num; i++) {
1087                if (! subjf[i]) error(test, 120+i);
1088            }
1089
1090// System.err.println( "WARNING: listNameSpace testing wonky for the moment" );
1091
// NsIterator nIter = m.listNameSpaces();
1092
// HashSet fromIterator = new HashSet();
1093
// HashSet fromPredicates = new HashSet();
1094
// while (nIter.hasNext()) fromIterator.add( nIter.next() );
1095
// for (int i = 0; i < num; i += 1) fromPredicates.add( predicate[i].getNameSpace() );
1096
// if (fromIterator.equals( fromPredicates ))
1097
// {}
1098
// else
1099
// {
1100
// System.err.println( "| oh dear." );
1101
// System.err.println( "| predicate namespaces: " + fromPredicates );
1102
// System.err.println( "| iterator namespaces: " + fromIterator );
1103
// }
1104

1105            NsIterator nIter = m.listNameSpaces();
1106            while (nIter.hasNext()) {
1107                String JavaDoc ns = nIter.nextNs();
1108                found = false;
1109                for (int i=0; i<num; i++) {
1110                    if (ns.equals(predicate[i].getNameSpace())) {
1111                        found = true;
1112                        if (predf[i]) error(test, 130);
1113                        predf[i] = true;
1114                    }
1115                }
1116                if (! found) error(test, 140);
1117            }
1118            for (int i=0; i<num; i++) {
1119                if (! predf[i]) error(test, 140+i);
1120            }
1121
1122            StmtIterator sIter = m.listStatements();
1123            while (sIter.hasNext()) {
1124                Statement stmt = sIter.nextStatement();
1125                found = false;
1126                for (int i=0; i<numStmts; i++) {
1127                    if (stmt.equals(stmts[i])) {
1128                        found = true;
1129                        if (stmtf[i]) error(test, 150);
1130                        stmtf[i] = true;
1131                    }
1132                }
1133                if (! found) error(test, 160);
1134            }
1135            for (int i=0; i<numStmts; i++) {
1136                if (! stmtf[i]) error(test, 160+i);
1137            }
1138
1139// SEE the tests in model.test: TestReifiedStatements and TestStatementResources
1140
// {
1141
// System.err.println( "WARNING: reification testing suppressed for the moment" );
1142
///* Reification is not working properly
1143
//
1144
// for (int i=0; i<num; i++) {
1145
// stmtf[i] = false;
1146
// m.add(stmts[i], predicate[i], i);
1147
// }
1148
// sIter = m.listReifiedStatements();
1149
// while (sIter.hasNext()) {
1150
// Statement stmt = sIter.next();
1151
// found = false;
1152
// for (int i=0; i<num; i++) {
1153
// if (stmt.equals(stmts[i])) {
1154
// found = true;
1155
// if (stmtf[i]) error(test, 200);
1156
// stmtf[i] = true;
1157
// }
1158
// }
1159
// if (! found) error(test, 210);
1160
// }
1161
// for (int i=0; i<num; i++) {
1162
// if (! stmtf[i]) error(test, 220+i);
1163
// } */
1164
// }
1165

1166            {
1167                NodeIterator iter;
1168                boolean[] object= new boolean[num*num];
1169                n = 300;
1170                for (int i=0; i<(num*num); i++) {
1171                    object[i] = false;
1172                }
1173                iter = m.listObjectsOfProperty(predicate[0]);
1174                while (iter.hasNext()) {
1175                    Literal l = (Literal) iter.nextNode();
1176                    int i = l.getInt();
1177                    object[i] = true;
1178                }
1179                for (int i=0; i<(num*num); i++) {
1180                    if ((i % num) == 0) {
1181                      if (! object[i]) error(test,300+i);
1182                    } else {
1183                      if ( object[i]) error(test,350+i);
1184                    }
1185                }
1186            }
1187
1188            {
1189                NodeIterator iter;
1190                boolean[] object = new boolean[num];
1191                n=400;
1192                Resource subj = m.createResource();
1193                for (int i=0; i<num; i++) {
1194                    m.add(subj, RDF.value, i);
1195                    object[i] = false;
1196                }
1197
1198                iter = m.listObjectsOfProperty(subj, RDF.value);
1199                while (iter.hasNext()) {
1200                    int i = ((Literal)iter.nextNode()).getInt();
1201                    object[i] = true;
1202                }
1203                for (int i=0; i<(num); i++) {
1204                    if (! object[i]) error(test,n+i);
1205                }
1206            }
1207
1208            {
1209                int count = 0;
1210                NodeIterator iter;
1211                n = 500;
1212                iter = m.listObjects();
1213                while (iter.hasNext()) {
1214                    iter.nextNode();
1215                    count++;
1216                }
1217                if (! (count == 25)) error(test, n+count);
1218            }
1219        } catch (Exception JavaDoc e) {
1220            logger.error( "test " + test + "[" + n + "]", e );
1221            errors = true;
1222        }
1223// System.out.println("End of " + test);
1224
}
1225
1226    /** test add and remove sets and models
1227     * @param m the model implementation under test
1228     */

1229    public void test7(Model m1, Model m2) {
1230        String JavaDoc test = "Test7";
1231        int n = 0;
1232
1233        try {
1234            StmtIterator iter;
1235// System.out.println("Beginning " + test);
1236

1237            try {
1238                n=100;
1239                n++; iter = m1.listStatements();
1240                n++; m2.add(iter); iter.close();
1241                n++; if (! (m1.size() == m2.size())) error(test,n);
1242                n++; iter = m1.listStatements();
1243                n=110;
1244                while (iter.hasNext()) {
1245                    n++; if (! m2.contains(iter.nextStatement())) error(test, n);
1246                }
1247                n=200;
1248                iter = m2.listStatements();
1249                while (iter.hasNext()) {
1250                    n++; if (! m1.contains(iter.nextStatement())) error(test,n);
1251                }
1252            } catch (Exception JavaDoc e) {
1253                error(test, n, e);
1254            }
1255
1256            try {
1257                n=300;
1258                m1.add(m1.createResource(),
1259                       RDF.value,
1260                       m1.createResource());
1261                m1.add(m1.createResource(),
1262                       RDF.value,
1263                       m1.createResource());
1264                m1.add(m1.createResource(),
1265                       RDF.value,
1266                       m1.createResource());
1267                n++; iter = m1.listStatements();
1268                n++; m2.remove(iter.nextStatement());
1269                n++; m2.remove(iter); iter.close();
1270                n++; if (! (m2.size() == 0)) error(test,n);
1271            } catch (Exception JavaDoc e) {
1272                error(test, n, e);
1273            }
1274
1275            try {
1276                n=400;
1277                n++; m2.add(m1);
1278                n++; if (! (m1.size() == m2.size())) error(test,n);
1279                n++; iter = m1.listStatements();
1280                n=410;
1281                while (iter.hasNext()) {
1282                    n++; if (! m2.contains(iter.nextStatement())) error(test, n);
1283                }
1284                n=500;
1285                iter = m2.listStatements();
1286                while (iter.hasNext()) {
1287                    n++; if (! m1.contains(iter.nextStatement())) error(test,n);
1288                }
1289            } catch (Exception JavaDoc e) {
1290                error(test, n, e);
1291            }
1292
1293            try {
1294                n=600;
1295                // System.err.println( "| m2.size() = " + m2.size() );
1296
n++; m2.remove(m1);
1297                n++; if (! (m2.size() == 0)) error(test,n);
1298                // System.err.println( "| after: m2.size = " + m2.size() );
1299
} catch (Exception JavaDoc e) {
1300                error(test, n, e);
1301            }
1302        } catch (Exception JavaDoc e) {
1303            logger.error( "test " + test + "[" + n + "]", e );
1304            errors = true;
1305        }
1306// System.out.println("End of " + test);
1307
}
1308
1309    /** test list subjects with methods
1310     * @param m the model implementation under test
1311     */

1312    public void test8(Model m) {
1313        String JavaDoc test = "Test8";
1314        int n = 0;
1315        int num = 5;
1316
1317        Resource subject[] = new Resource[num];
1318        Property predicate[] = new Property[num];
1319        Vector stmtv = new Vector();
1320        Statement stmts[];
1321        Statement stmt;
1322
1323        String JavaDoc suri = "http://aldabaran/test8/s";
1324        String JavaDoc puri = "http://aldabaran/test8/";
1325
1326        boolean tvBoolean[] = { false, true };
1327        long tvLong[] = { 123, 321 };
1328        char tvChar[] = { '@', ';' };
1329        float tvFloat[] = { 456.789f, 789.456f };
1330        double tvDouble[] = { 123.456, 456.123 };
1331        String JavaDoc tvString[] = { "test8 testing string 1",
1332                                   "test8 testing string 2" };
1333        String JavaDoc lang[] = { "en", "fr" };
1334
1335        boolean subjf[] = new boolean[num];
1336        boolean predf[] = new boolean[num];
1337
1338        int numObj = 9;
1339        boolean objf[] = new boolean[numObj];
1340        RDFNode object[] = new RDFNode[numObj];
1341
1342
1343        // System.out.println("Beginning " + test);
1344

1345        try {
1346            Literal tvLitObj[] = { m.createLiteral(new LitTestObjF()),
1347                                        m.createLiteral(new LitTestObjF()) };
1348            Resource tvResObj[] = { m.createResource(new ResTestObjF()),
1349                                        m.createResource(new ResTestObjF()) };
1350
1351            for (int i = 0; i<num; i++) {
1352                subject[i] = m.createResource(suri + Integer.toString(i));
1353                predicate[i] = m.createProperty(puri + Integer.toString(i),
1354                "p");
1355            }
1356
1357            for (int i=0; i<num; i++) {
1358                m.add(subject[i], predicate[4], false);
1359            }
1360
1361            for (int i=0; i<2; i++) {
1362                for (int j=0; j<2; j++) {
1363                    stmt = m.createStatement(subject[i], predicate[j],
1364                                            tvBoolean[j]);
1365                    m.add(stmt);
1366                    stmt = m.createStatement(subject[i], predicate[j],
1367                                             tvLong[j]);
1368                    m.add(stmt);
1369                    stmt = m.createStatement(subject[i], predicate[j],
1370                                             tvChar[j]);
1371                    m.add(stmt);
1372                    stmt = m.createStatement(subject[i], predicate[j],
1373                                             tvFloat[j]);
1374                    m.add(stmt);
1375                    stmt = m.createStatement(subject[i], predicate[j],
1376                                             tvDouble[j]);
1377                    m.add(stmt);
1378                    stmt = m.createStatement(subject[i], predicate[j],
1379                                            tvString[j]);
1380                    m.add(stmt);
1381                    stmt = m.createStatement(subject[i], predicate[j],
1382                                            tvString[j], lang[j]);
1383                    m.add(stmt);
1384                    stmt = m.createStatement(subject[i], predicate[j],
1385                                            tvLitObj[j]);
1386                    m.add(stmt);
1387                    stmt = m.createStatement(subject[i], predicate[j],
1388                                            tvResObj[j]);
1389                    m.add(stmt);
1390                }
1391            }
1392            object[0] = m.createLiteral(tvBoolean[1]);
1393            object[1] = m.createLiteral(tvLong[1]);
1394            object[2] = m.createLiteral(tvChar[1]);
1395            object[3] = m.createLiteral(tvFloat[1]);
1396            object[4] = m.createLiteral(tvDouble[1]);
1397            object[5] = m.createLiteral(tvString[1]);
1398            object[6] = m.createLiteral(tvString[1], lang[1]);
1399            object[7] = tvLitObj[1];
1400            object[8] = tvResObj[1];
1401
1402            n = 100;
1403
1404            n++; stmt = m.getRequiredProperty(subject[1], predicate[1]);
1405
1406            n++; try {
1407                stmt = m.getRequiredProperty(subject[1], RDF.value); error(test,n);
1408            } catch (PropertyNotFoundException jx) {
1409                // as required
1410
}
1411
1412            for (int i=0; i<num; i++) {
1413                subjf[i] = false;
1414            }
1415            boolean found = false;
1416
1417            ResIterator rIter = m.listSubjectsWithProperty(predicate[4]);
1418            while (rIter.hasNext()) {
1419                Resource subj = rIter.nextResource();
1420                found = false;
1421                for (int i=0; i<num; i++) {
1422                    if (subj.equals(subject[i])) {
1423                        found = true;
1424                        if (subjf[i]) error(test, 110);
1425                        subjf[i] = true;
1426                    }
1427                }
1428                if (! found) error(test, 120);
1429            }
1430            for (int i=0; i<num; i++) {
1431                if (! subjf[i]) error(test, 130+i);
1432            }
1433
1434            for (int i=0; i<num; i++) {
1435                subjf[i] = false;
1436            }
1437            found = false;
1438            rIter = m.listSubjectsWithProperty(predicate[0]);
1439            while (rIter.hasNext()) {
1440                Resource subj = rIter.nextResource();
1441                found = false;
1442                for (int i=0; i<num; i++) {
1443                    if (subj.equals(subject[i])) {
1444                        found = true;
1445                        if (subjf[i]) error(test, 150);
1446                        subjf[i] = true;
1447                    }
1448                }
1449                if (! found) error(test, 160);
1450            }
1451            for (int i=0; i<num; i++) {
1452                if (subjf[i]) {
1453                    if (i>1) error(test, 170+i);
1454                } else {
1455                    if (i<2) error(test, 190+i);
1456                }
1457            }
1458
1459            n=200;
1460            // System.out.println( "* -- n := " + n );
1461
for (int i=0; i<num; i++) {
1462                subjf[i] = false;
1463            }
1464            found = false;
1465            rIter = m.listSubjectsWithProperty(predicate[0], tvBoolean[0]);
1466            while (rIter.hasNext()) {
1467                Resource subj = rIter.nextResource();
1468                found = false;
1469                for (int i=0; i<num; i++) {
1470                    if (subj.equals(subject[i])) {
1471                        found = true;
1472                        if (subjf[i]) error(test, n+10);
1473                        subjf[i] = true;
1474                    }
1475                }
1476                if (! found) error(test, n+20);
1477            }
1478            for (int i=0; i<num; i++) {
1479                if (subjf[i]) {
1480                    if (i>1) error(test, n+30+i);
1481                } else {
1482                    if (i<2) error(test, n+40+i);
1483                }
1484            }
1485
1486            for (int i=0; i<num; i++) {
1487                subjf[i] = false;
1488            }
1489            found = false;
1490            rIter = m.listSubjectsWithProperty(predicate[0], tvBoolean[1]);
1491            while (rIter.hasNext()) {
1492                Resource subj = rIter.nextResource();
1493                found = false;
1494                for (int i=0; i<num; i++) {
1495                    if (subj.equals(subject[i])) {
1496                        found = true;
1497                        if (subjf[i]) error(test, n+50);
1498                        subjf[i] = true;
1499                    }
1500                }
1501                if (! found) error(test, n+60);
1502            }
1503            for (int i=0; i<num; i++) {
1504                if (subjf[i]) error(test, n+70+i);
1505            }
1506
1507            n=300;
1508            // System.out.println( "* -- n := " + n );
1509
for (int i=0; i<num; i++) {
1510                subjf[i] = false;
1511            }
1512            found = false;
1513            rIter = m.listSubjectsWithProperty(predicate[0], (byte)tvLong[0]);
1514            while (rIter.hasNext()) {
1515                Resource subj = rIter.nextResource();
1516                // System.out.println( "+ " + subj );
1517
found = false;
1518                for (int i=0; i<num; i++) {
1519                    if (subj.equals(subject[i])) {
1520                        found = true;
1521                        if (subjf[i]) error(test, n+10);
1522                        subjf[i] = true;
1523                    }
1524                }
1525                if (! found) error(test, n+20);
1526            }
1527
1528            for (int i=0; i<num; i++) {
1529                if (subjf[i]) {
1530                    if (i>1) error(test, n+30+i);
1531                } else {
1532                    if (i<2) error(test, n+40+i);
1533                }
1534            }
1535
1536            for (int i=0; i<num; i++) {
1537                subjf[i] = false;
1538            }
1539            found = false;
1540            rIter = m.listSubjectsWithProperty(predicate[0], (byte) tvLong[1]);
1541            while (rIter.hasNext()) {
1542                Resource subj = rIter.nextResource();
1543                found = false;
1544                for (int i=0; i<num; i++) {
1545                    if (subj.equals(subject[i])) {
1546                        found = true;
1547                        if (subjf[i]) error(test, n+50);
1548                        subjf[i] = true;
1549                    }
1550                }
1551                if (! found) error(test, n+60);
1552            }
1553
1554            for (int i=0; i<num; i++) {
1555                if (subjf[i]) error(test, n+70+i);
1556            }
1557
1558            n=400;
1559            // System.out.println( "* -- n := " + n );
1560
for (int i=0; i<num; i++) {
1561                subjf[i] = false;
1562            }
1563            found = false;
1564            rIter = m.listSubjectsWithProperty(predicate[0], (short) tvLong[0]);
1565            while (rIter.hasNext()) {
1566                Resource subj = rIter.nextResource();
1567                found = false;
1568                for (int i=0; i<num; i++) {
1569                    if (subj.equals(subject[i])) {
1570                        found = true;
1571                        if (subjf[i]) error(test, n+10);
1572                        subjf[i] = true;
1573                    }
1574                }
1575                if (! found) error(test, n+20);
1576            }
1577            for (int i=0; i<num; i++) {
1578                if (subjf[i]) {
1579                    if (i>1) error(test, n+30+i);
1580                } else {
1581                    if (i<2) error(test, n+40+i);
1582                }
1583            }
1584
1585            for (int i=0; i<num; i++) {
1586                subjf[i] = false;
1587            }
1588            found = false;
1589            rIter = m.listSubjectsWithProperty(predicate[0], (short) tvLong[1]);
1590            while (rIter.hasNext()) {
1591                Resource subj = rIter.nextResource();
1592                found = false;
1593                for (int i=0; i<num; i++) {
1594                    if (subj.equals(subject[i])) {
1595                        found = true;
1596                        if (subjf[i]) error(test, n+50);
1597                        subjf[i] = true;
1598                    }
1599                }
1600                if (! found) error(test, n+60);
1601            }
1602            for (int i=0; i<num; i++) {
1603                if (subjf[i]) error(test, n+70+i);
1604            }
1605
1606            n=500;
1607            // System.out.println( "* -- n := " + n );
1608
for (int i=0; i<num; i++) {
1609                subjf[i] = false;
1610            }
1611            found = false;
1612            rIter = m.listSubjectsWithProperty(predicate[0], (int) tvLong[0]);
1613            while (rIter.hasNext()) {
1614                Resource subj = rIter.nextResource();
1615                found = false;
1616                for (int i=0; i<num; i++) {
1617                    if (subj.equals(subject[i])) {
1618                        found = true;
1619                        if (subjf[i]) error(test, n+10);
1620                        subjf[i] = true;
1621                    }
1622                }
1623                if (! found) error(test, n+20);
1624            }
1625            for (int i=0; i<num; i++) {
1626                if (subjf[i]) {
1627                    if (i>1) error(test, n+30+i);
1628                } else {
1629                    if (i<2) error(test, n+40+i);
1630                }
1631            }
1632
1633            for (int i=0; i<num; i++) {
1634                subjf[i] = false;
1635            }
1636            found = false;
1637            rIter = m.listSubjectsWithProperty(predicate[0], (int) tvLong[1]);
1638            while (rIter.hasNext()) {
1639                Resource subj = rIter.nextResource();
1640                found = false;
1641                for (int i=0; i<num; i++) {
1642                    if (subj.equals(subject[i])) {
1643                        found = true;
1644                        if (subjf[i]) error(test, n+50);
1645                        subjf[i] = true;
1646                    }
1647                }
1648                if (! found) error(test, n+60);
1649            }
1650            for (int i=0; i<num; i++) {
1651                if (subjf[i]) error(test, n+70+i);
1652            }
1653
1654            // System.out.println( "* -- n := " + n );
1655
n=600;
1656            // System.out.println( "* -- n := " + n );
1657
for (int i=0; i<num; i++) {
1658                subjf[i] = false;
1659            }
1660            found = false;
1661            rIter = m.listSubjectsWithProperty(predicate[0], tvLong[0]);
1662            while (rIter.hasNext()) {
1663                Resource subj = rIter.nextResource();
1664                found = false;
1665                for (int i=0; i<num; i++) {
1666                    if (subj.equals(subject[i])) {
1667                        found = true;
1668                        if (subjf[i]) error(test, n+10);
1669                        subjf[i] = true;
1670                    }
1671                }
1672                if (! found) error(test, n+20);
1673            }
1674            for (int i=0; i<num; i++) {
1675                if (subjf[i]) {
1676                    if (i>1) error(test, n+30+i);
1677                } else {
1678                    if (i<2) error(test, n+40+i);
1679                }
1680            }
1681
1682            for (int i=0; i<num; i++) {
1683                subjf[i] = false;
1684            }
1685            found = false;
1686            rIter = m.listSubjectsWithProperty(predicate[0], tvLong[1]);
1687            while (rIter.hasNext()) {
1688                Resource subj = rIter.nextResource();
1689                found = false;
1690                for (int i=0; i<num; i++) {
1691                    if (subj.equals(subject[i])) {
1692                        found = true;
1693                        if (subjf[i]) error(test, n+50);
1694                        subjf[i] = true;
1695                    }
1696                }
1697                if (! found) error(test, n+60);
1698            }
1699            for (int i=0; i<num; i++) {
1700                if (subjf[i]) error(test, n+70+i);
1701            }
1702
1703            n=700;
1704            for (int i=0; i<num; i++) {
1705                subjf[i] = false;
1706            }
1707            found = false;
1708            rIter = m.listSubjectsWithProperty(predicate[0], tvChar[0]);
1709            while (rIter.hasNext()) {
1710                Resource subj = rIter.nextResource();
1711                found = false;
1712                for (int i=0; i<num; i++) {
1713                    if (subj.equals(subject[i])) {
1714                        found = true;
1715                        if (subjf[i]) error(test, n+10);
1716                        subjf[i] = true;
1717                    }
1718                }
1719                if (! found) error(test, n+20);
1720            }
1721            for (int i=0; i<num; i++) {
1722                if (subjf[i]) {
1723                    if (i>1) error(test, n+30+i);
1724                } else {
1725                    if (i<2) error(test, n+40+i);
1726                }
1727            }
1728
1729            for (int i=0; i<num; i++) {
1730                subjf[i] = false;
1731            }
1732            found = false;
1733            rIter = m.listSubjectsWithProperty(predicate[0], tvChar[1]);
1734            while (rIter.hasNext()) {
1735                Resource subj = rIter.nextResource();
1736                found = false;
1737                for (int i=0; i<num; i++) {
1738                    if (subj.equals(subject[i])) {
1739                        found = true;
1740                        if (subjf[i]) error(test, n+50);
1741                        subjf[i] = true;
1742                    }
1743                }
1744                if (! found) error(test, n+60);
1745            }
1746            for (int i=0; i<num; i++) {
1747                if (subjf[i]) error(test, n+70+i);
1748            }
1749
1750            n=800;
1751            // System.out.println( "* -- n := " + n );
1752
for (int i=0; i<num; i++) {
1753                subjf[i] = false;
1754            }
1755            found = false;
1756            rIter = m.listSubjectsWithProperty(predicate[0], tvDouble[0]);
1757            while (rIter.hasNext()) {
1758                Resource subj = rIter.nextResource();
1759                found = false;
1760                for (int i=0; i<num; i++) {
1761                    if (subj.equals(subject[i])) {
1762                        found = true;
1763                        if (subjf[i]) error(test, n+10);
1764                        subjf[i] = true;
1765                    }
1766                }
1767                if (! found) error(test, n+20);
1768            }
1769            for (int i=0; i<num; i++) {
1770                if (subjf[i]) {
1771                    if (i>1) error(test, n+30+i);
1772                } else {
1773                    if (i<2) error(test, n+40+i);
1774                }
1775            }
1776
1777            for (int i=0; i<num; i++) {
1778                subjf[i] = false;
1779            }
1780            found = false;
1781            rIter = m.listSubjectsWithProperty(predicate[0], tvDouble[1]);
1782            while (rIter.hasNext()) {
1783                Resource subj = rIter.nextResource();
1784                found = false;
1785                for (int i=0; i<num; i++) {
1786                    if (subj.equals(subject[i])) {
1787                        found = true;
1788                        if (subjf[i]) error(test, n+50);
1789                        subjf[i] = true;
1790                    }
1791                }
1792                if (! found) error(test, n+60);
1793            }
1794            for (int i=0; i<num; i++) {
1795                if (subjf[i]) error(test, n+70+i);
1796            }
1797
1798            n=900;
1799            // System.out.println( "* -- n := " + n );
1800
for (int i=0; i<num; i++) {
1801                subjf[i] = false;
1802            }
1803            found = false;
1804            rIter = m.listSubjectsWithProperty(predicate[0], tvDouble[0]);
1805            while (rIter.hasNext()) {
1806                Resource subj = rIter.nextResource();
1807                found = false;
1808                for (int i=0; i<num; i++) {
1809                    if (subj.equals(subject[i])) {
1810                        found = true;
1811                        if (subjf[i]) error(test, n+10);
1812                        subjf[i] = true;
1813                    }
1814                }
1815                if (! found) error(test, n+20);
1816            }
1817            for (int i=0; i<num; i++) {
1818                if (subjf[i]) {
1819                    if (i>1) error(test, n+30+i);
1820                } else {
1821                    if (i<2) error(test, n+40+i);
1822                }
1823            }
1824
1825            for (int i=0; i<num; i++) {
1826                subjf[i] = false;
1827            }
1828            found = false;
1829            rIter = m.listSubjectsWithProperty(predicate[0], tvDouble[1]);
1830            while (rIter.hasNext()) {
1831                Resource subj = rIter.nextResource();
1832                found = false;
1833                for (int i=0; i<num; i++) {
1834                    if (subj.equals(subject[i])) {
1835                        found = true;
1836                        if (subjf[i]) error(test, n+50);
1837                        subjf[i] = true;
1838                    }
1839                }
1840                if (! found) error(test, n+60);
1841            }
1842            for (int i=0; i<num; i++) {
1843                if (subjf[i]) error(test, n+70+i);
1844            }
1845
1846            n=1000;
1847            // System.out.println( "* -- n := " + n );
1848
for (int i=0; i<num; i++) {
1849                subjf[i] = false;
1850            }
1851            found = false;
1852            rIter = m.listSubjectsWithProperty(predicate[0], tvString[0]);
1853            while (rIter.hasNext()) {
1854                Resource subj = rIter.nextResource();
1855                found = false;
1856                for (int i=0; i<num; i++) {
1857                    if (subj.equals(subject[i])) {
1858                        found = true;
1859                        if (subjf[i]) error(test, n+10);
1860                        subjf[i] = true;
1861                    }
1862                }
1863                if (! found) error(test, n+20);
1864            }
1865            for (int i=0; i<num; i++) {
1866                if (subjf[i]) {
1867                    if (i>1) error(test, n+30+i);
1868                } else {
1869                    if (i<2) error(test, n+40+i);
1870                }
1871            }
1872
1873            for (int i=0; i<num; i++) {
1874                subjf[i] = false;
1875            }
1876            found = false;
1877            rIter = m.listSubjectsWithProperty(predicate[0], tvString[1]);
1878            while (rIter.hasNext()) {
1879                Resource subj = rIter.nextResource();
1880                found = false;
1881                for (int i=0; i<num; i++) {
1882                    if (subj.equals(subject[i])) {
1883                        found = true;
1884                        if (subjf[i]) error(test, n+50);
1885                        subjf[i] = true;
1886                    }
1887                }
1888                if (! found) error(test, n+60);
1889            }
1890            for (int i=0; i<num; i++) {
1891                if (subjf[i]) error(test, n+70+i);
1892            }
1893
1894            n=1100;
1895            // System.out.println( "* -- n := " + n );
1896
for (int i=0; i<num; i++) {
1897                subjf[i] = false;
1898            }
1899            found = false;
1900            rIter = m.listSubjectsWithProperty(predicate[0], tvString[0],
1901                                                lang[0]);
1902            while (rIter.hasNext()) {
1903                Resource subj = rIter.nextResource();
1904                found = false;
1905                for (int i=0; i<num; i++) {
1906                    if (subj.equals(subject[i])) {
1907                        found = true;
1908                        if (subjf[i]) error(test, n+10);
1909                        subjf[i] = true;
1910                    }
1911                }
1912                if (! found) error(test, n+20);
1913            }
1914            for (int i=0; i<num; i++) {
1915                if (subjf[i]) {
1916                    if (i>1) error(test, n+30+i);
1917                } else {
1918                    if (i<2) error(test, n+40+i);
1919                }
1920            }
1921
1922            for (int i=0; i<num; i++) {
1923                subjf[i] = false;
1924            }
1925            found = false;
1926            rIter = m.listSubjectsWithProperty(predicate[0], tvString[1]);
1927            while (rIter.hasNext()) {
1928                Resource subj = rIter.nextResource();
1929                found = false;
1930                for (int i=0; i<num; i++) {
1931                    if (subj.equals(subject[i])) {
1932                        found = true;
1933                        if (subjf[i]) error(test, n+50);
1934                        subjf[i] = true;
1935                    }
1936                }
1937                if (! found) error(test, n+60);
1938            }
1939            for (int i=0; i<num; i++) {
1940                if (subjf[i]) error(test, n+70+i);
1941            }
1942
1943            n=1200;
1944            // System.out.println( "* -- n := " + n );
1945
for (int i=0; i<num; i++) {
1946                subjf[i] = false;
1947            }
1948            found = false;
1949            rIter = m.listSubjectsWithProperty(predicate[0], tvLitObj[0]);
1950            while (rIter.hasNext()) {
1951                Resource subj = rIter.nextResource();
1952                found = false;
1953                for (int i=0; i<num; i++) {
1954                    if (subj.equals(subject[i])) {
1955                        found = true;
1956                        if (subjf[i]) error(test, n+10);
1957                        subjf[i] = true;
1958                    }
1959                }
1960                if (! found) error(test, n+20);
1961            }
1962            for (int i=0; i<num; i++) {
1963                if (subjf[i]) {
1964                    if (i>1) error(test, n+30+i);
1965                } else {
1966                    if (i<2) error(test, n+40+i);
1967                }
1968            }
1969
1970            for (int i=0; i<num; i++) {
1971                subjf[i] = false;
1972            }
1973            found = false;
1974            rIter = m.listSubjectsWithProperty(predicate[0], tvLitObj[1]);
1975            while (rIter.hasNext()) {
1976                Resource subj = rIter.nextResource();
1977                found = false;
1978                for (int i=0; i<num; i++) {
1979                    if (subj.equals(subject[i])) {
1980                        found = true;
1981                        if (subjf[i]) error(test, n+50);
1982                        subjf[i] = true;
1983                    }
1984                }
1985                if (! found) error(test, n+60);
1986            }
1987            for (int i=0; i<num; i++) {
1988                if (subjf[i]) error(test, n+70+i);
1989            }
1990
1991            n=1300;
1992            // System.out.println( "* -- n := " + n );
1993
for (int i=0; i<num; i++) {
1994                subjf[i] = false;
1995            }
1996            found = false;
1997            rIter = m.listSubjectsWithProperty(predicate[0], tvResObj[0]);
1998            while (rIter.hasNext()) {
1999                Resource subj = rIter.nextResource();
2000                found = false;
2001                for (int i=0; i<num; i++) {
2002                    if (subj.equals(subject[i])) {
2003                        found = true;
2004                        if (subjf[i]) error(test, n+10);
2005                        subjf[i] = true;
2006                    }
2007                }
2008                if (! found) error(test, n+20);
2009            }
2010            for (int i=0; i<num; i++) {
2011                if (subjf[i]) {
2012                    if (i>1) error(test, n+30+i);
2013                } else {
2014                    if (i<2) error(test, n+40+i);
2015                }
2016            }
2017
2018            for (int i=0; i<num; i++) {
2019                subjf[i] = false;
2020            }
2021            found = false;
2022            rIter = m.listSubjectsWithProperty(predicate[0], tvResObj[1]);
2023            while (rIter.hasNext()) {
2024                Resource subj = rIter.nextResource();
2025                found = false;
2026                for (int i=0; i<num; i++) {
2027                    if (subj.equals(subject[i])) {
2028                        found = true;
2029                        if (subjf[i]) error(test, n+50);
2030                        subjf[i] = true;
2031                    }
2032                }
2033                if (! found) error(test, n+60);
2034            }
2035            for (int i=0; i<num; i++) {
2036                if (subjf[i]) error(test, n+70+i);
2037            }
2038
2039            n = 1400;
2040            // System.out.println( "* -- n := " + n );
2041
for (int i=0; i<num; i++) {
2042                subjf[i] = false;
2043            }
2044            NodeIterator nIter = m.listObjectsOfProperty(predicate[1]);
2045            while (nIter.hasNext()) {
2046                RDFNode obj = nIter.nextNode();
2047                found = false;
2048                for (int i=0; i<numObj; i++) {
2049                    if (obj.equals(object[i])) {
2050                        found = true;
2051                        if (objf[i]) error(test, n+50);
2052                        objf[i] = true;
2053                    }
2054                }
2055                if (! found) error(test, n+60);
2056            }
2057            for (int i=0; i<numObj; i++) {
2058                if (!objf[i]) error(test, n+70+i);
2059            }
2060
2061        } catch (Exception JavaDoc e) {
2062            logger.error( "test " + test + "[" + n + "]", e );
2063            errors = true;
2064        }
2065       // System.out.println("End of " + test);
2066
}
2067
2068    /** test the list statements methods of model
2069     * @param m the model implementation under test
2070     */

2071    public void test9(Model m) {
2072        String JavaDoc test = "Test9";
2073        int n = 0;
2074        int num = 2;
2075
2076        Resource subject[] = new Resource[num];
2077        Property predicate[] = new Property[num];
2078        Vector stmtv = new Vector();
2079        Statement stmts[];
2080        Statement stmt;
2081
2082        String JavaDoc suri = "http://aldabaran/test9/s";
2083        String JavaDoc puri = "http://aldabaran/test9/";
2084
2085        boolean tvBoolean[] = { false, true };
2086        long tvLong[] = { 123, 321 };
2087        char tvChar[] = { '@', ';' };
2088        double tvDouble[] = { 123.456, 456.123 };
2089        String JavaDoc tvString[] = { "test8 testing string 1",
2090                                   "test8 testing string 2" };
2091        String JavaDoc lang[] = { "en", "fr" };
2092
2093// System.out.println("Beginning " + test);
2094

2095        try {
2096            Literal tvLitObj[] = { m.createLiteral(new LitTestObjF()),
2097                                        m.createLiteral(new LitTestObjF()) };
2098            Resource tvResObj[] = { m.createResource(new ResTestObjF()),
2099                                        m.createResource(new ResTestObjF()) };
2100
2101            for (int i = 0; i<num; i++) {
2102                subject[i] = m.createResource(suri + Integer.toString(i));
2103                predicate[i] = m.createProperty(puri + Integer.toString(i),
2104                "p");
2105            }
2106
2107            for (int i=0; i<num; i++) {
2108                for (int j=0; j<num; j++) {
2109                    stmt = m.createStatement(subject[i], predicate[j],
2110                                            tvBoolean[j]);
2111                    m.add(stmt);
2112                    stmt = m.createStatement(subject[i], predicate[j],
2113                                             tvLong[j]);
2114                    m.add(stmt);
2115                    stmt = m.createStatement(subject[i], predicate[j],
2116                                             tvChar[j]);
2117                    m.add(stmt);
2118                    stmt = m.createStatement(subject[i], predicate[j],
2119                                             tvDouble[j]);
2120                    m.add(stmt);
2121                    stmt = m.createStatement(subject[i], predicate[j],
2122                                            tvString[j]);
2123                    m.add(stmt);
2124                    stmt = m.createStatement(subject[i], predicate[j],
2125                                            tvString[j], lang[j]);
2126                    m.add(stmt);
2127                    stmt = m.createStatement(subject[i], predicate[j],
2128                                            tvLitObj[j]);
2129                    m.add(stmt);
2130                    stmt = m.createStatement(subject[i], predicate[j],
2131                                            tvResObj[j]);
2132                    m.add(stmt);
2133                }
2134            }
2135
2136            StmtIterator iter;
2137            n=100;
2138            int count = 0;
2139            n++; iter = m.listStatements(
2140                                  new SimpleSelector(null, null, (RDFNode)null));
2141            while (iter.hasNext()) {
2142                iter.nextStatement();
2143                count++;
2144            }
2145            n++; iter.close();
2146            n++; if (! (count==num*num*8)) {
2147                error(test,n);
2148                System.err.println(count);
2149            }
2150
2151
2152
2153            class foo extends SimpleSelector
2154            {
2155                public foo(Resource s, Property p, RDFNode o) {
2156                    super(s,p,o);
2157                }
2158                public boolean selects(Statement s) {return false;}
2159            }
2160
2161            n=110;
2162            count = 0;
2163            n++; iter = m.listStatements(
2164                           new SimpleSelector(subject[0], null, (RDFNode) null));
2165            while (iter.hasNext()) {
2166                stmt = iter.nextStatement();
2167                if (! stmt.getSubject().equals(subject[0])) error(test, n);
2168                count++;
2169            }
2170            n++; iter.close();
2171            n++; if (! (count==num*8)) error(test,n);
2172
2173            n=120;
2174            count = 0;
2175            n++; iter = m.listStatements(
2176                           new SimpleSelector(null, predicate[1], (RDFNode) null));
2177            while (iter.hasNext()) {
2178                stmt = iter.nextStatement();
2179                if (! stmt.getPredicate().equals(predicate[1])) error(test, n);
2180                count++;
2181            }
2182            n++; iter.close();
2183            n++; if (! (count==num*8)) error(test,n);
2184
2185            n=130;
2186            count = 0;
2187            n++; iter = m.listStatements(
2188                            new SimpleSelector(null, null, tvResObj[1]));
2189            while (iter.hasNext()) {
2190                stmt = iter.nextStatement();
2191                if (! stmt.getObject().equals(tvResObj[1])) error(test, n);
2192                count++;
2193            }
2194            n++; iter.close();
2195            n++; if (! (count==2)) error(test,n);
2196
2197            n=140;
2198            count = 0;
2199            n++; iter = m.listStatements(
2200                            new SimpleSelector(null, null, false));
2201            while (iter.hasNext()) {
2202                stmt = iter.nextStatement();
2203                if ( stmt.getBoolean()) error(test, n);
2204                count++;
2205            }
2206            n++; iter.close();
2207            n++; if (! (count==2)) error(test,n);
2208
2209            n=150;
2210            count=0;
2211            n++; iter=m.listStatements(
2212                          new SimpleSelector(null, null, tvString[1], lang[1]));
2213            n++; while (iter.hasNext()) {
2214                    stmt = iter.nextStatement();
2215                    if (! stmt.getLanguage().equals(lang[1])) error(test,n);
2216                    count++;
2217                }
2218            n++; iter.close();
2219            n++; if (! (count==2)) error(test,n);
2220
2221        } catch (Exception JavaDoc e) {
2222            logger.error( "test " + test + "[" + n + "]", e );
2223            errors = true;
2224        }
2225// System.out.println("End of " + test);
2226
}
2227
2228    /** test the query statements methods of model
2229     * @param m the model implementation under test
2230     */

2231    public void test10(Model m) {
2232        String JavaDoc test = "Test10";
2233        int n = 0;
2234        int num = 2;
2235
2236        Resource subject[] = new Resource[num];
2237        Property predicate[] = new Property[num];
2238        Vector stmtv = new Vector();
2239        Statement stmts[];
2240        Statement stmt;
2241
2242        String JavaDoc suri = "http://aldabaran/test10/s";
2243        String JavaDoc puri = "http://aldabaran/test10/";
2244
2245        boolean tvBoolean[] = { false, true };
2246        long tvLong[] = { 123, 321 };
2247        char tvChar[] = { '@', ';' };
2248        double tvDouble[] = { 123.456, 456.123 };
2249        String JavaDoc tvString[] = { "test8 testing string 1",
2250                                   "test8 testing string 2" };
2251        String JavaDoc lang[] = { "en", "fr" };
2252
2253// System.out.println("Beginning " + test);
2254

2255        try {
2256            Literal tvLitObj[] =
2257                                     { m.createLiteral(new LitTestObj(1)),
2258                                       m.createLiteral(new LitTestObj(2))};
2259            Resource tvResObj[] = { m.createResource(new ResTestObjF()),
2260                                        m.createResource(new ResTestObjF()) };
2261
2262            for (int i = 0; i<num; i++) {
2263                subject[i] = m.createResource(suri + Integer.toString(i));
2264                predicate[i] = m.createProperty(puri + Integer.toString(i),
2265                "p");
2266            }
2267
2268            for (int i=0; i<num; i++) {
2269                for (int j=0; j<num; j++) {
2270                    stmt = m.createStatement(subject[i], predicate[j],
2271                                            tvBoolean[j]);
2272                    m.add(stmt);
2273                    stmt = m.createStatement(subject[i], predicate[j],
2274                                             tvLong[j]);
2275                    m.add(stmt);
2276                    stmt = m.createStatement(subject[i], predicate[j],
2277                                             tvChar[j]);
2278                    m.add(stmt);
2279                    stmt = m.createStatement(subject[i], predicate[j],
2280                                             tvDouble[j]);
2281                    m.add(stmt);
2282                    stmt = m.createStatement(subject[i], predicate[j],
2283                                            tvString[j]);
2284                    m.add(stmt);
2285                    stmt = m.createStatement(subject[i], predicate[j],
2286                                            tvString[j], lang[i]);
2287                    m.add(stmt);
2288                    stmt = m.createStatement(subject[i], predicate[j],
2289                                            tvLitObj[j]);
2290                    m.add(stmt);
2291                    stmt = m.createStatement(subject[i], predicate[j],
2292                                            tvResObj[j]);
2293                    m.add(stmt);
2294                    stmt = m.createStatement(subject[i], predicate[j],
2295                                            tvResObj[j]);
2296                    m.add(stmt);
2297                }
2298            }
2299
2300            Model mm;
2301            StmtIterator iter;
2302            n=100;
2303            int count = 0;
2304            n++; mm = m.query(new SimpleSelector(null, null, (RDFNode)null));
2305            n++; iter = mm.listStatements();
2306            while (iter.hasNext()) {
2307                iter.nextStatement();
2308                count++;
2309            }
2310            n++; iter.close();
2311            n++; if (! (count==num*num*8)) error(test,n);
2312            n++; if (! (mm.size() == count)) error(test,n);
2313
2314            n=110;
2315            count = 0;
2316            n++; mm = m.query(
2317                           new SimpleSelector(subject[0], null, (RDFNode) null));
2318            n++; iter = mm.listStatements();
2319            while (iter.hasNext()) {
2320                stmt = iter.nextStatement();
2321                if (! stmt.getSubject().equals(subject[0])) error(test, n);
2322                count++;
2323            }
2324            n++; iter.close();
2325            n++; if (! (count==num*8)) error(test,n);
2326            n++; if (! (mm.size()==count))error(test,n);
2327
2328            n=120;
2329            count = 0;
2330            n++; mm = m.query(
2331                        new SimpleSelector(null, predicate[1], (RDFNode) null));
2332            n++; iter = mm.listStatements();
2333            while (iter.hasNext()) {
2334                stmt = iter.nextStatement();
2335                if (! stmt.getPredicate().equals(predicate[1])) error(test, n);
2336                count++;
2337            }
2338            n++; iter.close();
2339            n++; if (! (count==num*8)) error(test,n);
2340            n++; if (! (mm.size()==count)) error(test,n);
2341
2342            n=130;
2343            count = 0;
2344            n++; mm = m.query(new SimpleSelector(null, null, tvResObj[1]));
2345            n++; iter = mm.listStatements();
2346            while (iter.hasNext()) {
2347                stmt = iter.nextStatement();
2348                if (! stmt.getObject().equals(tvResObj[1])) error(test, n);
2349                count++;
2350            }
2351            n++; iter.close();
2352            n++; if (! (count==2)) error(test,n);
2353            n++; if (! (mm.size()==count)) error(test,n);
2354
2355            n=140;
2356            count = 0;
2357            n++; mm = m.query(new SimpleSelector(null, null, false));
2358            n++; iter = mm.listStatements();
2359            while (iter.hasNext()) {
2360                stmt = iter.nextStatement();
2361                if ( stmt.getBoolean()) error(test, n);
2362                count++;
2363            }
2364            n++; iter.close();
2365            n++; if (! (count==2)) error(test,n);
2366            n++; if (! (mm.size()==count)) error(test,n);
2367
2368            n=150;
2369            n++; mm=m.query(new SimpleSelector(null, null, tvString[1], lang[0]));
2370            n++; if (! (mm.size()==1)) error(test,n);
2371            n++; iter=mm.listStatements();
2372            n++; while (iter.hasNext()) {
2373                    stmt = iter.nextStatement();
2374                    if (! stmt.getLanguage().equals(lang[0])) error(test,n);
2375                }
2376                iter.close();
2377
2378
2379        } catch (Exception JavaDoc e) {
2380            logger.error( "test " + test + "[" + n + "]", e );
2381            errors = true;
2382        }
2383// System.out.println("End of " + test);
2384
}
2385
2386    /** test model set operations
2387     * @param m the model implementation under test
2388     */

2389    public void test11(Model m1, Model m2) {
2390        String JavaDoc test = "Test11";
2391        int n = 0;
2392        Statement stmt;
2393
2394        Model um = null;
2395        Model im = null;
2396        Model dm = null;
2397
2398        if (! ( m1.supportsSetOperations() // jjc
2399
&& m2.supportsSetOperations() ) ) // jjc
2400
return; // jjc
2401

2402
2403        try {
2404            StmtIterator iter;
2405// System.out.println("Beginning " + test);
2406

2407            try {
2408                n=100;
2409                m2.add(m2.createResource(new ResTestObjF()), RDF.value, 1);
2410                if (m1.containsAll(m2)) error(test,n);
2411                n++; um = m1.union(m2);
2412                n++; iter = um.listStatements();
2413                while (iter.hasNext()) {
2414                    stmt = iter.nextStatement();
2415                    if (! (m1.contains(stmt) || m2.contains(stmt))) {
2416                        System.out.println(stmt.toString());
2417                        error(test,n);
2418                    }
2419                }
2420                n++; iter.close();
2421                n++; iter = m1.listStatements();
2422                while (iter.hasNext()) {
2423                    stmt = iter.nextStatement();
2424                    if (! um.contains(stmt)) error(test,n);
2425                }
2426                n++; iter.close();
2427                n++; iter = m2.listStatements();
2428                while (iter.hasNext()) {
2429                    stmt = iter.nextStatement();
2430                    if (! um.contains(stmt)) error(test,n);
2431                }
2432                n++; iter.close();
2433
2434                n++; if (!um.containsAll(m1)) error(test,n);
2435                n++; if (!um.containsAll(m2)) error(test,n);
2436                n++; iter = m1.listStatements();
2437                n++; if (!um.containsAll(iter)) error(test,n);
2438                     iter.close();
2439            } catch (Exception JavaDoc e) {
2440                error(test, n, e);
2441            }
2442
2443            try {
2444                n=200;
2445                im= um.intersection(m1);
2446                n++; iter = im.listStatements();
2447                while (iter.hasNext()) {
2448                    stmt = iter.nextStatement();
2449                    if (! (um.contains(stmt) && m1.contains(stmt)))
2450                        error(test,n);
2451                }
2452                n++; iter.close();
2453                n++; iter = um.listStatements();
2454                while (iter.hasNext()) {
2455                    stmt = iter.nextStatement();
2456                    if (m1.contains(stmt)) {
2457                        if (! im.contains(stmt)) error(test,n);
2458                    }
2459                }
2460                n++; iter.close();
2461                n++; iter = m1.listStatements();
2462                while (iter.hasNext()) {
2463                    stmt = iter.nextStatement();
2464                    if (m1.contains(stmt)) {
2465                        if (! im.contains(stmt)) error(test,n);
2466                    }
2467                }
2468                n++; iter.close();
2469            } catch (Exception JavaDoc e) {
2470                error(test, n, e);
2471            }
2472
2473            try {
2474                n=300;
2475                dm = um.difference(m2);
2476                n++; iter = dm.listStatements();
2477                while (iter.hasNext()) {
2478                    stmt = iter.nextStatement();
2479                    if (! (um.contains(stmt) && !(m2.contains(stmt))))
2480                        error(test,n);
2481                }
2482                n++; iter.close();
2483                n++; iter = um.listStatements();
2484                while (iter.hasNext()) {
2485                    stmt = iter.nextStatement();
2486                    if (m2.contains(stmt)) {
2487                        if ( dm.contains(stmt)) error(test,n);
2488                    } else {
2489                        if (! dm.contains(stmt)) error(test, 1000+n);
2490                    }
2491                }
2492                n++; iter.close();
2493                n++; iter = m2.listStatements();
2494                while (iter.hasNext()) {
2495                    stmt = iter.nextStatement();
2496                    if ( dm.contains(stmt)) error(test,n);
2497                }
2498                n++; iter.close();
2499                n++; if (dm.containsAny(m2)) error(test,n);
2500                n++; iter = m2.listStatements();
2501                n++; if (dm.containsAny(iter)) error(test,n);
2502                n++; iter.close();
2503            } catch (Exception JavaDoc e) {
2504                error(test, n, e);
2505            }
2506        } catch (Exception JavaDoc e) {
2507            logger.error( "test " + test + "[" + n + "]", e );
2508            errors = true;
2509        }
2510// System.out.println("End of " + test);
2511
}
2512
2513    /** test Resource methods
2514     * @param m the model implementation under test
2515     */

2516    public void test12(Model m) {
2517        String JavaDoc test = "Test12";
2518        int n = 0;
2519
2520        try {
2521            StmtIterator iter;
2522// System.out.println("Beginning " + test);
2523
Resource r = m.createResource();
2524            boolean tvBoolean = true;
2525            byte tvByte = 1;
2526            short tvShort = 2;
2527            int tvInt = -1;
2528            long tvLong = -2;
2529            char tvChar = '!';
2530            float tvFloat = (float) 123.456;
2531            double tvDouble = -123.456;
2532            String JavaDoc tvString = "test 12 string";
2533            LitTestObj tvObject = new LitTestObj(12345);
2534            Literal tvLiteral = m.createLiteral("test 12 string 2");
2535            Resource tvResource = m.createResource();
2536            String JavaDoc lang = "en";
2537            Statement stmt;
2538
2539            n = 100;
2540            n++; if (! r.addProperty(RDF.value, tvByte)
2541                        .hasProperty(RDF.value, tvByte)) error(test, n);
2542            n++; if (! r.addProperty(RDF.value, tvShort)
2543                        .hasProperty(RDF.value, tvShort)) error(test, n);
2544            n++; if (! r.addProperty(RDF.value, tvInt)
2545                        .hasProperty(RDF.value, tvInt)) error(test, n);
2546            n++; if (! r.addProperty(RDF.value, tvLong)
2547                        .hasProperty(RDF.value, tvLong)) error(test, n);
2548            n++; if (! r.addProperty(RDF.value, tvChar)
2549                        .hasProperty(RDF.value, tvChar)) error(test, n);
2550            n++; if (! r.addProperty(RDF.value, tvFloat)
2551                        .hasProperty(RDF.value, tvFloat)) error(test, n);
2552            n++; if (! r.addProperty(RDF.value, tvDouble)
2553                        .hasProperty(RDF.value, tvDouble)) error(test, n);
2554            n++; if (! r.addProperty(RDF.value, tvString)
2555                        .hasProperty(RDF.value, tvString)) error(test, n);
2556            n++; if (! r.addProperty(RDF.value, tvString, lang)
2557                        .hasProperty(RDF.value, tvString, lang)) error(test, n);
2558            n++; if (! r.addProperty(RDF.value, tvObject)
2559                        .hasProperty(RDF.value, tvObject)) error(test, n);
2560            n++; if (! r.addProperty(RDF.value, tvLiteral)
2561                        .hasProperty(RDF.value, tvLiteral)) error(test, n);
2562            n++; if (! r.addProperty(RDF.value, tvResource)
2563                        .hasProperty(RDF.value, tvResource)) error(test, n);
2564            n++; if (! r.getRequiredProperty(RDF.value).getSubject().equals(r))
2565                       error(test,n);
2566            n++; try {
2567                     r.getRequiredProperty(RDF.type); error(test, n);
2568                } catch (PropertyNotFoundException e) { // as expected
2569
}
2570            n++; iter = r.listProperties(RDF.value);
2571                 int count = 0;
2572                 while (iter.hasNext()) {
2573                    stmt = iter.nextStatement();
2574                    if (! stmt.getSubject().equals(r)) error(test, n);
2575                    count++;
2576                }
2577           n++; if (count != 12) error(test,n);
2578           n++; iter = r.listProperties(RDF.type);
2579                 count = 0;
2580                 while (iter.hasNext()) {
2581                    stmt = iter.nextStatement();
2582                    if (! stmt.getSubject().equals(r)) error(test, n);
2583                    count++;
2584                }
2585           n++; if (count != 0) error(test,n);
2586           n++; iter = r.listProperties();
2587                 count = 0;
2588                 while (iter.hasNext()) {
2589                    stmt = iter.nextStatement();
2590                    if (! stmt.getSubject().equals(r)) error(test, n);
2591                    count++;
2592                }
2593           n++; if (count != 12) error(test,n);
2594
2595           n++; r.removeProperties();
2596           n++; Model mm = m.query(new SimpleSelector(r, null, (RDFNode) null));
2597                if (! (mm.size()==0)) error(test,n);
2598
2599        } catch (Exception JavaDoc e) {
2600            logger.error( "test " + test + "[" + n + "]", e );
2601            errors = true;
2602        }
2603// System.out.println("End of " + test);
2604
}
2605
2606
2607    /** Test Statement methods
2608     * @param m the model implementation under test
2609     */

2610    public void test13(Model m) {
2611        String JavaDoc test = "Test13";
2612        int n = 0;
2613
2614        try {
2615            StmtIterator iter;
2616// System.out.println("Beginning " + test);
2617
Resource r = m.createResource();
2618            boolean tvBoolean = true;
2619            byte tvByte = 1;
2620            short tvShort = 2;
2621            int tvInt = -1;
2622            long tvLong = -2;
2623            char tvChar = '!';
2624            float tvFloat = (float) 123.456;
2625            double tvDouble = -123.456;
2626            String JavaDoc tvString = "test 12 string";
2627            LitTestObj tvObject = new LitTestObj(12345);
2628            Literal tvLiteral = m.createLiteral("test 12 string 2");
2629            Resource tvResObj = m.createResource(new ResTestObjF());
2630            Object JavaDoc tvLitObj = new LitTestObj(1234);
2631            Bag tvBag = m.createBag();
2632            Alt tvAlt = m.createAlt();
2633            Seq tvSeq = m.createSeq();
2634            Resource tvResource = m.createResource();
2635            String JavaDoc lang = "fr";
2636            Statement stmt;
2637
2638            n=100;
2639            n++; if (! m.createStatement(r, RDF.value, r)
2640                        .getResource()
2641                        .equals(r)) error(test,n);
2642            n++; try {
2643                       m.createStatement(r, RDF.value, false)
2644                        .getResource();
2645                       error(test,n);
2646                } catch(ResourceRequiredException e) {
2647                    // as required
2648
}
2649            n++; if (! m.createStatement(r, RDF.value, true)
2650                        .getLiteral()
2651                        .getBoolean()) error(test,n);
2652            n++; try {
2653                       m.createStatement(r, RDF.value, r)
2654                        .getLiteral();
2655                       error(test,n);
2656                } catch(LiteralRequiredException e) {
2657                    // as required
2658
}
2659            n = 200;
2660            n++; if (! m.createStatement(r, RDF.value, true)
2661                        .getBoolean()) error(test,n);
2662            n++; if (! (m.createStatement(r, RDF.value, tvByte)
2663                         .getByte()==tvByte)) error(test,n);
2664            n++; if (! (m.createStatement(r, RDF.value, tvShort)
2665                         .getShort()==tvShort)) error(test,n);
2666            n++; if (! (m.createStatement(r, RDF.value, tvInt)
2667                         .getInt()==tvInt)) error(test,n);
2668            n++; if (! (m.createStatement(r, RDF.value, tvLong)
2669                         .getLong()==tvLong)) error(test,n);
2670            n++; if (! (m.createStatement(r, RDF.value, tvChar)
2671                         .getChar()==tvChar)) error(test,n);
2672            n++; if (! (m.createStatement(r, RDF.value, tvFloat)
2673                         .getFloat()==tvFloat)) error(test,n);
2674            n++; if (! (m.createStatement(r, RDF.value, tvDouble)
2675                         .getDouble()==tvDouble)) error(test,n);
2676            n++; if (! (m.createStatement(r, RDF.value, tvString)
2677                         .getString().equals(tvString))) error(test,n);
2678            n++; if (! (m.createStatement(r, RDF.value, tvString, lang)
2679                         .getString().equals(tvString))) error(test,n);
2680            n++; if (! (m.createStatement(r, RDF.value, tvString,lang)
2681                         .getLanguage().equals(lang))) error(test,n);
2682            n++; if (! (m.createStatement(r, RDF.value, tvResObj)
2683                         .getResource(new ResTestObjF())
2684                         .equals(tvResObj))) error(test,n);
2685            n++; if (! (m.createStatement(r, RDF.value, tvLitObj)
2686                         .getObject(new LitTestObjF())
2687                         .equals(tvLitObj))) error(test,n);
2688            n++; if (! (m.createStatement(r, RDF.value, tvBag)
2689                         .getBag().equals(tvBag))) error(test,n);
2690            n++; if (! (m.createStatement(r, RDF.value, tvAlt)
2691                         .getAlt().equals(tvAlt))) error(test,n);
2692            n++; if (! (m.createStatement(r, RDF.value, tvSeq)
2693                         .getSeq().equals(tvSeq))) error(test,n);
2694            n=300;
2695            n++; stmt = m.createStatement(m.createResource(),
2696                                          RDF.value, tvBoolean);
2697            n++; m.add(stmt);
2698            n++; stmt = stmt.changeObject(!tvBoolean);
2699            n++; if (! (stmt.getBoolean() == !tvBoolean)) error(test,n);
2700            n++; if ( m.contains(stmt.getSubject(), RDF.value, tvBoolean))
2701                        error(test,n);
2702            n++; if (! m.contains(stmt.getSubject(), RDF.value, !tvBoolean))
2703                       error(test,n);
2704
2705            n=310;
2706            n++; stmt = m.createStatement(m.createResource(),
2707                                          RDF.value, tvBoolean);
2708            n++; m.add(stmt);
2709            n++; stmt = stmt.changeObject(tvByte);
2710            n++; if (! (stmt.getByte() == tvByte)) error(test,n);
2711            n++; if ( m.contains(stmt.getSubject(), RDF.value, tvBoolean))
2712                        error(test,n);
2713            n++; if (! m.contains(stmt.getSubject(), RDF.value, tvByte))
2714                       error(test,n);
2715
2716            n= 320;
2717            n++; stmt = m.createStatement(m.createResource(),
2718                                          RDF.value, tvBoolean);
2719            n++; m.add(stmt);
2720            n++; stmt = stmt.changeObject(tvShort);
2721            n++; if (! (stmt.getShort() == tvShort)) error(test,n);
2722            n++; if ( m.contains(stmt.getSubject(), RDF.value, tvBoolean))
2723                        error(test,n);
2724            n++; if (! m.contains(stmt.getSubject(), RDF.value, tvShort))
2725                       error(test,n);
2726
2727            n=330;
2728            n++; stmt = m.createStatement(m.createResource(),
2729                                          RDF.value, tvBoolean);
2730            n++; m.add(stmt);
2731            n++; stmt = stmt.changeObject(tvInt);
2732            n++; if (! (stmt.getInt() == tvInt)) error(test,n);
2733            n++; if ( m.contains(stmt.getSubject(), RDF.value, tvBoolean))
2734                        error(test,n);
2735            n++; if (! m.contains(stmt.getSubject(), RDF.value, tvInt))
2736                       error(test,n);
2737
2738            n=340;
2739            n++; stmt = m.createStatement(m.createResource(),
2740                                          RDF.value, tvBoolean);
2741            n++; m.add(stmt);
2742            n++; stmt = stmt.changeObject(tvLong);
2743            n++; if (! (stmt.getLong() == tvLong)) error(test,n);
2744            n++; if ( m.contains(stmt.getSubject(), RDF.value, tvBoolean))
2745                        error(test,n);
2746            n++; if (! m.contains(stmt.getSubject(), RDF.value, tvLong))
2747                       error(test,n);
2748
2749            n=350;
2750            n++; stmt = m.createStatement(m.createResource(),
2751                                          RDF.value, tvBoolean);
2752            n++; m.add(stmt);
2753            n++; stmt = stmt.changeObject(tvChar);
2754            n++; if (! (stmt.getChar() == tvChar)) error(test,n);
2755            n++; if ( m.contains(stmt.getSubject(), RDF.value, tvBoolean))
2756                        error(test,n);
2757            n++; if (! m.contains(stmt.getSubject(), RDF.value, tvChar))
2758                       error(test,n);
2759
2760            n=360;
2761            n++; stmt = m.createStatement(m.createResource(),
2762                                          RDF.value, tvBoolean);
2763            n++; m.add(stmt);
2764            n++; stmt = stmt.changeObject(tvFloat);
2765            n++; if (! ((stmt.getFloat()-tvFloat)<0.00005)) error(test,n);
2766            n++; if ( m.contains(stmt.getSubject(), RDF.value, tvBoolean))
2767                        error(test,n);
2768            n++; if (! m.contains(stmt.getSubject(), RDF.value, tvFloat))
2769                       error(test,n);
2770
2771            n=370;
2772            n++; stmt = m.createStatement(m.createResource(),
2773                                          RDF.value, tvBoolean);
2774            n++; m.add(stmt);
2775            n++; stmt = stmt.changeObject(tvDouble);
2776            n++; if (! ((stmt.getDouble()-tvDouble)<0.0005)) error(test,n);
2777            n++; if ( m.contains(stmt.getSubject(), RDF.value, tvBoolean))
2778                        error(test,n);
2779            n++; if (! m.contains(stmt.getSubject(), RDF.value, tvDouble))
2780                       error(test,n);
2781
2782            n=380;
2783            n++; stmt = m.createStatement(m.createResource(),
2784                                          RDF.value, tvBoolean);
2785            n++; stmt = m.createStatement(m.createResource(),
2786                                          RDF.value, tvBoolean);
2787            n++; m.add(stmt);
2788            n++; stmt = stmt.changeObject(tvString);
2789            n++; if (! (stmt.getString().equals(tvString))) error(test,n);
2790            n++; if ( m.contains(stmt.getSubject(), RDF.value, tvBoolean))
2791                        error(test,n);
2792            n++; if (! m.contains(stmt.getSubject(), RDF.value, tvString))
2793                       error(test,n);
2794            n++; stmt = stmt.changeObject(tvString, lang);
2795            n++; if (! (stmt.getString().equals(tvString))) error(test,n);
2796            n++; if ( m.contains(stmt.getSubject(), RDF.value, tvString))
2797                        error(test,n);
2798            n++; if (! m.contains(stmt.getSubject(), RDF.value, tvString, lang))
2799                       error(test,n);
2800
2801            n=390;
2802            n++; stmt = m.createStatement(m.createResource(),
2803                                          RDF.value, tvBoolean);
2804            n++; m.add(stmt);
2805            n++; stmt = stmt.changeObject(tvResObj);
2806            n++; if (! (stmt.getResource().equals(tvResObj))) error(test,n);
2807            n++; if ( m.contains(stmt.getSubject(), RDF.value, tvBoolean))
2808                        error(test,n);
2809            n++; if (! m.contains(stmt.getSubject(), RDF.value, tvResObj))
2810                       error(test,n);
2811
2812            n=400;
2813            n++; stmt = m.createStatement(m.createResource(),
2814                                          RDF.value, tvBoolean);
2815            n++; m.add(stmt);
2816            n++; stmt = stmt.changeObject(tvLitObj);
2817            n++; if (! (stmt.getObject(new LitTestObjF()).equals(tvLitObj)))
2818                      error(test,n);
2819            n++; if ( m.contains(stmt.getSubject(), RDF.value, tvBoolean))
2820                        error(test,n);
2821            n++; if (! m.contains(stmt.getSubject(), RDF.value, tvLitObj))
2822                       error(test,n);
2823
2824            n=500;
2825            n++; stmt = m.createStatement(m.createResource(),
2826                                          RDF.value, tvBoolean);
2827            n++; m.add(stmt);
2828            n++; m.remove(stmt);
2829            n++; if ( m.contains(stmt.getSubject(), RDF.value, tvBoolean))
2830                        error(test,n);
2831        } catch (Exception JavaDoc e) {
2832            logger.error( "test " + test + "[" + n + "]", e );
2833            errors = true;
2834        }
2835// System.out.println("End of " + test);
2836
}
2837
2838    /** test bag
2839     * @param m the model implementation under test
2840     */

2841    public void test14(Model m) {
2842        String JavaDoc test = "Test14";
2843        int n = 0;
2844
2845        try {
2846            NodeIterator nIter;
2847            StmtIterator sIter;
2848// System.out.println("Beginning " + test);
2849
boolean tvBoolean = true;
2850            byte tvByte = 1;
2851            short tvShort = 2;
2852            int tvInt = -1;
2853            long tvLong = -2;
2854            char tvChar = '!';
2855            float tvFloat = (float) 123.456;
2856            double tvDouble = -123.456;
2857            String JavaDoc tvString = "test 12 string";
2858            LitTestObj tvObject = new LitTestObj(12345);
2859            Literal tvLiteral = m.createLiteral("test 12 string 2");
2860            Resource tvResObj = m.createResource(new ResTestObjF());
2861            Object JavaDoc tvLitObj = new LitTestObj(1234);
2862            Bag tvBag = m.createBag();
2863            Alt tvAlt = m.createAlt();
2864            Seq tvSeq = m.createSeq();
2865            int num=10;
2866            Statement stmt;
2867
2868            n=100;
2869            n++; Bag bag = m.createBag();
2870            n++; if (! m.contains(bag, RDF.type, RDF.Bag)) error(test,n);
2871            n++; if (! (bag.size() == 0)) error(test,n);
2872
2873            n=200;
2874            n++; bag.add(tvBoolean);
2875            n++; if (! bag.contains(tvBoolean)) error(test, n);
2876            n++; bag.add(tvByte);
2877            n++; if (! bag.contains(tvByte)) error(test, n);
2878            n++; bag.add(tvShort);
2879            n++; if (! bag.contains(tvShort)) error(test, n);
2880            n++; bag.add(tvInt);
2881            n++; if (! bag.contains(tvInt)) error(test, n);
2882            n++; bag.add(tvLong);
2883            n++; if (! bag.contains(tvLong)) error(test, n);
2884            n++; bag.add(tvChar);
2885            n++; if (! bag.contains(tvChar)) error(test, n);
2886            n++; bag.add(tvFloat);
2887            n++; if (! bag.contains(tvFloat)) error(test, n);
2888            n++; bag.add(tvDouble);
2889            n++; if (! bag.contains(tvDouble)) error(test, n);
2890            n++; bag.add(tvString);
2891            n++; if (! bag.contains(tvString)) error(test, n);
2892            n++; bag.add(tvLiteral);
2893            n++; if (! bag.contains(tvLiteral)) error(test, n);
2894            n++; bag.add(tvResObj);
2895            n++; if (! bag.contains(tvResObj)) error(test, n);
2896            n++; bag.add(tvLitObj);
2897            n++; if (! bag.contains(tvLitObj)) error(test, n);
2898            n++; if (! (bag.size()==12)) error(test,n);
2899
2900            {
2901                n=300;
2902                n++; bag = m.createBag();
2903                     for (int i=0; i<num; i++) {
2904                        bag.add(i);
2905                    }
2906                n++; if (! (bag.size()==num)) error(test,n);
2907                n++; nIter = bag.iterator();
2908                    for (int i=0; i<num; i++) {
2909                        if ( ! (((Literal) nIter.nextNode()).getInt() == i))
2910                            error(test, 320+i);
2911                    }
2912                    nIter.close();
2913            }
2914
2915            {
2916                boolean[] found = new boolean[num];
2917                boolean[] pattern =
2918                  {true, true, true, false, false,
2919                   false, false, false, true, true };
2920
2921                n=400;
2922                n++; nIter=bag.iterator();
2923                     for (int i=0; i<num; i++) {
2924                n++; nIter.nextNode();
2925                n++; if (! pattern[i]) nIter.remove();
2926                        found[i] = false;
2927                     }
2928                n++; nIter.close();
2929                n=450;
2930                n++; nIter = bag.iterator();
2931                     while (nIter.hasNext()) {
2932                        int v = ((Literal) nIter.nextNode()).getInt();
2933                n++; if ( found[v]) error(test,n);
2934                        found[v] = true;
2935                     }
2936                n++; nIter.close();
2937                n=480;
2938                     for (int i=0; i<num; i++) {
2939                n++; if (! (found[i]==pattern[i])) error(test,n);
2940                    }
2941            }
2942
2943            {
2944                boolean[] found = new boolean[num];
2945                boolean[] pattern =
2946                  {false, true, true, false, false,
2947                   false, false, false, true, false };
2948
2949                n=500;
2950                n++; bag = m.createBag();
2951                     for (int i=0; i<num; i++) {
2952                        bag.add(i);
2953                    }
2954                n++; nIter=bag.iterator();
2955                     for (int i=0; i<num; i++) {
2956                n++; nIter.nextNode();
2957                n++; if (! pattern[i]) nIter.remove();
2958                        found[i] = false;
2959                     }
2960                n++; nIter.close();
2961                n=550;
2962                n++; nIter = bag.iterator();
2963                     while (nIter.hasNext()) {
2964                        int v = ((Literal) nIter.nextNode()).getInt();
2965                n++; if ( found[v]) error(test,n);
2966                        found[v] = true;
2967                     }
2968                n++; nIter.close();
2969                n=580;
2970                     for (int i=0; i<num; i++) {
2971                n++; if (! (found[i]==pattern[i])) error(test,n);
2972                    }
2973            }
2974
2975            {
2976                boolean[] found = new boolean[num];
2977                boolean[] pattern =
2978                  {false, false, false, false, false,
2979                   false, false, false, false, false};
2980
2981                n=600;
2982                n++; bag = m.createBag();
2983                     for (int i=0; i<num; i++) {
2984                        bag.add(i);
2985                    }
2986                n++; nIter=bag.iterator();
2987                     for (int i=0; i<num; i++) {
2988                n++; nIter.nextNode();
2989                n++; if (! pattern[i]) nIter.remove();
2990                        found[i] = false;
2991                     }
2992                n++; nIter.close();
2993                n=650;
2994                n++; nIter = bag.iterator();
2995                     while (nIter.hasNext()) {
2996                        int v = ((Literal) nIter.nextNode()).getInt();
2997                n++; if ( found[v]) error(test,n);
2998                        found[v] = true;
2999                     }
3000                n++; nIter.close();
3001                n=680;
3002                     for (int i=0; i<num; i++) {
3003                n++; if (! (found[i]==pattern[i])) error(test,n);
3004                    }
3005            }
3006
3007        } catch (Exception JavaDoc e) {
3008            logger.error( "test " + test + "[" + n + "]", e );
3009            errors = true;
3010        }
3011// System.out.println("End of " + test);
3012
}
3013
3014    /** test Alt
3015     * @param m the model implementation under test
3016     */

3017    public void test15(Model m) {
3018        String JavaDoc test = "Test15";
3019        int n = 0;
3020
3021        try {
3022            NodeIterator nIter;
3023            StmtIterator sIter;
3024// System.out.println("Beginning " + test);
3025
boolean tvBoolean = true;
3026            byte tvByte = 1;
3027            short tvShort = 2;
3028            int tvInt = -1;
3029            long tvLong = -2;
3030            char tvChar = '!';
3031            float tvFloat = (float) 123.456;
3032            double tvDouble = -123.456;
3033            String JavaDoc tvString = "test 12 string";
3034            LitTestObj tvObject = new LitTestObj(12345);
3035            Literal tvLiteral = m.createLiteral("test 12 string 2");
3036            Resource tvResource = m.createResource();
3037            Resource tvResObj = m.createResource(new ResTestObjF());
3038            Object JavaDoc tvLitObj = new LitTestObj(1234);
3039            Bag tvBag = m.createBag();
3040            Alt tvAlt = m.createAlt();
3041            Seq tvSeq = m.createSeq();
3042            int num=10;
3043            Statement stmt;
3044
3045            n=100;
3046            n++; Alt alt = m.createAlt();
3047            n++; if (! m.contains(alt, RDF.type, RDF.Alt)) error(test,n);
3048            n++; if (! (alt.size() == 0)) error(test,n);
3049
3050            n=200;
3051            n++; alt.add(tvBoolean);
3052            n++; if (! alt.contains(tvBoolean)) error(test, n);
3053            n++; alt.add(tvByte);
3054            n++; if (! alt.contains(tvByte)) error(test, n);
3055            n++; alt.add(tvShort);
3056            n++; if (! alt.contains(tvShort)) error(test, n);
3057            n++; alt.add(tvInt);
3058            n++; if (! alt.contains(tvInt)) error(test, n);
3059            n++; alt.add(tvLong);
3060            n++; if (! alt.contains(tvLong)) error(test, n);
3061            n++; alt.add(tvChar);
3062            n++; if (! alt.contains(tvChar)) error(test, n);
3063            n++; alt.add(tvFloat);
3064            n++; if (! alt.contains(tvFloat)) error(test, n);
3065            n++; alt.add(tvDouble);
3066            n++; if (! alt.contains(tvDouble)) error(test, n);
3067            n++; alt.add(tvString);
3068            n++; if (! alt.contains(tvString)) error(test, n);
3069            n++; alt.add(tvLiteral);
3070            n++; if (! alt.contains(tvLiteral)) error(test, n);
3071            n++; alt.add(tvResObj);
3072            n++; if (! alt.contains(tvResObj)) error(test, n);
3073            n++; alt.add(tvLitObj);
3074            n++; if (! alt.contains(tvLitObj)) error(test, n);
3075            n++; if (! (alt.size()==12)) error(test,n);
3076
3077            {
3078                n=300;
3079                n++; alt = m.createAlt();
3080                     for (int i=0; i<num; i++) {
3081                        alt.add(i);
3082                    }
3083                n++; if (! (alt.size()==num)) error(test,n);
3084                n++; nIter = alt.iterator();
3085                    for (int i=0; i<num; i++) {
3086                        if ( ! (((Literal) nIter.nextNode()).getInt() == i))
3087                            error(test, 320+i);
3088                    }
3089                    nIter.close();
3090            }
3091
3092            {
3093                boolean[] found = new boolean[num];
3094                boolean[] pattern =
3095                  {true, true, true, false, false,
3096                   false, false, false, true, true };
3097
3098                n=400;
3099                n++; nIter=alt.iterator();
3100                     for (int i=0; i<num; i++) {
3101                n++; nIter.nextNode();
3102                n++; if (! pattern[i]) nIter.remove();
3103                        found[i] = false;
3104                     }
3105                n++; nIter.close();
3106                n=450;
3107                n++; nIter = alt.iterator();
3108                     while (nIter.hasNext()) {
3109                        int v = ((Literal) nIter.nextNode()).getInt();
3110                n++; if ( found[v]) error(test,n);
3111                        found[v] = true;
3112                     }
3113                n++; nIter.close();
3114                n=480;
3115                     for (int i=0; i<num; i++) {
3116                n++; if (! (found[i]==pattern[i])) error(test,n);
3117                    }
3118            }
3119
3120            {
3121                boolean[] found = new boolean[num];
3122                boolean[] pattern =
3123                  {false, true, true, false, false,
3124                   false, false, false, true, false };
3125
3126                n=500;
3127                n++; alt = m.createAlt();
3128                     for (int i=0; i<num; i++) {
3129                        alt.add(i);
3130                    }
3131                n++; nIter=alt.iterator();
3132                     for (int i=0; i<num; i++) {
3133                n++; nIter.nextNode();
3134                n++; if (! pattern[i]) nIter.remove();
3135                        found[i] = false;
3136                     }
3137                n++; nIter.close();
3138                n=550;
3139                n++; nIter = alt.iterator();
3140                     while (nIter.hasNext()) {
3141                        int v = ((Literal) nIter.nextNode()).getInt();
3142                n++; if ( found[v]) error(test,n);
3143                        found[v] = true;
3144                     }
3145                n++; nIter.close();
3146                n=580;
3147                     for (int i=0; i<num; i++) {
3148                n++; if (! (found[i]==pattern[i])) error(test,n);
3149                    }
3150            }
3151
3152            {
3153                boolean[] found = new boolean[num];
3154                boolean[] pattern =
3155                  {false, false, false, false, false,
3156                   false, false, false, false, false};
3157
3158                n=600;
3159                n++; alt = m.createAlt();
3160                     for (int i=0; i<num; i++) {
3161                        alt.add(i);
3162                    }
3163                n++; nIter=alt.iterator();
3164                     for (int i=0; i<num; i++) {
3165                n++; nIter.nextNode();
3166                n++; if (! pattern[i]) nIter.remove();
3167                        found[i] = false;
3168                     }
3169                n++; nIter.close();
3170                n=650;
3171                n++; nIter = alt.iterator();
3172                     while (nIter.hasNext()) {
3173                        int v = ((Literal) nIter.nextNode()).getInt();
3174                n++; if ( found[v]) error(test,n);
3175                        found[v] = true;
3176                     }
3177                n++; nIter.close();
3178                n=680;
3179                     for (int i=0; i<num; i++) {
3180                n++; if (! (found[i]==pattern[i])) error(test,n);
3181                    }
3182            }
3183
3184            {
3185                n=700;
3186                n++; alt = m.createAlt();
3187                n++; if (! (alt.setDefault(tvLiteral)
3188                               .getDefault().equals(tvLiteral)))
3189                       error(test,n);
3190                n++; if (! (alt.setDefault(tvLiteral)
3191                               .getDefaultLiteral().equals(tvLiteral)))
3192                       error(test,n);
3193                n++; if (! alt.setDefault(tvResource)
3194                               .getDefaultResource().equals(tvResource))
3195                       error(test,n);
3196                n++; if (! (alt.setDefault(tvByte)
3197                               .getDefaultByte()== tvByte))
3198                       error(test,n);
3199                n++; if (! (alt.setDefault(tvShort)
3200                               .getDefaultShort()==tvShort))
3201                       error(test,n);
3202                n++; if (! (alt.setDefault(tvInt)
3203                               .getDefaultInt()==tvInt))
3204                       error(test,n);
3205                n++; if (! (alt.setDefault(tvLong)
3206                               .getDefaultLong()==tvLong))
3207                       error(test,n);
3208                n++; if (! (alt.setDefault(tvChar)
3209                               .getDefaultChar()==tvChar))
3210                       error(test,n);
3211                n++; if (! (alt.setDefault(tvFloat)
3212                               .getDefaultFloat()==tvFloat))
3213                       error(test,n);
3214                n++; if (! (alt.setDefault(tvDouble)
3215                               .getDefaultDouble()==tvDouble))
3216                       error(test,n);
3217                n++; if (! alt.setDefault(tvString)
3218                               .getDefaultString().equals(tvString))
3219                       error(test,n);
3220                n++; if (! alt.setDefault(tvResObj)
3221                               .getDefaultResource(new ResTestObjF())
3222                               .equals(tvResObj))
3223                       error(test,n);
3224                n++; if (! alt.setDefault(tvLitObj)
3225                               .getDefaultObject(new LitTestObjF())
3226                               .equals(tvLitObj))
3227                       error(test,n);
3228                n++; if (! alt.setDefault(tvAlt)
3229                               .getDefaultAlt()
3230                               .equals(tvAlt))
3231                       error(test,n);
3232                n++; if (! alt.setDefault(tvBag)
3233                               .getDefaultBag()
3234                               .equals(tvBag))
3235                       error(test,n);
3236                n++; if (! alt.setDefault(tvSeq)
3237                               .getDefaultSeq()
3238                               .equals(tvSeq))
3239                       error(test,n);
3240            }
3241
3242        } catch (Exception JavaDoc e) {
3243            logger.error( "test " + test + "[" + n + "]", e );
3244            errors = true;
3245        }
3246// System.out.println("End of " + test);
3247
}
3248
3249    /** test Seq
3250     * @param m the model implementation under test
3251     */

3252    public void test16(Model m) {
3253        String JavaDoc test = "Test16";
3254        int n = 0;
3255
3256        try {
3257            NodeIterator nIter;
3258            StmtIterator sIter;
3259// System.out.println("Beginning " + test);
3260
boolean tvBoolean = true;
3261            byte tvByte = 1;
3262            short tvShort = 2;
3263            int tvInt = -1;
3264            long tvLong = -2;
3265            char tvChar = '!';
3266            float tvFloat = (float) 123.456;
3267            double tvDouble = -123.456;
3268            String JavaDoc tvString = "test 12 string";
3269            LitTestObj tvObject = new LitTestObj(12345);
3270            Literal tvLiteral = m.createLiteral("test 12 string 2");
3271            Resource tvResource = m.createResource();
3272            Resource tvResObj = m.createResource(new ResTestObjF());
3273            Object JavaDoc tvLitObj = new LitTestObj(1234);
3274            Bag tvBag = m.createBag();
3275            Alt tvAlt = m.createAlt();
3276            Seq tvSeq = m.createSeq();
3277            int num=10;
3278            Statement stmt;
3279
3280            n=100;
3281            n++; Seq seq = m.createSeq();
3282            n++; if (! m.contains(seq, RDF.type, RDF.Seq)) error(test,n);
3283            n++; if (! (seq.size() == 0)) error(test,n);
3284
3285            n=200;
3286            n++; seq.add(tvBoolean);
3287            n++; if (! seq.contains(tvBoolean)) error(test, n);
3288            n++; seq.add(tvByte);
3289            n++; if (! seq.contains(tvByte)) error(test, n);
3290            n++; seq.add(tvShort);
3291            n++; if (! seq.contains(tvShort)) error(test, n);
3292            n++; seq.add(tvInt);
3293            n++; if (! seq.contains(tvInt)) error(test, n);
3294            n++; seq.add(tvLong);
3295            n++; if (! seq.contains(tvLong)) error(test, n);
3296            n++; seq.add(tvChar);
3297            n++; if (! seq.contains(tvChar)) error(test, n);
3298            n++; seq.add(tvFloat);
3299            n++; if (! seq.contains(tvFloat)) error(test, n);
3300            n++; seq.add(tvDouble);
3301            n++; if (! seq.contains(tvDouble)) error(test, n);
3302            n++; seq.add(tvString);
3303            n++; if (! seq.contains(tvString)) error(test, n);
3304            n++; seq.add(tvLiteral);
3305            n++; if (! seq.contains(tvLiteral)) error(test, n);
3306            n++; seq.add(tvResObj);
3307            n++; if (! seq.contains(tvResObj)) error(test, n);
3308            n++; seq.add(tvLitObj);
3309            n++; if (! seq.contains(tvLitObj)) error(test, n);
3310            n++; if (! (seq.size()==12)) error(test,n);
3311
3312            {
3313                n=300;
3314                n++; seq = m.createSeq();
3315                     for (int i=0; i<num; i++) {
3316                        seq.add(i);
3317                    }
3318                n++; if (! (seq.size()==num)) error(test,n);
3319                n++; nIter = seq.iterator();
3320                    for (int i=0; i<num; i++) {
3321                        if ( ! (((Literal) nIter.nextNode()).getInt() == i))
3322                            error(test, 320+i);
3323                    }
3324                    nIter.close();
3325            }
3326
3327            {
3328                boolean[] found = new boolean[num];
3329                boolean[] pattern =
3330                  {true, true, true, false, false,
3331                   false, false, false, true, true };
3332
3333                n=400;
3334                n++; nIter=seq.iterator();
3335                     for (int i=0; i<num; i++) {
3336                n++; nIter.nextNode();
3337                n++; if (! pattern[i]) nIter.remove();
3338                        found[i] = false;
3339                     }
3340                n++; nIter.close();
3341                n=450;
3342                n++; nIter = seq.iterator();
3343                     while (nIter.hasNext()) {
3344                        int v = ((Literal) nIter.nextNode()).getInt();
3345                n++; if ( found[v]) error(test,n);
3346                        found[v] = true;
3347                     }
3348                n++; nIter.close();
3349                n=480;
3350                     for (int i=0; i<num; i++) {
3351                n++; if (! (found[i]==pattern[i])) error(test,n);
3352                    }
3353            }
3354
3355            {
3356                boolean[] found = new boolean[num];
3357                boolean[] pattern =
3358                  {false, true, true, false, false,
3359                   false, false, false, true, false };
3360
3361                n=500;
3362                n++; seq = m.createSeq();
3363                     for (int i=0; i<num; i++) {
3364                        seq.add(i);
3365                    }
3366                n++; nIter=seq.iterator();
3367                     for (int i=0; i<num; i++) {
3368                n++; nIter.nextNode();
3369                n++; if (! pattern[i]) nIter.remove();
3370                        found[i] = false;
3371                     }
3372                n++; nIter.close();
3373                n=550;
3374                n++; nIter = seq.iterator();
3375                     while (nIter.hasNext()) {
3376                        int v = ((Literal) nIter.nextNode()).getInt();
3377                n++; if ( found[v]) error(test,n);
3378                        found[v] = true;
3379                     }
3380                n++; nIter.close();
3381                n=580;
3382                     for (int i=0; i<num; i++) {
3383                n++; if (! (found[i]==pattern[i])) error(test,n);
3384                    }
3385            }
3386
3387            {
3388                boolean[] found = new boolean[num];
3389                boolean[] pattern =
3390                  {false, false, false, false, false,
3391                   false, false, false, false, false};
3392
3393                n=600;
3394                n++; seq = m.createSeq();
3395                     for (int i=0; i<num; i++) {
3396                        seq.add(i);
3397                    }
3398                n++; nIter=seq.iterator();
3399                     for (int i=0; i<num; i++) {
3400                n++; nIter.nextNode();
3401                n++; if (! pattern[i]) nIter.remove();
3402                        found[i] = false;
3403                     }
3404                n++; nIter.close();
3405                n=650;
3406                n++; nIter = seq.iterator();
3407                     while (nIter.hasNext()) {
3408                        int v = ((Literal) nIter.nextNode()).getInt();
3409                n++; if ( found[v]) error(test,n);
3410                        found[v] = true;
3411                     }
3412                n++; nIter.close();
3413                n=680;
3414                     for (int i=0; i<num; i++) {
3415                n++; if (! (found[i]==pattern[i])) error(test,n);
3416                    }
3417            }
3418
3419            {
3420                n=700;
3421                seq = m.createSeq();
3422                n++; seq.add(tvBoolean);
3423                n++; if (! (seq.getBoolean(1)==tvBoolean)) error(test,n);
3424                n++; seq.add(tvByte);
3425                n++; if (! (seq.getByte(2)==tvByte)) error(test,n);
3426                n++; seq.add(tvShort);
3427                n++; if (! (seq.getShort(3)==tvShort)) error(test,n);
3428                n++; seq.add(tvInt);
3429                n++; if (! (seq.getInt(4)==tvInt)) error(test,n);
3430                n++; seq.add(tvLong);
3431                n++; if (! (seq.getLong(5)==tvLong)) error(test,n);
3432                n++; seq.add(tvChar);
3433                n++; if (! (seq.getChar(6)==tvChar)) error(test,n);
3434                n++; seq.add(tvFloat);
3435                n++; if (! (seq.getFloat(7)==tvFloat)) error(test,n);
3436                n++; seq.add(tvDouble);
3437                n++; if (! (seq.getDouble(8)==tvDouble)) error(test,n);
3438                n++; seq.add(tvString);
3439                n++; if (! (seq.getString(9).equals(tvString))) error(test,n);
3440                n++; seq.add(tvLitObj);
3441                n++; if (! (seq.getObject(10, new LitTestObjF())
3442                                .equals(tvLitObj))) error(test,n);
3443                n++; seq.add(tvResource);
3444                n++; if (! (seq.getResource(11).equals(tvResource))) error(test,n);
3445                n++; seq.add(tvLiteral);
3446                n++; if (! (seq.getLiteral(12).equals(tvLiteral))) error(test,n);
3447                n++; seq.add(tvResObj);
3448                n++; if (! (seq.getResource(13, new ResTestObjF())
3449                                .equals(tvResObj))) error(test,n);
3450                n++; seq.add(tvBag);
3451                n++; if (! (seq.getBag(14).equals(tvBag))) error(test,n);
3452                n++; seq.add(tvAlt);
3453                n++; if (! (seq.getAlt(15).equals(tvAlt))) error(test,n);
3454                n++; seq.add(tvSeq);
3455                n++; if (! (seq.getSeq(16).equals(tvSeq))) error(test,n);
3456                n++; try {
3457                        seq.getInt(17); error(test,n);
3458                    } catch (SeqIndexBoundsException e) {
3459                        // as required
3460
}
3461                n++; try {
3462                        seq.getInt(0); error(test,n);
3463                    } catch (SeqIndexBoundsException e) {
3464                        // as required
3465
}
3466            }
3467
3468            {
3469                n=800;
3470                seq = m.createSeq();
3471                for (int i=0; i<num; i++) {
3472                    seq.add(i);
3473                }
3474
3475                     try {
3476                n++; seq.add(0, false); error(test,n);
3477                     } catch (SeqIndexBoundsException e) {
3478                        // as required
3479
}
3480                     seq.add(num+1, false);
3481                     if (seq.size() != num+1) error(test,n);
3482                     seq.remove(num+1);
3483                     try {
3484                n++; seq.add(num+2, false); error(test,n);
3485                     } catch (SeqIndexBoundsException e) {
3486                        // as required
3487
}
3488
3489               n=820;
3490                    int size = seq.size();
3491                    for (int i=1; i<=num-1; i++) {
3492               n++; seq.add(i, 1000+i);
3493               n++; if (! (seq.getInt(i)==1000+i)) error(test,n);
3494               n++; if (! (seq.getInt(i+1)==0)) error(test, n);
3495               n++; if (! (seq.size()==(size+i))) error(test,n);
3496               n++; if (! (seq.getInt(size)==(num-i-1))) error(test,n);
3497                    }
3498               n=900;
3499                    seq = m.createSeq();
3500                    seq.add(m.createResource());
3501                    seq.add(1, tvBoolean);
3502               n++; if (! (seq.getBoolean(1)==tvBoolean)) error(test,n);
3503                    seq.add(1, tvByte);
3504               n++; if (! (seq.getByte(1)==tvByte)) error(test,n);
3505                    seq.add(1, tvShort);
3506               n++; if (! (seq.getShort(1)==tvShort)) error(test,n);
3507                    seq.add(1, tvInt);
3508               n++; if (! (seq.getInt(1)==tvInt)) error(test,n);
3509                    seq.add(1, tvLong);
3510               n++; if (! (seq.getLong(1)==tvLong)) error(test,n);
3511                    seq.add(1, tvChar);
3512               n++; if (! (seq.getChar(1)==tvChar)) error(test,n);
3513                    seq.add(1, tvFloat);
3514               n++; if (! (seq.getFloat(1)==tvFloat)) error(test,n);
3515                    seq.add(1, tvDouble);
3516               n++; if (! (seq.getDouble(1)==tvDouble)) error(test,n);
3517                    seq.add(1, tvString);
3518               n++; if (! (seq.getString(1).equals(tvString))) error(test,n);
3519                    seq.add(1, tvResource);
3520               n++; if (! (seq.getResource(1).equals(tvResource))) error(test,n);
3521                    seq.add(1, tvLiteral);
3522               n++; if (! (seq.getLiteral(1).equals(tvLiteral))) error(test,n);
3523                    seq.add(1, tvLitObj);
3524               n++; if (! (seq.getObject(1, new LitTestObjF())
3525                              .equals(tvLitObj))) error(test,n);
3526
3527               n=1000;
3528               n++; if (! (seq.indexOf(tvLitObj)==1)) error(test,n);
3529               n++; if (! (seq.indexOf(tvLiteral)==2)) error(test,n);
3530               n++; if (! (seq.indexOf(tvResource)==3)) error(test,n);
3531               n++; if (! (seq.indexOf(tvString)==4)) error(test,n);
3532               n++; if (! (seq.indexOf(tvDouble)==5)) error(test,n);
3533               n++; if (! (seq.indexOf(tvFloat)==6)) error(test,n);
3534               n++; if (! (seq.indexOf(tvChar)==7)) error(test,n);
3535               n++; if (! (seq.indexOf(tvLong)==8)) error(test,n);
3536               n++; if (! (seq.indexOf(tvInt)==9)) error(test,n);
3537               n++; if (! (seq.indexOf(tvShort)==10)) error(test,n);
3538               n++; if (! (seq.indexOf(tvByte)==11)) error(test,n);
3539               n++; if (! (seq.indexOf(tvBoolean)==12)) error(test,n);
3540               n++; if (! (seq.indexOf(1234543)==0)) error(test,n);
3541
3542               n=1100;
3543                   seq = m.createSeq();
3544                   for (int i=0; i<num; i++) {
3545                       seq.add(i);
3546                   }
3547              n=1110;
3548                   seq.set(5, tvBoolean);
3549              n++; if (! (seq.getBoolean(5)==tvBoolean)) error(test,n);
3550              n++; if (! (seq.getInt(4)==3)) error(test,n);
3551              n++; if (! (seq.getInt(6)==5)) error(test,n);
3552              n++; if (! (seq.size()==num)) error(test,n);
3553              n=1120;
3554                   seq.set(5, tvByte);
3555              n++; if (! (seq.getByte(5)==tvByte)) error(test,n);
3556              n++; if (! (seq.getInt(4)==3)) error(test,n);
3557              n++; if (! (seq.getInt(6)==5)) error(test,n);
3558              n++; if (! (seq.size()==num)) error(test,n);
3559              n=1130;
3560                   seq.set(5, tvShort);
3561              n++; if (! (seq.getShort(5)==tvShort)) error(test,n);
3562              n++; if (! (seq.getInt(4)==3)) error(test,n);
3563              n++; if (! (seq.getInt(6)==5)) error(test,n);
3564              n++; if (! (seq.size()==num)) error(test,n);
3565              n=1140;
3566                   seq.set(5, tvInt);
3567              n++; if (! (seq.getInt(5)==tvInt)) error(test,n);
3568              n++; if (! (seq.getInt(4)==3)) error(test,n);
3569              n++; if (! (seq.getInt(6)==5)) error(test,n);
3570              n++; if (! (seq.size()==num)) error(test,n);
3571              n=1150;
3572                   seq.set(5, tvLong);
3573              n++; if (! (seq.getLong(5)==tvLong)) error(test,n);
3574              n++; if (! (seq.getInt(4)==3)) error(test,n);
3575              n++; if (! (seq.getInt(6)==5)) error(test,n);
3576              n++; if (! (seq.size()==num)) error(test,n);
3577              n=1160;
3578                   seq.set(5, tvChar);
3579              n++; if (! (seq.getChar(5)==tvChar)) error(test,n);
3580              n++; if (! (seq.getInt(4)==3)) error(test,n);
3581              n++; if (! (seq.getInt(6)==5)) error(test,n);
3582              n++; if (! (seq.size()==num)) error(test,n);
3583              n=1170;
3584                   seq.set(5, tvFloat);
3585              n++; if (! (seq.getFloat(5)==tvFloat)) error(test,n);
3586              n++; if (! (seq.getInt(4)==3)) error(test,n);
3587              n++; if (! (seq.getInt(6)==5)) error(test,n);
3588              n++; if (! (seq.size()==num)) error(test,n);
3589              n=1180;
3590                   seq.set(5, tvDouble);
3591              n++; if (! (seq.getDouble(5)==tvDouble)) error(test,n);
3592              n++; if (! (seq.getInt(4)==3)) error(test,n);
3593              n++; if (! (seq.getInt(6)==5)) error(test,n);
3594              n++; if (! (seq.size()==num)) error(test,n);
3595              n=1190;
3596                   seq.set(5, tvLiteral);
3597              n++; if (! (seq.getLiteral(5).equals(tvLiteral))) error(test,n);
3598              n++; if (! (seq.getInt(4)==3)) error(test,n);
3599              n++; if (! (seq.getInt(6)==5)) error(test,n);
3600              n++; if (! (seq.size()==num)) error(test,n);
3601              n=1200;
3602                   seq.set(5, tvResource);
3603              n++; if (! (seq.getResource(5).equals(tvResource))) error(test,n);
3604              n++; if (! (seq.getInt(4)==3)) error(test,n);
3605              n++; if (! (seq.getInt(6)==5)) error(test,n);
3606              n++; if (! (seq.size()==num)) error(test,n);
3607              n=1210;
3608                   seq.set(5, tvLitObj);
3609              n++; if (! (seq.getObject(5, new LitTestObjF()))
3610                             .equals(tvLitObj)) error(test,n);
3611              n++; if (! (seq.getInt(4)==3)) error(test,n);
3612              n++; if (! (seq.getInt(6)==5)) error(test,n);
3613              n++; if (! (seq.size()==num)) error(test,n);
3614              n=1220;
3615                   seq.set(5, tvResObj);
3616              n++; if (! (seq.getResource(5, new ResTestObjF())
3617                             .equals(tvResObj))) error(test,n);
3618              n++; if (! (seq.getInt(4)==3)) error(test,n);
3619              n++; if (! (seq.getInt(6)==5)) error(test,n);
3620              n++; if (! (seq.size()==num)) error(test,n);
3621        }
3622
3623        } catch (Exception JavaDoc e) {
3624            logger.error( "test " + test + "[" + n + "]", e );
3625            errors = true;
3626        }
3627// System.out.println("End of " + test);
3628
}
3629
3630    /** test enhanced resources
3631     * @param m the model implementation under test
3632     */

3633    public void test17(Model m) {
3634        String JavaDoc test = "Test17";
3635        int n = 0;
3636
3637        try {
3638            // System.out.println("Beginning " + test);
3639
Resource r = new ResourceImpl((ModelCom)m);
3640            n=1000; testResource(m, r, test, n, 0);
3641
3642
3643            n=2000; testResource(m, m.createBag(), test, n, 1);
3644            n=3000; testContainer(m, m.createBag(), m.createBag(), test, n);
3645            n=4000; testBag(m, m.createBag(), m.createBag(), m.createBag(),
3646                             test, n);
3647
3648            n=5000; testResource(m, m.createAlt(), test, n, 1);
3649            n=6000; testContainer(m, m.createAlt(), m.createAlt(), test, n);
3650            n=7000; testAlt(m, m.createAlt(), m.createAlt(),
3651                              m.createAlt(), m.createAlt(), test, n);
3652
3653
3654            n=8000; testResource(m, m.createSeq(), test, n, 1);
3655            n=9000; testContainer(m, m.createSeq(), m.createSeq(), test, n);
3656            n=10000; testSeq(m, m.createSeq(), m.createSeq(), m.createSeq(),
3657                                m.createSeq(), m.createSeq(), m.createSeq(),
3658                                m.createSeq(), test, n);
3659        } catch (Exception JavaDoc e) {
3660            logger.error( "test " + test + "[" + n + "]", e );
3661            errors = true;
3662        }
3663// System.out.println("End of " + test);
3664
}
3665
3666    /** test load from xml file
3667     * @param m the model implementation under test
3668     */

3669    public void test18(Model m) {
3670        String JavaDoc test = "Test18";
3671        if (test.equals( test )) return;
3672        String JavaDoc testURI = "http://aldabaran.hpl.hp.com/rdftest/test18/";
3673        String JavaDoc subject1 = testURI + "1";
3674        String JavaDoc object1 =
3675   "<foo bar=\"bar\"><bar>abc<foobar/>def&lt;&gt;&apos;&quot;&amp;</bar></foo>";
3676        String JavaDoc RDFSchemaURI = "http://lists.w3.org/Archives/Public/www-archive/"
3677                            + "2001Sep/att-0064/00-rdfschema.rdf";
3678        int n = 0;
3679
3680        try {
3681            System.out.println("Beginning " + test);
3682            m.read(ResourceReader.getInputStream("modules/rdf/rdfschema.html"),
3683                                      RDFSchemaURI);
3684            n++; if (m.size() != 124) error(test, n);
3685   // n++; m.write(new PrintWriter(System.out));
3686

3687            StmtIterator iter = m.listStatements();
3688            while (iter.hasNext()) {
3689                iter.nextStatement();
3690                iter.remove();
3691            }
3692
3693            m.read(ResourceReader.getInputStream("modules/rdf/embeddedxml.xml"), "");
3694            n++;
3695 /* I'd like to test for the exactly correct value here, but can't since the
3696  * exactly correct value is not defined.
3697            if (! m.contains(m.createResource(subject1),
3698                             RDF.value, object1)) error(test, n++);
3699  * So instead lets do some rough checks its right */

3700            String JavaDoc xml = m.getResource(subject1)
3701                          .getRequiredProperty(RDF.value)
3702                          .getString();
3703            n++; if ( xml.indexOf("&lt;") == -1) error(test, n);
3704            n++; if ( xml.indexOf("&gt;") == -1) error(test, n);
3705            n++; if ( xml.indexOf("&amp;") == -1) error(test, n);
3706            n++; if ((xml.indexOf("'bar'") == -1) &&
3707                     (xml.indexOf("\"bar\"") == -1)) error(test, n);
3708
3709            m.createResource()
3710             .addProperty(RDF.value, "can't loose");
3711  // m.write(new PrintWriter(System.out));
3712

3713            iter = m.listStatements();
3714            while (iter.hasNext()) {
3715                iter.nextStatement();
3716                iter.remove();
3717            }
3718            n++;
3719            m.read(ResourceReader.getInputStream("modules/rdf/testcollection.rdf"), "");
3720            if (m.size() != 24) error(test, (int) m.size());
3721
3722            iter = m.listStatements();
3723            while (iter.hasNext()) {
3724                iter.nextStatement();
3725                iter.remove();
3726            }
3727
3728            try {
3729                m.read(System.getProperty("com.hp.hpl.jena.regression.testURL",
3730                                          RDFSchemaURI));
3731 // n++; m.write(new PrintWriter(System.out));
3732
n++; if ((m.size() != 124) && (m.size() != 125)) {
3733                    System.out.println("size = " + m.size());
3734                      error(test, n);
3735                }
3736                if (! m.contains(RDF.Property, RDF.type, RDFS.Class))
3737                    error(test, n);
3738            } catch (JenaException rdfx) {
3739                Throwable JavaDoc th = rdfx.getCause();
3740                if ( th instanceof NoRouteToHostException
3741                 || th instanceof UnknownHostException
3742                 || th instanceof IOException
3743                 || th instanceof ConnectException) {
3744                    logger.warn( "Cannot access public internet- part of test not executed" );
3745                } else {
3746                    throw rdfx;
3747                }
3748            }
3749
3750        } catch (Exception JavaDoc e) {
3751            logger.error( "test " + test + "[" + n + "]", e );
3752            errors = true;
3753        }
3754// System.out.println("End of " + test);
3755
}
3756
3757    /** test moving things between models
3758     * @param m the model implementation under test
3759     */

3760    public void test19(Model m1, Model m2) {
3761        String JavaDoc test = "Test19";
3762        int n = 0;
3763
3764        try {
3765            Statement stmt;
3766            StmtIterator sIter;
3767// System.out.println("Beginning " + test);
3768

3769            try {
3770                n=100;
3771                Resource r11 = m1.createResource();
3772                Resource r12 = m2.createResource(new ResTestObjF());
3773                long size1 = m1.size();
3774                long size2 = m2.size();
3775
3776                r11.addProperty(RDF.value, 1);
3777                n++; if (! (m1.size() == ++size1)) error(test, n);
3778                n++; if (! (m2.size() == size2)) error(test,n);
3779
3780                stmt = m2.createStatement(r11, RDF.value, r12);
3781                n++; if (! (stmt.getSubject().getModel() == m2)) error(test,n);
3782                n++; if (! (stmt.getResource().getModel() == m2)) error(test,n);
3783
3784                m1.add(stmt);
3785                n++; if (! (m1.size() == ++size1)) error(test, n);
3786                n++; if (! (m2.size() == size2)) error(test,n);
3787
3788                sIter = m1.listStatements(
3789                                    new SimpleSelector(r11, RDF.value, r12));
3790                n++; if (! sIter.hasNext()) error(test, n);
3791                n++; stmt = sIter.nextStatement();
3792                n++; if (! (stmt.getSubject().getModel() == m1)) error(test,n);
3793                n++; if (! (stmt.getResource().getModel() == m1)) error(test,n);
3794                sIter.close();
3795
3796
3797            } catch (Exception JavaDoc e) {
3798                error(test, n, e);
3799            }
3800        } catch (Exception JavaDoc e) {
3801            logger.error( "test " + test + "[" + n + "]", e );
3802            errors = true;
3803        }
3804// System.out.println("End of " + test);
3805
}
3806
3807   /** Empty the passed in model
3808     * @param m the model implementation under test
3809     */

3810    public void test20(Model m) {
3811        String JavaDoc test = "Test20";
3812        int n = 0;
3813
3814        try {
3815// System.out.println("Beginning " + test);
3816
Statement s1 = null;
3817            Statement s2 = null;
3818
3819            try {
3820                n=100;
3821                n++; s1 = m.createStatement(m.createResource(),
3822                                            RDF.type,
3823                                            RDFS.Class);
3824                n++; if (s1.isReified()) error(test,n);
3825                n++; m.add(s1);
3826                n++; if (s1.isReified()) error(test,n);
3827                n++; s2 = m.createStatement(m.createResource(),
3828                                            RDF.type,
3829                                            RDFS.Class);
3830                n++; if (s2.isReified()) error(test,n);
3831                n++; m.add(s2);
3832                n++; if (s2.isReified()) error(test,n);
3833/*
3834                n++; m.add(s1, RDF.value, new LiteralImpl("foo"));
3835                n++; if (!s1.isReified()) error(test,n);
3836
3837                n++; m.add(s1, RDF.value, s2);
3838                n++; if (!s2.isReified()) error(test,n);
3839 */

3840            } catch (Exception JavaDoc e) {
3841                error(test, n, e);
3842            }
3843        } catch (Exception JavaDoc e) {
3844            logger.error( "test " + test + "[" + n + "]", e );
3845            errors = true;
3846        }
3847// System.out.println("End of " + test);
3848
}
3849
3850    /** Testing for miscellaneous bugs
3851     * @param m the model implementation under test
3852     */

3853    public void test97(Model m) {
3854        String JavaDoc test = "Test97";
3855        int n = 0;
3856
3857        try {
3858
3859// System.out.println("Beginning " + test);
3860

3861                /*
3862                    the _null_ argument to LiteralImpl was preserved only for backward
3863                    compatability. It was be logged and has now become an exception.
3864                    (Brian and Chris had a discussion about this and agreed).
3865                */

3866                // Node.nullLiteralsGenerateWarnings();
3867
try
3868                    {
3869                   n=100; m.query(new SimpleSelector(null,
3870                                                   null,
3871                                                   new LiteralImpl( Node.createLiteral( null, "", false ), (ModelCom) m)));
3872                    error( test, n );
3873                    }
3874                catch (NullPointerException JavaDoc e)
3875                        {}
3876                try
3877                    {
3878                   n=101; m.query(new SimpleSelector(null,
3879                                                   null,
3880                                                   new LiteralImpl( Node.createLiteral( null, "en", false ), (ModelCom) m)));
3881                    error( test, n );
3882                    }
3883                catch (NullPointerException JavaDoc e)
3884                    {}
3885                // end of nullLiteralsGenerateWarnings code
3886

3887               n=102;
3888               StmtIterator iter
3889                            = m.listStatements(new SimpleSelector(null,
3890                                                                null,
3891                                                                (String JavaDoc) null));
3892               while (iter.hasNext()) {
3893                   RDFNode o = iter.nextStatement().getObject();
3894               }
3895
3896               n=103;
3897               iter = m.listStatements(new SimpleSelector(null,
3898                                                        null,
3899                                                        (Object JavaDoc) null));
3900               while (iter.hasNext()) {
3901                   RDFNode o = iter.nextStatement().getObject();
3902               }
3903
3904            } catch (Exception JavaDoc e) {
3905                error(test, n, e);
3906            }
3907// System.out.println("End of " + test);
3908
}
3909
3910    /** Empty the passed in model
3911     * @param m the model implementation under test
3912     */

3913    public void test99(Model m) {
3914        String JavaDoc test = "Test5";
3915        int n = 0;
3916
3917        try {
3918            StmtIterator iter;
3919// System.out.println("Beginning " + test);
3920

3921            try {
3922                n=100;
3923                n++; iter = m.listStatements();
3924                while (iter.hasNext()) {
3925                    iter.nextStatement();
3926                    n++; iter.remove();
3927                }
3928                n++; iter.close();
3929                n++; if (! (m.size()==0)) error(test,999);
3930            } catch (Exception JavaDoc e) {
3931                error(test, n, e);
3932            }
3933        } catch (Exception JavaDoc e) {
3934            logger.error( "test " + test + "[" + n + "]", e );
3935            errors = true;
3936        }
3937// System.out.println("End of " + test);
3938
}
3939
3940    public void testResource(Model m, Resource r, String JavaDoc test,
3941                               int n, int numProps) {
3942        try {
3943            StmtIterator iter;
3944            boolean tvBoolean = true;
3945            byte tvByte = 1;
3946            short tvShort = 2;
3947            int tvInt = -1;
3948            long tvLong = -2;
3949            char tvChar = '!';
3950            float tvFloat = (float) 123.456;
3951            double tvDouble = -123.456;
3952            String JavaDoc tvString = "test 12 string";
3953            LitTestObj tvObject = new LitTestObj(12345);
3954            Literal tvLiteral = m.createLiteral("test 12 string 2");
3955            Resource tvResource = m.createResource();
3956            String JavaDoc lang = "fr";
3957            Statement stmt;
3958
3959            n++; if (! r.addProperty(RDF.value, tvByte)
3960                        .hasProperty(RDF.value, tvByte)) error(test, n);
3961            n++; if (! r.addProperty(RDF.value, tvShort)
3962                        .hasProperty(RDF.value, tvShort)) error(test, n);
3963            n++; if (! r.addProperty(RDF.value, tvInt)
3964                        .hasProperty(RDF.value, tvInt)) error(test, n);
3965            n++; if (! r.addProperty(RDF.value, tvLong)
3966                        .hasProperty(RDF.value, tvLong)) error(test, n);
3967            n++; if (! r.addProperty(RDF.value, tvChar)
3968                        .hasProperty(RDF.value, tvChar)) error(test, n);
3969            n++; if (! r.addProperty(RDF.value, tvFloat)
3970                        .hasProperty(RDF.value, tvFloat)) error(test, n);
3971            n++; if (! r.addProperty(RDF.value, tvDouble)
3972                        .hasProperty(RDF.value, tvDouble)) error(test, n);
3973            n++; if (! r.addProperty(RDF.value, tvString)
3974                        .hasProperty(RDF.value, tvString)) error(test, n);
3975            n++; if (! r.addProperty(RDF.value, tvString, lang)
3976                        .hasProperty(RDF.value, tvString, lang)) error(test, n);
3977            n++; if (! r.addProperty(RDF.value, tvObject)
3978                        .hasProperty(RDF.value, tvObject)) error(test, n);
3979            n++; if (! r.addProperty(RDF.value, tvLiteral)
3980                        .hasProperty(RDF.value, tvLiteral)) error(test, n);
3981            n++; if (! r.addProperty(RDF.value, tvResource)
3982                        .hasProperty(RDF.value, tvResource)) error(test, n);
3983            n++; if (! r.getRequiredProperty(RDF.value).getSubject().equals(r))
3984                       error(test,n);
3985            n++;Property p = m.createProperty("foo/", "bar");
3986                try {
3987                     r.getRequiredProperty(p); error(test, n);
3988                } catch (PropertyNotFoundException e) {
3989                    // as required
3990
}
3991            n++; iter = r.listProperties(RDF.value);
3992                 int count = 0;
3993                 while (iter.hasNext()) {
3994                    stmt = iter.nextStatement();
3995                    if (! stmt.getSubject().equals(r)) error(test, n);
3996                    count++;
3997                }
3998           n++; if (count != 12) error(test,n);
3999           n++; iter = r.listProperties(p);
4000                 count = 0;
4001                 while (iter.hasNext()) {
4002                    stmt = iter.nextStatement();
4003                    if (! stmt.getSubject().equals(r)) error(test, n);
4004                    count++;
4005                }
4006           n++; if (count != 0) error(test,n);
4007           n++; iter = r.listProperties();
4008                 count = 0;
4009                 while (iter.hasNext()) {
4010                    stmt = iter.nextStatement();
4011                    if (! stmt.getSubject().equals(r)) error(test, n);
4012                    count++;
4013                }
4014           n++; if (count != (12+numProps)) error(test,n);
4015
4016           n++; r.removeProperties();
4017           n++; Model mm = m.query(new SimpleSelector(r, null, (RDFNode) null));
4018                if (! (mm.size()==0)) error(test,n);
4019
4020        } catch (Exception JavaDoc e) {
4021            logger.error( "test " + test + "[" + n + "]", e );
4022            errors = true;
4023        }
4024    }
4025
4026    public void testContainer(Model m, Container cont1, Container cont2,
4027                                String JavaDoc test, int n) {
4028
4029        try {
4030            NodeIterator nIter;
4031            StmtIterator sIter;
4032            boolean tvBoolean = true;
4033            byte tvByte = 1;
4034            short tvShort = 2;
4035            int tvInt = -1;
4036            long tvLong = -2;
4037            char tvChar = '!';
4038            float tvFloat = (float) 123.456;
4039            double tvDouble = -123.456;
4040            String JavaDoc tvString = "test 12 string";
4041            LitTestObj tvObject = new LitTestObj(12345);
4042            Literal tvLiteral = m.createLiteral("test 12 string 2");
4043            Resource tvResObj = m.createResource(new ResTestObjF());
4044            Object JavaDoc tvLitObj = new LitTestObj(1234);
4045            Bag tvBag = m.createBag();
4046            Alt tvAlt = m.createAlt();
4047            Seq tvSeq = m.createSeq();
4048            String JavaDoc lang = "en";
4049            int num=10;
4050            Statement stmt;
4051
4052            n=(n/100+1)*100;
4053            n++; if (! (cont1.size() == 0)) error(test,n);
4054
4055            n=(n/100+1)*100;
4056            n++; cont1.add(tvBoolean);
4057            n++; if (! cont1.contains(tvBoolean)) error(test, n);
4058            n++; cont1.add(tvByte);
4059            n++; if (! cont1.contains(tvByte)) error(test, n);
4060            n++; cont1.add(tvShort);
4061            n++; if (! cont1.contains(tvShort)) error(test, n);
4062            n++; cont1.add(tvInt);
4063            n++; if (! cont1.contains(tvInt)) error(test, n);
4064            n++; cont1.add(tvLong);
4065            n++; if (! cont1.contains(tvLong)) error(test, n);
4066            n++; cont1.add(tvChar);
4067            n++; if (! cont1.contains(tvChar)) error(test, n);
4068            n++; cont1.add(tvFloat);
4069            n++; if (! cont1.contains(tvFloat)) error(test, n);
4070            n++; cont1.add(tvDouble);
4071            n++; if (! cont1.contains(tvDouble)) error(test, n);
4072            n++; cont1.add(tvString);
4073            n++; if (! cont1.contains(tvString)) error(test, n);
4074            n++; if ( cont1.contains(tvString, lang)) error(test, n);
4075            n++; cont1.add(tvString, lang);
4076            n++; if (! cont1.contains(tvString, lang)) error(test, n);
4077            n++; cont1.add(tvLiteral);
4078            n++; if (! cont1.contains(tvLiteral)) error(test, n);
4079            n++; cont1.add(tvResObj);
4080            n++; if (! cont1.contains(tvResObj)) error(test, n);
4081            n++; cont1.add(tvLitObj);
4082            n++; if (! cont1.contains(tvLitObj)) error(test, n);
4083            n++; if (! (cont1.size()==13)) error(test,n);
4084
4085            {
4086                n=(n/100+1)*100;;
4087                     for (int i=0; i<num; i++) {
4088                        cont2.add(i);
4089                    }
4090                n++; if (! (cont2.size()==num)) error(test,n);
4091                n++; nIter = cont2.iterator();
4092                    for (int i=0; i<num; i++) {
4093                        if ( ! (((Literal) nIter.nextNode()).getInt() == i))
4094                            error(test, 320+i);
4095                    }
4096                    nIter.close();
4097            }
4098
4099            {
4100                boolean[] found = new boolean[num];
4101                boolean[] pattern =
4102                  {true, true, true, false, false,
4103                   false, false, false, true, true };
4104
4105                n=(n/100+1)*100;;
4106                n++; nIter=cont2.iterator();
4107                     for (int i=0; i<num; i++) {
4108                n++; nIter.nextNode();
4109                n++; if (! pattern[i]) nIter.remove();
4110                        found[i] = false;
4111                     }
4112                n++; nIter.close();
4113                n=(n/100+1)*100;;
4114                n++; nIter = cont2.iterator();
4115                     while (nIter.hasNext()) {
4116                        int v = ((Literal) nIter.nextNode()).getInt();
4117                n++; if ( found[v]) error(test,n);
4118                        found[v] = true;
4119                     }
4120                n++; nIter.close();
4121                n=(n/100+1)*100;
4122                     for (int i=0; i<num; i++) {
4123                n++; if (! (found[i]==pattern[i])) error(test,n);
4124                    }
4125            }
4126        } catch (Exception JavaDoc e) {
4127            logger.error( "test " + test + "[" + n + "]", e );
4128            errors = true;
4129        }
4130    }
4131
4132    public void testBag(Model m, Bag bag1, Bag bag2, Bag bag3,
4133                          String JavaDoc test, int n) {
4134        int num = 10;
4135        NodeIterator nIter;
4136
4137        try {
4138            {
4139                boolean[] found = new boolean[num];
4140                boolean[] pattern =
4141                  {true, true, true, false, false,
4142                   false, false, false, true, true };
4143
4144
4145                    for (int i=0; i<num; i++) {
4146                        bag1.add(i);
4147                    }
4148                n++; nIter=bag1.iterator();
4149                     for (int i=0; i<num; i++) {
4150                n++; nIter.nextNode();
4151                n++; if (! pattern[i]) nIter.remove();
4152                        found[i] = false;
4153                     }
4154                     nIter.close();
4155                n=(n/100+1)*100;
4156                n++; nIter = bag1.iterator();
4157                     while (nIter.hasNext()) {
4158                        int v = ((Literal) nIter.nextNode()).getInt();
4159                n++; if ( found[v]) error(test,n);
4160                        found[v] = true;
4161                     }
4162                n++; nIter.close();
4163                n=(n/100+1)*100;
4164                     for (int i=0; i<num; i++) {
4165                n++; if (! (found[i]==pattern[i])) error(test,n);
4166                    }
4167            }
4168
4169            {
4170                boolean[] found = new boolean[num];
4171                boolean[] pattern =
4172                  {false, true, true, false, false,
4173                   false, false, false, true, false };
4174
4175                n=(n/100+1)*100;
4176                     for (int i=0; i<num; i++) {
4177                        bag2.add(i);
4178                    }
4179                n++; nIter=bag2.iterator();
4180                     for (int i=0; i<num; i++) {
4181                n++; nIter.nextNode();
4182                n++; if (! pattern[i]) nIter.remove();
4183                        found[i] = false;
4184                     }
4185                n++; nIter.close();
4186               n=(n/100+1)*100;
4187                n++; nIter = bag2.iterator();
4188                     while (nIter.hasNext()) {
4189                        int v = ((Literal) nIter.nextNode()).getInt();
4190                n++; if ( found[v]) error(test,n);
4191                        found[v] = true;
4192                     }
4193                n++; nIter.close();
4194                n=(n/100+1)*100;
4195                     for (int i=0; i<num; i++) {
4196                n++; if (! (found[i]==pattern[i])) error(test,n);
4197                    }
4198            }
4199
4200            {
4201                boolean[] found = new boolean[num];
4202                boolean[] pattern =
4203                  {false, false, false, false, false,
4204                   false, false, false, false, false};
4205
4206              n=(n/100+1)*100;
4207                     for (int i=0; i<num; i++) {
4208                        bag3.add(i);
4209                    }
4210                n++; nIter=bag3.iterator();
4211                     for (int i=0; i<num; i++) {
4212                n++; nIter.nextNode();
4213                n++; if (! pattern[i]) nIter.remove();
4214                        found[i] = false;
4215                     }
4216                n++; nIter.close();
4217                n=(n/100+1)*100;;
4218                n++; nIter = bag3.iterator();
4219                     while (nIter.hasNext()) {
4220                        int v = ((Literal) nIter.nextNode()).getInt();
4221                n++; if ( found[v]) error(test,n);
4222                        found[v] = true;
4223                     }
4224                n++; nIter.close();
4225                n=(n/100+1)*100;
4226                     for (int i=0; i<num; i++) {
4227                n++; if (! (found[i]==pattern[i])) error(test,n);
4228                    }
4229            }
4230
4231        } catch (Exception JavaDoc e) {
4232            logger.error( "test " + test + "[" + n + "]", e );
4233            errors = true;
4234        }
4235    }
4236
4237    public void testAlt(Model m, Alt alt1, Alt alt2, Alt alt3, Alt alt4,
4238                         String JavaDoc test, int n) {
4239
4240        try {
4241            NodeIterator nIter;
4242            StmtIterator sIter;
4243            boolean tvBoolean = true;
4244            byte tvByte = 1;
4245            short tvShort = 2;
4246            int tvInt = -1;
4247            long tvLong = -2;
4248            char tvChar = '!';
4249            float tvFloat = (float) 123.456;
4250            double tvDouble = -123.456;
4251            String JavaDoc tvString = "test 12 string";
4252            LitTestObj tvObject = new LitTestObj(12345);
4253            Literal tvLiteral = m.createLiteral("test 12 string 2");
4254            Resource tvResource = m.createResource();
4255            Resource tvResObj = m.createResource(new ResTestObjF());
4256            Object JavaDoc tvLitObj = new LitTestObj(1234);
4257            Bag tvBag = m.createBag();
4258            Alt tvAlt = m.createAlt();
4259            Seq tvSeq = m.createSeq();
4260            String JavaDoc lang = "fr";
4261            int num=10;
4262            Statement stmt;
4263
4264            {
4265                boolean[] found = new boolean[num];
4266                boolean[] pattern =
4267                  {true, true, true, false, false,
4268                   false, false, false, true, true };
4269
4270               n=(n/100+1)*100;
4271                     for (int i=0; i<num; i++) {
4272                        alt1.add(i);
4273                    }
4274                n++; nIter=alt1.iterator();
4275                     for (int i=0; i<num; i++) {
4276                n++; nIter.nextNode();
4277                n++; if (! pattern[i]) nIter.remove();
4278                        found[i] = false;
4279                     }
4280                n++; nIter.close();
4281                n=(n/100+1)*100;
4282                n++; nIter = alt1.iterator();
4283                     while (nIter.hasNext()) {
4284                        int v = ((Literal) nIter.nextNode()).getInt();
4285                n++; if ( found[v]) error(test,n);
4286                        found[v] = true;
4287                     }
4288                n++; nIter.close();
4289                n=(n/100+1)*100;
4290                     for (int i=0; i<num; i++) {
4291                n++; if (! (found[i]==pattern[i])) error(test,n);
4292                    }
4293            }
4294
4295            {
4296                boolean[] found = new boolean[num];
4297                boolean[] pattern =
4298                  {false, true, true, false, false,
4299                   false, false, false, true, false };
4300
4301                n=(n/100+1)*100;
4302                     for (int i=0; i<num; i++) {
4303                        alt2.add(i);
4304                    }
4305                n++; nIter=alt2.iterator();
4306                     for (int i=0; i<num; i++) {
4307                n++; nIter.nextNode();
4308                n++; if (! pattern[i]) nIter.remove();
4309                        found[i] = false;
4310                     }
4311                n++; nIter.close();
4312                n=550;
4313                n++; nIter = alt2.iterator();
4314                     while (nIter.hasNext()) {
4315                        int v = ((Literal) nIter.nextNode()).getInt();
4316                n++; if ( found[v]) error(test,n);
4317                        found[v] = true;
4318                     }
4319                n++; nIter.close();
4320                n=580;
4321                     for (int i=0; i<num; i++) {
4322                n++; if (! (found[i]==pattern[i])) error(test,n);
4323                    }
4324            }
4325
4326            {
4327                boolean[] found = new boolean[num];
4328                boolean[] pattern =
4329                  {false, false, false, false, false,
4330                   false, false, false, false, false};
4331
4332                n=(n/100+1)*100;
4333                     for (int i=0; i<num; i++) {
4334                        alt3.add(i);
4335                    }
4336                n++; nIter=alt3.iterator();
4337                     for (int i=0; i<num; i++) {
4338                n++; nIter.nextNode();
4339                n++; if (! pattern[i]) nIter.remove();
4340                        found[i] = false;
4341                     }
4342                n++; nIter.close();
4343                n=(n/100+1)*100;
4344                n++; nIter = alt3.iterator();
4345                     while (nIter.hasNext()) {
4346                        int v = ((Literal) nIter.nextNode()).getInt();
4347                n++; if ( found[v]) error(test,n);
4348                        found[v] = true;
4349                     }
4350                n++; nIter.close();
4351                n=(n/100+1)*100;
4352                     for (int i=0; i<num; i++) {
4353                n++; if (! (found[i]==pattern[i])) error(test,n);
4354                    }
4355            }
4356
4357            {
4358                n=(n/100+1)*100;
4359                n++; if (! (alt4.setDefault(tvLiteral)
4360                               .getDefault().equals(tvLiteral)))
4361                       error(test,n);
4362                n++; if (! (alt4.setDefault(tvLiteral)
4363                               .getDefaultLiteral().equals(tvLiteral)))
4364                       error(test,n);
4365                n++; if (! alt4.setDefault(tvResource)
4366                               .getDefaultResource().equals(tvResource))
4367                       error(test,n);
4368                n++; if (! (alt4.setDefault(tvByte)
4369                               .getDefaultByte()== tvByte))
4370                       error(test,n);
4371                n++; if (! (alt4.setDefault(tvShort)
4372                               .getDefaultShort()==tvShort))
4373                       error(test,n);
4374                n++; if (! (alt4.setDefault(tvInt)
4375                               .getDefaultInt()==tvInt))
4376                       error(test,n);
4377                n++; if (! (alt4.setDefault(tvLong)
4378                               .getDefaultLong()==tvLong))
4379                       error(test,n);
4380                n++; if (! (alt4.setDefault(tvChar)
4381                               .getDefaultChar()==tvChar))
4382                       error(test,n);
4383                n++; if (! (alt4.setDefault(tvFloat)
4384                               .getDefaultFloat()==tvFloat))
4385                       error(test,n);
4386                n++; if (! (alt4.setDefault(tvDouble)
4387                               .getDefaultDouble()==tvDouble))
4388                       error(test,n);
4389                n++; if (! alt4.setDefault(tvString)
4390                               .getDefaultString().equals(tvString))
4391                       error(test,n);
4392                n++; if (! alt4.getDefaultLanguage().equals(""))
4393                       error(test,n);
4394                n++; if (! alt4.setDefault(tvString, lang)
4395                               .getDefaultString().equals(tvString))
4396                       error(test,n);
4397                n++; if (! alt4.getDefaultLanguage().equals(lang))
4398                       error(test,n);
4399                n++; if (! alt4.setDefault(tvResObj)
4400                               .getDefaultResource(new ResTestObjF())
4401                               .equals(tvResObj))
4402                       error(test,n);
4403                n++; if (! alt4.setDefault(tvLitObj)
4404                               .getDefaultObject(new LitTestObjF())
4405                               .equals(tvLitObj))
4406                       error(test,n);
4407                n++; if (! alt4.setDefault(tvAlt)
4408                               .getDefaultAlt()
4409                               .equals(tvAlt))
4410                       error(test,n);
4411                n++; if (! alt4.setDefault(tvBag)
4412                               .getDefaultBag()
4413                               .equals(tvBag))
4414                       error(test,n);
4415                n++; if (! alt4.setDefault(tvSeq)
4416                               .getDefaultSeq()
4417                               .equals(tvSeq))
4418                       error(test,n);
4419            }
4420
4421        } catch (Exception JavaDoc e) {
4422            logger.error( "test " + test + "[" + n + "]", e );
4423            errors = true;
4424        }
4425    }
4426
4427    public void testSeq(Model m, Seq seq1, Seq seq2, Seq seq3, Seq seq4,
4428                           Seq seq5, Seq seq6, Seq seq7, String JavaDoc test, int n) {
4429
4430        try {
4431            NodeIterator nIter;
4432            StmtIterator sIter;
4433            boolean tvBoolean = true;
4434            byte tvByte = 1;
4435            short tvShort = 2;
4436            int tvInt = -1;
4437            long tvLong = -2;
4438            char tvChar = '!';
4439            float tvFloat = (float) 123.456;
4440            double tvDouble = -123.456;
4441            String JavaDoc tvString = "test 12 string";
4442            LitTestObj tvObject = new LitTestObj(12345);
4443            Literal tvLiteral = m.createLiteral("test 12 string 2");
4444            Resource tvResource = m.createResource();
4445            Resource tvResObj = m.createResource(new ResTestObjF());
4446            Object JavaDoc tvLitObj = new LitTestObj(1234);
4447            Bag tvBag = m.createBag();
4448            Alt tvAlt = m.createAlt();
4449            Seq tvSeq = m.createSeq();
4450            String JavaDoc lang = "fr";
4451            int num=10;
4452            Statement stmt;
4453
4454            {
4455
4456                     for (int i=0; i<num; i++) {
4457                        seq1.add(i);
4458                    }
4459                n++; if (! (seq1.size()==num)) error(test,n);
4460                n++; nIter = seq1.iterator();
4461                    for (int i=0; i<num; i++) {
4462                        if ( ! (((Literal) nIter.nextNode()).getInt() == i))
4463                            error(test, 320+i);
4464                    }
4465                    nIter.close();
4466            }
4467
4468            {
4469                boolean[] found = new boolean[num];
4470                boolean[] pattern =
4471                  {true, true, true, false, false,
4472                   false, false, false, true, true };
4473
4474                n=(n/100)*100 + 100;
4475                n++; nIter=seq1.iterator();
4476                     for (int i=0; i<num; i++) {
4477                n++; nIter.nextNode();
4478                n++; if (! pattern[i]) nIter.remove();
4479                        found[i] = false;
4480                     }
4481                n++; nIter.close();
4482                n=(n/100)*100 + 100;
4483                n++; nIter = seq1.iterator();
4484                     while (nIter.hasNext()) {
4485                        int v = ((Literal) nIter.nextNode()).getInt();
4486                n++; if ( found[v]) error(test,n);
4487                        found[v] = true;
4488                     }
4489                n++; nIter.close();
4490                n=(n/100)*100 + 100;
4491                     for (int i=0; i<num; i++) {
4492                n++; if (! (found[i]==pattern[i])) error(test,n);
4493                    }
4494            }
4495
4496            {
4497                boolean[] found = new boolean[num];
4498                boolean[] pattern =
4499                  {false, true, true, false, false,
4500                   false, false, false, true, false };
4501
4502                n=(n/100)*100 + 100;
4503                     for (int i=0; i<num; i++) {
4504                        seq2.add(i);
4505                    }
4506                n++; nIter=seq2.iterator();
4507                     for (int i=0; i<num; i++) {
4508                n++; nIter.nextNode();
4509                n++; if (! pattern[i]) nIter.remove();
4510                        found[i] = false;
4511                     }
4512                n++; nIter.close();
4513                n=(n/100)*100 + 100;
4514                n++; nIter = seq2.iterator();
4515                     while (nIter.hasNext()) {
4516                        int v = ((Literal) nIter.nextNode()).getInt();
4517                n++; if ( found[v]) error(test,n);
4518                        found[v] = true;
4519                     }
4520                n++; nIter.close();
4521                n=(n/100)*100 + 100;
4522                     for (int i=0; i<num; i++) {
4523                n++; if (! (found[i]==pattern[i])) error(test,n);
4524                    }
4525            }
4526
4527            {
4528                boolean[] found = new boolean[num];
4529                boolean[] pattern =
4530                  {false, false, false, false, false,
4531                   false, false, false, false, false};
4532
4533               n=(n/100)*100 + 100;
4534                     for (int i=0; i<num; i++) {
4535                        seq3.add(i);
4536                    }
4537                n++; nIter=seq3.iterator();
4538                     for (int i=0; i<num; i++) {
4539                n++; nIter.nextNode();
4540                n++; if (! pattern[i]) nIter.remove();
4541                        found[i] = false;
4542                     }
4543                n++; nIter.close();
4544                n=(n/100)*100 + 100;
4545                n++; nIter = seq3.iterator();
4546                     while (nIter.hasNext()) {
4547                        int v = ((Literal) nIter.nextNode()).getInt();
4548                n++; if ( found[v]) error(test,n);
4549                        found[v] = true;
4550                     }
4551                n++; nIter.close();
4552                n=(n/100)*100 + 100;
4553                     for (int i=0; i<num; i++) {
4554                n++; if (! (found[i]==pattern[i])) error(test,n);
4555                    }
4556            }
4557
4558            {
4559                n=(n/100)*100 + 100;
4560                n++; seq4.add(tvBoolean);
4561                n++; if (! (seq4.getBoolean(1)==tvBoolean)) error(test,n);
4562                n++; seq4.add(tvByte);
4563                n++; if (! (seq4.getByte(2)==tvByte)) error(test,n);
4564                n++; seq4.add(tvShort);
4565                n++; if (! (seq4.getShort(3)==tvShort)) error(test,n);
4566                n++; seq4.add(tvInt);
4567                n++; if (! (seq4.getInt(4)==tvInt)) error(test,n);
4568                n++; seq4.add(tvLong);
4569                n++; if (! (seq4.getLong(5)==tvLong)) error(test,n);
4570                n++; seq4.add(tvChar);
4571                n++; if (! (seq4.getChar(6)==tvChar)) error(test,n);
4572                n++; seq4.add(tvFloat);
4573                n++; if (! (seq4.getFloat(7)==tvFloat)) error(test,n);
4574                n++; seq4.add(tvDouble);
4575                n++; if (! (seq4.getDouble(8)==tvDouble)) error(test,n);
4576                n++; seq4.add(tvString);
4577                n++; if (! (seq4.getString(9).equals(tvString))) error(test,n);
4578                n++; if (! (seq4.getLanguage(9).equals(""))) error(test,n);
4579                n++; seq4.add(tvString, lang);
4580                n++; if (! (seq4.getString(10).equals(tvString))) error(test,n);
4581                n++; if (! (seq4.getLanguage(10).equals(lang))) error(test,n);
4582                n++; seq4.add(tvLitObj);
4583                n++; if (! (seq4.getObject(11, new LitTestObjF())
4584                                .equals(tvLitObj))) error(test,n);
4585                n++; seq4.add(tvResource);
4586                n++; if (! (seq4.getResource(12).equals(tvResource))) error(test,n);
4587                n++; seq4.add(tvLiteral);
4588                n++; if (! (seq4.getLiteral(13).equals(tvLiteral))) error(test,n);
4589                n++; seq4.add(tvResObj);
4590                n++; if (! (seq4.getResource(14, new ResTestObjF())
4591                                .equals(tvResObj))) error(test,n);
4592                n++; seq4.add(tvBag);
4593                n++; if (! (seq4.getBag(15).equals(tvBag))) error(test,n);
4594                n++; seq4.add(tvAlt);
4595                n++; if (! (seq4.getAlt(16).equals(tvAlt))) error(test,n);
4596                n++; seq4.add(tvSeq);
4597                n++; if (! (seq4.getSeq(17).equals(tvSeq))) error(test,n);
4598                n++; try {
4599                        seq4.getInt(18); error(test,n);
4600                    } catch (SeqIndexBoundsException e) {
4601                        // as required
4602
}
4603                n++; try {
4604                        seq4.getInt(0); error(test,n);
4605                    } catch (SeqIndexBoundsException e) {
4606                        // as required
4607
}
4608            }
4609
4610            {
4611                n=(n/100)*100 + 100;
4612                for (int i=0; i<num; i++) {
4613                    seq5.add(i);
4614                }
4615
4616                     try {
4617                n++; seq5.add(0, false); error(test,n);
4618                     } catch (SeqIndexBoundsException e) {
4619                        // as required
4620
}
4621                     seq5.add(num+1, false);
4622                     if (seq5.size()!=num+1) error(test,n);
4623                     seq5.remove(num+1);
4624                     try {
4625                n++; seq5.add(num+2, false); error(test,n);
4626                     } catch (SeqIndexBoundsException e) {
4627                        // as required
4628
}
4629
4630               n=(n/100)*100 + 100;
4631                    int size = seq5.size();
4632                    for (int i=1; i<=num-1; i++) {
4633               n++; seq5.add(i, 1000+i);
4634               n++; if (! (seq5.getInt(i)==1000+i)) error(test,n);
4635               n++; if (! (seq5.getInt(i+1)==0)) error(test, n);
4636               n++; if (! (seq5.size()==(size+i))) error(test,n);
4637               n++; if (! (seq5.getInt(size)==(num-i-1))) error(test,n);
4638                    }
4639               n=(n/100)*100 + 100;
4640                    seq6.add(m.createResource());
4641                    seq6.add(1, tvBoolean);
4642               n++; if (! (seq6.getBoolean(1)==tvBoolean)) error(test,n);
4643                    seq6.add(1, tvByte);
4644               n++; if (! (seq6.getByte(1)==tvByte)) error(test,n);
4645                    seq6.add(1, tvShort);
4646               n++; if (! (seq6.getShort(1)==tvShort)) error(test,n);
4647                    seq6.add(1, tvInt);
4648               n++; if (! (seq6.getInt(1)==tvInt)) error(test,n);
4649                    seq6.add(1, tvLong);
4650               n++; if (! (seq6.getLong(1)==tvLong)) error(test,n);
4651                    seq6.add(1, tvChar);
4652               n++; if (! (seq6.getChar(1)==tvChar)) error(test,n);
4653                    seq6.add(1, tvFloat);
4654               n++; if (! (seq6.getFloat(1)==tvFloat)) error(test,n);
4655                    seq6.add(1, tvDouble);
4656               n++; if (! (seq6.getDouble(1)==tvDouble)) error(test,n);
4657                    seq6.add(1, tvString);
4658               n++; if (! (seq6.getString(1).equals(tvString))) error(test,n);
4659                    seq6.add(1, tvString, lang);
4660               n++; if (! (seq6.getString(1).equals(tvString))) error(test,n);
4661                    seq6.add(1, tvResource);
4662               n++; if (! (seq6.getResource(1).equals(tvResource))) error(test,n);
4663                    seq6.add(1, tvLiteral);
4664               n++; if (! (seq6.getLiteral(1).equals(tvLiteral))) error(test,n);
4665                    seq6.add(1, tvLitObj);
4666               n++; if (! (seq6.getObject(1, new LitTestObjF())
4667                              .equals(tvLitObj))) error(test,n);
4668
4669               n=(n/100)*100 + 100;
4670               n++; if (! (seq6.indexOf(tvLitObj)==1)) error(test,n);
4671               n++; if (! (seq6.indexOf(tvLiteral)==2)) error(test,n);
4672               n++; if (! (seq6.indexOf(tvResource)==3)) error(test,n);
4673               n++; if (! (seq6.indexOf(tvString,lang)==4)) error(test,n);
4674               n++; if (! (seq6.indexOf(tvString)==5)) error(test,n);
4675               n++; if (! (seq6.indexOf(tvDouble)==6)) error(test,n);
4676               n++; if (! (seq6.indexOf(tvFloat)==7)) error(test,n);
4677               n++; if (! (seq6.indexOf(tvChar)==8)) error(test,n);
4678               n++; if (! (seq6.indexOf(tvLong)==9)) error(test,n);
4679               n++; if (! (seq6.indexOf(tvInt)==10)) error(test,n);
4680               n++; if (! (seq6.indexOf(tvShort)==11)) error(test,n);
4681               n++; if (! (seq6.indexOf(tvByte)==12)) error(test,n);
4682               n++; if (! (seq6.indexOf(tvBoolean)==13)) error(test,n);
4683               n++; if (! (seq6.indexOf(1234543)==0)) error(test,n);
4684
4685               n=(n/100)*100 + 100;
4686                   for (int i=0; i<num; i++) {
4687                       seq7.add(i);
4688                   }
4689              n=(n/100)*100 + 100;
4690                   seq7.set(5, tvBoolean);
4691              n++; if (! (seq7.getBoolean(5)==tvBoolean)) error(test,n);
4692              n++; if (! (seq7.getInt(4)==3)) error(test,n);
4693              n++; if (! (seq7.getInt(6)==5)) error(test,n);
4694              n++; if (! (seq7.size()==num)) error(test,n);
4695              n=(n/100)*100 + 100;
4696                   seq7.set(5, tvByte);
4697              n++; if (! (seq7.getByte(5)==tvByte)) error(test,n);
4698              n++; if (! (seq7.getInt(4)==3)) error(test,n);
4699              n++; if (! (seq7.getInt(6)==5)) error(test,n);
4700              n++; if (! (seq7.size()==num)) error(test,n);
4701              n=(n/100)*100 + 100;
4702                   seq7.set(5, tvShort);
4703              n++; if (! (seq7.getShort(5)==tvShort)) error(test,n);
4704              n++; if (! (seq7.getInt(4)==3)) error(test,n);
4705              n++; if (! (seq7.getInt(6)==5)) error(test,n);
4706              n++; if (! (seq7.size()==num)) error(test,n);
4707              n=(n/100)*100 + 100;
4708                   seq7.set(5, tvInt);
4709              n++; if (! (seq7.getInt(5)==tvInt)) error(test,n);
4710              n++; if (! (seq7.getInt(4)==3)) error(test,n);
4711              n++; if (! (seq7.getInt(6)==5)) error(test,n);
4712              n++; if (! (seq7.size()==num)) error(test,n);
4713             n=(n/100)*100 + 100;
4714                   seq7.set(5, tvLong);
4715              n++; if (! (seq7.getLong(5)==tvLong)) error(test,n);
4716              n++; if (! (seq7.getInt(4)==3)) error(test,n);
4717              n++; if (! (seq7.getInt(6)==5)) error(test,n);
4718              n++; if (! (seq7.size()==num)) error(test,n);
4719              n=(n/100)*100 + 100;
4720                   seq7.set(5, tvChar);
4721              n++; if (! (seq7.getChar(5)==tvChar)) error(test,n);
4722              n++; if (! (seq7.getInt(4)==3)) error(test,n);
4723              n++; if (! (seq7.getInt(6)==5)) error(test,n);
4724              n++; if (! (seq7.size()==num)) error(test,n);
4725              n=(n/100)*100 + 100;
4726                   seq7.set(5, tvFloat);
4727              n++; if (! (seq7.getFloat(5)==tvFloat)) error(test,n);
4728              n++; if (! (seq7.getInt(4)==3)) error(test,n);
4729              n++; if (! (seq7.getInt(6)==5)) error(test,n);
4730              n++; if (! (seq7.size()==num)) error(test,n);
4731              n=(n/100)*100 + 100;
4732                   seq7.set(5, tvDouble);
4733              n++; if (! (seq7.getDouble(5)==tvDouble)) error(test,n);
4734              n++; if (! (seq7.getInt(4)==3)) error(test,n);
4735              n++; if (! (seq7.getInt(6)==5)) error(test,n);
4736              n++; if (! (seq7.size()==num)) error(test,n);
4737              n=(n/100)*100 + 100;
4738                   seq7.set(5, tvString);
4739              n++; if (! (seq7.getString(5).equals(tvString))) error(test,n);
4740              n++; if (! (seq7.getLanguage(5).equals(""))) error(test,n);
4741              n++; if (! (seq7.getInt(4)==3)) error(test,n);
4742              n++; if (! (seq7.getInt(6)==5)) error(test,n);
4743              n++; if (! (seq7.size()==num)) error(test,n);
4744                   seq7.set(5, tvString,lang);
4745              n++; if (! (seq7.getString(5).equals(tvString))) error(test,n);
4746              n++; if (! (seq7.getLanguage(5).equals(lang))) error(test,n);
4747              n++; if (! (seq7.getInt(4)==3)) error(test,n);
4748              n++; if (! (seq7.getInt(6)==5)) error(test,n);
4749              n++; if (! (seq7.size()==num)) error(test,n);
4750              n=(n/100)*100 + 100;
4751                   seq7.set(5, tvLiteral);
4752              n++; if (! (seq7.getLiteral(5).equals(tvLiteral))) error(test,n);
4753              n++; if (! (seq7.getInt(4)==3)) error(test,n);
4754              n++; if (! (seq7.getInt(6)==5)) error(test,n);
4755              n++; if (! (seq7.size()==num)) error(test,n);
4756              n=(n/100)*100 + 100;
4757                   seq7.set(5, tvResource);
4758              n++; if (! (seq7.getResource(5).equals(tvResource))) error(test,n);
4759              n++; if (! (seq7.getInt(4)==3)) error(test,n);
4760              n++; if (! (seq7.getInt(6)==5)) error(test,n);
4761              n++; if (! (seq7.size()==num)) error(test,n);
4762              n=(n/100)*100 + 100;
4763                   seq7.set(5, tvLitObj);
4764              n++; if (! (seq7.getObject(5, new LitTestObjF()))
4765                             .equals(tvLitObj)) error(test,n);
4766              n++; if (! (seq7.getInt(4)==3)) error(test,n);
4767              n++; if (! (seq7.getInt(6)==5)) error(test,n);
4768              n++; if (! (seq7.size()==num)) error(test,n);
4769              n=(n/100)*100 + 100;
4770                   seq7.set(5, tvResObj);
4771              n++; if (! (seq7.getResource(5, new ResTestObjF())
4772                             .equals(tvResObj))) error(test,n);
4773              n++; if (! (seq7.getInt(4)==3)) error(test,n);
4774              n++; if (! (seq7.getInt(6)==5)) error(test,n);
4775              n++; if (! (seq7.size()==num)) error(test,n);
4776
4777        }
4778
4779        } catch (Exception JavaDoc e) {
4780            logger.error( "test " + test + "[" + n + "]", e );
4781            errors = true;
4782        }
4783    }
4784
4785    public void error(String JavaDoc testName, int testNum) {
4786        System.out.println("Test Failed: "
4787        + testName + " "
4788        + testNum + " ");
4789        errors = true;
4790    }
4791
4792    public void error(String JavaDoc testName, int testNum, long v) {
4793        System.out.println("Test Failed: "
4794        + testName + " "
4795        + testNum + " "
4796        + Long.toString(v));
4797        errors = true;
4798    }
4799
4800    public void error(String JavaDoc testName, int testNum, Exception JavaDoc e) {
4801        System.out.println("Test Failed: "
4802        + testName + " "
4803        + testNum + " "
4804        + e.toString());
4805        errors = true;
4806    }
4807
4808    public boolean getErrors() {
4809        return errors;
4810    }
4811
4812    public boolean setErrors(boolean b) {
4813        boolean temp = errors;
4814        errors = b;
4815        return temp;
4816    }
4817
4818    public class LitTestObj {
4819        protected long content;
4820
4821        public LitTestObj(long l) {
4822            content = l;
4823        }
4824
4825        public LitTestObj(String JavaDoc s) {
4826            content = Long.parseLong(s.substring(1, s.length()-1));
4827        }
4828
4829        public String JavaDoc toString() {
4830            return "[" + Long.toString(content) + "]";
4831        }
4832
4833        public boolean equals(Object JavaDoc o) {
4834            if (o instanceof LitTestObj) {
4835                return content == ((LitTestObj)o).content;
4836            } else {
4837                return false;
4838            }
4839        }
4840    }
4841
4842    public class LitTestObjF implements ObjectF {
4843        public Object JavaDoc createObject(String JavaDoc s) {
4844            return new LitTestObj(s);
4845        }
4846    }
4847
4848    public class ResTestObjF implements ResourceF {
4849        public Resource createResource(Resource r)
4850            { return new ResourceImpl( r, (ModelCom) r.getModel() ); }
4851    }
4852}
4853/*
4854 * (c) Copyright 2000, 2001, 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
4855 * All rights reserved.
4856 *
4857 * Redistribution and use in source and binary forms, with or without
4858 * modification, are permitted provided that the following conditions
4859 * are met:
4860 * 1. Redistributions of source code must retain the above copyright
4861 * notice, this list of conditions and the following disclaimer.
4862 * 2. Redistributions in binary form must reproduce the above copyright
4863 * notice, this list of conditions and the following disclaimer in the
4864 * documentation and/or other materials provided with the distribution.
4865 * 3. The name of the author may not be used to endorse or promote products
4866 * derived from this software without specific prior written permission.
4867
4868 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
4869 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
4870 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
4871 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
4872 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
4873 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
4874 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
4875 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
4876 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
4877 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4878 *
4879 * $Id: Regression.java,v 1.20 2005/02/21 12:18:40 andy_seaborne Exp $
4880 */

4881
Popular Tags