[jboss-cvs] JBossAS SVN: r60450 - in trunk/ejb3/src: test/org/jboss/ejb3/test/timestampentity/entity and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Feb 8 20:25:57 EST 2007
Author: bdecoste
Date: 2007-02-08 20:25:57 -0500 (Thu, 08 Feb 2007)
New Revision: 60450
Added:
trunk/ejb3/src/resources/test/timestampentity/META-INF/persistence.xml
trunk/ejb3/src/test/org/jboss/ejb3/test/timestampentity/entity/Table1IntegerEntity.java
trunk/ejb3/src/test/org/jboss/ejb3/test/timestampentity/entity/Table1Key.java
trunk/ejb3/src/test/org/jboss/ejb3/test/timestampentity/entity/Table1TimestampEntity.java
trunk/ejb3/src/test/org/jboss/ejb3/test/timestampentity/unit/EntityUnitTestCase.java
Log:
test for closing resources for Entities with timestamp fields
Added: trunk/ejb3/src/resources/test/timestampentity/META-INF/persistence.xml
===================================================================
--- trunk/ejb3/src/resources/test/timestampentity/META-INF/persistence.xml (rev 0)
+++ trunk/ejb3/src/resources/test/timestampentity/META-INF/persistence.xml 2007-02-09 01:25:57 UTC (rev 60450)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence>
+ <persistence-unit name="tempdb">
+ <jta-data-source>java:/DefaultDS</jta-data-source>
+ <properties>
+ <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+ </properties>
+ </persistence-unit>
+</persistence>
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/timestampentity/entity/Table1IntegerEntity.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/timestampentity/entity/Table1IntegerEntity.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/timestampentity/entity/Table1IntegerEntity.java 2007-02-09 01:25:57 UTC (rev 60450)
@@ -0,0 +1,257 @@
+/***********************************************************************************************************************************
+**
+** Research In Motion. Do not reproduce without permission in writing.
+**
+** Copyright (c) 2006 Research In Motion.
+** All rights reserved.
+**
+************************************************************************************************************************************
+*/
+package org.jboss.ejb3.test.timestampentity.entity;
+
+import javax.persistence.AttributeOverride;
+import javax.persistence.AttributeOverrides;
+import javax.persistence.Column;
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import javax.persistence.Version;
+import java.util.Date;
+
+/***********************************************************************************************************************************
+**
+** This is a entity bean primary key class for the BASAuthenticationCredentials table...Generated 4-Jan-2007 2:58:35 PM
+** by Hibernate Tools 3.2.0.beta7
+**
+** @author jgrills
+** @version T.B.D
+**
+************************************************************************************************************************************
+*/
+ at Entity
+ at Table(name = "Table1Integer")
+public class Table1IntegerEntity implements java.io.Serializable {
+
+/***********************************************************************************************************************************
+**
+** The primary key class
+**
+************************************************************************************************************************************
+*/
+ private Table1Key _table1Key;
+
+/***********************************************************************************************************************************
+**
+** The field1 attribute
+**
+************************************************************************************************************************************
+*/
+ private String _field1;
+
+/***********************************************************************************************************************************
+**
+** The fiedl2 attribute
+**
+************************************************************************************************************************************
+*/
+ private String _field2;
+
+/***********************************************************************************************************************************
+**
+** The field3 attribute
+**
+************************************************************************************************************************************
+*/
+ private Date _field3;
+
+/***********************************************************************************************************************************
+**
+** The versionNumber attribute
+**
+************************************************************************************************************************************
+*/
+ private int _versionNumber;
+
+/***********************************************************************************************************************************
+**
+** The default constructor for an Table1IntegerEntity
+**
+************************************************************************************************************************************
+*/
+ public Table1IntegerEntity () {
+
+ }
+
+/***********************************************************************************************************************************
+**
+** The minimal constructor for an Table1IntegerEntity
+**
+** @param table1Key the primary key class
+** @param field1 the field1
+** @param field2 the field2
+**
+************************************************************************************************************************************
+*/
+ public Table1IntegerEntity (Table1Key table1Key, String field1, String field2) {
+
+ _table1Key = table1Key;
+ _field1 = field1;
+ _field2 = field2;
+ }
+
+/***********************************************************************************************************************************
+**
+** The full constructor for an Table1IntegerEntity
+**
+** @param table1Key the primary key class
+** @param field1 the field1
+** @param field2 the field2
+** @param field3 the field3
+**
+************************************************************************************************************************************
+*/
+ public Table1IntegerEntity (Table1Key table1Key, String field1, String field2, Date field3) {
+
+ _table1Key = table1Key;
+ _field1 = field1;
+ _field2 = field2;
+ _field3 = field3;
+ }
+
+/***********************************************************************************************************************************
+**
+** The get method for the primary key class
+**
+** @return the primary key
+**
+************************************************************************************************************************************
+*/
+ @EmbeddedId
+ @AttributeOverrides({
+ @AttributeOverride(name = "keyfield1", column = @Column(name = "Keyfield1")),
+ @AttributeOverride(name = "keyfield2", column = @Column(name = "Keyfield2")),
+ @AttributeOverride(name = "keyfield3", column = @Column(name = "Keyfield3"))
+ })
+ public Table1Key getId () {
+
+ return _table1Key;
+ }
+
+/***********************************************************************************************************************************
+**
+** The set method for the primary key class
+**
+** @param table1Key the primary key class
+**
+************************************************************************************************************************************
+*/
+ public void setId (Table1Key table1Key) {
+
+ _table1Key = table1Key;
+ }
+
+/***********************************************************************************************************************************
+**
+** The get method for the field1
+**
+** @return the field1
+**
+************************************************************************************************************************************
+*/
+ public String getField1 () {
+
+ return _field1;
+ }
+
+/***********************************************************************************************************************************
+**
+** The set method for the field1
+**
+** @param field1 the field1
+**
+************************************************************************************************************************************
+*/
+ public void setField1 (String field1) {
+
+ _field1 = field1;
+ }
+
+/***********************************************************************************************************************************
+**
+** The get method for the field2
+**
+** @return the field2
+**
+************************************************************************************************************************************
+*/
+ public String getField2 () {
+
+ return _field2;
+ }
+
+/***********************************************************************************************************************************
+**
+** The set method for the field2
+**
+** @param field2 the field2
+**
+************************************************************************************************************************************
+*/
+ public void setField2 (String field2) {
+
+ _field2 = field2;
+ }
+
+/***********************************************************************************************************************************
+**
+** The get method for the field3
+**
+** @return the field3
+**
+************************************************************************************************************************************
+*/
+ public Date getField3 () {
+
+ return _field3;
+ }
+
+/***********************************************************************************************************************************
+**
+** The set method for the field3
+**
+** @param field3 the field3
+**
+************************************************************************************************************************************
+*/
+ public void setField3 (Date field3) {
+
+ _field3 = field3;
+ }
+
+/***********************************************************************************************************************************
+**
+** The get method for the lurnum attribute
+**
+** @return the lurnum attribute
+**
+************************************************************************************************************************************
+*/
+ @Version
+ public int getVersionNumber () {
+
+ return _versionNumber;
+ }
+
+/***********************************************************************************************************************************
+**
+** The set method for the versionNumber attribute
+**
+** @param versionNumber the versionNumber attribute
+**
+************************************************************************************************************************************
+*/
+ public void setVersionNumber (int versionNumber) {
+
+ _versionNumber = versionNumber;
+ }
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/timestampentity/entity/Table1Key.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/timestampentity/entity/Table1Key.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/timestampentity/entity/Table1Key.java 2007-02-09 01:25:57 UTC (rev 60450)
@@ -0,0 +1,194 @@
+/***********************************************************************************************************************************
+**
+** Research In Motion. Do not reproduce without permission in writing.
+**
+** Copyright (c) 2006 Research In Motion.
+** All rights reserved.
+**
+************************************************************************************************************************************
+*/
+package org.jboss.ejb3.test.timestampentity.entity;
+
+import javax.persistence.Embeddable;
+
+/***********************************************************************************************************************************
+**
+** This is a primary key class for the BMSTable1 table...Generated 27-Nov-2006 9:48:27 AM by Hibernate Tools 3.2.0.beta7
+**
+** @author jgrills
+** @version T.B.D
+**
+************************************************************************************************************************************
+*/
+ at Embeddable
+public class Table1Key implements java.io.Serializable {
+
+/***********************************************************************************************************************************
+**
+** The locale identifer
+**
+************************************************************************************************************************************
+*/
+ private String _keyField1;
+
+/***********************************************************************************************************************************
+**
+** The plugin identifier
+**
+************************************************************************************************************************************
+*/
+ private int _keyField2;
+
+/***********************************************************************************************************************************
+**
+** The string identifier
+**
+************************************************************************************************************************************
+*/
+ private String _keyField3;
+
+/***********************************************************************************************************************************
+**
+** The default constructor for a Table1 primary key
+**
+************************************************************************************************************************************
+*/
+ public Table1Key () {
+
+ }
+
+/***********************************************************************************************************************************
+**
+** The full constructor for a Table1 primary key
+**
+** @param keyField1 the localeIdentifier
+** @param keyField2 the localeIdentifier
+** @param keyField3 the localeIdentifier
+**
+************************************************************************************************************************************
+*/
+ public Table1Key (String keyField1, int keyField2, String keyField3) {
+
+ _keyField1 = keyField1;
+ _keyField2 = keyField2;
+ _keyField3 = keyField3;
+ }
+
+/***********************************************************************************************************************************
+**
+** The get method for the keyField1 identifier
+**
+** @return the keyField1 identifier
+**
+************************************************************************************************************************************
+*/
+ public String getKeyField1 () {
+
+ return _keyField1;
+ }
+
+/***********************************************************************************************************************************
+**
+** The set method for the keyField1 identifier
+**
+** @param keyField1 the keyField1 identifier
+**
+************************************************************************************************************************************
+*/
+ public void setKeyField1 (String keyField1) {
+
+ _keyField1 = keyField1;
+ }
+
+/***********************************************************************************************************************************
+**
+** The get method for the keyField2 identifier
+**
+** @return the keyField2 identifier
+**
+************************************************************************************************************************************
+*/
+ public int getKeyField2 () {
+
+ return _keyField2;
+ }
+
+/***********************************************************************************************************************************
+**
+** The set method for the keyField2 identifier
+**
+** @param keyField2 the keyField2 identifier
+**
+************************************************************************************************************************************
+*/
+ public void setKeyField2 (int keyField2) {
+
+ _keyField2 = keyField2;
+ }
+
+/***********************************************************************************************************************************
+**
+** The get method for the keyField3 identifier
+**
+** @return the keyField3 identifier
+**
+************************************************************************************************************************************
+*/
+ public String getKeyField3 () {
+
+ return _keyField3;
+ }
+
+/***********************************************************************************************************************************
+**
+** The set method for the keyField3 identifier
+**
+** @param keyField3 the keyField3 identifier
+**
+************************************************************************************************************************************
+*/
+ public void setKeyField3 (String keyField3) {
+
+ _keyField3 = keyField3;
+ }
+
+/***********************************************************************************************************************************
+**
+** The primary key class' equals method
+**
+** @param other a comparison object
+**
+************************************************************************************************************************************
+*/
+ public boolean equals (Object other) {
+
+ if ((this == other))
+ return true;
+ if ((other == null))
+ return false;
+ if (!(other instanceof Table1Key))
+ return false;
+ Table1Key castOther = (Table1Key) other;
+
+ return ((this.getKeyField1() == castOther.getKeyField1()) || (this.getKeyField1() != null && castOther.getKeyField1() != null
+ && this.getKeyField1().equals(castOther.getKeyField1()))) && (this.getKeyField2() == castOther.getKeyField2())
+ && ((this.getKeyField3() == castOther.getKeyField3()) || (this.getKeyField3() != null && castOther.getKeyField3() != null
+ && this.getKeyField3().equals(castOther.getKeyField3())));
+ }
+
+/***********************************************************************************************************************************
+**
+** The primary key class' hashCode method
+**
+************************************************************************************************************************************
+*/
+ public int hashCode () {
+
+ int result = 17;
+
+ result = 37 * result + (getKeyField1() == null ? 0 : this.getKeyField1().hashCode());
+ result = 37 * result + this.getKeyField2();
+ result = 37 * result+ (getKeyField3() == null ? 0 : this.getKeyField3().hashCode());
+ return result;
+ }
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/timestampentity/entity/Table1TimestampEntity.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/timestampentity/entity/Table1TimestampEntity.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/timestampentity/entity/Table1TimestampEntity.java 2007-02-09 01:25:57 UTC (rev 60450)
@@ -0,0 +1,261 @@
+/***********************************************************************************************************************************
+**
+** Research In Motion. Do not reproduce without permission in writing.
+**
+** Copyright (c) 2006 Research In Motion.
+** All rights reserved.
+**
+************************************************************************************************************************************
+*/
+package org.jboss.ejb3.test.timestampentity.entity;
+
+import javax.persistence.AttributeOverride;
+import javax.persistence.AttributeOverrides;
+import javax.persistence.Column;
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import javax.persistence.Version;
+import java.util.Date;
+import org.hibernate.annotations.Generated;
+import org.hibernate.annotations.GenerationTime;
+
+/***********************************************************************************************************************************
+**
+** This is a entity bean primary key class for the Table1 table...Generated 4-Jan-2007 2:58:35 PM
+** by Hibernate Tools 3.2.0.beta7
+**
+** @author jgrills
+** @version T.B.D
+**
+************************************************************************************************************************************
+*/
+ at Entity
+ at Table(name = "Table1Timestamp")
+public class Table1TimestampEntity implements java.io.Serializable {
+
+/***********************************************************************************************************************************
+**
+** The primary key class
+**
+************************************************************************************************************************************
+*/
+ private Table1Key _table1Key;
+
+/***********************************************************************************************************************************
+**
+** The field1 attribute
+**
+************************************************************************************************************************************
+*/
+ private String _field1;
+
+/***********************************************************************************************************************************
+**
+** The fiedl2 attribute
+**
+************************************************************************************************************************************
+*/
+ private String _field2;
+
+/***********************************************************************************************************************************
+**
+** The field3 attribute
+**
+************************************************************************************************************************************
+*/
+ private Date _field3;
+
+/***********************************************************************************************************************************
+**
+** The lurnum attribute
+**
+************************************************************************************************************************************
+*/
+ private byte[] _lurnum;
+
+/***********************************************************************************************************************************
+**
+** The default constructor for an Table1TimestampEntity
+**
+************************************************************************************************************************************
+*/
+ public Table1TimestampEntity () {
+
+ }
+
+/***********************************************************************************************************************************
+**
+** The minimal constructor for an Table1TimestampEntity
+**
+** @param table1Key the primary key class
+** @param field1 the field1
+** @param field2 the field2
+**
+************************************************************************************************************************************
+*/
+ public Table1TimestampEntity (Table1Key table1Key, String field1, String field2) {
+
+ _table1Key = table1Key;
+ _field1 = field1;
+ _field2 = field2;
+ }
+
+/***********************************************************************************************************************************
+**
+** The full constructor for an Table1TimestampEntity
+**
+** @param table1Key the primary key class
+** @param field1 the field1
+** @param field2 the field2
+** @param field3 the field3
+**
+************************************************************************************************************************************
+*/
+ public Table1TimestampEntity (Table1Key table1Key, String field1, String field2, Date field3) {
+
+ _table1Key = table1Key;
+ _field1 = field1;
+ _field2 = field2;
+ _field3 = field3;
+ }
+
+/***********************************************************************************************************************************
+**
+** The get method for the primary key class
+**
+** @return the primary key
+**
+************************************************************************************************************************************
+*/
+ @EmbeddedId
+ @AttributeOverrides({
+ @AttributeOverride(name = "keyfield1", column = @Column(name = "Keyfield1")),
+ @AttributeOverride(name = "keyfield2", column = @Column(name = "Keyfield2")),
+ @AttributeOverride(name = "keyfield3", column = @Column(name = "Keyfield3"))
+ })
+ public Table1Key getId () {
+
+ return _table1Key;
+ }
+
+/***********************************************************************************************************************************
+**
+** The set method for the primary key class
+**
+** @param table1Key the primary key class
+**
+************************************************************************************************************************************
+*/
+ public void setId (Table1Key table1Key) {
+
+ _table1Key = table1Key;
+ }
+
+/***********************************************************************************************************************************
+**
+** The get method for the field1
+**
+** @return the field1
+**
+************************************************************************************************************************************
+*/
+ public String getField1 () {
+
+ return _field1;
+ }
+
+/***********************************************************************************************************************************
+**
+** The set method for the field1
+**
+** @param field1 the field1
+**
+************************************************************************************************************************************
+*/
+ public void setField1 (String field1) {
+
+ _field1 = field1;
+ }
+
+/***********************************************************************************************************************************
+**
+** The get method for the field2
+**
+** @return the field2
+**
+************************************************************************************************************************************
+*/
+ public String getField2 () {
+
+ return _field2;
+ }
+
+/***********************************************************************************************************************************
+**
+** The set method for the field2
+**
+** @param field2 the field2
+**
+************************************************************************************************************************************
+*/
+ public void setField2 (String field2) {
+
+ _field2 = field2;
+ }
+
+/***********************************************************************************************************************************
+**
+** The get method for the field3
+**
+** @return the field3
+**
+************************************************************************************************************************************
+*/
+ public Date getField3 () {
+
+ return _field3;
+ }
+
+/***********************************************************************************************************************************
+**
+** The set method for the field3
+**
+** @param field3 the field3
+**
+************************************************************************************************************************************
+*/
+ public void setField3 (Date field3) {
+
+ _field3 = field3;
+ }
+
+/***********************************************************************************************************************************
+**
+** The get method for the lurnum attribute
+**
+** @return the lurnum attribute
+**
+************************************************************************************************************************************
+*/
+ @Version
+ @Generated(GenerationTime.ALWAYS)
+ @Column(insertable = false, updatable = false, columnDefinition="TIMESTAMP")
+ public byte[] getLurnum () {
+
+ return _lurnum;
+ }
+
+/***********************************************************************************************************************************
+**
+** The set method for the lurnum attribute
+**
+** @param lurnum the lurnum attribute
+**
+************************************************************************************************************************************
+*/
+ public void setLurnum (byte[] lurnum) {
+
+ _lurnum = lurnum;
+ }
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/timestampentity/unit/EntityUnitTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/timestampentity/unit/EntityUnitTestCase.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/timestampentity/unit/EntityUnitTestCase.java 2007-02-09 01:25:57 UTC (rev 60450)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.timestampentity.unit;
+
+import java.util.Date;
+
+import org.jboss.ejb3.test.timestampentity.*;
+
+import org.jboss.test.JBossTestCase;
+import junit.framework.Test;
+
+public class EntityUnitTestCase
+extends JBossTestCase
+{
+ public EntityUnitTestCase(String name)
+ {
+
+ super(name);
+
+ }
+
+ public void testOneToMany() throws Exception
+ {
+ /* TestManager test = (TestManager) getInitialContext().lookup(TestManagerConstants.JNDI_BINDING);
+ test.createTestInteger("keyField1", 1, "keyField3", "field1", "field2", new Date());
+ test.createTestTimestamp("keyField1", 1, "keyField3", "field1", "field2", new Date());
+
+ test.findTestInteger("keyField1", 1, "keyField3");
+ test.findTestTimestamp("keyField1", 1, "keyField3");*/
+
+ TestManager testManager = (TestManager) getInitialContext().lookup(TestManagerConstants.JNDI_BINDING);
+/* try {
+ testManager.createTestInteger("keyField1", 1, "keyField3", "field1", "field2", new Date(System.currentTimeMillis()));
+ testManager.updateTestInteger("keyField1", 1, "keyField3", "field-new", "field-new", new Date(System.currentTimeMillis()));
+ }
+ catch (Exception e) {
+ System.out.println("Exception caught during test #1. " + e);
+ e.printStackTrace();
+ }*/
+ System.out.println("Exectuing test #2");
+ try {
+ testManager.createTestTimestamp("keyField1", 1, "keyField3", "field1", "field2", new Date(System.currentTimeMillis()));
+ testManager.updateTestTimestamp("keyField1", 1, "keyField3", "field1-new", "field2-new", new Date(System.currentTimeMillis()));
+ }
+ catch (Exception e) {
+ System.out.println("Exception caught during test #2. " + e);
+ e.printStackTrace();
+ }
+
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(EntityUnitTestCase.class, "timestampentity-test.jar");
+ }
+
+}
More information about the jboss-cvs-commits
mailing list