Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/CloseFailsIfTransactionActive.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/CloseFailsIfTransactionActive.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/CloseFailsIfTransactionActive.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/CloseFailsIfTransactionActive.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,203 @@ +/* + * 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.JDOException; +import javax.jdo.JDOUserException; +import javax.jdo.PersistenceManager; +import javax.jdo.PersistenceManagerFactory; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *<B>Title:</B>CloseFailsIfTransactionActive of PersistenceManagerFactory + *<BR> + *<B>Keywords:</B> persistencemanagerfactory + *<BR> + *<B>Assertion IDs:</B> A11.4-4. + *<BR> + *<B>Assertion Description: </B> + * PersistenceManagerFactory.getPersistenceManager() throws + * JDOUserException after the PersistenceManagerFactory is closed. + * The exception contains an array of nested exceptions; each nested + * exception contains as its failed object the PersistenceManager whose + * Transaction is still active. + * During close of the PersistenceManagerFactory, all PersistenceManager + * instances obtained from this PersistenceManagerFactory are + * themselves closed. + */ + +/* + * Revision History + * ================ + * Author : Craig Russell + * Date : 05/16/03 + * + */ + +public class CloseFailsIfTransactionActive extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A11.4-4 (CloseFailsIfTransactionActive) failed: "; + + /** + * 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(CloseFailsIfTransactionActive.class); + } + + protected boolean aborted = false; + + /** */ + public void test() { + PersistenceManager pm1 = null; + PersistenceManager pm2 = null; + cleanupPMF(getPMF()); + pmf = null; + + try { + pm1 = getPM(); + pm2 = getPM(); + pm1.currentTransaction().begin(); + pm1.currentTransaction().commit(); + pm2.currentTransaction().begin(); + pmf.close(); + setAborted(); + fail(ASSERTION_FAILED, + "Close incorrectly succeeded with active transaction"); + } + catch (JDOUserException ex) { + try { + if (debug) + logger.debug("Caught expected exception " + ex.getMessage()); + PersistenceManager[] pms = getFailedPersistenceManagers(ex); + if (pms.length != 1) { + setAborted(); + fail(ASSERTION_FAILED, + "Unexpected number of nested exceptions: " + pms.length); + } + else { + Object failed = pms[0]; + if (pm2.equals(failed)) { + if (debug) + logger.debug("Found expected failed object " + + failed.toString()); + } + else { + setAborted(); + fail(ASSERTION_FAILED, + "Found unexpected failed object " + + failed.toString()); + } + } + } + catch (Exception uex) { + setAborted(); + fail(ASSERTION_FAILED, + "Caught 1 unexpected exception " + uex.toString()); + } + } + catch (Exception ex) { + setAborted(); + fail(ASSERTION_FAILED, + "Caught 2 unexpected exception " + ex.toString()); + } + + if (!isAborted()) { + try { + pm2.currentTransaction().commit(); + pmf.close(); + if (!pm1.isClosed()){ + fail(ASSERTION_FAILED, + "Unexpected pm1 is not closed."); + } + if (!pm2.isClosed()) { + fail(ASSERTION_FAILED, + "Unexpected pm2 is not closed."); + } + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "Caught 3 unexpected exception " + ex.toString()); + } + } + } + + /** */ + protected void cleanupPMF(PersistenceManagerFactory pmf) { + try { + pmf.close(); + } catch (JDOException ex) { + PersistenceManager[] pms = getFailedPersistenceManagers(ex); + int numberOfPersistenceManagers = pms.length; + for (int i = 0; i < numberOfPersistenceManagers; ++i) { + PersistenceManager pm = pms[i]; + if (pm == null) { + fail(ASSERTION_FAILED, + "Found unexpected null PersistenceManager"); + } + else { + Transaction tx = pm.currentTransaction(); + if (tx.isActive()) { + if (debug) + logger.debug("Found active transaction; rolling back."); + tx.rollback(); + } + else { + fail(ASSERTION_FAILED, + "Unexpectedly, this transaction is not active: " + tx); + } + } + } + } + } + + /** */ + protected void setAborted() { + aborted = true; + } + + /** */ + protected boolean isAborted() { + return aborted; + } + + /** */ + protected PersistenceManager[] getFailedPersistenceManagers(JDOException ex) { + Throwable[] nesteds = ex.getNestedExceptions(); + int numberOfExceptions = nesteds==null ? 0 : nesteds.length; + PersistenceManager[] result = new PersistenceManager[numberOfExceptions]; + for (int i = 0; i < numberOfExceptions; ++i) { + JDOException exc = (JDOException)nesteds[i]; + Object failedObject = exc.getFailedObject(); + if (exc.getFailedObject() instanceof PersistenceManager) { + result[i] = (PersistenceManager)failedObject; + } else { + fail(ASSERTION_FAILED, + "Unexpected failed object of type: " + + failedObject.getClass().getName()); + } + } + return result; + } +}
Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/CloseWithoutPermissionThrowsSecurityException.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/CloseWithoutPermissionThrowsSecurityException.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/CloseWithoutPermissionThrowsSecurityException.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/CloseWithoutPermissionThrowsSecurityException.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,87 @@ +/* + * 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.security.Permission; + +import javax.jdo.spi.JDOPermission; +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *<B>Title:</B>Close of PersistenceManagerFactory Throws SecurityException if + * JDOPermission("closePersistenceManagerFactory") Is Not Set + *<BR> + *<B>Keywords:</B> persistencemanagerfactory SecurityException + *<BR> + *<B>Assertion IDs:</B> A11.4-3 + *<BR> + *<B>Assertion Description: </B> + * PersistenceManagerFactory.close() closes this PersistenceManagerFactory. + * If JDOPermission("closePersistenceManagerFactory") is not set, then + * SecurityException in thrown. + */ + + +public class CloseWithoutPermissionThrowsSecurityException extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertions A11.4-3 (CloseWithoutPermissionThrowsSecurityException) failed: "; + + /** + * 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(CloseWithoutPermissionThrowsSecurityException.class); + } + + /** */ + public void test() { + pmf = getPMF(); + + SecurityManager oldSecMgr = System.getSecurityManager(); + try { + System.setSecurityManager(new MySecurityManager()); + } catch (SecurityException se) { + fail(ASSERTION_FAILED, + "SecurityManager already set, setSecurityManager throws " + + se.toString()); + } + + try { + pmf.close(); + } catch (SecurityException ex) { + // expected exception if JDOPermission("closePersistenceManagerFactory") is not set + if (debug) + logger.debug("caught expected exception " + ex.toString()); + } + finally { + System.setSecurityManager(oldSecMgr); + } + } + + public class MySecurityManager extends SecurityManager { + public void checkPermission(Permission perm) { + if (perm==JDOPermission.CLOSE_PERSISTENCE_MANAGER_FACTORY) + throw new SecurityException( + "JDOPermission.CLOSE_PERSISTENCE_MANAGER_FACTORY not set"); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManager.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManager.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManager.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManager.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,101 @@ +/* + * 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.util.Properties; + +import javax.jdo.PersistenceManager; +import javax.jdo.PersistenceManagerFactory; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.util.BatchTestRunner; + + +/** + *<B>Title:</B>GetPersistenceManager of PersistenceManagerFactory + *<BR> + *<B>Keywords:</B> persistencemanagerfactory + *<BR> + *<B>Assertion IDs:</B> A11.3-1. + *<BR> + *<B>Assertion Description: </B> + * PersistenceManagerFactory.getPersistenceManager() returns a +PersistenceManager instance with the configured properties and the +default values for option settings. + */ + +/* + * Revision History + * ================ + * Author : Linga Neerathilingam + * Date : 10/22/01 + * + */ + +public class GetPersistenceManager extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A11.3-1 (GetPersistenceManager) failed: "; + + /** + * 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(GetPersistenceManager.class); + } + + private PersistenceManagerFactory pmf; + private PersistenceManager pm; + private String pmfClass; + private String url; + private String username; + private String password; + + private static String PMFCLASS = "javax.jdo.PersistenceManagerFactoryClass"; + private static String URL = "javax.jdo.option.ConnectionURL"; + private static String USERNAME = "javax.jdo.option.ConnectionUserName"; + private static String PASSWORD = "javax.jdo.option.ConnectionPassword"; + + + public void test() { + Properties props = loadProperties(PMFProperties); + pmfClass = props.getProperty(PMFCLASS); + url = props.getProperty(URL); + username = props.getProperty(USERNAME); + password = props.getProperty(PASSWORD); + + try { + Class cl = Class.forName(pmfClass); + pmf = (PersistenceManagerFactory) cl.newInstance(); + pmf.setConnectionURL(url); + pmf.setConnectionUserName(username); + pmf.setConnectionPassword(password); + pm = pmf.getPersistenceManager(); + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "unexpected exception " + ex); + } + finally { + if (debug) logger.debug("Persistence Manager obtained: " + pm); + if (pm != null) pm.close(); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerFactoryByPropertiesInstance.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerFactoryByPropertiesInstance.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerFactoryByPropertiesInstance.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerFactoryByPropertiesInstance.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,70 @@ +/* + * 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.util.Date; + +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.company.Company; +import org.apache.jdo.tck.pc.company.Address; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *<B>Title:</B>Close of PersistenceManagerFactory + *<BR> + *<B>Keywords:</B> persistencemanagerfactory + *<BR> + *<B>Assertion IDs:</B> A11.1-32 + *<BR> + *<B>Assertion Description: </B> + * An implementation must provide a method to construct a PersistenceManagerFactory by a Properties instance. + * This static method is called by the JDOHelper method getPersistenceManagerFactory (Properties props). + */ + + +public class GetPersistenceManagerFactoryByPropertiesInstance extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertions A11.1-32 (GetPersistenceManagerFactoryByPropertiesInstance) failed: "; + + /** + * 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(GetPersistenceManagerFactoryByPropertiesInstance.class); + } + + /** */ + public void test() { + PMFPropertiesObject = loadProperties(PMFProperties); + pmf = JDOHelper.getPersistenceManagerFactory(PMFPropertiesObject); + //Try to get a PersistenceManager and begin and commit a transaction + pm = pmf.getPersistenceManager(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + Company comp = new Company(1L, "Sun Microsystems", new Date(), new Address(0,"","","","","")); + pm.makePersistent(comp); + tx.commit(); + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerForUser.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerForUser.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerForUser.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerForUser.java Fri Mar 18 17:07:39 2005 @@ -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 java.util.Properties; + +import javax.jdo.PersistenceManager; +import javax.jdo.PersistenceManagerFactory; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.util.BatchTestRunner; + + +/** + *<B>Title:</B>GetPersistenceManagerForUser of PersistenceManagerFactory + *<BR> + *<B>Keywords:</B> persistencemanagerfactory + *<BR> + *<B>Assertion IDs:</B> A11.3-2. + *<BR> + *<B>Assertion Description: </B> + * PersistenceManagerFactory.getPersistenceManager(String userid, +String password) returns a PersistenceManager instance with the +configured properties and the default values for option settings. + */ + +/* + * Revision History + * ================ + * Author : Linga Neerathilingam + * Date : 10/22/01 + * + */ + +public class GetPersistenceManagerForUser extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A11.3-2 (GetPersistenceManagerForUser) failed: "; + + /** + * 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(GetPersistenceManagerForUser.class); + } + private PersistenceManagerFactory pmf; + private PersistenceManager pm; + private String pmfClass; + private String url; + private String username; + private String password; + + private static String PMFCLASS = "javax.jdo.PersistenceManagerFactoryClass"; + private static String URL = "javax.jdo.option.ConnectionURL"; + private static String USERNAME = "javax.jdo.option.ConnectionUserName"; + private static String PASSWORD = "javax.jdo.option.ConnectionPassword"; + + /** */ + public void test() { + Properties props = loadProperties(PMFProperties); + pmfClass = props.getProperty(PMFCLASS); + url = props.getProperty(URL); + username = props.getProperty(USERNAME); + password = props.getProperty(PASSWORD); + + try { + Class cl = Class.forName(pmfClass); + pmf = (PersistenceManagerFactory) cl.newInstance(); + pmf.setConnectionURL(url); + pm = pmf.getPersistenceManager(username, password); + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "unexpected exception " + ex); + } + finally { + if (debug) logger.debug("Persistence Manager obtained: " + pm); + if (pm != null) pm.close(); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetProperties.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetProperties.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetProperties.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetProperties.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,77 @@ +/* + * 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.util.Enumeration; +import java.util.Properties; + +import javax.jdo.PersistenceManagerFactory; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.util.BatchTestRunner; + + +/** + *<B>Title:</B>Get properties of PersistenceManagerFactory + *<BR> + *<B>Keywords:</B> persistencemanagerfactory + *<BR> + *<B>Assertion IDs:</B> A11.4-1. + *<BR> + *<B>Assertion Description: </B> + PersistenceManagerFactory.getProperties() returns a Properties instance + containing two standard JDO implementation properties + VendorName: The name of the JDO vendor. + VersionNumber: The version number string. + */ + +public class GetProperties extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A11.4-1 (GetProperties) failed: "; + + /** + * 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); + } + + /** */ + public void test() { + PersistenceManagerFactory pmf = getPMF(); + int foundStandardProperties = 0; + + Properties p = pmf.getProperties(); + for (Enumeration e = p.propertyNames(); e.hasMoreElements(); ) { + String s = (String) e.nextElement(); + if (debug) logger.debug ("\t" + s + ": " + p.getProperty(s)); + + if (s.equals("VendorName") || s.equals("VersionNumber")) { + foundStandardProperties++; + } + } + + if (foundStandardProperties != 2) { + fail(ASSERTION_FAILED, + "Standard properties not found."); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionPassword.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionPassword.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionPassword.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionPassword.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,84 @@ +/* + * 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.util.Properties; + +import javax.jdo.PersistenceManager; +import javax.jdo.PersistenceManagerFactory; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.util.BatchTestRunner; + + +/** + *<B>Title:</B>Set ConnectionPassword of persistencemanagerfactory + *<BR> + *<B>Keywords:</B> persistencemanagerfactory + *<BR> + *<B>Assertion IDs:</B> A11.1-15. + *<BR> + *<B>Assertion Description: </B> + * PersistenceManagerFactory.setConnectionPassword(String +password) sets the value of the ConnectionPassword property (the password for the user) + */ + +public class SetConnectionPassword extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A11.1-15 (SetConnectionPassword) failed: "; + + /** + * 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(SetConnectionPassword.class); + } + + private PersistenceManagerFactory pmf; + private PersistenceManager pm; + private String pmfClass; + private String url; + private String username; + private String password; + + private static String PMFCLASS = "javax.jdo.PersistenceManagerFactoryClass"; + private static String URL = "javax.jdo.option.ConnectionURL"; + private static String USERNAME = "javax.jdo.option.ConnectionUserName"; + private static String PASSWORD = "javax.jdo.option.ConnectionPassword"; + + /** set ConnectionPassword */ + public void test() { + Properties props = loadProperties(PMFProperties); + pmfClass = props.getProperty(PMFCLASS); + url = props.getProperty(URL); + username = props.getProperty(USERNAME); + password = props.getProperty(PASSWORD); + + try { + Class cl = Class.forName(pmfClass); + pmf = (PersistenceManagerFactory) cl.newInstance(); + pmf.setConnectionPassword(password); + } catch (Exception ex) { + fail(ASSERTION_FAILED, + "Failed in setting ConnectionPassword " + ex); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionURL.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionURL.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionURL.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionURL.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,93 @@ +/* + * 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.util.Properties; + +import javax.jdo.PersistenceManager; +import javax.jdo.PersistenceManagerFactory; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.util.BatchTestRunner; + + +/** + *<B>Title:</B>Set ConnectionURL of PersistenceManagerFactory + *<BR> + *<B>Keywords:</B> persistencemanagerfactory + *<BR> + *<B>Assertion IDs:</B> A11.1-16,A11.1-17. + *<BR> + *<B>Assertion Description: </B> + * PersistenceManagerFactory.setConnectionURL(String URL) sets the value of the ConnectionURL property (the URL for the data source). + * PersistenceManagerFactory.getConnectionURL() returns the value of the ConnectionURL property. + */ + +public class SetConnectionURL extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A11.1-16,A11.1-17 (SetConnectionURL) failed: "; + + /** + * 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(SetConnectionURL.class); + } + + private PersistenceManagerFactory pmf; + private PersistenceManager pm; + private String pmfClass; + private String url; + private String username; + private String password; + + private static String PMFCLASS = "javax.jdo.PersistenceManagerFactoryClass"; + private static String URL = "javax.jdo.option.ConnectionURL"; + private static String USERNAME = "javax.jdo.option.ConnectionUserName"; + private static String PASSWORD = "javax.jdo.option.ConnectionPassword"; + + + /** set ConnectionURL value and get ConnectionURL value to verify */ + public void test() { + Properties props = loadProperties(PMFProperties); + pmfClass = props.getProperty(PMFCLASS); + url = props.getProperty(URL); + username = props.getProperty(USERNAME); + password = props.getProperty(PASSWORD); + + try { + Class cl = Class.forName(pmfClass); + pmf = (PersistenceManagerFactory) cl.newInstance(); + pmf.setConnectionURL(url); + if (!url.equals(pmf.getConnectionURL())) { + fail(ASSERTION_FAILED, + "ConnectionURL " + url + + " not equal to value returned by PMF " + + pmf.getConnectionURL()); + } + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "Failed in setting ConnectionURL" + ex); + } + if (debug) logger.debug("ConnectionURL: " + pmf.getConnectionURL()); + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionUserName.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionUserName.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionUserName.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionUserName.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,94 @@ +/* + * 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.util.Properties; + +import javax.jdo.PersistenceManager; +import javax.jdo.PersistenceManagerFactory; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.util.BatchTestRunner; + + +/** + *<B>Title:</B>Set ConnectionUserName of PersistenceManagerFactory + *<BR> + *<B>Keywords:</B> persistencemanagerfactory + *<BR> + *<B>Assertion IDs:</B> A11.1-13,A11.1-14. + *<BR> + *<B>Assertion Description: </B> +PersistenceManagerFactory.setConnectionUserName(String name) sets the +value of the ConnectionUserName property (the name of the user establishing the connection). + */ + +public class SetConnectionUserName extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertions A11.1-13,A11.1-14 (SetConnectionUserName) failed: "; + + /** + * 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(SetConnectionUserName.class); + } + + private PersistenceManagerFactory pmf; + private PersistenceManager pm; + private String pmfClass; + private String url; + private String username; + private String password; + + private static String PMFCLASS = "javax.jdo.PersistenceManagerFactoryClass"; + private static String URL = "javax.jdo.option.ConnectionURL"; + private static String USERNAME = "javax.jdo.option.ConnectionUserName"; + private static String PASSWORD = "javax.jdo.option.ConnectionPassword"; + + + /** set ConnectionUserName value and get ConnectionUserName value to verify */ + public void test() { + Properties props = loadProperties(PMFProperties); + pmfClass = props.getProperty(PMFCLASS); + url = props.getProperty(URL); + username = props.getProperty(USERNAME); + password = props.getProperty(PASSWORD); + + try { + Class cl = Class.forName(pmfClass); + pmf = (PersistenceManagerFactory) cl.newInstance(); + pmf.setConnectionUserName(username); + if (!username.equals(pmf.getConnectionUserName())) { + fail(ASSERTION_FAILED, + "ConnectionUserName " + username + + " not equal to value returned by PMF " + + pmf.getConnectionUserName()); + } + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "Failed in setting ConnectionUserName " + ex); + } + if (debug) + logger.debug("ConnectionUserName: " + pmf.getConnectionUserName()); + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetIgnoreCache.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetIgnoreCache.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetIgnoreCache.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetIgnoreCache.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,103 @@ +/* + * 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.util.Properties; + +import javax.jdo.PersistenceManager; +import javax.jdo.PersistenceManagerFactory; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *<B>Title:</B>Set IgnoreCache of persistencemanagerfactory + *<BR> + *<B>Keywords:</B> persistencemanagerfactory + *<BR> + *<B>Assertion IDs:</B> A11.1-5. + *<BR> + *<B>Assertion Description: </B> +PersistenceManagerFactory.setIgnoreCache(boolean flag) sets the value of the IgnoreCache property (the query mode that specifies whether cached instances are considered when evaluating the filter expression). + */ + +/* + * Revision History + * ================ + * Author : Linga Neerathilingam + * Date : 10/15/01 + * Version : 1.0 + * + */ + +public class SetIgnoreCache extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A11.1-5 (SetIgnoreCache) failed: "; + + /** + * 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(SetIgnoreCache.class); + } + + private PersistenceManagerFactory pmf; + private PersistenceManager pm; + private String pmfClass; + private String url; + private String username; + private String password; + + private static String PMFCLASS = "javax.jdo.PersistenceManagerFactoryClass"; + private static String URL = "javax.jdo.option.ConnectionURL"; + private static String USERNAME = "javax.jdo.option.ConnectionUserName"; + private static String PASSWORD = "javax.jdo.option.ConnectionPassword"; + + + /** set IgnoreCache to true or false and use getIgnoreCache value to verify */ + public void test() { + Properties props = loadProperties(PMFProperties); + pmfClass = props.getProperty(PMFCLASS); + url = props.getProperty(URL); + username = props.getProperty(USERNAME); + password = props.getProperty(PASSWORD); + + try { + Class cl = Class.forName(pmfClass); + pmf = (PersistenceManagerFactory) cl.newInstance(); + pmf.setIgnoreCache(false); + if (pmf.getIgnoreCache() != false) { + fail(ASSERTION_FAILED, + "IgnoreCache set to false, value returned by PMF is " + + pmf.getIgnoreCache()); + } + pmf.setIgnoreCache(true); + if (pmf.getIgnoreCache() != true) { + fail(ASSERTION_FAILED, + "IgnoreCache set to true, value returned by PMF is " + + pmf.getIgnoreCache()); + } + } catch (Exception ex) { + fail(ASSERTION_FAILED, + "Failed in setting IgnoreCache" + ex); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetMultithreaded.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetMultithreaded.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetMultithreaded.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetMultithreaded.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,104 @@ +/* + * 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.util.Properties; + +import javax.jdo.PersistenceManager; +import javax.jdo.PersistenceManagerFactory; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.util.BatchTestRunner; + + +/** + *<B>Title:</B>Set Multithreaded of persistencemanagerfactory + *<BR> + *<B>Keywords:</B> persistencemanagerfactory + *<BR> + *<B>Assertion IDs:</B> A11.1-11,A11.1-12. + *<BR> + *<B>Assertion Description: </B> + *PersistenceManagerFactory.setMultithreaded(boolean flag) sets the value of the Multithreaded flag that indicates that the application will invoke methods or access fields of managed instances from multiple threads. + */ + +/* + * Revision History + * ================ + * Author : Linga Neerathilingam + * Date : 10/15/01 + * Version : 1.0 + * + */ + +public class SetMultithreaded extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertions A11.1-11,A11.1-12 (SetMultithreaded) failed: "; + + /** + * 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(SetMultithreaded.class); + } + + private PersistenceManagerFactory pmf; + private PersistenceManager pm; + private String pmfClass; + private String url; + private String username; + private String password; + + private static String PMFCLASS = "javax.jdo.PersistenceManagerFactoryClass"; + private static String URL = "javax.jdo.option.ConnectionURL"; + private static String USERNAME = "javax.jdo.option.ConnectionUserName"; + private static String PASSWORD = "javax.jdo.option.ConnectionPassword"; + + /** set Multithreaded to true or false and use getMultithreaded value to verify */ + public void test() { + Properties props = loadProperties(PMFProperties); + pmfClass = props.getProperty(PMFCLASS); + url = props.getProperty(URL); + username = props.getProperty(USERNAME); + password = props.getProperty(PASSWORD); + + try { + Class cl = Class.forName(pmfClass); + pmf = (PersistenceManagerFactory) cl.newInstance(); + pmf.setMultithreaded(true); + if (pmf.getMultithreaded() != true) { + fail(ASSERTION_FAILED, + "Multithreaded set to true, value returned by PMF is " + + pmf.getMultithreaded()); + } + pmf.setMultithreaded(false); + if (pmf.getMultithreaded() != false) { + fail(ASSERTION_FAILED, + "Multithreaded set to false, value returned by PMF is " + + pmf.getMultithreaded()); + } + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "Failed in setting Multithreaded " + ex); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalRead.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalRead.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalRead.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalRead.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,105 @@ +/* + * 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.util.Properties; + +import javax.jdo.PersistenceManager; +import javax.jdo.PersistenceManagerFactory; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.util.BatchTestRunner; + + +/** + *<B>Title:</B>Set NonTransactionalRead of persistencemanagerfactory + *<BR> + *<B>Keywords:</B> persistencemanagerfactory + *<BR> + *<B>Assertion IDs:</B> A11.1-7,A11.1-8. + *<BR> + *<B>Assertion Description: </B> + *PersistenceManagerFactory.setNontransactionalRead(boolean flag) sets the value of the NontransactionalRead property (the PersistenceManager mode that allows instances to be read outside a transaction). + */ + +/* + * Revision History + * ================ + * Author : Linga Neerathilingam + * Date : 10/15/01 + * Version : 1.0 + * + */ + +public class SetNonTransactionalRead extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertions A11.1-7,A11.1-8 (SetNonTransactionalRead) failed: "; + + /** + * 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(SetNonTransactionalRead.class); + } + + private PersistenceManagerFactory pmf; + private PersistenceManager pm; + private String pmfClass; + private String url; + private String username; + private String password; + + private static String PMFCLASS = "javax.jdo.PersistenceManagerFactoryClass"; + private static String URL = "javax.jdo.option.ConnectionURL"; + private static String USERNAME = "javax.jdo.option.ConnectionUserName"; + private static String PASSWORD = "javax.jdo.option.ConnectionPassword"; + + + /** set NonTransactionalRead to true or false and use getNonTransactionalRead value to verify */ + public void test() { + Properties props = loadProperties(PMFProperties); + pmfClass = props.getProperty(PMFCLASS); + url = props.getProperty(URL); + username = props.getProperty(USERNAME); + password = props.getProperty(PASSWORD); + + try { + Class cl = Class.forName(pmfClass); + pmf = (PersistenceManagerFactory) cl.newInstance(); + pmf.setNontransactionalRead(false); + if (pmf.getNontransactionalRead() != false) { + fail(ASSERTION_FAILED, + "NonTransactionalRead set to false, value returned by PMF is " + + pmf.getNontransactionalRead()); + } + pmf.setNontransactionalRead(true); + if (pmf.getNontransactionalRead() != true) { + fail(ASSERTION_FAILED, + "NonTransactionalRead set to true, value returned by PMF is " + + pmf.getNontransactionalRead()); + } + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "Failed in setting NonTransactionalRead " + ex); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalWrite.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalWrite.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalWrite.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalWrite.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,104 @@ +/* + * 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.util.Properties; + +import javax.jdo.PersistenceManager; +import javax.jdo.PersistenceManagerFactory; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.util.BatchTestRunner; + + +/** + *<B>Title:</B>Set NonTransactionalWrite of persistencemanagerfactory + *<BR> + *<B>Keywords:</B> persistencemanagerfactory + *<BR> + *<B>Assertion IDs:</B> A11.1-9,A11.1-10. + *<BR> + *<B>Assertion Description: </B> + * PersistenceManagerFactory.setNontransactionalWrite(boolean flag) sets the value of the NontransactionalWrite property (the PersistenceManager mode that allows instances to be written outside a transaction). + */ + +/* + * Revision History + * ================ + * Author : Linga Neerathilingam + * Date : 10/15/01 + * Version : 1.0 + * + */ + +public class SetNonTransactionalWrite extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertions A11.1-9,A11.1-10 (SetNonTransactionalWrite) failed: "; + + /** + * 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(SetNonTransactionalWrite.class); + } + + private PersistenceManagerFactory pmf; + private PersistenceManager pm; + private String pmfClass; + private String url; + private String username; + private String password; + + private static String PMFCLASS = "javax.jdo.PersistenceManagerFactoryClass"; + private static String URL = "javax.jdo.option.ConnectionURL"; + private static String USERNAME = "javax.jdo.option.ConnectionUserName"; + private static String PASSWORD = "javax.jdo.option.ConnectionPassword"; + + + /** set NonTransactionalWrite to true or false and use getNonTransactionalWrite value to verify */ + public void test () { + Properties props = loadProperties(PMFProperties); + pmfClass = props.getProperty(PMFCLASS); + url = props.getProperty(URL); + username = props.getProperty(USERNAME); + password = props.getProperty(PASSWORD); + + try { + Class cl = Class.forName(pmfClass); + pmf = (PersistenceManagerFactory) cl.newInstance(); + pmf.setNontransactionalWrite(false); + if (pmf.getNontransactionalWrite() != false) { + fail(ASSERTION_FAILED, + "NonTransactionalWrite set to false, value returned by PMF is " + + pmf.getNontransactionalWrite()); + } + pmf.setNontransactionalWrite(true); + if (pmf.getNontransactionalWrite() != true) { + fail(ASSERTION_FAILED, + "NonTransactionalWrite set to true, value returned by PMF is " + + pmf.getNontransactionalWrite()); + } + } catch (Exception ex) { + fail(ASSERTION_FAILED, + "Failed in setting NonTransactionalWrite " + ex); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetOptimistic.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetOptimistic.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetOptimistic.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetOptimistic.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,102 @@ +/* + * 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.util.Properties; + +import javax.jdo.PersistenceManager; +import javax.jdo.PersistenceManagerFactory; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.util.BatchTestRunner; + + +/** + *<B>Title:</B>Set optimistic of persistencemanagerfactory + *<BR> + *<B>Keywords:</B> persistencemanagerfactory + *<BR> + *<B>Assertion IDs:</B> A11.1-1, A11.1-2. + *<BR> + *<B>Assertion Description: </B> + PersistenceManagerFactory.getOptimistic() returns Value of the Optimistic property,persistenceManagerFactory.setOptimistic(boolean flag) sets +the value of the Optimistic property (the transaction mode that specifies concurrency control + */ + +public class SetOptimistic extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A11.1-1, A11.1-2 (SetOptimistic) failed: "; + + /** + * 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(SetOptimistic.class); + } + + private PersistenceManagerFactory pmf; + private PersistenceManager pm; + private String pmfClass; + private String url; + private String username; + private String password; + + private static String PMFCLASS = "javax.jdo.PersistenceManagerFactoryClass"; + private static String URL = "javax.jdo.option.ConnectionURL"; + private static String USERNAME = "javax.jdo.option.ConnectionUserName"; + private static String PASSWORD = "javax.jdo.option.ConnectionPassword"; + + /** set Optimistic to true or false and use getOptimistic value to verify */ + public void test() { + if (!isOptimisticSupported()) { + if (debug) + logger.debug("\n SetOptimistic() passed: this implementation does not support Optimistic."); + return; + } + + Properties props = loadProperties(PMFProperties); + pmfClass = props.getProperty(PMFCLASS); + url = props.getProperty(URL); + username = props.getProperty(USERNAME); + password = props.getProperty(PASSWORD); + + try { + Class cl = Class.forName(pmfClass); + pmf = (PersistenceManagerFactory) cl.newInstance(); + pmf.setOptimistic(false); + if (pmf.getOptimistic() != false) { + fail(ASSERTION_FAILED, + "Optimistic set to false, value returned by PMF is " + + pmf.getOptimistic()); + } + pmf.setOptimistic(true); + if (pmf.getOptimistic() != true) { + fail(ASSERTION_FAILED, + "Optimistic set to true, value returned by PMF is " + + pmf.getOptimistic()); + } + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "Failed in setting Optimistic " + ex); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetRetainValues.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetRetainValues.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetRetainValues.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetRetainValues.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,104 @@ +/* + * 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.util.Properties; + +import javax.jdo.PersistenceManager; +import javax.jdo.PersistenceManagerFactory; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *<B>Title:</B>Set RetainValues of persistencemanagerfactory + *<BR> + *<B>Keywords:</B> persistencemanagerfactory + *<BR> + *<B>Assertion IDs:</B> A11.1-3,A11.1-4. + *<BR> + *<B>Assertion Description: </B> + * PersistenceManagerFactory.setRetainValues(boolean flag) sets the value of the RetainValues property (the transaction mode that specifies the treatment of persistent instances after commit), +PersistenceManagerFactory.getRetainValues() returns the value of the +RetainValues property. + */ + +/* + * Revision History + * ================ + * Author : Linga Neerathilingam + * Date : 10/18/01 + * Version : 1.0 + * + */ + +public class SetRetainValues extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A11.1-3,A11.1-4 (SetRetainValues) failed: "; + + /** + * 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(SetRetainValues.class); + } + + private PersistenceManagerFactory pmf; + private PersistenceManager pm; + private String pmfClass; + private String url; + private String username; + private String password; + + private static String PMFCLASS = "javax.jdo.PersistenceManagerFactoryClass"; + private static String URL = "javax.jdo.option.ConnectionURL"; + private static String USERNAME = "javax.jdo.option.ConnectionUserName"; + private static String PASSWORD = "javax.jdo.option.ConnectionPassword"; + + /** set RetainValues to true or false and use getRetainValues value to verify */ + public void test() { + Properties props = loadProperties(PMFProperties); + pmfClass = props.getProperty(PMFCLASS); + url = props.getProperty(URL); + username = props.getProperty(USERNAME); + password = props.getProperty(PASSWORD); + + try { + Class cl = Class.forName(pmfClass); + pmf = (PersistenceManagerFactory) cl.newInstance(); + pmf.setRetainValues(false); + if (pmf.getRetainValues() != false) { + fail(ASSERTION_FAILED, + "RetainValues set to false, value returned by PMF is " + + pmf.getRetainValues()); + } + pmf.setRetainValues(true); + if (pmf.getRetainValues() != true) { + fail(ASSERTION_FAILED, + "RetainValues set to true, value returned by PMF is " + + pmf.getRetainValues()); + } + } catch (Exception ex) { + fail(ASSERTION_FAILED, + "Failed in setting RetainValues " + ex); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SupportedOptions.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SupportedOptions.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SupportedOptions.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/SupportedOptions.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,75 @@ +/* + * 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.util.Collection; +import java.util.Iterator; + +import javax.jdo.PersistenceManagerFactory; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.util.BatchTestRunner; + + +/** + *<B>Title:</B>SupportedOptions of persistencemanagerfactory + *<BR> + *<B>Keywords:</B> persistencemanagerfactory + *<BR> + *<B>Assertion IDs:</B> A11.5-1. + *<BR> + *<B>Assertion Description: </B> + * PersistenceManagerFactory.supportedOptions() returns a Collection +of String, each String instance representing an optional feature of the +implementation or a supported query language. + */ + +/* + * Revision History + * ================ + * Author : Linga Neerathilingam + * Date : 10/22/01 + * + */ + +public class SupportedOptions extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A11.5-1 (SupportedOptions) failed: "; + + /** + * 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(SupportedOptions.class); + } + + /** */ + public void test() { + PersistenceManagerFactory pmf = getPMF(); + if (debug) logger.debug("Options supported by this implementation:"); + Collection c = pmf.supportedOptions(); + Iterator iter = c.iterator(); + while( iter.hasNext() ){ + String option = (String) iter.next(); + if (debug) logger.debug(option); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/enhancement/EnhancerTest.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/enhancement/EnhancerTest.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/enhancement/EnhancerTest.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/enhancement/EnhancerTest.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,100 @@ +/* + * 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. + */ + +/* + * EnhancerTest.java + * + * Created on February 17, 2002, 1:59 PM + */ + +package org.apache.jdo.tck.enhancement; + +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; +import java.util.Properties; +import java.util.StringTokenizer; + +import org.apache.jdo.tck.JDO_Test; + +/** + * + * @author Craig Russell + * @version 1.0 + */ +public abstract class EnhancerTest extends JDO_Test { + + /** Creates new EnhancerTest */ + public EnhancerTest() { + } + + /** */ + protected Properties getProperties(String resourceName) { + Properties props = null; + try { + InputStream in = this.getClass().getClassLoader().getResourceAsStream(resourceName); + props = new Properties(); + props.load(in); + } catch (Exception ex) { + ex.printStackTrace(); + fail("EnhancerTest:", + "Error loading properties " + resourceName + " exception " + ex); + } + return props; + } + + /** */ + protected abstract void runTestOnePackage (String packageName, List fullyQualifiedClassNameList); + + /** */ + protected String convertClassName (String packageName, String className) { + return packageName + "." + className; + } + + /** */ + void runTestAllPackages() { + /** First, get classes to test from properties file. + */ + Properties classesToTest = getProperties("enhancement-test.properties"); //NOI18N + + Enumeration enum = classesToTest.propertyNames(); + int numberOfPackages = 0; + + /** Each key is a package name; the value is a list of class names to test. + */ + while (enum.hasMoreElements()) { + ++numberOfPackages; + String packageName = (String) enum.nextElement(); + if (debug) logger.debug("EnhancerTest Package: " + packageName); + String classNames = (String) classesToTest.get(packageName); + if (debug) logger.debug("EnhancerTest Classes: " + classNames); + StringTokenizer st = new StringTokenizer(classNames, " ,"); + ArrayList classNameList = new ArrayList(); + /** Each entry is a list of class names separated by comma or space + */ + while (st.hasMoreTokens()) { + String className = st.nextToken(); + String listEntry = convertClassName(packageName, className); + classNameList.add (listEntry); + if (debug) logger.debug("EnhancerTest Class: " + className); + } + runTestOnePackage (packageName, classNameList); + } + if (debug) logger.debug("EnhancerTest numberOfPackages: " + numberOfPackages); + return; + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/enhancement/FieldAccessModified.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/enhancement/FieldAccessModified.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/enhancement/FieldAccessModified.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/enhancement/FieldAccessModified.java Fri Mar 18 17:07:39 2005 @@ -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.enhancement; + +import java.io.PrintWriter; +import java.util.Arrays; +import java.util.List; + +import org.apache.jdo.impl.enhancer.util.AnnotationTest; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *<B>Title:</B> FieldAccessModified + *<BR> + *<B>Keywords:</B> enhancement + *<BR> + *<B>Assertion ID:</B> . + *<BR> + *<B>Assertion Description: </B> +The enhancer modifies field accesses to guarantee that the values of fields +are retrieved from the data store prior to application usage. +<OL TYPE="A"> +<LI>For any field access that reads the value of a field, the getfield byte code +is replaced with a call to a generated local method, <code>jdoGetXXX</code></LI> +<LI>For any field access that stores the new value of a field, the putfield +byte code is replaced with a call to a generated local method, +<code>jdoSetXXX</code></LI> +</OL> + + */ + +public class FieldAccessModified extends EnhancerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion (FieldAccessModified) failed: "; + + /** + * 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(FieldAccessModified.class); + } + + + /** */ + public void test() { + if (debug) + logger.debug("org.apache.jdo.tck.enhancement.FieldAccessModified.run"); + PMFPropertiesObject = loadProperties(PMFProperties); // will exit here if no properties + runTestAllPackages(); + cleanup(); + } + + /** */ + protected void runTestOnePackage (String packageName, List classNames) { + if (debug) + logger.debug("FieldAccessModified.testOnePackage: " + + packageName + " classes " + classNames); + + PrintWriter out = new PrintWriter(System.out); + final AnnotationTest test = new AnnotationTest(out, out); + final String classpath = System.getProperty("java.class.path"); + final String jdoPropertiesFileName = + packageName.replace ('.', '/') + "/jdoTest.properties"; //NOI18N + final String[] args = new String[classNames.size() + 6]; + int index = 0; + // init arguments for AnnotationTest.run call + // specify properties file + args[index++] = "--properties"; + args[index++] = jdoPropertiesFileName; + // specify jdo path to find the properties file + args[index++] = "-j"; + args[index++] = classpath; + // specify source path to find the classes + args[index++] = "-s"; + args[index++] = classpath; + // add class names + for (java.util.Iterator i = classNames.iterator(); i.hasNext();) { + args[index++] = (String)i.next(); + } + if (debug) + logger.debug ("Run AnnotationTest with args " + Arrays.asList(args)); + int errors = test.run(args); + if (errors > 0) { + fail(ASSERTION_FAILED, + "AnnotationTest with args " + Arrays.asList(args) + + " results in " + errors + " errors."); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/enhancement/ImplementsPersistenceCapable.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/enhancement/ImplementsPersistenceCapable.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/enhancement/ImplementsPersistenceCapable.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/enhancement/ImplementsPersistenceCapable.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,100 @@ +/* + * 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.enhancement; + +import java.io.PrintWriter; +import java.util.Arrays; +import java.util.List; + +import org.apache.jdo.impl.enhancer.util.AugmentationTest; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *<B>Title:</B> Implements PersistenceCapable Added + *<BR> + *<B>Keywords:</B> enhancement + *<BR> + *<B>Assertion ID:</B> A20.3-0. + *<BR> + *<B>Assertion Description: </B> +The Reference Enhancer makes the following change +to persistence-capable classes: +it adds <code>"implements javax.jdo.PersistenceCapable</code>" +to the class definition. + + */ + +public class ImplementsPersistenceCapable extends EnhancerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A20.3-0 (ImplementsPersistenceCapable) failed: "; + + /** + * 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(ImplementsPersistenceCapable.class); + } + + /** */ + public void test() { + if (debug) + logger.debug("org.apache.jdo.tck.enhancement.ImplementsPersistenceCapable.run"); + runTestAllPackages(); + cleanup(); + } + + /** */ + protected void runTestOnePackage (String packageName, List classNames) { + if (debug) + logger.debug("ImplementsPersistenceCapable.testOnePackage: " + + packageName + " classes " + classNames); + + PrintWriter out = new PrintWriter(System.out); + final AugmentationTest test = new AugmentationTest(out, out); + final String classpath = System.getProperty("java.class.path"); + final String jdoPropertiesFileName = + packageName.replace ('.', '/') + "/jdoTest.properties"; //NOI18N + final String[] args = new String[classNames.size() + 6]; + int index = 0; + // init arguments for AugmentationTest.run call + // specify properties file + args[index++] = "--properties"; + args[index++] = jdoPropertiesFileName; + // specify jdo path to find the properties file + args[index++] = "-j"; + args[index++] = classpath; + // specify source path to find the classes + args[index++] = "-s"; + args[index++] = classpath; + // add class names + for (java.util.Iterator i = classNames.iterator(); i.hasNext();) { + args[index++] = (String)i.next(); + } + if (debug) + logger.debug ("Run AugmentationTest with args " + Arrays.asList(args)); + int errors = test.run(args); + if (errors > 0) { + fail(ASSERTION_FAILED, + "AugmentationTest with args " + Arrays.asList(args) + + " results in " + errors + " errors."); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/extents/CloseAll.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/extents/CloseAll.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/extents/CloseAll.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/extents/CloseAll.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,85 @@ +/* + * 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.extents; + +import java.util.Iterator; + +import javax.jdo.Extent; + +import org.apache.jdo.tck.pc.company.Employee; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *<B>Title:</B> CloseAll + *<BR> + *<B>Keywords:</B> extent + *<BR> + *<B>Assertion ID:</B> A15.3-12. + *<BR> + *<B>Assertion Description: </B> +After a call to <code>Extent.closeAll()</code>, all iterators acquired from this +<code>Extent</code> will return <code>false</code> to <code>hasNext()</code>. + + */ + +public class CloseAll extends ExtentTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A15.3-12 (CloseAll) failed: "; + + /** + * 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(CloseAll.class); + } + + /** */ + public void test() { + try { + beginTransaction(); + Extent ex = getPM().getExtent (Employee.class, true); + Iterator it1 = ex.iterator(); + deleteEmployee((Employee)it1.next()); + Iterator it2 = ex.iterator(); + addEmployee(); + Iterator it3 = ex.iterator(); + ex.closeAll(); + if (it1.hasNext()) { + fail(ASSERTION_FAILED, + "After extent.closeAll() iterator1.hasNext(): " + it1.hasNext()); + } + if (it2.hasNext()) { + fail(ASSERTION_FAILED, + "After extent.closeAll() iterator2.hasNext(): " + it2.hasNext()); + } + if (it3.hasNext()) { + fail(ASSERTION_FAILED, + "After extent.closeAll() iterator3.hasNext(): " + it3.hasNext()); + } + if (debug) logger.debug("Assertion A15.3-12 passed"); + } + finally { + rollbackTransaction(); + cleanup(); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/extents/CloseOfExtentIteratorIsIteratorSpecific.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/extents/CloseOfExtentIteratorIsIteratorSpecific.java?view=auto&rev=158179 ============================================================================== --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/extents/CloseOfExtentIteratorIsIteratorSpecific.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/extents/CloseOfExtentIteratorIsIteratorSpecific.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,77 @@ +/* + * 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.extents; + +import java.util.Collection; +import java.util.Iterator; + +import javax.jdo.Extent; +import javax.jdo.Query; + +import org.apache.jdo.tck.util.BatchTestRunner; + + +/** + *<B>Title:</B> Close of Extent Iterator is Iterator Specific + *<BR> + *<B>Keywords:</B> extent + *<BR> + *<B>Assertion ID:</B> A15.3-11. + *<BR> + *<B>Assertion Description: </B> +After a call to <code>Extent.close(Iterator i)</code>, +the <code>Extent</code> itself can still be used to acquire other +iterators and can be used as the <code>Extent</code> for queries. + + */ + +public class CloseOfExtentIteratorIsIteratorSpecific extends ExtentTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A15.3-11 (CloseOfExtentIteratorIsIteratorSpecific) failed: "; + + /** + * 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(CloseOfExtentIteratorIsIteratorSpecific.class); + } + + /** */ + public void test() { + Extent ex = getExtent(); + Iterator it1 = ex.iterator(); + ex.close(it1); + int count = countIterator(ex.iterator()); + if (count != 2) { + fail(ASSERTION_FAILED, + "iterating Employees after close of first iterator; counted " + count + " instances; should be 2"); + } + Query q = getPM().newQuery(ex); + Collection c = (Collection)q.execute(); + int count2 = countIterator(c.iterator()); + if (count2 != 2) { + fail(ASSERTION_FAILED, + "in query after closing iterator; counted " + count + " instances; should be 2"); + } + if (debug) logger.debug("Assertion A15.3-11 passed"); + } +}