1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.betwixt.strategy;
19
20 import org.apache.commons.betwixt.AbstractTestCase;
21
22 /***
23 * @author <a href='http://jakarta.apache.org/'>Apache Commons Team</a>
24 * @version $Revision: 1.2 $
25 */
26 public class TestNamespaces extends AbstractTestCase {
27
28 public TestNamespaces(String name) {
29 super(name);
30 }
31
32 public void testNamespacePrefixMapper() {
33 NamespacePrefixMapper mapper = new NamespacePrefixMapper();
34 mapper.setPrefix("http://www.w3.org/2001/XMLSchema", "xsd");
35 assertEquals("Expected prefix set earlier", "xsd", mapper.getPrefix("http://www.w3.org/2001/XMLSchema"));
36 }
37
38 public void testNamespacePrefixMapperPrefixGeneration() {
39 NamespacePrefixMapper mapper = new NamespacePrefixMapper();
40 mapper.setPrefix("http://www.w3.org/2001/XMLSchema", "xsd");
41 assertNotNull("Expected prefix assigned not to be null", mapper.getPrefix("http://commons.apache.org/Betwixt"));
42 }
43
44 public void testNamespacePrefixMapperMatchingPrefix() {
45 NamespacePrefixMapper mapper = new NamespacePrefixMapper();
46 mapper.setPrefix("http://www.w3.org/2001/XMLSchema", "bt1");
47 String prefix = mapper.getPrefix("http://commons.apache.org/Betwixt");
48 assertFalse("Generated should not clash", prefix.equals(mapper.getPrefix("http://www.w3.org/2001/XMLSchema")));
49 }
50 }