Return-Path: Delivered-To: apmail-db-jdo-dev-archive@www.apache.org Received: (qmail 72722 invoked from network); 6 Jul 2005 16:28:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 6 Jul 2005 16:28:03 -0000 Received: (qmail 56074 invoked by uid 500); 6 Jul 2005 16:28:03 -0000 Mailing-List: contact jdo-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jdo-dev@db.apache.org Delivered-To: mailing list jdo-dev@db.apache.org Received: (qmail 56052 invoked by uid 99); 6 Jul 2005 16:28:03 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Jul 2005 09:28:03 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [62.154.194.149] (HELO miraculix.spree.de) (62.154.194.149) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Jul 2005 09:28:01 -0700 Received: from [172.16.1.19] (rio.spree.de [172.16.1.19]) by miraculix.spree.de (8.11.6/8.11.6) with ESMTP id j66GRsQ04191 for ; Wed, 6 Jul 2005 18:27:54 +0200 Message-ID: <42CC071B.7080103@spree.de> Date: Wed, 06 Jul 2005 18:30:19 +0200 From: Michael Watzek Organization: Tech@Spree GmbH User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: jdo-dev@db.apache.org Subject: Assertions-A8.patch Content-Type: multipart/mixed; boundary="------------030700030105070204050403" X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N --------------030700030105070204050403 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit -- ------------------------------------------------------------------- Michael Watzek Tech@Spree Engineering GmbH mailto:mwa.tech@spree.de Buelowstr. 66 Tel.: ++49/30/235 520 36 10783 Berlin - Germany Fax.: ++49/30/217 520 12 http://www.spree.de/ ------------------------------------------------------------------- --------------030700030105070204050403 Content-Type: text/plain; name="Assertions-A8.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="Assertions-A8.patch" Index: test/java/org/apache/jdo/tck/api/persistencemanagerfactory/AbstractGetPMF.java =================================================================== --- test/java/org/apache/jdo/tck/api/persistencemanagerfactory/AbstractGetPMF.java (revision 0) +++ test/java/org/apache/jdo/tck/api/persistencemanagerfactory/AbstractGetPMF.java (revision 0) @@ -0,0 +1,98 @@ +/* + * 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.persistencemanagerfactory; + +import javax.jdo.JDOFatalUserException; +import javax.jdo.PersistenceManagerFactory; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.mylib.PCPoint; + +/** + * The abstract super class for all GetPMF test cases. + * @author Michael Watzek + */ + +abstract class AbstractGetPMF extends JDO_Test { + + protected static final String nameExists = + System.getProperty("PMFProperties"); + + protected static final String nameDoesNotExist = + //we use '/' instead of File.separatorChar because + //this character is passed by maven + nameExists.substring(0, nameExists.lastIndexOf('/')+1) + + "logging.properties"; + + protected static final String jndiName = + //we use '/' instead of File.separatorChar because + //this character is passed by maven + nameExists.substring(0, nameExists.lastIndexOf('/')+1) + + "pmf.ser"; + + /** + * Removing the path prefix from argument name. + * @return argument name removed by the path prefix. + */ + protected String removePathPrefix(String name) { + //we use '/' instead of File.separatorChar because + //this character is passed by maven + int index = name.lastIndexOf('/'); + if (index!=-1) { + name = name.substring(index+1); + } + return name; + } + + protected void makePersistent() { + pm = pmf.getPersistenceManager(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + PCPoint comp = new PCPoint(1, 2); + pm.makePersistent(comp); + tx.commit(); + addTearDownInstance(comp); + } + + /** + * Returns pmf instance for the given name. + * Subclasses may use argument name as file name, + * resource name etc. + * @param name the name + * @return the pmf instance + */ + protected abstract PersistenceManagerFactory getPMF(String name); + + /** */ + protected void jdoFatalUserException(String assertionMessage) { + try { + pmf = getPMF(nameDoesNotExist); + fail(assertionMessage); + } catch (JDOFatalUserException e) { + // expected exception + if (debug) + logger.debug("caught expected exception " + e.toString()); + } + } + + /** */ + protected void success() { + pmf = getPMF(nameExists); + makePersistent(); + } +} Property changes on: test/java/org/apache/jdo/tck/api/persistencemanagerfactory/AbstractGetPMF.java ___________________________________________________________________ Name: svn:executable + * Index: test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByJNDILocation.java =================================================================== --- test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByJNDILocation.java (revision 0) +++ test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByJNDILocation.java (revision 0) @@ -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.persistencemanagerfactory; + +import java.io.File; +import java.util.Hashtable; + +import javax.jdo.JDOHelper; +import javax.jdo.PersistenceManagerFactory; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; + +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title:GetPMFByJNDILocation of PersistenceManagerFactory + *
+ *Keywords: persistencemanagerfactory + *
+ *Assertion IDs: A8.6-19. + *
+ *Assertion Description: + * Uses the parameter(s) passed as arguments to construct a Properties + * instance, and then delegates to the static method + * getPersistenceManagerFactory in the class named in the property + * javax.jdo.PersistenceManagerFactoryClass. + * If there are any exceptions while trying to construct the Properties + * instance or to call the static method, + * then either A8.6-4 [JDOFatalUserException] or + * A8.6-5 [JDOFatalInternalException is thrown], + * depending on whether the exception is due to the user + * or the implementation. + * The nested exception indicates the cause of the exception. + * + * @author Michael Watzek + */ + +public class GetPMFByJNDILocation extends AbstractGetPMF { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.6-19 (GetPMFByJNDILocation) failed: "; + + /** + * The main 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(GetPMFByJNDILocation.class); + } + + /** + * @see AbstractGetPMF#getPMF(String) + */ + protected PersistenceManagerFactory getPMF(String name) { + Hashtable env = new Hashtable(); + env.put(Context.INITIAL_CONTEXT_FACTORY, + "com.sun.jndi.fscontext.RefFSContextFactory"); + + Context context = null; + try { + context = new InitialContext(env); + if (name.equals(nameExists)) { + PersistenceManagerFactory pmf = + JDOHelper.getPersistenceManagerFactory(new File(name)); + context.bind(jndiName, pmf); + } + return JDOHelper.getPersistenceManagerFactory(jndiName, context); + } catch (NamingException e) { + throw new RuntimeException("", e); + } finally { + if (context != null) { + try { + context.unbind(jndiName); + context.close(); + } catch (NamingException e) { + // stay quiet + } + } + } + } + + /** */ + public void testJDOFatalUserException() { + jdoFatalUserException(ASSERTION_FAILED); + } + + /** */ + public void testSuccess() { + success(); + } +} Property changes on: test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByJNDILocation.java ___________________________________________________________________ Name: svn:executable + * Index: test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByJNDILocationAndClassLoader.java =================================================================== --- test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByJNDILocationAndClassLoader.java (revision 0) +++ test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByJNDILocationAndClassLoader.java (revision 0) @@ -0,0 +1,109 @@ +/* + * 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.persistencemanagerfactory; + +import java.io.File; +import java.util.Hashtable; + +import javax.jdo.JDOHelper; +import javax.jdo.PersistenceManagerFactory; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; + +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title:GetPMFByJNDILocationAndClassLoader of PersistenceManagerFactory + *
+ *Keywords: persistencemanagerfactory + *
+ *Assertion IDs: A8.6-20. + *
+ *Assertion Description: + * Uses the parameter(s) passed as arguments to construct a Properties + * instance, and then delegates to the static method + * getPersistenceManagerFactory in the class named in the property + * javax.jdo.PersistenceManagerFactoryClass. + * If there are any exceptions while trying to construct the Properties + * instance or to call the static method, + * then either A8.6-4 [JDOFatalUserException] or + * A8.6-5 [JDOFatalInternalException is thrown], + * depending on whether the exception is due to the user + * or the implementation. + * The nested exception indicates the cause of the exception. + * + * @author Michael Watzek + */ + +public class GetPMFByJNDILocationAndClassLoader extends AbstractGetPMF { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.6-20 (GetPMFByJNDILocationAndClassLoader) failed: "; + + /** + * The main 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(GetPMFByJNDILocationAndClassLoader.class); + } + + /** + * @see AbstractGetPMF#getPMF(String) + */ + protected PersistenceManagerFactory getPMF(String name) { + Hashtable env = new Hashtable(); + env.put(Context.INITIAL_CONTEXT_FACTORY, + "com.sun.jndi.fscontext.RefFSContextFactory"); + + Context context = null; + try { + context = new InitialContext(env); + if (name.equals(nameExists)) { + PersistenceManagerFactory pmf = + JDOHelper.getPersistenceManagerFactory(new File(name)); + context.bind(jndiName, pmf); + } + return JDOHelper.getPersistenceManagerFactory(jndiName, context, + getClass().getClassLoader()); + } catch (NamingException e) { + throw new RuntimeException("", e); + } finally { + if (context != null) { + try { + context.unbind(jndiName); + context.close(); + } catch (NamingException e) { + // stay quiet + } + } + } + } + + /** */ + public void testJDOFatalUserException() { + jdoFatalUserException(ASSERTION_FAILED); + } + + /** */ + public void testSuccess() { + success(); + } +} Property changes on: test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByJNDILocationAndClassLoader.java ___________________________________________________________________ Name: svn:executable + * Index: test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByFile.java =================================================================== --- test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByFile.java (revision 0) +++ test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByFile.java (revision 0) @@ -0,0 +1,80 @@ +/* + * 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.persistencemanagerfactory; + +import java.io.File; + +import javax.jdo.JDOHelper; +import javax.jdo.PersistenceManagerFactory; + +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title:GetPMFByFile of PersistenceManagerFactory + *
+ *Keywords: persistencemanagerfactory + *
+ *Assertion IDs: A8.6-13. + *
+ *Assertion Description: + * Uses the parameter(s) passed as arguments to construct a Properties + * instance, and then delegates to the static method + * getPersistenceManagerFactory in the class named in the property + * javax.jdo.PersistenceManagerFactoryClass. + * If there are any exceptions while trying to construct the Properties + * instance or to call the static method, + * then either A8.6-4 [JDOFatalUserException] or + * A8.6-5 [JDOFatalInternalException is thrown], + * depending on whether the exception is due to the user + * or the implementation. + * The nested exception indicates the cause of the exception. + * + * @author Michael Watzek + */ + +public class GetPMFByFile extends AbstractGetPMF { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.6-13 (GetPMFByFile) failed: "; + + /** + * The main 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(GetPMFByFile.class); + } + + /** + * @see AbstractGetPMF#getPMF(String) + */ + protected PersistenceManagerFactory getPMF(String name) { + return JDOHelper.getPersistenceManagerFactory(new File(name)); + } + + /** */ + public void testJDOFatalUserException() { + jdoFatalUserException(ASSERTION_FAILED); + } + + /** */ + public void testSuccess() { + success(); + } +} Property changes on: test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByFile.java ___________________________________________________________________ Name: svn:executable + * Index: test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByFileAndClassLoader.java =================================================================== --- test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByFileAndClassLoader.java (revision 0) +++ test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByFileAndClassLoader.java (revision 0) @@ -0,0 +1,86 @@ +/* + * 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.persistencemanagerfactory; + +import java.io.File; + +import javax.jdo.JDOHelper; +import javax.jdo.PersistenceManagerFactory; + +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title:GetPMFByFileAndClassLoader of PersistenceManagerFactory + *
+ *Keywords: persistencemanagerfactory + *
+ *Assertion IDs: A8.6-14. + *
+ *Assertion Description: + * Uses the parameter(s) passed as arguments to construct a Properties + * instance, and then delegates to the static method + * getPersistenceManagerFactory in the class named in the property + * javax.jdo.PersistenceManagerFactoryClass. + * If there are any exceptions while trying to construct the Properties + * instance or to call the static method, + * then either A8.6-4 [JDOFatalUserException] or + * A8.6-5 [JDOFatalInternalException is thrown], + * depending on whether the exception is due to the user + * or the implementation. + * The nested exception indicates the cause of the exception. + * + * @author Michael Watzek + */ + +public class GetPMFByFileAndClassLoader extends AbstractGetPMF { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.6-14 (GetPMFByFileAndClassLoader) failed: "; + + private static final String propertiesFileDoesNotExist = + "FileDoesNotExist.properties"; + private static final String propertiesFileExists = + System.getProperty("PMFProperties"); + + /** + * The main 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(GetPMFByFileAndClassLoader.class); + } + + /** + * @see AbstractGetPMF#getPMF(String) + */ + protected PersistenceManagerFactory getPMF(String name) { + return JDOHelper.getPersistenceManagerFactory(new File(name), + getClass().getClassLoader()); + } + + /** */ + public void testJDOFatalUserException() { + jdoFatalUserException(ASSERTION_FAILED); + } + + /** */ + public void testSuccess() { + success(); + } +} Property changes on: test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByFileAndClassLoader.java ___________________________________________________________________ Name: svn:executable + * Index: test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByResourceAndClassLoader.java =================================================================== --- test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByResourceAndClassLoader.java (revision 0) +++ test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByResourceAndClassLoader.java (revision 0) @@ -0,0 +1,79 @@ +/* + * 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.persistencemanagerfactory; + +import javax.jdo.JDOHelper; +import javax.jdo.PersistenceManagerFactory; + +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title:GetPMFByResourceAndClassLoader of PersistenceManagerFactory + *
+ *Keywords: persistencemanagerfactory + *
+ *Assertion IDs: A8.6-16. + *
+ *Assertion Description: + * Uses the parameter(s) passed as arguments to construct a Properties + * instance, and then delegates to the static method + * getPersistenceManagerFactory in the class named in the property + * javax.jdo.PersistenceManagerFactoryClass. + * If there are any exceptions while trying to construct the Properties + * instance or to call the static method, + * then either A8.6-4 [JDOFatalUserException] or + * A8.6-5 [JDOFatalInternalException is thrown], + * depending on whether the exception is due to the user + * or the implementation. + * The nested exception indicates the cause of the exception. + * + * @author Michael Watzek + */ + +public class GetPMFByResourceAndClassLoader extends AbstractGetPMF { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.6-16 (GetPMFByResourceAndClassLoader) failed: "; + + /** + * The main 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(GetPMFByResourceAndClassLoader.class); + } + + /** + * @see AbstractGetPMF#getPMF(String) + */ + protected PersistenceManagerFactory getPMF(String name) { + return JDOHelper.getPersistenceManagerFactory(removePathPrefix(name), + getClass().getClassLoader()); + } + + /** */ + public void testJDOFatalUserException() { + jdoFatalUserException(ASSERTION_FAILED); + } + + /** */ + public void testSuccess() { + success(); + } +} Property changes on: test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByResourceAndClassLoader.java ___________________________________________________________________ Name: svn:executable + * Index: test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByResource.java =================================================================== --- test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByResource.java (revision 0) +++ test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByResource.java (revision 0) @@ -0,0 +1,78 @@ +/* + * 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.persistencemanagerfactory; + +import javax.jdo.JDOHelper; +import javax.jdo.PersistenceManagerFactory; + +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title:GetPMFByResource of PersistenceManagerFactory + *
+ *Keywords: persistencemanagerfactory + *
+ *Assertion IDs: A8.6-15. + *
+ *Assertion Description: + * Uses the parameter(s) passed as arguments to construct a Properties + * instance, and then delegates to the static method + * getPersistenceManagerFactory in the class named in the property + * javax.jdo.PersistenceManagerFactoryClass. + * If there are any exceptions while trying to construct the Properties + * instance or to call the static method, + * then either A8.6-4 [JDOFatalUserException] or + * A8.6-5 [JDOFatalInternalException is thrown], + * depending on whether the exception is due to the user + * or the implementation. + * The nested exception indicates the cause of the exception. + * + * @author Michael Watzek + */ + +public class GetPMFByResource extends AbstractGetPMF { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.6-15 (GetPMFByResource) failed: "; + + /** + * The main 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(GetPMFByResource.class); + } + + /** + * @see AbstractGetPMF#getPMF(String) + */ + protected PersistenceManagerFactory getPMF(String name) { + return JDOHelper.getPersistenceManagerFactory(removePathPrefix(name)); + } + + /** */ + public void testJDOFatalUserException() { + jdoFatalUserException(ASSERTION_FAILED); + } + + /** */ + public void testSuccess() { + success(); + } +} Property changes on: test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByResource.java ___________________________________________________________________ Name: svn:executable + * Index: test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByStream.java =================================================================== --- test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByStream.java (revision 0) +++ test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByStream.java (revision 0) @@ -0,0 +1,96 @@ +/* + * 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.persistencemanagerfactory; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; + +import javax.jdo.JDOHelper; +import javax.jdo.PersistenceManagerFactory; + +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title:GetPMFByStream of PersistenceManagerFactory + *
+ *Keywords: persistencemanagerfactory + *
+ *Assertion IDs: A8.6-17. + *
+ *Assertion Description: + * Uses the parameter(s) passed as arguments to construct a Properties + * instance, and then delegates to the static method + * getPersistenceManagerFactory in the class named in the property + * javax.jdo.PersistenceManagerFactoryClass. + * If there are any exceptions while trying to construct the Properties + * instance or to call the static method, + * then either A8.6-4 [JDOFatalUserException] or + * A8.6-5 [JDOFatalInternalException is thrown], + * depending on whether the exception is due to the user + * or the implementation. + * The nested exception indicates the cause of the exception. + * + * @author Michael Watzek + */ + +public class GetPMFByStream extends AbstractGetPMF { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.6-17 (GetPMFByStream) failed: "; + + /** + * The main 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(GetPMFByStream.class); + } + + /** + * @see AbstractGetPMF#getPMF(String) + */ + protected PersistenceManagerFactory getPMF(String name) { + FileInputStream stream = null; + try { + stream = new FileInputStream(name); + return JDOHelper.getPersistenceManagerFactory(stream); + } catch (FileNotFoundException e) { + throw new RuntimeException("", e); + } finally { + if (stream != null) { + try { + stream.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + } + + /** */ + public void testJDOFatalUserException() { + jdoFatalUserException(ASSERTION_FAILED); + } + + /** */ + public void testSuccess() { + success(); + } +} Property changes on: test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByStream.java ___________________________________________________________________ Name: svn:executable + * Index: test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByStreamAndClassLoader.java =================================================================== --- test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByStreamAndClassLoader.java (revision 0) +++ test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByStreamAndClassLoader.java (revision 0) @@ -0,0 +1,97 @@ +/* + * 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.persistencemanagerfactory; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; + +import javax.jdo.JDOHelper; +import javax.jdo.PersistenceManagerFactory; + +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title:GetPMFByStreamAndClassLoader of PersistenceManagerFactory + *
+ *Keywords: persistencemanagerfactory + *
+ *Assertion IDs: A8.6-18. + *
+ *Assertion Description: + * Uses the parameter(s) passed as arguments to construct a Properties + * instance, and then delegates to the static method + * getPersistenceManagerFactory in the class named in the property + * javax.jdo.PersistenceManagerFactoryClass. + * If there are any exceptions while trying to construct the Properties + * instance or to call the static method, + * then either A8.6-4 [JDOFatalUserException] or + * A8.6-5 [JDOFatalInternalException is thrown], + * depending on whether the exception is due to the user + * or the implementation. + * The nested exception indicates the cause of the exception. + * + * @author Michael Watzek + */ + +public class GetPMFByStreamAndClassLoader extends AbstractGetPMF { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.6-18 (GetPMFByStreamAndClassLoader) failed: "; + + /** + * The main 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(GetPMFByStreamAndClassLoader.class); + } + + /** + * @see AbstractGetPMF#getPMF(String) + */ + protected PersistenceManagerFactory getPMF(String name) { + FileInputStream stream = null; + try { + stream = new FileInputStream(name); + return JDOHelper.getPersistenceManagerFactory(stream, + getClass().getClassLoader()); + } catch (FileNotFoundException e) { + throw new RuntimeException("", e); + } finally { + if (stream != null) { + try { + stream.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + } + + /** */ + public void testJDOFatalUserException() { + jdoFatalUserException(ASSERTION_FAILED); + } + + /** */ + public void testSuccess() { + success(); + } +} Property changes on: test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByStreamAndClassLoader.java ___________________________________________________________________ Name: svn:executable + * --------------030700030105070204050403--