Author: mcaisse
Date: Tue Oct 17 20:58:02 2006
New Revision: 465134
URL: http://svn.apache.org/viewvc?view=rev&rev=465134
Log:
JDO-432 complete
Added:
db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/
db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/DeletePersistentNullArgs.java
db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/DetachCopyNullArgs.java
db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/EvictNullArgs.java
db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakeNontransactionalNullArgs.java
db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakePersistentNullArgs.java
db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakeTransactionalNullArgs.java
db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakeTransientNullArgs.java
db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/PersistenceManagerNullsTest.java
db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/RefreshNullArgs.java
db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/RetrieveNullArgs.java
db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/RetrieveWithFetchPlanNullArgs.java
Modified:
db/jdo/trunk/tck20/src/conf/pm.conf
Modified: db/jdo/trunk/tck20/src/conf/pm.conf
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/conf/pm.conf?view=diff&rev=465134&r1=465133&r2=465134
==============================================================================
--- db/jdo/trunk/tck20/src/conf/pm.conf (original)
+++ db/jdo/trunk/tck20/src/conf/pm.conf Tue Oct 17 20:58:02 2006
@@ -98,4 +98,15 @@
org.apache.jdo.tck.api.persistencemanager.lifecycle.MakeTransientFailsWithDirtyInstance \
org.apache.jdo.tck.api.persistencemanager.lifecycle.MakeTransientFieldsPreservedUnchanged \
org.apache.jdo.tck.api.persistencemanager.lifecycle.MakeTransientHasNoEffectOnTransientInstances \
-org.apache.jdo.tck.api.persistencemanager.lifecycle.MakeTransientNotSubjectToRollback
+org.apache.jdo.tck.api.persistencemanager.lifecycle.MakeTransientNotSubjectToRollback \
+org.apache.jdo.tck.api.persistencemanager.nullargs.MakePersistentNullArgs \
+org.apache.jdo.tck.api.persistencemanager.nullargs.DeletePersistentNullArgs \
+org.apache.jdo.tck.api.persistencemanager.nullargs.DetachCopyNullArgs \
+org.apache.jdo.tck.api.persistencemanager.nullargs.MakeTransientNullArgs \
+org.apache.jdo.tck.api.persistencemanager.nullargs.EvictNullArgs \
+org.apache.jdo.tck.api.persistencemanager.nullargs.MakeNontransactionalNullArgs \
+org.apache.jdo.tck.api.persistencemanager.nullargs.MakeTransactionalNullArgs \
+org.apache.jdo.tck.api.persistencemanager.nullargs.RefreshNullArgs \
+org.apache.jdo.tck.api.persistencemanager.nullargs.RetrieveNullArgs \
+org.apache.jdo.tck.api.persistencemanager.nullargs.RetrieveWithFetchPlanNullArgs
+
Added: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/DeletePersistentNullArgs.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/DeletePersistentNullArgs.java?view=auto&rev=465134
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/DeletePersistentNullArgs.java (added)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/DeletePersistentNullArgs.java Tue Oct 17 20:58:02 2006
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.nullargs;
+
+import java.util.Collection;
+
+import javax.jdo.JDOUserException;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> deletePersistent with Null Arguments
+ *<BR>
+ *<B>Keywords:</B>
+ *<BR>
+ *<B>Assertion IDs:</B> A12.6.3, A12.6.4, A12.6.5
+ *<BR>
+ *<B>Assertion Description: </B>
+A12.6-3 [Null arguments to APIs that take an Object parameter cause the API to have no effect.] A12.6-4 [Null arguments to APIs that take Object[] or Collection will cause the API to throw NullPointerException.] A12.6-5 [Non-null Object[] or Collection arguments that contain null elements will have the documented behavior for non-null elements, and the null elements will be ignored.]
+ */
+
+public class DeletePersistentNullArgs extends PersistenceManagerNullsTest {
+
+ /**
+ * 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(DeletePersistentNullArgs.class);
+ }
+
+ static MethodUnderTest deletePersistent =
+ new MethodUnderTestDeletePersistent();
+ static class MethodUnderTestDeletePersistent extends MethodUnderTest {
+ public void pmApi(PersistenceManager pm, Object pc) {
+ pm.deletePersistent(pc);
+ }
+ public void pmApi(PersistenceManager pm, Collection pcs) {
+ pm.deletePersistentAll(pcs);
+ }
+ public void pmApi(PersistenceManager pm, Object[] pcs) {
+ pm.deletePersistentAll(pcs);
+ }
+ };
+
+ /**
+ * Test that deletePersistent() with null valued argument does nothing.
+ */
+ public void testDeletePersistentNullObject() {
+ executeNullObjectParameter(deletePersistent, "deletePersistent(null)");
+ }
+
+ /**
+ * Test that deletePersistentAll() with null valued Collection argument
+ * throws NullPointerException.
+ */
+ public void testDeletePersistentNullCollection() {
+ executeNullCollectionParameter(deletePersistent,
+ "deletePersistentAll((Collection)null)");
+ }
+
+ /**
+ * Test that deletePersistentAll() with null valued array argument
+ * throws NullPointerException.
+ */
+ public void testDeletePersistentNullArray() {
+ executeNullArrayParameter(deletePersistent,
+ "deletePersistentAll((Object[])null)");
+ }
+
+ /**
+ * Test that deletePersistentAll() with a null element of a
+ * Collection argument throws NullPointerException.
+ */
+ public void testDeletePersistentCollectionNullElement() {
+ executeCollectionNullElement(collNullElem, deletePersistent,
+ "deletePersistentAll(Collection)");
+ }
+
+ /**
+ * Test that deletePersistentAll() with a null element of a
+ * array argument throws NullPointerException.
+ */
+ public void testDeletePersistentArrayNullElement() {
+ executeArrayNullElement(arrayNullElem, deletePersistent,
+ "deletePersistentAll(Object[])");
+ }
+
+}
Added: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/DetachCopyNullArgs.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/DetachCopyNullArgs.java?view=auto&rev=465134
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/DetachCopyNullArgs.java (added)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/DetachCopyNullArgs.java Tue Oct 17 20:58:02 2006
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.nullargs;
+
+import java.util.Collection;
+
+import javax.jdo.JDOUserException;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> detachCopy with Null Arguments
+ *<BR>
+ *<B>Keywords:</B>
+ *<BR>
+ *<B>Assertion IDs:</B> A12.6.3, A12.6.4, A12.6.5
+ *<BR>
+ *<B>Assertion Description: </B>
+A12.6-3 [Null arguments to APIs that take an Object parameter cause the API to have no effect.] A12.6-4 [Null arguments to APIs that take Object[] or Collection will cause the API to throw NullPointerException.] A12.6-5 [Non-null Object[] or Collection arguments that contain null elements will have the documented behavior for non-null elements, and the null elements will be ignored.]
+ */
+
+public class DetachCopyNullArgs extends PersistenceManagerNullsTest {
+
+ /**
+ * 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(DetachCopyNullArgs.class);
+ }
+
+ static MethodUnderTest detachCopy = new MethodUnderTestDetachCopy();
+ static class MethodUnderTestDetachCopy extends MethodUnderTest {
+ public Object pmApiReturn(PersistenceManager pm, Object pc) {
+ return pm.detachCopy(pc);
+ }
+ public Collection pmApiReturn(PersistenceManager pm, Collection pcs) {
+ return pm.detachCopyAll(pcs);
+ }
+ public Object[] pmApiReturn(PersistenceManager pm, Object[] pcs) {
+ return pm.detachCopyAll(pcs);
+ }
+ };
+
+ /**
+ * Test that detachCopy() with null valued argument does nothing.
+ */
+ public void testDetachCopyNullObject() {
+ executeNullObjectParameterReturn(detachCopy, "detachCopy(null)");
+ }
+
+ /**
+ * Test that detachCopyAll() with null valued Collection argument
+ * throws NullPointerException.
+ */
+ public void testDetachCopyNullCollection() {
+ executeNullCollectionParameterReturn(detachCopy,
+ "detachCopyAll((Collection)null)");
+ }
+
+ /**
+ * Test that detachCopyAll() with null valued array argument
+ * throws NullPointerException.
+ */
+ public void testDetachCopyNullArray() {
+ executeNullArrayParameterReturn(detachCopy,
+ "detachCopyAll((Array)null)");
+ }
+
+ /**
+ * Test that detachCopyAll() with a null element of a
+ * Collection argument throws NullPointerException.
+ */
+ public void testDetachCopyCollectionNullElement() {
+ executeCollectionNullElementReturn(collNullElem, detachCopy,
+ "detachCopyAll(Collection)");
+ }
+
+ /**
+ * Test that detachCopyAll() with a null element of a
+ * array argument throws NullPointerException.
+ */
+ public void testDetachCopyArrayNullElement() {
+ executeArrayNullElementReturn(arrayNullElem, detachCopy,
+ "detachCopyAll(Array)");
+ }
+
+}
Added: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/EvictNullArgs.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/EvictNullArgs.java?view=auto&rev=465134
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/EvictNullArgs.java (added)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/EvictNullArgs.java Tue Oct 17 20:58:02 2006
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.nullargs;
+
+import java.util.Collection;
+
+import javax.jdo.JDOUserException;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> evict with Null Arguments
+ *<BR>
+ *<B>Keywords:</B>
+ *<BR>
+ *<B>Assertion IDs:</B> A12.6.3, A12.6.4, A12.6.5
+ *<BR>
+ *<B>Assertion Description: </B>
+A12.6-3 [Null arguments to APIs that take an Object parameter cause the API to have no effect.] A12.6-4 [Null arguments to APIs that take Object[] or Collection will cause the API to throw NullPointerException.] A12.6-5 [Non-null Object[] or Collection arguments that contain null elements will have the documented behavior for non-null elements, and the null elements will be ignored.]
+ */
+
+public class EvictNullArgs extends PersistenceManagerNullsTest {
+
+ /**
+ * 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(EvictNullArgs.class);
+ }
+
+ static MethodUnderTest evict =
+ new MethodUnderTestEvict();
+ static class MethodUnderTestEvict extends MethodUnderTest {
+ public void pmApi(PersistenceManager pm, Object pc) {
+ pm.evict(pc);
+ }
+ public void pmApi(PersistenceManager pm, Collection pcs) {
+ pm.evictAll(pcs);
+ }
+ public void pmApi(PersistenceManager pm, Object[] pcs) {
+ pm.evictAll(pcs);
+ }
+ };
+
+ /**
+ * Test that evict() with null valued argument does nothing.
+ */
+ public void testEvictNullObject() {
+ executeNullObjectParameter(evict, "evict(null)");
+ }
+
+ /**
+ * Test that evictAll() with null valued Collection argument
+ * throws NullPointerException.
+ */
+ public void testEvictNullCollection() {
+ executeNullCollectionParameter(evict,
+ "evictAll((Collection)null)");
+ }
+
+ /**
+ * Test that evictAll() with null valued array argument
+ * throws NullPointerException.
+ */
+ public void testEvictNullArray() {
+ executeNullArrayParameter(evict,
+ "evictAll((Object[])null)");
+ }
+
+ /**
+ * Test that evictAll() with a null element of a
+ * Collection argument throws NullPointerException.
+ */
+ public void testEvictCollectionNullElement() {
+ executeCollectionNullElement(collNullElem, evict,
+ "evictAll(Collection)");
+ }
+
+ /**
+ * Test that evictAll() with a null element of a
+ * array argument throws NullPointerException.
+ */
+ public void testEvictArrayNullElement() {
+ executeArrayNullElement(arrayNullElem, evict,
+ "evictAll(Object[])");
+ }
+
+}
Added: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakeNontransactionalNullArgs.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakeNontransactionalNullArgs.java?view=auto&rev=465134
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakeNontransactionalNullArgs.java (added)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakeNontransactionalNullArgs.java Tue Oct 17 20:58:02 2006
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.nullargs;
+
+import java.util.Collection;
+
+import javax.jdo.JDOUserException;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> makeNontransactional with Null Arguments
+ *<BR>
+ *<B>Keywords:</B>
+ *<BR>
+ *<B>Assertion IDs:</B> A12.6.3, A12.6.4, A12.6.5
+ *<BR>
+ *<B>Assertion Description: </B>
+A12.6-3 [Null arguments to APIs that take an Object parameter cause the API to have no effect.] A12.6-4 [Null arguments to APIs that take Object[] or Collection will cause the API to throw NullPointerException.] A12.6-5 [Non-null Object[] or Collection arguments that contain null elements will have the documented behavior for non-null elements, and the null elements will be ignored.]
+ */
+
+public class MakeNontransactionalNullArgs extends PersistenceManagerNullsTest {
+
+ /**
+ * 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(MakeNontransactionalNullArgs.class);
+ }
+
+ static MethodUnderTest makeNontransactional =
+ new MethodUnderTestMakeNontransactional();
+ static class MethodUnderTestMakeNontransactional extends MethodUnderTest {
+ public void pmApi(PersistenceManager pm, Object pc) {
+ pm.makeNontransactional(pc);
+ }
+ public void pmApi(PersistenceManager pm, Collection pcs) {
+ pm.makeNontransactionalAll(pcs);
+ }
+ public void pmApi(PersistenceManager pm, Object[] pcs) {
+ pm.makeNontransactionalAll(pcs);
+ }
+ };
+
+ /**
+ * Test that makeNontransactional() with null valued argument does nothing.
+ */
+ public void testMakeNontransactionalNullObject() {
+ executeNullObjectParameter(makeNontransactional, "makeNontransactional(null)");
+ }
+
+ /**
+ * Test that makeNontransactionalAll() with null valued Collection argument
+ * throws NullPointerException.
+ */
+ public void testMakeNontransactionalNullCollection() {
+ executeNullCollectionParameter(makeNontransactional,
+ "makeNontransactionalAll((Collection)null)");
+ }
+
+ /**
+ * Test that makeNontransactionalAll() with null valued array argument
+ * throws NullPointerException.
+ */
+ public void testMakeNontransactionalNullArray() {
+ executeNullArrayParameter(makeNontransactional,
+ "makeNontransactionalAll((Object[])null)");
+ }
+
+ /**
+ * Test that makeNontransactionalAll() with a null element of a
+ * Collection argument throws NullPointerException.
+ */
+ public void testMakeNontransactionalCollectionNullElement() {
+ executeCollectionNullElement(collNullElem, makeNontransactional,
+ "makeNontransactionalAll(Collection)");
+ }
+
+ /**
+ * Test that makeNontransactionalAll() with a null element of a
+ * array argument throws NullPointerException.
+ */
+ public void testMakeNontransactionalArrayNullElement() {
+ executeArrayNullElement(arrayNullElem, makeNontransactional,
+ "makeNontransactionalAll(Object[])");
+ }
+
+}
Added: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakePersistentNullArgs.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakePersistentNullArgs.java?view=auto&rev=465134
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakePersistentNullArgs.java (added)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakePersistentNullArgs.java Tue Oct 17 20:58:02 2006
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.nullargs;
+
+import java.util.Collection;
+
+import javax.jdo.JDOUserException;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> makePersistent with Null Arguments
+ *<BR>
+ *<B>Keywords:</B>
+ *<BR>
+ *<B>Assertion IDs:</B> A12.6.3, A12.6.4, A12.6.5
+ *<BR>
+ *<B>Assertion Description: </B>
+A12.6-3 [Null arguments to APIs that take an Object parameter cause the API to have no effect.] A12.6-4 [Null arguments to APIs that take Object[] or Collection will cause the API to throw NullPointerException.] A12.6-5 [Non-null Object[] or Collection arguments that contain null elements will have the documented behavior for non-null elements, and the null elements will be ignored.]
+ */
+
+public class MakePersistentNullArgs extends PersistenceManagerNullsTest {
+
+ /**
+ * 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(MakePersistentNullArgs.class);
+ }
+
+ static MethodUnderTest makePersistent = new MethodUnderTestMakePersistent();
+ static class MethodUnderTestMakePersistent extends MethodUnderTest {
+ public Object pmApiReturn(PersistenceManager pm, Object pc) {
+ return pm.makePersistent(pc);
+ }
+ public Collection pmApiReturn(PersistenceManager pm, Collection pcs) {
+ return pm.makePersistentAll(pcs);
+ }
+ public Object[] pmApiReturn(PersistenceManager pm, Object[] pcs) {
+ return pm.makePersistentAll(pcs);
+ }
+ };
+
+ /**
+ * Test that makePersistent() with null valued argument does nothing.
+ */
+ public void testMakePersistentNullObject() {
+ executeNullObjectParameterReturn(makePersistent, "makePersistent(null)");
+ }
+
+ /**
+ * Test that makePersistentAll() with null valued Collection argument
+ * throws NullPointerException.
+ */
+ public void testMakePersistentNullCollection() {
+ executeNullCollectionParameterReturn(makePersistent,
+ "makePersistentAll((Collection)null)");
+ }
+
+ /**
+ * Test that makePersistentAll() with null valued array argument
+ * throws NullPointerException.
+ */
+ public void testMakePersistentNullArray() {
+ executeNullArrayParameterReturn(makePersistent,
+ "makePersistentAll((Array)null)");
+ }
+
+ /**
+ * Test that makePersistentAll() with a null element of a
+ * Collection argument throws NullPointerException.
+ */
+ public void testMakePersistentCollectionNullElement() {
+ executeCollectionNullElementReturn(collNullElem, makePersistent,
+ "makePersistentAll(Collection)");
+ }
+
+ /**
+ * Test that makePersistentAll() with a null element of a
+ * array argument throws NullPointerException.
+ */
+ public void testMakePersistentArrayNullElement() {
+ executeArrayNullElementReturn(arrayNullElem, makePersistent,
+ "makePersistentAll(Array)");
+ }
+
+}
Added: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakeTransactionalNullArgs.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakeTransactionalNullArgs.java?view=auto&rev=465134
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakeTransactionalNullArgs.java (added)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakeTransactionalNullArgs.java Tue Oct 17 20:58:02 2006
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.nullargs;
+
+import java.util.Collection;
+
+import javax.jdo.JDOUserException;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> makeTransactional with Null Arguments
+ *<BR>
+ *<B>Keywords:</B>
+ *<BR>
+ *<B>Assertion IDs:</B> A12.6.3, A12.6.4, A12.6.5
+ *<BR>
+ *<B>Assertion Description: </B>
+A12.6-3 [Null arguments to APIs that take an Object parameter cause the API to have no effect.] A12.6-4 [Null arguments to APIs that take Object[] or Collection will cause the API to throw NullPointerException.] A12.6-5 [Non-null Object[] or Collection arguments that contain null elements will have the documented behavior for non-null elements, and the null elements will be ignored.]
+ */
+
+public class MakeTransactionalNullArgs extends PersistenceManagerNullsTest {
+
+ /**
+ * 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(MakeTransactionalNullArgs.class);
+ }
+
+ static MethodUnderTest makeTransactional =
+ new MethodUnderTestMakeTransactional();
+ static class MethodUnderTestMakeTransactional extends MethodUnderTest {
+ public void pmApi(PersistenceManager pm, Object pc) {
+ pm.makeTransactional(pc);
+ }
+ public void pmApi(PersistenceManager pm, Collection pcs) {
+ pm.makeTransactionalAll(pcs);
+ }
+ public void pmApi(PersistenceManager pm, Object[] pcs) {
+ pm.makeTransactionalAll(pcs);
+ }
+ };
+
+ /**
+ * Test that makeTransactional() with null valued argument does nothing.
+ */
+ public void testMakeTransactionalNullObject() {
+ executeNullObjectParameter(makeTransactional, "makeTransactional(null)");
+ }
+
+ /**
+ * Test that makeTransactionalAll() with null valued Collection argument
+ * throws NullPointerException.
+ */
+ public void testMakeTransactionalNullCollection() {
+ executeNullCollectionParameter(makeTransactional,
+ "makeTransactionalAll((Collection)null)");
+ }
+
+ /**
+ * Test that makeTransactionalAll() with null valued array argument
+ * throws NullPointerException.
+ */
+ public void testMakeTransactionalNullArray() {
+ executeNullArrayParameter(makeTransactional,
+ "makeTransactionalAll((Object[])null)");
+ }
+
+ /**
+ * Test that makeTransactionalAll() with a null element of a
+ * Collection argument throws NullPointerException.
+ */
+ public void testMakeTransactionalCollectionNullElement() {
+ executeCollectionNullElement(collNullElem, makeTransactional,
+ "makeTransactionalAll(Collection)");
+ }
+
+ /**
+ * Test that makeTransactionalAll() with a null element of a
+ * array argument throws NullPointerException.
+ */
+ public void testMakeTransactionalArrayNullElement() {
+ executeArrayNullElement(arrayNullElem, makeTransactional,
+ "makeTransactionalAll(Object[])");
+ }
+
+}
Added: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakeTransientNullArgs.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakeTransientNullArgs.java?view=auto&rev=465134
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakeTransientNullArgs.java (added)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakeTransientNullArgs.java Tue Oct 17 20:58:02 2006
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.nullargs;
+
+import java.util.Collection;
+
+import javax.jdo.JDOUserException;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> makeTransient with Null Arguments
+ *<BR>
+ *<B>Keywords:</B>
+ *<BR>
+ *<B>Assertion IDs:</B> A12.6.3, A12.6.4, A12.6.5
+ *<BR>
+ *<B>Assertion Description: </B>
+A12.6-3 [Null arguments to APIs that take an Object parameter cause the API to have no effect.] A12.6-4 [Null arguments to APIs that take Object[] or Collection will cause the API to throw NullPointerException.] A12.6-5 [Non-null Object[] or Collection arguments that contain null elements will have the documented behavior for non-null elements, and the null elements will be ignored.]
+ */
+
+public class MakeTransientNullArgs extends PersistenceManagerNullsTest {
+
+ /**
+ * 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(MakeTransientNullArgs.class);
+ }
+
+ static MethodUnderTest makeTransient =
+ new MethodUnderTestMakeTransient();
+ static class MethodUnderTestMakeTransient extends MethodUnderTest {
+ public void pmApi(PersistenceManager pm, Object pc) {
+ pm.makeTransient(pc);
+ }
+ public void pmApi(PersistenceManager pm, Collection pcs) {
+ pm.makeTransientAll(pcs);
+ }
+ public void pmApi(PersistenceManager pm, Object[] pcs) {
+ pm.makeTransientAll(pcs);
+ }
+ };
+
+ /**
+ * Test that makeTransient() with null valued argument does nothing.
+ */
+ public void testMakeTransientNullObject() {
+ executeNullObjectParameter(makeTransient, "makeTransient(null)");
+ }
+
+ /**
+ * Test that makeTransientAll() with null valued Collection argument
+ * throws NullPointerException.
+ */
+ public void testMakeTransientNullCollection() {
+ executeNullCollectionParameter(makeTransient,
+ "makeTransientAll((Collection)null)");
+ }
+
+ /**
+ * Test that makeTransientAll() with null valued array argument
+ * throws NullPointerException.
+ */
+ public void testMakeTransientNullArray() {
+ executeNullArrayParameter(makeTransient,
+ "makeTransientAll((Object[])null)");
+ }
+
+ /**
+ * Test that makeTransientAll() with a null element of a
+ * Collection argument throws NullPointerException.
+ */
+ public void testMakeTransientCollectionNullElement() {
+ executeCollectionNullElement(collNullElem, makeTransient,
+ "makeTransientAll(Collection)");
+ }
+
+ /**
+ * Test that makeTransientAll() with a null element of a
+ * array argument throws NullPointerException.
+ */
+ public void testMakeTransientArrayNullElement() {
+ executeArrayNullElement(arrayNullElem, makeTransient,
+ "makeTransientAll(Object[])");
+ }
+
+}
Added: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/PersistenceManagerNullsTest.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/PersistenceManagerNullsTest.java?view=auto&rev=465134
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/PersistenceManagerNullsTest.java (added)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/PersistenceManagerNullsTest.java Tue Oct 17 20:58:02 2006
@@ -0,0 +1,541 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.nullargs;
+
+
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.jdo.JDOHelper;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+
+/**
+ * The superclass for the tests of null arguments to pm methods.
+ *
+ * Null arguments to APIs that take an Object parameter cause the API
+ * to have no effect. Null arguments to APIs that take Object[] or Collection
+ * will cause the API to throw NullPointerException. Non-null Object[] or
+ * Collection arguments that contain null elements will have the documented
+ * behavior for non-null elements, and the null elements will be ignored.
+ *
+ */
+
+public class PersistenceManagerNullsTest extends JDO_Test {
+
+ /**
+ public static interface MethodUnderTest {
+ public void pmApi(PersistenceManager pm, Object obj);
+ public void pmApi(PersistenceManager pm, Collection coll);
+ public void pmApi(PersistenceManager pm, Object[] objs);
+ public Object pmApiReturn(PersistenceManager pm, Object obj);
+ public Collection pmApiReturn(PersistenceManager pm, Collection coll);
+ public Object[] pmApiReturn(PersistenceManager pm, Object [ ] objs);
+ }
+ */
+
+ /**
+ */
+ public static class MethodUnderTest {
+ public void pmApi(PersistenceManager pm, Object obj) {
+ throw new UnsupportedOperationException("Test must implement this method");
+ }
+ public void pmApi(PersistenceManager pm, Collection coll) {
+ throw new UnsupportedOperationException("Test must implement this method");
+ }
+ public void pmApi(PersistenceManager pm, Object[] objs) {
+ throw new UnsupportedOperationException("Test must implement this method");
+ }
+ public Object pmApiReturn(PersistenceManager pm, Object obj) {
+ throw new UnsupportedOperationException("Test must implement this method");
+ }
+ public Collection pmApiReturn(PersistenceManager pm, Collection coll) {
+ throw new UnsupportedOperationException("Test must implement this method");
+ }
+ public Object[] pmApiReturn(PersistenceManager pm, Object[] objs) {
+ throw new UnsupportedOperationException("Test must implement this method");
+ }
+ }
+
+
+ private static final String ASSERTION3_FAILED =
+ "Assertion A12.6-3 failed: ";
+
+ private static final String ASSERTION4_FAILED =
+ "Assertion A12.6-4 failed: ";
+
+ private static final String ASSERTION5_FAILED =
+ "Assertion A12.6-5 failed: ";
+
+ protected PCPoint pNotNull = null;
+ protected Collection collNullElem = null;
+ protected Collection expectedCollection = null;
+ protected Object[] arrayNullElem = new Object[] {null, null};
+ protected Object[] expectedArray = new Object[] {null, null};
+ protected Collection testInstances = null;
+
+ /** */
+ protected PersistenceManagerNullsTest() { }
+
+ /**
+ * @see JDO_Test#localSetUp()
+ */
+ protected void localSetUp() {
+ // The order of addTearDownClass calls is significant
+ // as it takes into account database FKs.
+ addTearDownClass(PCPoint.class);
+
+ // Initialize test objects and expected values
+ pNotNull = new PCPoint(3, 5);
+ arrayNullElem[1] = pNotNull;
+ expectedArray[1] = pNotNull;
+ collNullElem = Arrays.asList(arrayNullElem);
+
+ pm = getPM();
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx = pm.currentTransaction();
+
+ tx.begin();
+ try {
+ pm.makePersistent(pNotNull);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ tx.commit();
+
+ logger.debug(" \nSetup committed in DeletePersistentNullArgs()");
+ }
+ finally {
+ if (tx.isActive()) {
+ tx.rollback();
+ }
+ } expectedCollection = Arrays.asList(arrayNullElem);
+
+ }
+
+ protected static String toString(Object[] objs) {
+ StringBuffer out = new StringBuffer();
+ for (int i=0; i < objs.length; i++) {
+ out.append("[" + i + "]: ");
+ if (objs[i] == null)
+ out.append("null");
+ else out.append(objs[i].toString());
+ out.append(", ");
+ }
+ return out.toString();
+ }
+
+ protected static String toString(Collection objs) {
+ return toString(objs.toArray());
+ }
+
+ /**
+ * Checks if expected and actual arguments match for null/non-null value
+ * @return true if arguments match
+ * @param expected Collection
+ * @param actual Collection
+ */
+ protected boolean checkReturn(Collection expected, Collection actual) {
+ Object eElem = null;
+ Object aElem = null;
+ if (expected.size() != actual.size())
+ return false;
+ Iterator eIt = expected.iterator();
+ Iterator aIt = actual.iterator();
+ while (eIt.hasNext()) {
+ eElem = eIt.next();
+ aElem = aIt.next();
+ if ( (eElem == null && aElem != null)
+ || (aElem == null && eElem != null) )
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Checks if expected and actual arguments match for null/non-null value
+ * @return true if arguments match
+ * @param expected Object[]
+ * @param actual Object[]
+ */
+ protected boolean checkReturn(Object[] expected, Object[] actual) {
+ Object eElem = null;
+ Object aElem = null;
+ if (expected.length != actual.length)
+ return false;
+ for (int i=0; i < expected.length; i++) {
+ eElem = expected[i];
+ aElem = actual[i];
+ if ( (eElem == null && aElem != null)
+ || (aElem == null && eElem != null) )
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Test that method under test with null valued argument does nothing.
+ */
+ public void executeNullObjectParameter(MethodUnderTest mut, String method) {
+
+ Transaction tx = pm.currentTransaction();
+ Object obj = null;
+ try {
+ tx = pm.currentTransaction();
+
+ tx.begin();
+ try {
+ mut.pmApi(pm, obj);
+ } catch (Exception e) {
+ fail(ASSERTION3_FAILED,
+ method + " on a null object should do nothing."
+ + " Instead we get: " + e.toString());
+ }
+ tx.commit();
+
+ logger.debug(" \nPASSED in executeNullObjectParameter() on "
+ + method);
+ } finally {
+ if (tx.isActive())
+ tx.rollback();
+ }
+
+ }
+
+ /**
+ * Test that the method under test with null valued Collection argument
+ * throws NullPointerException.
+ */
+ public void executeNullCollectionParameter(MethodUnderTest mut,
+ String method) {
+
+ Collection coll = null;
+ Transaction tx = pm.currentTransaction();
+
+ try {
+ tx.begin();
+ try {
+ mut.pmApi(pm, coll);
+ fail(ASSERTION4_FAILED,
+ method
+ + " with null Collection argument should throw NPE.");
+ } catch (NullPointerException npe) {
+ // this is what we want
+ } catch (Exception e) {
+ fail(ASSERTION4_FAILED,
+ method
+ + " with null Collection argument should throw NPE."
+ + " Instead we get: " + e.toString());
+ e.printStackTrace();
+ }
+ tx.commit();
+
+ logger.debug(" \nPASSED in executeNullCollectionParameter()");
+ } finally {
+ if (tx.isActive())
+ tx.rollback();
+ }
+
+ }
+
+ /**
+ * Test that the method under test with null valued array argument
+ * throws NullPointerException.
+ */
+ public void executeNullArrayParameter(MethodUnderTest mut,
+ String method) {
+
+ Object[] array = null;
+ Transaction tx = pm.currentTransaction();
+
+ try {
+ tx.begin();
+ try {
+ mut.pmApi(pm, array);
+ fail(ASSERTION4_FAILED, method +
+ " with null array argument should throw NPE.");
+ } catch (NullPointerException npe) {
+ // this is what we want
+ } catch (Exception e) {
+ fail(ASSERTION4_FAILED,
+ method + " with null array argument should throw NPE."
+ + " Instead we get: " + e.toString());
+ e.printStackTrace();
+ }
+ tx.commit();
+
+ logger.debug(" \nPASSED in executeNullArrayParameter()");
+ } finally {
+ if (tx.isActive())
+ tx.rollback();
+ }
+
+ }
+
+ /**
+ * Test that the method under test with a null element of a
+ * Collection argument ignores the null element.
+ */
+ public void executeCollectionNullElement(Collection coll,
+ MethodUnderTest mut, String method) {
+
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx = pm.currentTransaction();
+
+ tx.begin();
+ try {
+ mut.pmApi(pm, coll);
+ } catch (Exception e) {
+ fail(ASSERTION5_FAILED,
+ method + " on a null Collection element should"
+ + " do nothing. Instead we get: " + e.toString());
+ e.printStackTrace();
+ }
+
+ tx.commit();
+ } finally {
+ if (tx.isActive())
+ tx.rollback();
+ }
+
+ }
+
+ /**
+ * Test that the method under test with a null element of a
+ * array argument ignores the null element.
+ */
+ public void executeArrayNullElement(Object[] array, MethodUnderTest mut,
+ String method) {
+
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx = pm.currentTransaction();
+
+ tx.begin();
+ try {
+ mut.pmApi(pm, array);
+ } catch (Exception e) {
+ fail(ASSERTION5_FAILED,
+ method + " on a null array element should "
+ + "do nothing. Instead we get: " + e.toString());
+ e.printStackTrace();
+ }
+
+ tx.commit();
+
+ } finally {
+ if (tx.isActive())
+ tx.rollback();
+ }
+
+ }
+
+ /**
+ * Test that method under test with null valued argument does nothing.
+ */
+ public void executeNullObjectParameterReturn(MethodUnderTest mut,
+ String method) {
+
+ Object returnVal = null;
+ Object obj = null;
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx = pm.currentTransaction();
+
+ tx.begin();
+ try {
+ returnVal = mut.pmApiReturn(pm, obj);
+ } catch (Exception e) {
+ fail(ASSERTION3_FAILED,
+ method + " on a null object should do nothing."
+ + " Instead we get: " + e.toString());
+ e.printStackTrace();
+ }
+ if (returnVal != null)
+ fail(ASSERTION3_FAILED,
+ method + " returns non-null Object; expected null.");
+
+ tx.commit();
+
+ logger.debug(" \nPASSED in executeNullObjectParameter() on "
+ + method);
+ }
+ finally {
+ if (tx.isActive())
+ tx.rollback();
+ }
+
+ }
+
+ /**
+ * Test that the method under test with null valued Collection argument
+ * throws NullPointerException.
+ */
+ public void executeNullCollectionParameterReturn( MethodUnderTest mut,
+ String method) {
+
+ Collection returnVal = null;
+ Collection coll = null;
+ Transaction tx = pm.currentTransaction();
+
+ try {
+ tx.begin();
+ try {
+ returnVal = mut.pmApiReturn(pm, coll);
+ fail(ASSERTION4_FAILED,
+ method
+ + " with null Collection argument should throw NPE.");
+ } catch (NullPointerException npe) {
+ // this is what we want
+ } catch (Exception e) {
+ fail(ASSERTION4_FAILED,
+ method
+ + " with null Collection argument should throw NPE."
+ + " Instead we get: " + e.toString());
+ e.printStackTrace();
+ }
+ if (returnVal != null)
+ fail(ASSERTION4_FAILED,
+ method + " returns non-null Object. ");
+ tx.commit();
+
+ logger.debug(" \nPASSED in executeNullCollectionParameter()");
+ }
+ finally {
+ if (tx.isActive())
+ tx.rollback();
+ }
+
+ }
+
+ /**
+ * Test that the method under test with null valued array argument
+ * throws NullPointerException.
+ */
+ public void executeNullArrayParameterReturn(MethodUnderTest mut,
+ String method) {
+
+ Object[] returnVal = null;
+ Object[] array = null;
+ Transaction tx = pm.currentTransaction();
+
+ try {
+ tx.begin();
+ try {
+ returnVal = mut.pmApiReturn(pm, array);
+ fail(ASSERTION4_FAILED, method
+ + " with null array argument should throw NPE.");
+ } catch (NullPointerException npe) {
+ // this is what we want
+ } catch (Exception e) {
+ fail(ASSERTION4_FAILED,
+ method + " with null array argument should throw NPE."
+ + " Instead we get: " + e.toString());
+ e.printStackTrace();
+ }
+ if (returnVal != null)
+ fail(ASSERTION4_FAILED,
+ method + " returns non-null Object.");
+ tx.commit();
+
+ logger.debug(" \nPASSED in executeNullArrayParameter()");
+ }
+ finally {
+ if (tx.isActive())
+ tx.rollback();
+ }
+
+ }
+
+ /**
+ * Test that the method under test with a null element of a
+ * Collection argument ignores the null element.
+ */
+ public void executeCollectionNullElementReturn(Collection coll,
+ MethodUnderTest mut, String method) {
+
+ Collection returnVal = null;
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx = pm.currentTransaction();
+
+ tx.begin();
+ try {
+ returnVal = mut.pmApiReturn(pm, coll);
+ } catch (Exception e) {
+ fail(ASSERTION5_FAILED,
+ method + " on a null Collection element should"
+ + " do nothing. Instead we get: " + e.toString());
+ e.printStackTrace();
+ }
+
+ if (!checkReturn(expectedCollection, returnVal))
+ fail(ASSERTION5_FAILED,
+ method + " returns incorrect Object. Expected "
+ + expectedCollection.toString() + " actual was "
+ + returnVal.toString());
+ tx.commit();
+ } finally {
+ if (tx.isActive())
+ tx.rollback();
+ }
+
+ }
+
+ /**
+ * Test that the method under test with a null element of a
+ * array argument ignores the null element.
+ */
+ public void executeArrayNullElementReturn(Object[] obj,
+ MethodUnderTest mut, String method) {
+
+ Object[] returnVal = null;
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx = pm.currentTransaction();
+
+ tx.begin();
+ try {
+ returnVal = mut.pmApiReturn(pm, obj);
+ } catch (Exception e) {
+ fail(ASSERTION5_FAILED,
+ method + " on a null array element should "
+ + "do nothing. Instead we get: " + e.toString());
+ e.printStackTrace();
+ }
+
+ if (!checkReturn(expectedArray, returnVal))
+ fail(ASSERTION5_FAILED,
+ method + " returns incorrect Object. Expected "
+ + Arrays.toString(expectedArray) + " actual was "
+ + Arrays.toString(returnVal));
+ tx.commit();
+
+ } finally {
+ if (tx.isActive())
+ tx.rollback();
+ }
+
+ }
+}
Added: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/RefreshNullArgs.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/RefreshNullArgs.java?view=auto&rev=465134
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/RefreshNullArgs.java (added)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/RefreshNullArgs.java Tue Oct 17 20:58:02 2006
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.nullargs;
+
+import java.util.Collection;
+
+import javax.jdo.JDOUserException;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> refresh with Null Arguments
+ *<BR>
+ *<B>Keywords:</B>
+ *<BR>
+ *<B>Assertion IDs:</B> A12.6.3, A12.6.4, A12.6.5
+ *<BR>
+ *<B>Assertion Description: </B>
+A12.6-3 [Null arguments to APIs that take an Object parameter cause the API to have no effect.] A12.6-4 [Null arguments to APIs that take Object[] or Collection will cause the API to throw NullPointerException.] A12.6-5 [Non-null Object[] or Collection arguments that contain null elements will have the documented behavior for non-null elements, and the null elements will be ignored.]
+ */
+
+public class RefreshNullArgs extends PersistenceManagerNullsTest {
+
+ /**
+ * 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(RefreshNullArgs.class);
+ }
+
+ static MethodUnderTest refresh =
+ new MethodUnderTestRefresh();
+ static class MethodUnderTestRefresh extends MethodUnderTest {
+ public void pmApi(PersistenceManager pm, Object pc) {
+ pm.refresh(pc);
+ }
+ public void pmApi(PersistenceManager pm, Collection pcs) {
+ pm.refreshAll(pcs);
+ }
+ public void pmApi(PersistenceManager pm, Object[] pcs) {
+ pm.refreshAll(pcs);
+ }
+ };
+
+ /**
+ * Test that refresh() with null valued argument does nothing.
+ */
+ public void testRefreshNullObject() {
+ executeNullObjectParameter(refresh, "refresh(null)");
+ }
+
+ /**
+ * Test that refreshAll() with null valued Collection argument
+ * throws NullPointerException.
+ */
+ public void testRefreshNullCollection() {
+ executeNullCollectionParameter(refresh,
+ "refreshAll((Collection)null)");
+ }
+
+ /**
+ * Test that refreshAll() with null valued array argument
+ * throws NullPointerException.
+ */
+ public void testRefreshNullArray() {
+ executeNullArrayParameter(refresh,
+ "refreshAll((Object[])null)");
+ }
+
+ /**
+ * Test that refreshAll() with a null element of a
+ * Collection argument throws NullPointerException.
+ */
+ public void testRefreshCollectionNullElement() {
+ executeCollectionNullElement(collNullElem, refresh,
+ "refreshAll(Collection)");
+ }
+
+ /**
+ * Test that refreshAll() with a null element of a
+ * array argument throws NullPointerException.
+ */
+ public void testRefreshArrayNullElement() {
+ executeArrayNullElement(arrayNullElem, refresh,
+ "refreshAll(Object[])");
+ }
+
+}
Added: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/RetrieveNullArgs.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/RetrieveNullArgs.java?view=auto&rev=465134
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/RetrieveNullArgs.java (added)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/RetrieveNullArgs.java Tue Oct 17 20:58:02 2006
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.nullargs;
+
+import java.util.Collection;
+
+import javax.jdo.JDOUserException;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> retrieve with Null Arguments
+ *<BR>
+ *<B>Keywords:</B>
+ *<BR>
+ *<B>Assertion IDs:</B> A12.6.3, A12.6.4, A12.6.5
+ *<BR>
+ *<B>Assertion Description: </B>
+A12.6-3 [Null arguments to APIs that take an Object parameter cause the API to have no effect.] A12.6-4 [Null arguments to APIs that take Object[] or Collection will cause the API to throw NullPointerException.] A12.6-5 [Non-null Object[] or Collection arguments that contain null elements will have the documented behavior for non-null elements, and the null elements will be ignored.]
+ */
+
+public class RetrieveNullArgs extends PersistenceManagerNullsTest {
+
+ /**
+ * 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(RetrieveNullArgs.class);
+ }
+
+ static MethodUnderTest retrieve =
+ new MethodUnderTestRetrieve();
+ static class MethodUnderTestRetrieve extends MethodUnderTest {
+ public void pmApi(PersistenceManager pm, Object pc) {
+ pm.retrieve(pc);
+ }
+ public void pmApi(PersistenceManager pm, Collection pcs) {
+ pm.retrieveAll(pcs);
+ }
+ public void pmApi(PersistenceManager pm, Object[] pcs) {
+ pm.retrieveAll(pcs);
+ }
+ };
+
+ /**
+ * Test that retrieve() with null valued argument does nothing.
+ */
+ public void testRetrieveNullObject() {
+ executeNullObjectParameter(retrieve, "retrieve(null)");
+ }
+
+ /**
+ * Test that retrieveAll() with null valued Collection argument
+ * throws NullPointerException.
+ */
+ public void testRetrieveNullCollection() {
+ executeNullCollectionParameter(retrieve,
+ "retrieveAll((Collection)null)");
+ }
+
+ /**
+ * Test that retrieveAll() with null valued array argument
+ * throws NullPointerException.
+ */
+ public void testRetrieveNullArray() {
+ executeNullArrayParameter(retrieve,
+ "retrieveAll((Object[])null)");
+ }
+
+ /**
+ * Test that retrieveAll() with a null element of a
+ * Collection argument throws NullPointerException.
+ */
+ public void testRetrieveCollectionNullElement() {
+ executeCollectionNullElement(collNullElem, retrieve,
+ "retrieveAll(Collection)");
+ }
+
+ /**
+ * Test that retrieveAll() with a null element of a
+ * array argument throws NullPointerException.
+ */
+ public void testRetrieveArrayNullElement() {
+ executeArrayNullElement(arrayNullElem, retrieve,
+ "retrieveAll(Object[])");
+ }
+
+}
Added: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/RetrieveWithFetchPlanNullArgs.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/RetrieveWithFetchPlanNullArgs.java?view=auto&rev=465134
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/RetrieveWithFetchPlanNullArgs.java (added)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/nullargs/RetrieveWithFetchPlanNullArgs.java Tue Oct 17 20:58:02 2006
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.nullargs;
+
+import java.util.Collection;
+
+import javax.jdo.JDOUserException;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> retrieveWithFetchPlan with Null Arguments
+ *<BR>
+ *<B>Keywords:</B>
+ *<BR>
+ *<B>Assertion IDs:</B> A12.6.3, A12.6.4, A12.6.5
+ *<BR>
+ *<B>Assertion Description: </B>
+A12.6-3 [Null arguments to APIs that take an Object parameter cause the API to have no effect.] A12.6-4 [Null arguments to APIs that take Object[] or Collection will cause the API to throw NullPointerException.] A12.6-5 [Non-null Object[] or Collection arguments that contain null elements will have the documented behavior for non-null elements, and the null elements will be ignored.]
+ */
+
+public class RetrieveWithFetchPlanNullArgs extends PersistenceManagerNullsTest {
+
+ /**
+ * 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(RetrieveWithFetchPlanNullArgs.class);
+ }
+
+ static MethodUnderTest retrieveWithFetchPlan =
+ new MethodUnderTestRetrieveWithFetchPlan();
+ static class MethodUnderTestRetrieveWithFetchPlan extends MethodUnderTest {
+ public void pmApi(PersistenceManager pm, Object pc) {
+ pm.retrieve(pc, false);
+ }
+ public void pmApi(PersistenceManager pm, Collection pcs) {
+ pm.retrieveAll(pcs, false);
+ }
+ public void pmApi(PersistenceManager pm, Object[] pcs) {
+ pm.retrieveAll(pcs, false);
+ }
+ };
+
+ /**
+ * Test that retrieveWithFetchPlan() with null valued argument does nothing.
+ */
+ public void testRetrieveWithFetchPlanNullObject() {
+ executeNullObjectParameter(retrieveWithFetchPlan, "retrieveWithFetchPlan(null)");
+ }
+
+ /**
+ * Test that retrieveWithFetchPlanAll() with null valued Collection argument
+ * throws NullPointerException.
+ */
+ public void testRetrieveWithFetchPlanNullCollection() {
+ executeNullCollectionParameter(retrieveWithFetchPlan,
+ "retrieveWithFetchPlanAll((Collection)null)");
+ }
+
+ /**
+ * Test that retrieveWithFetchPlanAll() with null valued array argument
+ * throws NullPointerException.
+ */
+ public void testRetrieveWithFetchPlanNullArray() {
+ executeNullArrayParameter(retrieveWithFetchPlan,
+ "retrieveWithFetchPlanAll((Object[])null)");
+ }
+
+ /**
+ * Test that retrieveWithFetchPlanAll() with a null element of a
+ * Collection argument throws NullPointerException.
+ */
+ public void testRetrieveWithFetchPlanCollectionNullElement() {
+ executeCollectionNullElement(collNullElem, retrieveWithFetchPlan,
+ "retrieveWithFetchPlanAll(Collection)");
+ }
+
+ /**
+ * Test that retrieveWithFetchPlanAll() with a null element of a
+ * array argument throws NullPointerException.
+ */
+ public void testRetrieveWithFetchPlanArrayNullElement() {
+ executeArrayNullElement(arrayNullElem, retrieveWithFetchPlan,
+ "retrieveWithFetchPlanAll(Object[])");
+ }
+
+}
|