KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > rdf > model > test > TestAnonID


1 /******************************************************************
2  * File: TestAnonID.java
3  * Created by: Dave Reynolds
4  * Created on: 18-Mar-2004
5  *
6  * (c) Copyright 2004, 2005 Hewlett-Packard Development Company, LP, all rights reserved.
7  * [See end of file]
8  * $Id: TestAnonID.java,v 1.4 2005/02/21 12:15:00 andy_seaborne Exp $
9  *****************************************************************/

10 package com.hp.hpl.jena.rdf.model.test;
11
12 import com.hp.hpl.jena.rdf.model.AnonId;
13 import com.hp.hpl.jena.shared.impl.JenaParameters;
14
15 import junit.framework.TestCase;
16 import junit.framework.TestSuite;
17
18 /**
19  * Test for anonID generation. Actually test for the debugging hack
20  * that switches off anonID generation.
21  *
22  * @author <a HREF="mailto:der@hplb.hpl.hp.com">Dave Reynolds</a>
23  * @version $Revision: 1.4 $ on $Date: 2005/02/21 12:15:00 $
24  */

25 public class TestAnonID extends TestCase {
26     
27     /**
28      * Boilerplate for junit
29      */

30     public TestAnonID( String JavaDoc name ) {
31         super( name );
32     }
33     
34     /**
35      * Boilerplate for junit.
36      * This is its own test suite
37      */

38     public static TestSuite suite() {
39         return new TestSuite( TestAnonID.class );
40     }
41
42     /**
43      * Check that anonIDs are distinct whichever state the flag is in.
44      */

45     public void testAnonID() {
46         boolean prior = JenaParameters.disableBNodeUIDGeneration;
47         try
48             {
49             JenaParameters.disableBNodeUIDGeneration = false;
50             doTestAnonID();
51             JenaParameters.disableBNodeUIDGeneration = true;
52             doTestAnonID();
53             }
54         finally
55             { JenaParameters.disableBNodeUIDGeneration = prior; }
56     }
57
58     /**
59      * Check that anonIDs are distinct whichever state the flag is in.
60      */

61     public void doTestAnonID() {
62         AnonId id1 = new AnonId();
63         AnonId id2 = new AnonId();
64         AnonId id3 = new AnonId();
65         AnonId id4 = new AnonId();
66         
67         assertNotSame(id1, id2);
68         assertNotSame(id1, id3);
69         assertNotSame(id1, id4);
70         assertNotSame(id2, id3);
71         assertNotSame(id2, id4);
72     }
73
74 }
75
76
77 /*
78     (c) Copyright 2004, 2005 Hewlett-Packard Development Company, LP
79     All rights reserved.
80
81     Redistribution and use in source and binary forms, with or without
82     modification, are permitted provided that the following conditions
83     are met:
84
85     1. Redistributions of source code must retain the above copyright
86        notice, this list of conditions and the following disclaimer.
87
88     2. Redistributions in binary form must reproduce the above copyright
89        notice, this list of conditions and the following disclaimer in the
90        documentation and/or other materials provided with the distribution.
91
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
Popular Tags