KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > db > test > TestQuery1


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

6
7 package com.hp.hpl.jena.db.test;
8
9 import com.hp.hpl.jena.graph.*;
10 import com.hp.hpl.jena.db.*;
11 import com.hp.hpl.jena.shared.*;
12
13 import java.util.*;
14
15 import junit.framework.*;
16
17 /**
18     Apply the abstract query tests to an RDB graph.
19     @author kers
20 */

21 public class TestQuery1 extends AbstractTestQuery1
22     {
23     public TestQuery1( String JavaDoc name )
24         { super( name ); }
25
26     public static TestSuite suite()
27         { return new TestSuite( TestQuery1.class ); }
28        
29     private IDBConnection theConnection;
30     private int count = 0;
31     
32     private List graphs;
33     
34     public void setUp() throws Exception JavaDoc
35         {
36         theConnection = TestConnection.makeTestConnection();
37         graphs = new ArrayList();
38         super.setUp();
39         }
40         
41     public void tearDown() throws Exception JavaDoc
42         {
43         removeGraphs();
44         theConnection.close();
45         super.tearDown();
46         }
47         
48     private void removeGraphs()
49         { for (int i = 0; i < graphs.size(); i += 1) ((GraphRDB) graphs.get(i)).remove(); }
50
51     public Graph getGraph ( ) {
52         return getGraph( ReificationStyle.Minimal );
53     }
54         
55     public Graph getGraph ( ReificationStyle style )
56         {
57         String JavaDoc name = "jena-test-rdb-TestQuery1-" + count ++;
58         if (theConnection.containsModel( name )) makeGraph( name, false, style ).remove();
59         GraphRDB result = makeGraph( name, true, style );
60         graphs.add( result );
61         return result;
62         }
63         
64     protected GraphRDB makeGraph( String JavaDoc name, boolean fresh, ReificationStyle style )
65         { return new GraphRDB
66             (
67             theConnection,
68             name,
69             theConnection.getDefaultModelProperties().getGraph(),
70             GraphRDB.styleRDB( style ),
71             fresh
72             ); }
73
74     }
75
76         
77
78
79
80 /*
81     (c) Copyright 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
82     All rights reserved.
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
88     1. Redistributions of source code must retain the above copyright
89        notice, this list of conditions and the following disclaimer.
90
91     2. Redistributions in binary form must reproduce the above copyright
92        notice, this list of conditions and the following disclaimer in the
93        documentation and/or other materials provided with the distribution.
94
95     3. The name of the author may not be used to endorse or promote products
96        derived from this software without specific prior written permission.
97
98     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
99     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
100     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
101     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
102     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
103     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
104     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
105     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
106     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
107     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
108 */
Popular Tags