KickJava   Java API By Example, From Geeks To Geeks.

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


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

6 package com.hp.hpl.jena.rdf.model.test;
7
8 import java.io.StringReader JavaDoc;
9
10 import com.hp.hpl.jena.graph.*;
11 import com.hp.hpl.jena.rdf.model.*;
12
13 import junit.framework.TestSuite;
14
15 /**
16     TestReaderEvents - test that reader events are issued
17     @author kers
18 */

19 public class TestReaderEvents extends ModelTestBase
20     {
21     public TestReaderEvents( String JavaDoc name )
22         { super(name); }
23
24     public static TestSuite suite()
25         { return new TestSuite( TestReaderEvents.class ); }
26     
27     public void testXMLReaderEvents()
28         {
29         String JavaDoc emptyModel = "<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'></rdf:RDF>";
30         testReaderEvent( "RDF/XML", emptyModel );
31         }
32
33     public void testN3ReaderEvents()
34         {
35         testReaderEvent( "N3", "" );
36         }
37
38     public void testNTriplesReaderEvents()
39         {
40         testReaderEvent( "N-TRIPLE", "" );
41         }
42     
43     public void testReaderEvent( String JavaDoc language, String JavaDoc emptyModel )
44         {
45         Model m = ModelFactory.createDefaultModel();
46         RecordingModelListener L = new RecordingModelListener();
47         m.register( L );
48         RDFReader r = m.getReader( language );
49         StringReader JavaDoc stringReader = new StringReader JavaDoc( emptyModel );
50         r.read( m, stringReader, "" );
51         L.assertHasStart( new Object JavaDoc[] {"someEvent", m, GraphEvents.startRead} );
52         L.assertHasEnd( new Object JavaDoc[] {"someEvent", m, GraphEvents.finishRead} );
53         }
54     
55     }
56
57
58 /*
59 (c) Copyright 2004, 2005 Hewlett-Packard Development Company, LP
60 All rights reserved.
61
62 Redistribution and use in source and binary forms, with or without
63 modification, are permitted provided that the following conditions
64 are met:
65
66 1. Redistributions of source code must retain the above copyright
67    notice, this list of conditions and the following disclaimer.
68
69 2. Redistributions in binary form must reproduce the above copyright
70    notice, this list of conditions and the following disclaimer in the
71    documentation and/or other materials provided with the distribution.
72
73 3. The name of the author may not be used to endorse or promote products
74    derived from this software without specific prior written permission.
75
76 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
77 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
78 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
79 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
80 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
81 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
82 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
83 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
84 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
85 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
86 */
Popular Tags