001: /*
002: * $Id: TestBaseTableOrganizationContext.java,v 1.2 2005/10/13 02:25:32 ahimanikya Exp $
003: * =======================================================================
004: * Copyright (c) 2004 Axion Development Team. All rights reserved.
005: *
006: * Redistribution and use in source and binary forms, with or without
007: * modification, are permitted provided that the following conditions
008: * are met:
009: *
010: * 1. Redistributions of source code must retain the above
011: * copyright notice, this list of conditions and the following
012: * disclaimer.
013: *
014: * 2. Redistributions in binary form must reproduce the above copyright
015: * notice, this list of conditions and the following disclaimer in
016: * the documentation and/or other materials provided with the
017: * distribution.
018: *
019: * 3. The names "Tigris", "Axion", nor the names of its contributors may
020: * not be used to endorse or promote products derived from this
021: * software without specific prior written permission.
022: *
023: * 4. Products derived from this software may not be called "Axion", nor
024: * may "Tigris" or "Axion" appear in their names without specific prior
025: * written permission.
026: *
027: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
028: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
029: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
030: * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
031: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
032: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
033: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
034: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
035: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
036: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
037: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
038: * =======================================================================
039: */
040:
041: package org.axiondb.engine.tables;
042:
043: import java.util.HashSet;
044: import java.util.Properties;
045: import java.util.Set;
046:
047: import junit.framework.Test;
048: import junit.framework.TestCase;
049: import junit.framework.TestSuite;
050:
051: import org.axiondb.AxionException;
052:
053: /**
054: * @version $Revision: 1.2 $ $Date: 2005/10/13 02:25:32 $
055: * @author Rodney Waldhoff
056: */
057: public class TestBaseTableOrganizationContext extends TestCase {
058:
059: //------------------------------------------------------------ Conventional
060:
061: public TestBaseTableOrganizationContext(String testName) {
062: super (testName);
063: }
064:
065: public static Test suite() {
066: TestSuite suite = new TestSuite(
067: TestBaseTableOrganizationContext.class);
068: return suite;
069: }
070:
071: public void setUp() throws Exception {
072: _table = new BaseTableOrganizationContext() {
073:
074: private Set _propertyKeys = new HashSet();
075: {
076: _propertyKeys.add("propertyKeyRequired1");
077: _propertyKeys.add("propertyKeyRequired2");
078: _propertyKeys.add("propertyKeyOptional");
079: }
080: private Set _requiredPropertyKeys = new HashSet();
081: {
082: _requiredPropertyKeys.add("propertyKeyRequired1");
083: _requiredPropertyKeys.add("propertyKeyRequired2");
084: }
085:
086: public Properties getTableProperties() {
087: return null;
088: }
089:
090: public Set getPropertyKeys() {
091: return _propertyKeys;
092: }
093:
094: public Set getRequiredPropertyKeys() {
095: return _requiredPropertyKeys;
096: }
097:
098: public void updateProperties() {
099:
100: }
101:
102: public void readOrSetDefaultProperties(Properties props)
103: throws AxionException {
104:
105: }
106:
107: };
108: }
109:
110: private BaseTableOrganizationContext _table = null;
111:
112: // tests
113: //-------------------------------------------------------------------------
114:
115: public void testInvalidPropertyKey() {
116: Properties props = new Properties();
117: props.put("invalidKey", "value");
118: props.put("propertyKeyRequired1", "value");
119: props.put("propertyKeyRequired2", "value");
120: try {
121: _table.assertValidPropertyKeys(props);
122: fail("Expected AxionException");
123: } catch (AxionException e) {
124: // expected
125: }
126: }
127:
128: public void testMissingPropertyKey() {
129: Properties props = new Properties();
130: props.put("propertyKeyOptional", "value");
131: try {
132: _table.assertValidPropertyKeys(props);
133: fail("Expected AxionException");
134: } catch (AxionException e) {
135: // expected
136: }
137: }
138:
139: public void testMissingPropertyKeys() {
140: Properties props = new Properties();
141: try {
142: props.put("propertyKeyRequired1", "value");
143: _table.assertValidPropertyKeys(props);
144: fail("Expected AxionException");
145: } catch (AxionException e) {
146: // expected
147: }
148: }
149:
150: public void testValidPropertyKeys() throws AxionException {
151: Properties props = new Properties();
152: props.put("propertyKeyRequired1", "value");
153: props.put("propertyKeyRequired2", "value");
154: _table.assertValidPropertyKeys(props);
155: props.put("propertyKeyOptional", "value");
156: _table.assertValidPropertyKeys(props);
157: }
158: }
|