KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > util > test > TestCollectionFactory


1 /*
2   (c) Copyright 2004, 2005 Hewlett-Packard Development Company, LP, all rights reserved.
3   [See end of file]
4   $Id: TestCollectionFactory.java,v 1.2 2005/02/21 12:19:21 andy_seaborne Exp $
5 */

6 package com.hp.hpl.jena.util.test;
7
8 import java.util.*;
9
10 import junit.framework.TestSuite;
11
12 import com.hp.hpl.jena.rdf.model.test.ModelTestBase;
13 import com.hp.hpl.jena.util.CollectionFactory;
14
15 /**
16     TestHashUtils - test that the hash utility returns a map.
17     @author kers
18 */

19 public class TestCollectionFactory extends ModelTestBase
20     {
21     public TestCollectionFactory( String JavaDoc name )
22         { super( name ); }
23     
24     public static TestSuite suite()
25         { return new TestSuite( TestCollectionFactory.class ); }
26
27     public void testHashMapExists()
28         {
29         Map map = CollectionFactory.createHashedMap();
30         assertTrue( map instanceof Map );
31         }
32     
33     public void testHashMapSized()
34         {
35         Map map = CollectionFactory.createHashedMap( 42 );
36         assertTrue( map instanceof Map );
37         }
38     
39     public void testHashMapCopy()
40         {
41         Map map = new HashMap();
42         map.put( "here", "Bristol" );
43         map.put( "there", "Oxford" );
44         Map copy = CollectionFactory.createHashedMap( map );
45         assertEquals( map, copy );
46         }
47     
48     public void testHashSetExists()
49         {
50         Set set = CollectionFactory.createHashedSet();
51         assertTrue( set instanceof Set );
52         }
53     
54     public void testHashSetCopy()
55         {
56         Set s = new HashSet();
57         s.add( "jelly" );
58         s.add( "concrete" );
59         Set copy = CollectionFactory.createHashedSet( s );
60         assertEquals( s, copy );
61         }
62     }
63
64
65 /*
66 (c) Copyright 2004, 2005 Hewlett-Packard Development Company, LP
67 All rights reserved.
68
69 Redistribution and use in source and binary forms, with or without
70 modification, are permitted provided that the following conditions
71 are met:
72
73 1. Redistributions of source code must retain the above copyright
74    notice, this list of conditions and the following disclaimer.
75
76 2. Redistributions in binary form must reproduce the above copyright
77    notice, this list of conditions and the following disclaimer in the
78    documentation and/or other materials provided with the distribution.
79
80 3. The name of the author may not be used to endorse or promote products
81    derived from this software without specific prior written permission.
82
83 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
84 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
85 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
86 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
87 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
88 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
89 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
90 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
91 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
92 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
93 */
Popular Tags