001: /*
002: (c) Copyright 2001, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003: All rights reserved.
004: [See end of file]
005: $Id: TestPackage.java,v 1.23 2008/01/02 12:06:48 andy_seaborne Exp $
006: */
007: package com.hp.hpl.jena.xmloutput.test;
008:
009: // Imports
010: ///////////////
011: import java.io.StringWriter;
012:
013: import junit.framework.TestCase;
014: import junit.framework.TestSuite;
015:
016: import com.hp.hpl.jena.rdf.model.Model;
017: import com.hp.hpl.jena.rdf.model.ModelFactory;
018: import com.hp.hpl.jena.shared.BadURIException;
019:
020: /**
021: * JUnit regression tests for output
022: *
023: * @author Jeremy Carroll
024: * @version CVS info: $Id: TestPackage.java,v 1.23 2008/01/02 12:06:48 andy_seaborne Exp $,
025: */
026: public class TestPackage extends TestCase {
027:
028: /**
029: * Answer a suite of all the tests defined here
030: */
031: public static TestSuite suite() {
032: TestSuite suite = new TestSuite();
033: suite.addTest(TestMacEncodings.suite());
034: // add all the tests defined in this class to the suite
035: /* */
036: suite.addTestSuite(PrettyWriterTest.class);
037: suite.addTest(new testWriterInterface("testInterface", null));
038: /* */
039: suite.addTest(new testWriterInterface("testNoWriter", null));
040: /* */
041: suite
042: .addTest(new testWriterInterface("testAnotherWriter",
043: null));
044: /* */
045: if (false)
046: suite.addTest(BigAbbrevTestPackage.suite()); // TODO may be obsolete. Ask Jeremy.
047: suite.addTest(testWriterAndReader.suiteXML());
048: suite.addTest(testWriterAndReader.suiteXML_ABBREV());
049: suite.addTest(testWriterAndReader.suiteN_TRIPLE());
050: suite.addTestSuite(TestURIExceptions.class);
051: suite.addTestSuite(TestEntityOutput.class);
052: suite.addTestSuite(TestLiteralEncoding.class);
053: return suite;
054: }
055:
056: /**
057: Added as a place to put the test(s) which ensure that thrown URI exceptions
058: carry the bad URI with them. I (Chris) would embed them in the other tests,
059: but I can't work out how to do so ...
060: @author kers
061: */
062: public static class TestURIExceptions extends TestCase {
063: public TestURIExceptions(String name) {
064: super (name);
065: }
066:
067: public void testBadURIExceptionContainsBadURIInMessage() {
068: String badURI = "http:";
069: Model m = ModelFactory.createDefaultModel();
070: m.add(m.createResource(badURI), m.createProperty("eg:B C"),
071: m.createResource("eg:C D"));
072: try {
073: m.write(new StringWriter());
074: fail("should detect bad URI " + badURI);
075: } catch (BadURIException e) {
076: assertTrue("message must contain failing URI", e
077: .getMessage().indexOf(badURI) > 0);
078: }
079: }
080: }
081:
082: }
083:
084: /*
085: * (c) Copyright 2001,2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
086: * All rights reserved.
087: *
088: * Redistribution and use in source and binary forms, with or without
089: * modification, are permitted provided that the following conditions
090: * are met:
091: * 1. Redistributions of source code must retain the above copyright
092: * notice, this list of conditions and the following disclaimer.
093: * 2. Redistributions in binary form must reproduce the above copyright
094: * notice, this list of conditions and the following disclaimer in the
095: * documentation and/or other materials provided with the distribution.
096: * 3. The name of the author may not be used to endorse or promote products
097: * derived from this software without specific prior written permission.
098:
099: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
100: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
101: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
102: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
103: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
104: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
105: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
106: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
107: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
108: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
109: *
110: * $Id: TestPackage.java,v 1.23 2008/01/02 12:06:48 andy_seaborne Exp $
111: */
|