[jboss-cvs] JBossAS SVN: r96506 - in trunk/testsuite: src/main/org/jboss/test/hibernate/test and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Nov 18 14:08:32 EST 2009
Author: bstansberry at jboss.com
Date: 2009-11-18 14:08:32 -0500 (Wed, 18 Nov 2009)
New Revision: 96506
Added:
trunk/testsuite/src/main/org/jboss/test/hibernate/test/HarWithStandardPropertiesUnitTestCase.java
trunk/testsuite/src/resources/hibernate/jbas7411/
trunk/testsuite/src/resources/hibernate/jbas7411/Timers.hbm.xml
trunk/testsuite/src/resources/hibernate/jbas7411/jboss-hibernate.xml
Modified:
trunk/testsuite/imports/sections/hibernate.xml
Log:
[JBAS-7411] Test an actual deployment
Modified: trunk/testsuite/imports/sections/hibernate.xml
===================================================================
--- trunk/testsuite/imports/sections/hibernate.xml 2009-11-18 19:07:45 UTC (rev 96505)
+++ trunk/testsuite/imports/sections/hibernate.xml 2009-11-18 19:08:32 UTC (rev 96506)
@@ -88,5 +88,23 @@
</metainf>
<include name="hib-ejb2.jar"/>
</jar>
+
+ <jar basedir="${build.classes}" destfile="${build.lib}/hib-jbas7411.har">
+ <metainf dir="${build.resources}/hibernate/jbas7411">
+ <include name="jboss-hibernate.xml"/>
+ <include name="Timers.hbm.xml"/>
+ </metainf>
+ <include name="org/jboss/test/hibernate/SimpleInterceptor.class"/>
+ </jar>
+ <jar basedir="${build.classes}" destfile="${build.lib}/hib-jbas7411.jar">
+ <metainf dir="${build.resources}/hibernate/ejbtimers">
+ <include name="ejb-jar.xml"/>
+ <include name="jboss.xml"/>
+ </metainf>
+ <include name="org/jboss/test/hibernate/timers/**"/>
+ <fileset dir="${build.lib}">
+ <include name="hib-jbas7411.har"/>
+ </fileset>
+ </jar>
</target>
</project>
Added: trunk/testsuite/src/main/org/jboss/test/hibernate/test/HarWithStandardPropertiesUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/hibernate/test/HarWithStandardPropertiesUnitTestCase.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/hibernate/test/HarWithStandardPropertiesUnitTestCase.java 2009-11-18 19:08:32 UTC (rev 96506)
@@ -0,0 +1,145 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.test.hibernate.test;
+
+import org.jboss.test.JBossTestCase;
+import org.jboss.test.hibernate.timers.interfaces.ITimersHome;
+import org.jboss.test.hibernate.timers.interfaces.ITimers;
+import org.jboss.test.hibernate.timers.interfaces.Key;
+import org.jboss.test.hibernate.timers.interfaces.Info;
+import org.jboss.test.hibernate.timers.Timers;
+import org.jboss.test.hibernate.timers.TimersID;
+
+import java.util.List;
+import java.util.Iterator;
+import java.util.Date;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.io.IOException;
+import java.io.ByteArrayInputStream;
+import java.io.ObjectInputStream;
+
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+
+/**
+ * Test for JBAS-7411. Deploys a HAR whose -hibernate.xml uses standard
+ * Hibernate property names instead of properties of the
+ * org.jboss.hibernate.jmx.Hibernate class. Validates that it deploys and
+ * creates usable sessions.
+ *
+ * This test borrows the classes from TimersUnitTestCase; just uses a different
+ * jboss-hibernate.xml file.
+ *
+ * @author Brian Stansberry
+ * @version $Revision: 81036 $
+ */
+public class HarWithStandardPropertiesUnitTestCase extends JBossTestCase
+{
+ public HarWithStandardPropertiesUnitTestCase(String name) throws Exception
+ {
+ super(name);
+ }
+
+ /**
+ Setup the test suite.
+ */
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(HarWithStandardPropertiesUnitTestCase.class, "hib-jbas7411.jar");
+ }
+
+ public void testCurrentSession() throws Throwable
+ {
+ InitialContext ctx = super.getInitialContext();
+ ITimersHome home = (ITimersHome) ctx.lookup("hib-timers/ITimersHome");
+ ITimers bean = null;
+
+ try
+ {
+ bean = home.create();
+
+ int initialCount = bean.listTimers().size();
+
+ TimersID id = new TimersID("testCurrentSession", "*:ejb=None");
+ Timers timer = new Timers(id);
+ Date now = new Date();
+ Long interval = new Long(5*1000);
+ Key key = new Key("key2", 123456789);
+ Info info = new Info(System.getProperties());
+ timer.setInitialDate(now);
+ timer.setInstancePK(serialize(key));
+ timer.setTimerInterval(interval);
+ timer.setInfo(serialize(info));
+
+ bean.persist(timer);
+ log.info("Timers created with id = " + id);
+
+ List timers = bean.listTimers();
+ assertNotNull(timers);
+ assertEquals("Incorrect result size", initialCount + 1, timers.size());
+
+ Timers found = null;
+ Iterator itr = timers.iterator();
+ while (itr.hasNext())
+ {
+ Timers t = (Timers) itr.next();
+ if (id.equals(t.getId()))
+ {
+ found = t;
+ }
+ }
+ assertNotNull("Saved timer found in list", found);
+ Date d = found.getInitialDate();
+ long t0 = (now.getTime() / 1000) * 1000;
+ long t1 = (d.getTime() / 1000) * 1000;
+ assertTrue("Timer.InitialDate("+t1+") == now("+t0+")", t0 == t1);
+ assertTrue("Timer.Id == id", found.getId().equals(id));
+ assertTrue("Timer.TimerInterval == interval", found.getTimerInterval().equals(interval));
+ Object tmp = deserialize(found.getInstancePK());
+ assertTrue("Timer.InstancePK == key", tmp.equals(key));
+ tmp = deserialize(found.getInfo());
+ log.info("Info: "+tmp);
+ assertTrue("Timer.Info == info", tmp.equals(info));
+
+ // Scott forgot to remove the timer
+ bean.delete(timer);
+ }
+ finally
+ {
+ if (bean != null)
+ {
+ try
+ {
+ bean.remove();
+ }
+ catch (Throwable t)
+ {
+ // ignore
+ }
+ }
+ }
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/testsuite/src/main/org/jboss/test/hibernate/test/HarWithStandardPropertiesUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
+
Added: trunk/testsuite/src/resources/hibernate/jbas7411/Timers.hbm.xml
===================================================================
--- trunk/testsuite/src/resources/hibernate/jbas7411/Timers.hbm.xml (rev 0)
+++ trunk/testsuite/src/resources/hibernate/jbas7411/Timers.hbm.xml 2009-11-18 19:08:32 UTC (rev 96506)
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping package="org.jboss.test.hibernate.timers">
+<!--
+ $Id: Timers.hbm.xml 35847 2005-09-10 23:36:12Z starksm $
+-->
+ <class name="Timers"
+ table="TIMERS" schema="PUBLIC">
+
+ <cache usage="transactional"/>
+
+ <composite-id name="id" class="org.jboss.test.hibernate.timers.TimersID">
+ <key-property name="timerID" type="string">
+ <column name="TIMERID" length="80" />
+ </key-property>
+ <key-property name="targetID" type="string">
+ <column name="TARGETID" length="80" />
+ </key-property>
+ </composite-id>
+ <property name="initialDate" type="timestamp">
+ <column name="INITIALDATE" length="6" not-null="true" />
+ </property>
+ <property name="timerInterval" type="long">
+ <column name="TIMERINTERVAL" />
+ </property>
+ <property name="instancePK" type="binary">
+ <column name="INSTANCEPK" />
+ </property>
+ <property name="info" type="binary">
+ <column name="INFO" />
+ </property>
+ </class>
+</hibernate-mapping>
Property changes on: trunk/testsuite/src/resources/hibernate/jbas7411/Timers.hbm.xml
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+
Added: trunk/testsuite/src/resources/hibernate/jbas7411/jboss-hibernate.xml
===================================================================
--- trunk/testsuite/src/resources/hibernate/jbas7411/jboss-hibernate.xml (rev 0)
+++ trunk/testsuite/src/resources/hibernate/jbas7411/jboss-hibernate.xml 2009-11-18 19:08:32 UTC (rev 96506)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<hibernate-configuration xmlns="urn:jboss:hibernate-deployer:1.0">
+
+ <session-factory name="java:/hib-timers/SessionFactory" bean="jboss.test.har:service=Hibernate,testcase=HarWithStandardPropertiesUnitTestCase">
+ <property name="hibernate.connection.datasource">java:/DefaultDS</property>
+ <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
+ <!-- no such class
+ <property name="sessionFactoryInterceptor">org.jboss.test.hibernate.SimpleInterceptor</property>
+ -->
+ <property name="hibernate.hbm2ddl.auto">create</property>
+
+ <!-- The test doesn't actually cache anything, but let's set some properties to check
+ that they work -->
+ <property name="hibernate.cache.use_second_level_cache">true</property>
+ <property name="hibernate.cache.region_prefix">HarWithStandardProperties</property>
+ <property name="hibernate.cache.region.factory_class">org.hibernate.cache.jbc2.JndiMultiplexedJBossCacheRegionFactory</property>
+ <property name="hibernate.cache.region.jbc2.cachefactory">java:/CacheManager</property>
+ <property name="hibernate.cache.region.jbc2.cfg.entity">mvcc-shared</property>
+
+ <depends>jboss:service=Naming</depends>
+ <depends>jboss:service=TransactionManager</depends>
+ </session-factory>
+
+</hibernate-configuration>
Property changes on: trunk/testsuite/src/resources/hibernate/jbas7411/jboss-hibernate.xml
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+
More information about the jboss-cvs-commits
mailing list