Apache didn't like the attachment.
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License,
Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.jdo.tck.api.persistencemanager;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import javax.jdo.JDOUserException;
import javax.jdo.PersistenceManager;
import javax.jdo.Constants;
import org.apache.jdo.tck.JDO_Test;
import org.apache.jdo.tck.util.BatchTestRunner;
/**
*<B>Title:</B> Test GetProperties
*<BR>
*<B>Keywords:</B> getProperties getSupportedProperties setProperty
*<BR>
*<B>Assertion IDs:</B>
*<BR>
*<B>Assertion Description: </B>
*/
public class GetProperties extends JDO_Test implements Constants {
/** */
private static final String ASSERTION_FAILED_12_19_1 =
"Assertion 12-9-1 setProperty() Set the property name to the
specified value. " +
"If a vendor-specific property is not recognized, it is
silently ignored. ";
private static final String ASSERTION_FAILED_12_19_2 =
"Assertion 12-9-2 setProperty() If the value for the property
is not supported by the implementation, " +
"a JDOUserException is thrown. ";
private static final String ASSERTION_FAILED_12_19_3 =
"Assertion 12-9-3 getProperties() Return a map of String,
Object with the properties and values currently in effect. ";
private static final String ASSERTION_FAILED_12_19_4 =
"Assertion 12-9-4 Changing the values in the map will not
affect the properties in the PersistenceManager. ";
private static final String ASSERTION_FAILED_12_19_5 =
"Assertion 12-9-5 getSupportedProperties() Return the set of
properties supported by this PersistenceManager. ";
/**
* The <code>main</code> is called when the class
* is directly executed from the command line.
* @param args The arguments passed to the program.
*/
public static void main(String[] args) {
BatchTestRunner.run(GetProperties.class);
}
private Collection<String> supportedOptions;
private Set<String> supportedProperties;
private static Map<String, TestProperty> testProperties = new
HashMap<String, TestProperty>();
private TestProperty testCopyOnAttach = new TestProperty() {
public void test(PersistenceManager pm, Set<String>
supportedProperties) {
System.out.println("GetProperties testing CopyOnAttach.");
pm.setProperty(PROPERTY_COPY_ON_ATTACH, true);
errorIfNotEqual(ASSERTION_FAILED_12_19_1 +
"pm.setProperty(PROPERTY_COPY_ON_ATTACH) failed
to set CopyOnAttach",
true, pm.getCopyOnAttach());
errorIfNotEqual(ASSERTION_FAILED_12_19_1 +
"pm.getProperties failed to return proper value
for CopyOnAttach",
true,
pm.getProperties().get(PROPERTY_COPY_ON_ATTACH));
}
};
private TestProperty testDetachAllOnCommit = new TestProperty() {
public void test(PersistenceManager pm, Set<String>
supportedProperties) {
System.out.println("GetProperties testing
DetachAllOnCommit.");
pm.setProperty(PROPERTY_DETACH_ALL_ON_COMMIT, true);
errorIfNotEqual(ASSERTION_FAILED_12_19_1 +
"pm.setProperty(PROPERTY_DETACH_ALL_ON_COMMIT)
failed to set DetachAllOnCommit",
true, pm.getDetachAllOnCommit());
errorIfNotEqual(ASSERTION_FAILED_12_19_1 +
"pm.getProperties failed to return proper value
for DetachAllOnCommit",
true,
pm.getProperties().get(PROPERTY_DETACH_ALL_ON_COMMIT));
}
};
private TestProperty testIgnoreCache = new TestProperty() {
public void test(PersistenceManager pm, Set<String>
supportedProperties) {
System.out.println("GetProperties testing IgnoreCache.");
pm.setProperty(PROPERTY_IGNORE_CACHE, true);
errorIfNotEqual(ASSERTION_FAILED_12_19_1 +
"pm.setProperty(PROPERTY_IGNORE_CACHE) failed to
set IgnoreCache",
true, pm.getIgnoreCache());
errorIfNotEqual(ASSERTION_FAILED_12_19_1 +
"pm.getProperties failed to return proper value
for IgnoreCache",
true,
pm.getProperties().get(PROPERTY_IGNORE_CACHE));
}
};
private TestProperty testMultithreaded = new TestProperty() {
public void test(PersistenceManager pm, Set<String>
supportedProperties) {
System.out.println("GetProperties testing Multithreaded.");
boolean supported =
supportedProperties.contains(PROPERTY_MULTITHREADED);
try {
pm.setProperty(PROPERTY_MULTITHREADED, true);
} catch (JDOUserException ex){
System.out.println("Caught JDOUserException from
setProperty(PROPERTY_MULTITHREADED");
if (supported) {
fail(ASSERTION_FAILED_12_19_1);
} else {
// good catch of unsupported property
return;
}
}
errorIfNotEqual(ASSERTION_FAILED_12_19_1 +
"pm.getMultithreaded failed to return proper
value for Multithreaded",
true, pm.getMultithreaded());
errorIfNotEqual(ASSERTION_FAILED_12_19_1 +
"pm.getProperties failed to return proper value
for Multithreaded",
true,
pm.getProperties().get(PROPERTY_MULTITHREADED));
}
};
/**
* For each option supported by the PMF, test that
* the corresponding pm property is supported.
*/
public void testGetSupportedProperties() {
testProperties.put(PROPERTY_COPY_ON_ATTACH, testCopyOnAttach);
testProperties.put(PROPERTY_DETACH_ALL_ON_COMMIT,
testDetachAllOnCommit);
testProperties.put(PROPERTY_IGNORE_CACHE, testIgnoreCache);
testProperties.put(PROPERTY_MULTITHREADED, testMultithreaded);
getPM();
supportedOptions = pmf.supportedOptions();
supportedProperties = pm.getSupportedProperties();
// test required properties
testCopyOnAttach.test(pm, supportedProperties);
testDetachAllOnCommit.test(pm, supportedProperties);
testIgnoreCache.test(pm, supportedProperties);
testMultithreaded.test(pm, supportedProperties);
for (String supportedProperty: supportedProperties) {
System.out.println("supportedProperties returned: " +
supportedProperty);
}
Set<Map.Entry<String, Object>> properties =
pm.getProperties().entrySet();
for (Map.Entry<String, Object> entry: properties) {
System.out.println("getProperties returned: " +
entry.getKey() + ":" + entry.getValue());
}
for (String supportedOption: supportedOptions) {
System.out.println("GetProperties examining: " +
supportedOption);
// for each supported option, test the corresponding
supported property
TestProperty testProperty =
testProperties.get(supportedOption);
if (testProperty != null) {
System.out.println("GetProperties testing: " +
supportedOption);
testProperty.test(pm, supportedProperties);
} else {
System.out.println("GetProperties skipping: " +
supportedOption);
}
}
failOnError();
}
private interface TestProperty {
public void test(PersistenceManager pm, Set<String>
supportedProperties);
}
}
On Feb 15, 2013, at 9:30 AM, Craig L Russell wrote:
Here's the test case in process.
Craig L Russell
Architect, Oracle
http://db.apache.org/jdo
408 276-5638 mailto:[email protected]
P.S. A good JDO? O, Gasp!
Craig L Russell
Architect, Oracle
http://db.apache.org/jdo
408 276-5638 mailto:[email protected]
P.S. A good JDO? O, Gasp!