001: /*
002: (c) Copyright 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003: All rights reserved - see end of file.
004: $Id: TestFileManagerAssembler.java,v 1.6 2008/01/02 12:05:56 andy_seaborne Exp $
005: */
006:
007: package com.hp.hpl.jena.assembler.test;
008:
009: import java.util.*;
010:
011: import com.hp.hpl.jena.assembler.*;
012: import com.hp.hpl.jena.assembler.assemblers.FileManagerAssembler;
013: import com.hp.hpl.jena.rdf.model.Resource;
014: import com.hp.hpl.jena.util.*;
015:
016: public class TestFileManagerAssembler extends AssemblerTestBase {
017: public TestFileManagerAssembler(String name) {
018: super (name);
019: }
020:
021: protected Class getAssemblerClass() {
022: return FileManagerAssembler.class;
023: }
024:
025: public void testFileModelAssemblerType() {
026: testDemandsMinimalType(new FileManagerAssembler(),
027: JA.FileManager);
028: }
029:
030: public void testFileManagerVocabulary() {
031: assertSubclassOf(JA.FileManager, JA.Object);
032: assertDomain(JA.HasFileManager, JA.fileManager);
033: assertDomain(JA.FileManager, JA.locationMapper);
034: assertRange(JA.LocationMapper, JA.locationMapper);
035: }
036:
037: public void testCreatesFileManager() {
038: Resource root = resourceInModel("r rdf:type ja:FileManager");
039: Assembler a = new FileManagerAssembler();
040: Object x = a.open(root);
041: assertInstanceOf(FileManager.class, x);
042: }
043:
044: public void testCreatesFileManagerWithLocationMapper() {
045: Resource root = resourceInModel("f rdf:type ja:FileManager; f ja:locationMapper r");
046: LocationMapper mapper = new LocationMapper();
047: Assembler mock = new NamedObjectAssembler(resource("r"), mapper);
048: Assembler a = new FileManagerAssembler();
049: Object x = a.open(mock, root);
050: assertInstanceOf(FileManager.class, x);
051: assertSame(mapper, ((FileManager) x).getLocationMapper());
052: }
053:
054: /**
055: Can't just test for equality of locators list, since locators don't support
056: equality. Weak hack: check that the sizes are the same. TODO improve.
057: */
058: public void testCreatesFileManagerWIthHandlers() {
059: Resource root = resourceInModel("f rdf:type ja:FileManager");
060: Assembler a = new FileManagerAssembler();
061: FileManager f = (FileManager) a.open(null, root);
062: List wanted = IteratorCollection
063: .iteratorToList(standardLocators());
064: List obtained = IteratorCollection.iteratorToList(f.locators());
065: assertEquals(wanted.size(), obtained.size());
066: assertEquals(wanted, obtained);
067: }
068:
069: private Iterator standardLocators() {
070: FileManager fm = new FileManager();
071: FileManager.setStdLocators(fm);
072: return fm.locators();
073: }
074: }
075:
076: /*
077: * (c) Copyright 2006, 2007, 2008 Hewlett-Packard Development Company, LP
078: * All rights reserved.
079: *
080: * Redistribution and use in source and binary forms, with or without
081: * modification, are permitted provided that the following conditions
082: * are met:
083: * 1. Redistributions of source code must retain the above copyright
084: * notice, this list of conditions and the following disclaimer.
085: * 2. Redistributions in binary form must reproduce the above copyright
086: * notice, this list of conditions and the following disclaimer in the
087: * documentation and/or other materials provided with the distribution.
088: * 3. The name of the author may not be used to endorse or promote products
089: * derived from this software without specific prior written permission.
090: *
091: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
092: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
093: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
094: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
095: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
096: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
097: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
098: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
099: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
100: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
101: */
|