01: /*
02: (c) Copyright 2006, 2007, 2008 Hewlett-Packard Development Company, LP
03: All rights reserved - see end of file.
04: $Id: TestMode.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.Mode;
10: import com.hp.hpl.jena.rdf.model.Resource;
11:
12: public class TestMode extends AssemblerTestBase {
13: public TestMode(String name) {
14: super (name);
15: }
16:
17: public void testConstantsExist() {
18: Mode a = Mode.CREATE, b = Mode.DEFAULT;
19: Mode c = Mode.REUSE, d = Mode.ANY;
20: assertDiffer(Mode.CREATE, Mode.DEFAULT);
21: assertDiffer(Mode.CREATE, Mode.REUSE);
22: assertDiffer(Mode.CREATE, Mode.ANY);
23: assertDiffer(Mode.DEFAULT, Mode.REUSE);
24: assertDiffer(Mode.DEFAULT, Mode.ANY);
25: assertDiffer(Mode.REUSE, Mode.ANY);
26: }
27:
28: static final String someName = "aName";
29: static final Resource someRoot = resource("aRoot");
30:
31: public void testCreate() {
32: assertEquals(true, Mode.CREATE.permitCreateNew(someRoot,
33: someName));
34: assertEquals(false, Mode.CREATE.permitUseExisting(someRoot,
35: someName));
36: }
37:
38: public void testReuse() {
39: assertEquals(false, Mode.REUSE.permitCreateNew(someRoot,
40: someName));
41: assertEquals(true, Mode.REUSE.permitUseExisting(someRoot,
42: someName));
43: }
44:
45: public void testAny() {
46: assertEquals(true, Mode.ANY.permitCreateNew(someRoot, someName));
47: assertEquals(true, Mode.ANY.permitUseExisting(someRoot,
48: someName));
49: }
50:
51: public void testDefault() {
52: assertEquals(false, Mode.DEFAULT.permitCreateNew(someRoot,
53: someName));
54: assertEquals(true, Mode.DEFAULT.permitUseExisting(someRoot,
55: someName));
56: }
57: }
58:
59: /*
60: * (c) Copyright 2006, 2007, 2008 Hewlett-Packard Development Company, LP
61: * All rights reserved.
62: *
63: * Redistribution and use in source and binary forms, with or without
64: * modification, are permitted provided that the following conditions
65: * are met:
66: * 1. Redistributions of source code must retain the above copyright
67: * notice, this list of conditions and the following disclaimer.
68: * 2. Redistributions in binary form must reproduce the above copyright
69: * notice, this list of conditions and the following disclaimer in the
70: * documentation and/or other materials provided with the distribution.
71: * 3. The name of the author may not be used to endorse or promote products
72: * derived from this software without specific prior written permission.
73: *
74: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
75: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
76: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
77: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
78: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
79: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
80: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
81: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
82: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
83: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
84: */
|