01: /*
02: * Copyright (C) 2007, 2008 XStream Committers.
03: * All rights reserved.
04: *
05: * The software in this package is published under the terms of the BSD
06: * style license a copy of which has been included with this distribution in
07: * the LICENSE.txt file.
08: *
09: * Created on 03. November 2007 by Joerg Schaible
10: */
11: package com.thoughtworks.xstream.io.xml;
12:
13: import com.bea.xml.stream.XMLOutputFactoryBase;
14:
15: import junit.framework.Test;
16:
17: import javax.xml.stream.XMLOutputFactory;
18:
19: public final class BEAStaxWriterTest extends AbstractStaxWriterTest {
20: public BEAStaxWriterTest() {
21: System.setProperty(XMLOutputFactory.class.getName(),
22: XMLOutputFactoryBase.class.getName());
23: }
24:
25: public static Test suite() {
26: return createSuite(BEAStaxWriterTest.class,
27: XMLOutputFactoryBase.class.getName());
28: }
29:
30: protected void assertXmlProducedIs(String expected) {
31: if (outputFactory.getProperty(
32: XMLOutputFactory.IS_REPAIRING_NAMESPACES).equals(
33: Boolean.FALSE)) {
34: expected = perlUtil
35: .substitute(
36: "s#<(\\w+|\\w+:\\w+) (xmlns[^\"]*\"[^\"]*\")>#<$1>#g",
37: expected);
38: } else {
39: expected = perlUtil
40: .substitute("s# xmlns=\"\"##g", expected);
41: }
42: expected = perlUtil.substitute(
43: "s#<(\\w+)([^>]*)/>#<$1$2></$1>#g", expected);
44: expected = replaceAll(expected, "
", " ");
45: expected = getXMLHeader() + expected;
46: assertEquals(expected, buffer.toString());
47: }
48:
49: protected String getXMLHeader() {
50: return "<?xml version='1.0' encoding='utf-8'?>";
51: }
52:
53: protected XMLOutputFactory getOutputFactory() {
54: return new XMLOutputFactoryBase();
55: }
56: }
|