KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > graph > test > TestReifier


1 /*
2   (c) Copyright 2002, 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
3   [See end of file]
4   $Id: TestReifier.java,v 1.22 2005/02/21 11:52:48 andy_seaborne Exp $
5 */

6
7 package com.hp.hpl.jena.graph.test;
8
9 import java.lang.reflect.Constructor JavaDoc;
10
11 import com.hp.hpl.jena.graph.*;
12 import com.hp.hpl.jena.graph.impl.GraphBase;
13 import com.hp.hpl.jena.graph.impl.ReifierFragmentsMap;
14 import com.hp.hpl.jena.graph.impl.ReifierTripleMap;
15 import com.hp.hpl.jena.graph.impl.SimpleReifier;
16 import com.hp.hpl.jena.graph.impl.SimpleReifierFragmentsMap;
17 import com.hp.hpl.jena.graph.impl.SimpleReifierTripleMap;
18 import com.hp.hpl.jena.mem.*;
19 import com.hp.hpl.jena.shared.*;
20 import com.hp.hpl.jena.util.iterator.ExtendedIterator;
21
22 import junit.framework.*;
23
24 /**
25     This class tests the reifiers of ordinary GraphMem graphs.
26     @author kers
27 */

28
29 public class TestReifier extends AbstractTestReifier
30     {
31     public TestReifier( String JavaDoc name )
32         { super( name ); graphClass = null; style = null; }
33         
34     protected final Class JavaDoc graphClass;
35     protected final ReificationStyle style;
36     
37     public TestReifier( Class JavaDoc graphClass, String JavaDoc name, ReificationStyle style )
38         {
39         super( name );
40         this.graphClass = graphClass;
41         this.style = style;
42         }
43         
44     public static TestSuite suite()
45         {
46         TestSuite result = new TestSuite();
47         result.addTest( MetaTestGraph.suite( TestReifier.class, GraphMem.class ) );
48         return result;
49         }
50         
51     public Graph getGraph( ReificationStyle style )
52         {
53         try
54             {
55             Constructor JavaDoc cons = getConstructor( graphClass, new Class JavaDoc[] {ReificationStyle.class} );
56             if (cons != null) return (Graph) cons.newInstance( new Object JavaDoc[] { style } );
57             Constructor JavaDoc cons2 = getConstructor( graphClass, new Class JavaDoc [] {this.getClass(), ReificationStyle.class} );
58             if (cons2 != null) return (Graph) cons2.newInstance( new Object JavaDoc[] { this, style } );
59             throw new JenaException( "no suitable graph constructor found for " + graphClass );
60             }
61         catch (RuntimeException JavaDoc e)
62             { throw e; }
63         catch (Exception JavaDoc e)
64             { throw new JenaException( e ); }
65         }
66     
67     public void testExtendedConstructorExists()
68         {
69         GraphBase parent = new GraphBase() {
70
71             public ExtendedIterator graphBaseFind( TripleMatch m )
72                 {
73                 // TODO Auto-generated method stub
74
return null;
75                 }};
76         ReifierTripleMap tm = new SimpleReifierTripleMap();
77         ReifierFragmentsMap fm = new SimpleReifierFragmentsMap();
78         SimpleReifier sr = new SimpleReifier( parent, tm, fm, ReificationStyle.Minimal );
79         }
80     }
81
82 /*
83     (c) Copyright 2002, 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
84     All rights reserved.
85
86     Redistribution and use in source and binary forms, with or without
87     modification, are permitted provided that the following conditions
88     are met:
89
90     1. Redistributions of source code must retain the above copyright
91        notice, this list of conditions and the following disclaimer.
92
93     2. Redistributions in binary form must reproduce the above copyright
94        notice, this list of conditions and the following disclaimer in the
95        documentation and/or other materials provided with the distribution.
96
97     3. The name of the author may not be used to endorse or promote products
98        derived from this software without specific prior written permission.
99
100     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
101     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
102     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
103     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
104     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
105     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
106     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
107     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
108     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
109     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
110 */

111
Popular Tags