01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.commons.betwixt.dotbetwixt;
19:
20: import java.io.StringWriter;
21:
22: import org.apache.commons.betwixt.AbstractTestCase;
23: import org.apache.commons.betwixt.io.BeanWriter;
24:
25: /**
26: * @author <a href='http://jakarta.apache.org/'>Jakarta Commons Team</a>
27: * @version $Revision: 438373 $
28: */
29: public class TestDotBetwixtNamespace extends AbstractTestCase {
30:
31: public TestDotBetwixtNamespace(String name) {
32: super (name);
33: }
34:
35: public void testWriteSimpleDotBetwixtWithNamespaces()
36: throws Exception {
37: PersonWithNamespace bean = new PersonWithNamespace("Robert",
38: "Burrell", "Donkin");
39: StringWriter out = new StringWriter();
40: out.write("<?xml version='1.0'?>");
41: BeanWriter writer = new BeanWriter(out);
42: writer.getBindingConfiguration().setMapIDs(false);
43: writer
44: .getXMLIntrospector()
45: .getConfiguration()
46: .getPrefixMapper()
47: .setPrefix(
48: "http://jakarta.apache.org/commons/betwixt/PersonWithNamespaceExample",
49: "pn");
50: writer.write(bean);
51:
52: String xml = out.getBuffer().toString();
53:
54: String expected = "<?xml version='1.0'?>"
55: + "<pn:person "
56: + "xmlns:pn='http://jakarta.apache.org/commons/betwixt/PersonWithNamespaceExample' "
57: + "pn:middle='Burrell'>"
58: + "<forename>Robert</forename>"
59: + "<pn:surname>Donkin</pn:surname></pn:person>";
60:
61: xmlAssertIsomorphicContent(parseString(xml),
62: parseString(expected));
63: }
64: }
|