KickJava   Java API By Example, From Geeks To Geeks.

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


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

6 package com.hp.hpl.jena.regression;
7
8 import com.hp.hpl.jena.rdf.model.*;
9
10 import org.apache.commons.logging.Log;
11 import org.apache.commons.logging.LogFactory;
12 /**
13  *
14  * @author bwm
15  */

16 public class testModelEquals extends Object JavaDoc {
17    
18
19     protected static Log logger = LogFactory.getLog( testModelEquals.class );
20     
21     void test(GetModel gm) {
22         Model m1, m2;
23         String JavaDoc test = "testModelEquals";
24         String JavaDoc filebase = "modules/rdf/regression/" + test + "/";
25         boolean results[] = {
26             false, true, true, true, true, false, false, true, false };
27         int n = 0;
28         try {
29             for (n=1; n<7; n++) {
30                 m1 = gm.get();
31                 m2= gm.get();
32                 m1.read(
33                     ResourceReader.getInputStream(filebase + Integer.toString(n) + "-1.rdf"),
34                     "http://www.example.org/");
35                 m2.read(
36                     ResourceReader.getInputStream(filebase + Integer.toString(n) + "-2.rdf"),
37                     "http://www.example.org/");
38                 if (! (m1.isIsomorphicWith(m2) == results[n])) {
39                     error(test, n);
40                     System.out.println("m1:");
41                     m1.write(System.out, "N-TRIPLE");
42                     System.out.println("m2:");
43                     m2.write(System.out, "N-TRIPLE");
44                 }
45             }
46             for (n=7; n<9; n++) {
47                 m1 = gm.get();
48                 m2= gm.get();
49                 m1.read(
50                     ResourceReader.getInputStream(filebase + Integer.toString(n) + "-1.nt"),
51                                    "", "N-TRIPLE");
52                 m2.read(
53                     ResourceReader.getInputStream(filebase + Integer.toString(n) + "-2.nt"),
54                                    "", "N-TRIPLE");
55                 if (! (m1.isIsomorphicWith(m2) == results[n])) {
56                     error(test, n);
57                     System.out.println("m1:");
58                     m1.write(System.out, "N-TRIPLE");
59                     System.out.println("m2:");
60                     m2.write(System.out, "N-TRIPLE");
61                 }
62             }
63         } catch (Exception JavaDoc e) {
64             inError = true;
65             logger.error( " test " + test + "[" + n + "]", e);
66         }
67     }
68     
69     private boolean inError = false;
70        
71     protected void error(String JavaDoc test, int n) {
72         System.out.println(test + ": failed test " + Integer.toString(n));
73         inError = true;
74     }
75     
76     public boolean getErrors() {
77         return inError;
78     }
79 }
80
81 /*
82  * (c) Copyright 2001,2003, 2004, 2005 Hewlett-Packard Development Company, LP
83  *
84  * Redistribution and use in source and binary forms, with or without
85  * modification, are permitted provided that the following conditions
86  * are met:
87  * 1. Redistributions of source code must retain the above copyright
88  * notice, this list of conditions and the following disclaimer.
89  * 2. Redistributions in binary form must reproduce the above copyright
90  * notice, this list of conditions and the following disclaimer in the
91  * documentation and/or other materials provided with the distribution.
92  * 3. The name of the author may not be used to endorse or promote products
93  * derived from this software without specific prior written permission.
94
95  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
96  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
97  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
98  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
99  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
100  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
101  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
102  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
103  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
104  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
105  *
106  * $Id: testModelEquals.java,v 1.12 2005/02/21 12:18:40 andy_seaborne Exp $
107  */

108
Popular Tags