KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > xmloutput > test > TestPackage


1 /*
2     (c) Copyright 2001, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
3     All rights reserved.
4     [See end of file]
5     $Id: TestPackage.java,v 1.15 2005/04/15 10:34:38 jeremy_carroll Exp $
6 */

7 package com.hp.hpl.jena.xmloutput.test;
8
9 // Imports
10
///////////////
11
import java.io.StringWriter JavaDoc;
12
13 import com.hp.hpl.jena.rdf.model.*;
14 import com.hp.hpl.jena.shared.BadURIException;
15
16 import junit.framework.*;
17
18 /**
19  * JUnit regression tests for output
20  *
21  * @author Jeremy Carroll
22  * @version CVS info: $Id: TestPackage.java,v 1.15 2005/04/15 10:34:38 jeremy_carroll Exp $,
23  */

24 public class TestPackage extends TestCase{
25
26     /**
27      * Answer a suite of all the tests defined here
28      */

29     public static TestSuite suite() {
30         TestSuite suite = new TestSuite();
31         String JavaDoc langs[] =
32             new String JavaDoc[] { "RDF/XML", "RDF/XML-ABBREV",
33                 //
34
"N-TRIPLE",
35             //"N3"
36
};
37         suite.addTest(TestMacEncodings.suite());
38         // add all the tests defined in this class to the suite
39
/* */
40         suite.addTest(new PrettyWriterTest("testAnonDamlClass"));
41         /* */
42         suite.addTest(new PrettyWriterTest("testLi"));
43         suite.addTest(new PrettyWriterTest("test803804"));
44         
45         //if ( true ) return suite;
46
/* */
47         suite.addTest(new PrettyWriterTest("testRDFCollection"));
48         /* */
49         suite.addTest(new PrettyWriterTest("testOWLPrefix"));
50         /* */
51         suite.addTest(new testWriterInterface("testInterface", null));
52         /* */
53         suite.addTest(new testWriterInterface("testNoWriter", null));
54         /* */
55         suite.addTest(new testWriterInterface("testAnotherWriter", null));
56         /* */
57         for (int i = 0; i < langs.length
58               ; i++) {
59             suite.addTest(testWriterAndReader.suite(langs[i]));
60         }
61
62         suite.addTest( new TestSuite( TestURIExceptions.class ) );
63         return suite;
64     }
65     
66     /**
67          Added as a place to put the test(s) which ensure that thrown URI exceptions
68          carry the bad URI with them. I (Chris) would embed them in the other tests,
69          but I can't work out how to do so ...
70         @author kers
71     */

72     public static class TestURIExceptions extends TestCase
73         {
74         public TestURIExceptions( String JavaDoc name )
75             { super( name ); }
76         
77         public void testBadURIExceptionContainsBadURIInMessage()
78             {
79             String JavaDoc badURI = "http:";
80             Model m = ModelFactory.createDefaultModel();
81             m.add( m.createResource( badURI ), m.createProperty( "eg:B C" ), m.createResource( "eg:C D" ) );
82             try { m.write( new StringWriter JavaDoc() ); fail( "should detect bad URI " + badURI ); }
83             catch (BadURIException e) { assertTrue( "message must contain failing URI", e.getMessage().indexOf( badURI ) > 0 ); }
84             }
85         }
86
87 }
88
89 /*
90  * (c) Copyright 2001,2003, 2004, 2005 Hewlett-Packard Development Company, LP
91  * All rights reserved.
92  *
93  * Redistribution and use in source and binary forms, with or without
94  * modification, are permitted provided that the following conditions
95  * are met:
96  * 1. Redistributions of source code must retain the above copyright
97  * notice, this list of conditions and the following disclaimer.
98  * 2. Redistributions in binary form must reproduce the above copyright
99  * notice, this list of conditions and the following disclaimer in the
100  * documentation and/or other materials provided with the distribution.
101  * 3. The name of the author may not be used to endorse or promote products
102  * derived from this software without specific prior written permission.
103
104  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
105  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
106  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
107  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
108  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
109  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
110  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
111  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
112  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
113  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
114  *
115  * $Id: TestPackage.java,v 1.15 2005/04/15 10:34:38 jeremy_carroll Exp $
116  */

117
Popular Tags