01: /*
02: (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
03: All rights reserved - see end of file.
04: $Id: TestPrefixMappingAssembler.java,v 1.5 2008/01/02 12:05:55 andy_seaborne Exp $
05: */
06:
07: package com.hp.hpl.jena.assembler.test;
08:
09: import com.hp.hpl.jena.assembler.*;
10: import com.hp.hpl.jena.assembler.assemblers.PrefixMappingAssembler;
11: import com.hp.hpl.jena.rdf.model.Resource;
12: import com.hp.hpl.jena.shared.PrefixMapping;
13:
14: public class TestPrefixMappingAssembler extends AssemblerTestBase {
15: public TestPrefixMappingAssembler(String name) {
16: super (name);
17: }
18:
19: protected Class getAssemblerClass() {
20: return PrefixMappingAssembler.class;
21: }
22:
23: public void testPrefixMappingAssemblerType() {
24: testDemandsMinimalType(new PrefixMappingAssembler(),
25: JA.PrefixMapping);
26: }
27:
28: public void testConstructEmptyPrefixMapping() {
29: Assembler a = new PrefixMappingAssembler();
30: Resource root = resourceInModel("pm rdf:type ja:PrefixMapping");
31: Object pm = a.open(root);
32: assertInstanceOf(PrefixMapping.class, pm);
33: }
34:
35: public void testSimplePrefixMapping() {
36: PrefixMapping wanted = PrefixMapping.Factory.create()
37: .setNsPrefix("pre", "some:prefix/");
38: Assembler a = new PrefixMappingAssembler();
39: Resource root = resourceInModel("pm rdf:type ja:PrefixMapping; pm ja:prefix 'pre'; pm ja:namespace 'some:prefix/'");
40: PrefixMapping pm = (PrefixMapping) a.open(root);
41: assertSamePrefixMapping(wanted, pm);
42: }
43:
44: public void testIncludesSingleMapping() {
45: PrefixMapping wanted = PrefixMapping.Factory.create()
46: .setNsPrefix("pre", "some:prefix/");
47: Assembler a = new PrefixMappingAssembler();
48: Resource root = resourceInModel("root rdf:type ja:PrefixMapping; root ja:includes pm"
49: + "; pm rdf:type ja:PrefixMapping; pm ja:prefix 'pre'; pm ja:namespace 'some:prefix/'");
50: PrefixMapping pm = (PrefixMapping) a.open(root);
51: assertSamePrefixMapping(wanted, pm);
52: }
53:
54: public void testIncludesMultipleMappings() {
55: PrefixMapping wanted = PrefixMapping.Factory.create()
56: .setNsPrefix("p1", "some:prefix/").setNsPrefix("p2",
57: "other:prefix/").setNsPrefix("p3",
58: "simple:prefix#");
59: Assembler a = new PrefixMappingAssembler();
60: Resource root = resourceInModel("root rdf:type ja:PrefixMapping"
61: + "; root ja:includes pm1; pm1 rdf:type ja:PrefixMapping; pm1 ja:prefix 'p1'; pm1 ja:namespace 'some:prefix/'"
62: + "; root ja:includes pm2; pm2 rdf:type ja:PrefixMapping; pm2 ja:prefix 'p2'; pm2 ja:namespace 'other:prefix/'"
63: + "; root ja:prefix 'p3'; root ja:namespace 'simple:prefix#'");
64: PrefixMapping pm = (PrefixMapping) a.open(root);
65: assertSamePrefixMapping(wanted, pm);
66: }
67: }
68:
69: /*
70: * (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
71: * All rights reserved.
72: *
73: * Redistribution and use in source and binary forms, with or without
74: * modification, are permitted provided that the following conditions
75: * are met:
76: * 1. Redistributions of source code must retain the above copyright
77: * notice, this list of conditions and the following disclaimer.
78: * 2. Redistributions in binary form must reproduce the above copyright
79: * notice, this list of conditions and the following disclaimer in the
80: * documentation and/or other materials provided with the distribution.
81: * 3. The name of the author may not be used to endorse or promote products
82: * derived from this software without specific prior written permission.
83: *
84: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
85: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
86: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
87: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
88: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
89: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
90: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
91: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
92: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
93: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
94: */
|