001: /*
002: * (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003: * [See end of file]
004: */
005:
006: package com.hp.hpl.jena.xmloutput.test;
007:
008: import java.io.ByteArrayOutputStream;
009: import java.io.IOException;
010: import java.io.OutputStream;
011: import java.io.OutputStreamWriter;
012: import java.io.Writer;
013:
014: import junit.framework.TestSuite;
015:
016: import org.apache.commons.logging.Log;
017: import org.apache.commons.logging.LogFactory;
018:
019: import com.hp.hpl.jena.rdf.arp.test.MoreTests;
020: import com.hp.hpl.jena.rdf.model.Model;
021: import com.hp.hpl.jena.rdf.model.test.ModelTestBase;
022:
023: /**
024: * @author Jeremy J. Carroll
025: *
026: */
027: public class TestMacEncodings extends ModelTestBase {
028: private static Log logger = LogFactory
029: .getLog(TestMacEncodings.class);
030:
031: public TestMacEncodings(String name) {
032: super (name);
033: }
034:
035: public static TestSuite suite() {
036: TestSuite suite = new TestSuite(TestMacEncodings.class);
037: suite.setName("Encodings (particular MacRoman etc.)");
038:
039: try {
040: OutputStream out = new ByteArrayOutputStream();
041:
042: new OutputStreamWriter(out, "MacRoman");
043: InUse = true;
044: } catch (Exception e) {
045: InUse = false;
046: }
047: if (!InUse) {
048: logger
049: .warn("MacRoman not supported on this Java installation: mac encoding tests suppressed.");
050: return suite;
051: }
052: suite.addTest(new MoreTests("testARPMacRoman"));
053: suite.addTest(new MoreTests("testARPMacArabic"));
054: return suite;
055: }
056:
057: static private boolean InUse = false;
058:
059: /*
060: public void test00InitMacTests() {
061: try {
062: OutputStream out = new ByteArrayOutputStream();
063:
064: Writer wrtr = new OutputStreamWriter(out,"MacRoman");
065: InUse = true;
066: } catch (Exception e){
067: InUse = false;
068: }
069: if (!InUse){
070: logger.warn("MacRoman not supported on this Java installation: mac encoding tests suppressed.");
071:
072: }
073:
074: }
075: */
076:
077: public void testXMLWriterMacRoman() throws IOException {
078: if (!InUse)
079: return;
080: TestXMLFeatures.blockLogger();
081: Model m = createMemModel();
082: OutputStream fos = new ByteArrayOutputStream();
083: Writer w = new OutputStreamWriter(fos, "MacRoman");
084: m.write(w, "RDF/XML");
085: assertTrue(TestXMLFeatures.unblockLogger());
086: }
087:
088: public void testXMLWriteMacArabic() throws IOException {
089: if (!InUse)
090: return;
091: TestXMLFeatures.blockLogger();
092: Model m = createMemModel();
093: OutputStream fos = new ByteArrayOutputStream();
094: Writer w = new OutputStreamWriter(fos, "MacRoman");
095: m.write(w, "RDF/XML");
096: assertTrue(TestXMLFeatures.unblockLogger());
097: }
098:
099: }
100:
101: /*
102: * (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
103: * All rights reserved.
104: *
105: * Redistribution and use in source and binary forms, with or without
106: * modification, are permitted provided that the following conditions
107: * are met:
108: * 1. Redistributions of source code must retain the above copyright
109: * notice, this list of conditions and the following disclaimer.
110: * 2. Redistributions in binary form must reproduce the above copyright
111: * notice, this list of conditions and the following disclaimer in the
112: * documentation and/or other materials provided with the distribution.
113: * 3. The name of the author may not be used to endorse or promote products
114: * derived from this software without specific prior written permission.
115: *
116: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
117: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
118: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
119: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
120: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
121: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
122: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
123: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
124: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
125: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
126: */
|