Hibernate SVN: r14362 - in core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional: util and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-02-25 15:15:43 -0500 (Mon, 25 Feb 2008)
New Revision: 14362
Added:
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/Contact.hbm.xml
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/Contact.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/Customer.hbm.xml
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/Customer.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/DualNodeTestCaseBase.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/OptimisticEntityReplicationTest.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/PessimisticEntityReplicationTest.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/util/
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/util/TestCacheInstanceManager.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/util/TestJBossCacheRegionFactory.java
Log:
Add initial "clustered integration" test
Added: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/Contact.hbm.xml
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/Contact.hbm.xml (rev 0)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/Contact.hbm.xml 2008-02-25 20:15:43 UTC (rev 14362)
@@ -0,0 +1,48 @@
+<?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, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Middleware LLC.
+ ~
+ ~ This copyrighted material is made available to anyone wishing to use, modify,
+ ~ copy, or redistribute it subject to the terms and conditions of the GNU
+ ~ Lesser General Public License, as published by the Free Software Foundation.
+ ~
+ ~ This program 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 distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ -->
+<hibernate-mapping
+ package="org.hibernate.test.cache.jbc2.functional">
+
+ <class name="Contact" table="Contacts">
+
+ <cache usage="transactional"/>
+
+ <id name="id">
+ <generator class="increment"/>
+ </id>
+
+ <property name="name" not-null="true"/>
+ <property name="tlf" not-null="true"/>
+
+ <many-to-one name="customer"
+ class="org.hibernate.test.cache.jbc2.functional.Customer"
+ column="CUSTOMER_ID"/>
+ </class>
+
+</hibernate-mapping>
Property changes on: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/Contact.hbm.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/Contact.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/Contact.java (rev 0)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/Contact.java 2008-02-25 20:15:43 UTC (rev 14362)
@@ -0,0 +1,92 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program 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 distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.cache.jbc2.functional;
+
+import java.io.Serializable;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+
+/**
+ * Entity that has a many-to-one relationship to a Customer
+ */
+public class Contact implements Serializable
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ Integer id;
+ String name;
+ String tlf;
+ Customer customer;
+
+ public Contact()
+ {
+
+ }
+
+ @Id
+ public Integer getId()
+ {
+ return id;
+ }
+
+ public void setId(Integer id)
+ {
+ this.id = id;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getTlf()
+ {
+ return tlf;
+ }
+
+ public void setTlf(String tlf)
+ {
+ this.tlf = tlf;
+ }
+
+ @ManyToOne
+ @JoinColumn(name="CUST_ID")
+ public Customer getCustomer()
+ {
+ return customer;
+ }
+
+ public void setCustomer(Customer customer)
+ {
+ this.customer = customer;
+ }
+
+}
Property changes on: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/Contact.java
___________________________________________________________________
Name: svn:executable
+ *
Added: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/Customer.hbm.xml
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/Customer.hbm.xml (rev 0)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/Customer.hbm.xml 2008-02-25 20:15:43 UTC (rev 14362)
@@ -0,0 +1,50 @@
+<?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, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Middleware LLC.
+ ~
+ ~ This copyrighted material is made available to anyone wishing to use, modify,
+ ~ copy, or redistribute it subject to the terms and conditions of the GNU
+ ~ Lesser General Public License, as published by the Free Software Foundation.
+ ~
+ ~ This program 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 distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ -->
+<hibernate-mapping
+ package="org.hibernate.test.cache.jbc2.functional">
+
+ <class name="Customer" table="Customers">
+
+ <cache usage="transactional"/>
+
+ <id name="id">
+ <generator class="increment"/>
+ </id>
+
+ <property name="name" not-null="true"/>
+
+ <set name="contacts" cascade="all" lazy="false">
+ <cache usage="transactional"/>
+ <key column="CUSTOMER_ID"/>
+ <one-to-many class="org.hibernate.test.cache.jbc2.functional.Contact"/>
+ </set>
+
+ </class>
+
+</hibernate-mapping>
Property changes on: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/Customer.hbm.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/Customer.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/Customer.java (rev 0)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/Customer.java 2008-02-25 20:15:43 UTC (rev 14362)
@@ -0,0 +1,81 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program 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 distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.cache.jbc2.functional;
+
+import java.io.Serializable;
+import java.util.Set;
+
+import javax.persistence.Id;
+
+/**
+ * Company customer
+ *
+ * @author Emmanuel Bernard
+ * @author Kabir Khan
+ */
+public class Customer implements Serializable
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+ Integer id;
+ String name;
+
+ private transient Set<Contact> contacts;
+
+ public Customer()
+ {
+ }
+
+ @Id
+ public Integer getId()
+ {
+ return id;
+ }
+
+ public void setId(Integer id)
+ {
+ this.id = id;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String string)
+ {
+ name = string;
+ }
+
+ public Set<Contact> getContacts()
+ {
+ return contacts;
+ }
+
+ public void setContacts(Set<Contact> contacts)
+ {
+ this.contacts = contacts;
+ }
+}
+
Property changes on: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/Customer.java
___________________________________________________________________
Name: svn:executable
+ *
Added: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/DualNodeTestCaseBase.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/DualNodeTestCaseBase.java (rev 0)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/DualNodeTestCaseBase.java 2008-02-25 20:15:43 UTC (rev 14362)
@@ -0,0 +1,200 @@
+/*
+ * Copyright (c) 2008, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A 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, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Brian Stansberry
+ */
+
+package org.hibernate.test.cache.jbc2.functional;
+
+import org.hibernate.HibernateException;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Mappings;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.junit.functional.ExecutionEnvironment;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Base class for tests that need to create two separate SessionFactory
+ * instances to simulate a two-node cluster.
+ *
+ * @author <a href="brian.stansberry(a)jboss.com">Brian Stansberry</a>
+ */
+public abstract class DualNodeTestCaseBase extends CacheTestCaseBase
+{
+ private static final Logger log = LoggerFactory.getLogger( CacheTestCaseBase.class );
+
+ private ExecutionEnvironment secondNodeEnvironment;
+ private org.hibernate.classic.Session secondNodeSession;
+
+ /**
+ * Create a new DualNodeTestCaseBase.
+ *
+ * @param x
+ */
+ public DualNodeTestCaseBase(String x)
+ {
+ super(x);
+ }
+
+ @Override
+ public void configure(Configuration cfg)
+ {
+ standardConfigure(cfg);
+ configureFirstNode(cfg);
+ }
+
+ private void standardConfigure(Configuration cfg) {
+ super.configure(cfg);
+ }
+
+ /**
+ * Apply any node-specific configurations to our first node.
+ *
+ * @param the Configuration to update.
+ */
+ protected abstract void configureFirstNode(Configuration cfg);
+
+ /**
+ * Apply any node-specific configurations to our second node.
+ *
+ * @param the Configuration to update.
+ */
+ protected abstract void configureSecondNode(Configuration cfg);
+
+ @Override
+ protected void prepareTest() throws Exception
+ {
+ log.info( "Building second node locally managed execution env" );
+ secondNodeEnvironment = new ExecutionEnvironment( new SecondNodeSettings() );
+ secondNodeEnvironment.initialize();
+
+ super.prepareTest();
+ }
+
+ @Override
+ protected void runTest() throws Throwable
+ {
+ try {
+ super.runTest();
+ }
+ finally {
+
+ if ( secondNodeSession != null && secondNodeSession.isOpen() ) {
+ if ( secondNodeSession.isConnected() ) {
+ secondNodeSession.connection().rollback();
+ }
+ secondNodeSession.close();
+ secondNodeSession = null;
+ fail( "unclosed session" );
+ }
+ else {
+ secondNodeSession = null;
+ }
+
+ }
+ }
+
+ @Override
+ protected void cleanupTest() throws Exception
+ {
+ super.cleanupTest();
+
+ log.info( "Destroying second node locally managed execution env" );
+ secondNodeEnvironment.complete();
+ secondNodeEnvironment = null;
+ }
+
+ public ExecutionEnvironment getSecondNodeEnvironment() {
+ return secondNodeEnvironment;
+ }
+
+ /**
+ * Settings impl that delegates most calls to the DualNodeTestCase itself,
+ * but overrides the configure method to allow separate cache settings
+ * for the second node.
+ */
+ public class SecondNodeSettings implements ExecutionEnvironment.Settings {
+
+ private DualNodeTestCaseBase delegate;
+
+ public SecondNodeSettings() {
+ this.delegate = DualNodeTestCaseBase.this;
+ }
+
+ /**
+ * This is the important one -- we extend the delegate's work by
+ * adding second-node specific settings
+ */
+ public void configure(Configuration arg0)
+ {
+ delegate.standardConfigure(arg0);
+ configureSecondNode(arg0);
+ }
+
+ /**
+ * Disable creating of schemas; we let the primary session factory
+ * do that to our shared database.
+ */
+ public boolean createSchema()
+ {
+ return false;
+ }
+
+ /**
+ * Disable creating of schemas; we let the primary session factory
+ * do that to our shared database.
+ */
+ public boolean recreateSchemaAfterFailure()
+ {
+ return false;
+ }
+
+ public void afterConfigurationBuilt(Mappings arg0, Dialect arg1)
+ {
+ delegate.afterConfigurationBuilt(arg0, arg1);
+ }
+
+ public void afterSessionFactoryBuilt(SessionFactoryImplementor arg0)
+ {
+ delegate.afterSessionFactoryBuilt(arg0);
+ }
+
+ public boolean appliesTo(Dialect arg0)
+ {
+ return delegate.appliesTo(arg0);
+ }
+
+ public String getBaseForMappings()
+ {
+ return delegate.getBaseForMappings();
+ }
+
+ public String getCacheConcurrencyStrategy()
+ {
+ return delegate.getCacheConcurrencyStrategy();
+ }
+
+ public String[] getMappings()
+ {
+ return delegate.getMappings();
+ }
+
+ public boolean overrideCacheStrategy()
+ {
+ return delegate.overrideCacheStrategy();
+ }
+ }
+
+}
Added: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/OptimisticEntityReplicationTest.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/OptimisticEntityReplicationTest.java (rev 0)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/OptimisticEntityReplicationTest.java 2008-02-25 20:15:43 UTC (rev 14362)
@@ -0,0 +1,47 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program 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 distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.cache.jbc2.functional;
+
+
+/**
+ * Executes the superclass tests, but with Hibernate and JBoss Cache
+ * configured for optimistic locking.
+ *
+ * @author Brian Stansberry
+ */
+public class OptimisticEntityReplicationTest extends PessimisticEntityReplicationTest
+{
+
+ public OptimisticEntityReplicationTest(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected String getEntityCacheConfigName()
+ {
+ return "optimistic-shared";
+ }
+
+}
Added: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/PessimisticEntityReplicationTest.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/PessimisticEntityReplicationTest.java (rev 0)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/PessimisticEntityReplicationTest.java 2008-02-25 20:15:43 UTC (rev 14362)
@@ -0,0 +1,356 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program 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 distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.cache.jbc2.functional;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.transaction.TransactionManager;
+
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.cache.RegionFactory;
+import org.hibernate.cache.jbc2.builder.MultiplexingCacheInstanceManager;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.test.cache.jbc2.functional.util.TestCacheInstanceManager;
+import org.hibernate.test.cache.jbc2.functional.util.TestJBossCacheRegionFactory;
+import org.jboss.cache.Cache;
+import org.jboss.cache.CacheManager;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.notifications.annotation.CacheListener;
+import org.jboss.cache.notifications.annotation.NodeVisited;
+import org.jboss.cache.notifications.event.NodeVisitedEvent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Port of the earlier JBoss EJB3 project's
+ * org.jboss.ejb3.test.clusteredentity.unit.EntityUnitTestCase
+ *
+ */
+public class PessimisticEntityReplicationTest
+extends DualNodeTestCaseBase
+{
+ protected final Logger log = LoggerFactory.getLogger(getClass());
+
+ private static final long SLEEP_TIME = 100l;
+
+ private static final String LOCAL = "local";
+ private static final String REMOTE = "remote";
+
+ private static final Integer CUSTOMER_ID = new Integer(1);
+
+ static int test = 0;
+
+ public PessimisticEntityReplicationTest(String name)
+ {
+ super(name);
+ }
+
+
+
+ @Override
+ public void configure(Configuration cfg)
+ {
+ super.configure(cfg);
+ }
+
+
+
+ @Override
+ protected Class<? extends RegionFactory> getCacheRegionFactory()
+ {
+ return TestJBossCacheRegionFactory.class;
+ }
+
+ @Override
+ protected boolean getUseQueryCache()
+ {
+ return false;
+ }
+
+ @Override
+ protected void configureCacheFactory(Configuration cfg)
+ {
+ cfg.setProperty(MultiplexingCacheInstanceManager.ENTITY_CACHE_RESOURCE_PROP,
+ getEntityCacheConfigName());
+ }
+
+ @Override
+ protected void configureFirstNode(Configuration cfg)
+ {
+ cfg.setProperty(TestCacheInstanceManager.CACHE_MANAGER_NAME_PROP,
+ LOCAL);
+ }
+
+ @Override
+ protected void configureSecondNode(Configuration cfg)
+ {
+ cfg.setProperty(TestCacheInstanceManager.CACHE_MANAGER_NAME_PROP,
+ REMOTE);
+ }
+
+ protected String getEntityCacheConfigName() {
+ return "pessimistic-shared";
+ }
+
+
+ public void testAll() throws Exception
+ {
+ System.out.println("*** testAll()");
+
+ // Bind a listener to the "local" cache
+ // Our region factory makes its CacheManager available to us
+ CacheManager localManager = TestCacheInstanceManager.getTestCacheManager(LOCAL);
+ Cache localCache = localManager.getCache(getEntityCacheConfigName(), true);
+ MyListener localListener = new MyListener();
+ localCache.addCacheListener(localListener);
+
+ TransactionManager localTM = localCache.getConfiguration().getRuntimeConfig().getTransactionManager();
+
+ // Bind a listener to the "remote" cache
+ CacheManager remoteManager = TestCacheInstanceManager.getTestCacheManager(REMOTE);
+ Cache remoteCache = remoteManager.getCache(getEntityCacheConfigName(), true);
+ MyListener remoteListener = new MyListener();
+ remoteCache.addCacheListener(remoteListener);
+
+ TransactionManager remoteTM = remoteCache.getConfiguration().getRuntimeConfig().getTransactionManager();
+
+ SessionFactory localFactory = getEnvironment().getSessionFactory();
+ SessionFactory remoteFactory = getSecondNodeEnvironment().getSessionFactory();
+
+ try
+ {
+ System.out.println("Create node 0");
+ IdContainer ids = createCustomer(localFactory, localTM);
+
+ // Sleep a bit to let async commit propagate. Really just to
+ // help keep the logs organized for debugging any issues
+ sleep(SLEEP_TIME);
+
+ System.out.println("Find node 0");
+ // This actually brings the collection into the cache
+ getCustomer(ids.customerId, localFactory, localTM);
+
+ // Now the collection is in the cache so, we the 2nd "get"
+ // should read everything from the cache
+ System.out.println("Find(2) node 0");
+ localListener.clear();
+ getCustomer(ids.customerId, localFactory, localTM);
+
+ //Check the read came from the cache
+ System.out.println("Check cache 0");
+ assertLoadedFromCache(localListener, ids.customerId, ids.contactIds);
+
+ // The above placement of the collection in the cache is replicated async
+ // so pause a bit before checking node 1
+ sleep(SLEEP_TIME);
+
+ System.out.println("Find node 1");
+ getCustomer(ids.customerId, remoteFactory, remoteTM);
+
+ //Check everything was in cache
+ System.out.println("Check cache 1");
+ assertLoadedFromCache(remoteListener, ids.customerId, ids.contactIds);
+ }
+ finally
+ {
+ // cleanup the db
+ System.out.println("Cleaning up");
+ cleanup(localFactory, localTM);
+ }
+ }
+
+ private IdContainer createCustomer(SessionFactory sessionFactory, TransactionManager tm)
+ throws Exception
+ {
+ System.out.println("CREATE CUSTOMER");
+
+ tm.begin();
+
+ try
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ Customer customer = new Customer();
+ customer.setName("JBoss");
+ Set<Contact> contacts = new HashSet<Contact>();
+
+ Contact kabir = new Contact();
+ kabir.setCustomer(customer);
+ kabir.setName("Kabir");
+ kabir.setTlf("1111");
+ contacts.add(kabir);
+
+ Contact bill = new Contact();
+ bill.setCustomer(customer);
+ bill.setName("Bill");
+ bill.setTlf("2222");
+ contacts.add(bill);
+
+ customer.setContacts(contacts);
+
+ session.save(customer);
+ tm.commit();
+
+ IdContainer ids = new IdContainer();
+ ids.customerId = customer.getId();
+ Set contactIds = new HashSet();
+ contactIds.add(kabir.getId());
+ contactIds.add(bill.getId());
+ ids.contactIds = contactIds;
+
+ return ids;
+ }
+ catch (Exception e)
+ {
+ log.error("Caught exception creating customer", e);
+ try {
+ tm.rollback();
+ }
+ catch (Exception e1) {
+ log.error("Exception rolling back txn", e1);
+ }
+ throw e;
+ }
+ finally
+ {
+ System.out.println("CREATE CUSTOMER - END");
+ }
+ }
+
+ private Customer getCustomer(Integer id, SessionFactory sessionFactory, TransactionManager tm)
+ throws Exception
+ {
+ System.out.println("FIND CUSTOMER");
+
+ tm.begin();
+ try
+ {
+ Session session = sessionFactory.getCurrentSession();
+ Customer customer = (Customer) session.get(Customer.class, id);
+ // Access all the contacts
+ for (Iterator it = customer.getContacts().iterator(); it.hasNext();) {
+ ((Contact) it.next()).getName();
+ }
+ tm.commit();
+ return customer;
+ }
+ catch (Exception e)
+ {
+ try {
+ tm.rollback();
+ }
+ catch (Exception e1) {
+ log.error("Exception rolling back txn", e1);
+ }
+ throw e;
+ }
+ finally
+ {
+ System.out.println("FIND CUSTOMER - END");
+ }
+ }
+
+ private void cleanup(SessionFactory sessionFactory, TransactionManager tm) throws Exception
+ {
+ tm.begin();
+ try
+ {
+ Session session = sessionFactory.getCurrentSession();
+ Customer c = (Customer) session.get(Customer.class, CUSTOMER_ID);
+ if (c != null)
+ {
+ Set contacts = c.getContacts();
+ for (Iterator it = contacts.iterator(); it.hasNext();)
+ session.delete(it.next());
+ c.setContacts(null);
+ session.delete(c);
+ }
+
+ tm.commit();
+ }
+ catch (Exception e)
+ {
+ try {
+ tm.rollback();
+ }
+ catch (Exception e1) {
+ log.error("Exception rolling back txn", e1);
+ }
+ log.error("Caught exception in cleanup", e);
+ }
+ }
+
+ private void assertLoadedFromCache(MyListener listener, Integer custId, Set contactIds)
+ {
+ assertTrue("Customer#" + custId + " was in cache", listener.visited.contains("Customer#" + custId));
+ for (Iterator it = contactIds.iterator(); it.hasNext();) {
+ Integer contactId = (Integer) it.next();
+ assertTrue("Contact#"+ contactId + " was in cache", listener.visited.contains("Contact#"+ contactId));
+ assertTrue("Contact#"+ contactId + " was in cache", listener.visited.contains("Contact#"+ contactId));
+ }
+ assertTrue("Customer.contacts" + custId + " was in cache",
+ listener.visited.contains("Customer.contacts#" + custId));
+ }
+
+ @CacheListener
+ public class MyListener
+ {
+ HashSet<String> visited = new HashSet<String>();
+
+ public void clear()
+ {
+ visited.clear();
+ }
+
+ @NodeVisited
+ public void nodeVisited(NodeVisitedEvent event)
+ {
+ System.out.println(event);
+
+ if (!event.isPre())
+ {
+ Fqn fqn = event.getFqn();
+ System.out.println("MyListener - Visiting node " + fqn.toString());
+ String name = fqn.toString();
+ String token = ".functional.";
+ int index = name.indexOf(token);
+ if (index > -1)
+ {
+ index += token.length();
+ name = name.substring(index);
+ System.out.println("MyListener - recording visit to " + name);
+ visited.add(name);
+ }
+ }
+ }
+ }
+
+ private class IdContainer {
+ Integer customerId;
+ Set contactIds;
+ }
+}
Property changes on: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/PessimisticEntityReplicationTest.java
___________________________________________________________________
Name: svn:executable
+ *
Added: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/util/TestCacheInstanceManager.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/util/TestCacheInstanceManager.java (rev 0)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/util/TestCacheInstanceManager.java 2008-02-25 20:15:43 UTC (rev 14362)
@@ -0,0 +1,78 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program 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 distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.cache.jbc2.functional.util;
+
+import java.util.Hashtable;
+import java.util.Properties;
+
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.jbc2.builder.MultiplexingCacheInstanceManager;
+import org.hibernate.cfg.Settings;
+import org.jboss.cache.CacheManager;
+
+
+/**
+ * A {@link MultiplexingCacheInstanceManager} that exposes its
+ * CacheManager via a static getter so the test fixture can get ahold
+ * of it.
+ *
+ * @author <a href="brian.stansberry(a)jboss.com">Brian Stansberry</a>
+ */
+public class TestCacheInstanceManager extends MultiplexingCacheInstanceManager {
+
+ private static final Hashtable cacheManagers = new Hashtable();
+
+ public static final String CACHE_MANAGER_NAME_PROP = "hibernate.test.cache.jbc2.cache.manager.name";
+
+ public static CacheManager getTestCacheManager(String name) {
+ return (CacheManager) cacheManagers.get(name);
+ }
+
+ private String cacheManagerName;
+
+ /**
+ * Create a new TestCacheInstanceManager.
+ */
+ public TestCacheInstanceManager() {
+ super();
+ }
+
+ @Override
+ public void start(Settings settings, Properties properties) throws CacheException {
+
+ super.start(settings, properties);
+
+ cacheManagerName = properties.getProperty(CACHE_MANAGER_NAME_PROP);
+ cacheManagers.put(cacheManagerName, getCacheFactory());
+ }
+
+ @Override
+ public void stop()
+ {
+ cacheManagers.remove(cacheManagerName);
+
+ super.stop();
+ }
+
+}
Added: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/util/TestJBossCacheRegionFactory.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/util/TestJBossCacheRegionFactory.java (rev 0)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/util/TestJBossCacheRegionFactory.java 2008-02-25 20:15:43 UTC (rev 14362)
@@ -0,0 +1,64 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program 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 distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.cache.jbc2.functional.util;
+
+import java.util.Properties;
+
+import org.hibernate.cache.jbc2.JBossCacheRegionFactory;
+import org.jboss.cache.CacheManager;
+
+/**
+ * {@link JBossCacheRegionFactory} that uses
+ * {@link TestCacheInstanceManager} as its
+ * {@link #getCacheInstanceManager() CacheInstanceManager}.
+ * <p>
+ * This version lets a test fixture to access {@link CacheManager},
+ * making it easy for the test fixture to get access to the caches being
+ * used. Intended for FunctionalUnitTestCase subclasses where the creation
+ * of the region factory is hidden inside the initialization of a SessionFactory.
+ * </p>
+ *
+ * @author Brian Stansberry
+ */
+public class TestJBossCacheRegionFactory extends JBossCacheRegionFactory {
+
+ /**
+ * FIXME Per the RegionFactory class Javadoc, this constructor version
+ * should not be necessary.
+ *
+ * @param props The configuration properties
+ */
+ public TestJBossCacheRegionFactory(Properties props) {
+ this();
+ }
+
+ /**
+ * Create a new TestJBossCacheRegionFactory.
+ *
+ */
+ public TestJBossCacheRegionFactory() {
+ super(new TestCacheInstanceManager());
+ }
+
+}
16 years, 9 months
Hibernate SVN: r14361 - core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional.
by hibernate-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-02-25 15:14:52 -0500 (Mon, 25 Feb 2008)
New Revision: 14361
Modified:
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/CacheTestCaseBase.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/OptimisticJBossCacheTest.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/PessimisticJBossCacheTest.java
Log:
Refactor how session factory Configuration is built up
Modified: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/CacheTestCaseBase.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/CacheTestCaseBase.java 2008-02-25 20:03:07 UTC (rev 14360)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/CacheTestCaseBase.java 2008-02-25 20:14:52 UTC (rev 14361)
@@ -29,6 +29,9 @@
import org.hibernate.cfg.Mappings;
import org.hibernate.dialect.Dialect;
import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.transaction.CMTTransactionFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Provides common configuration setups for cache testing.
@@ -37,6 +40,8 @@
*/
public abstract class CacheTestCaseBase extends FunctionalTestCase {
+ private static final Logger log = LoggerFactory.getLogger( CacheTestCaseBase.class );
+
private static final String PREFER_IPV4STACK = "java.net.preferIPv4Stack";
private String preferIPv4Stack;
@@ -50,7 +55,7 @@
}
public String[] getMappings() {
- return new String[] { "cache/jbc2/functional/Item.hbm.xml" };
+ return new String[] { "cache/jbc2/functional/Item.hbm.xml", "cache/jbc2/functional/Customer.hbm.xml", "cache/jbc2/functional/Contact.hbm.xml" };
}
public void configure(Configuration cfg) {
@@ -65,7 +70,8 @@
cfg.setProperty(Environment.USE_QUERY_CACHE, String.valueOf(getUseQueryCache()));
cfg.setProperty(Environment.CONNECTION_PROVIDER, org.hibernate.test.tm.ConnectionProviderImpl.class.getName());
cfg.setProperty(Environment.TRANSACTION_MANAGER_STRATEGY, org.hibernate.test.tm.TransactionManagerLookupImpl.class.getName());
-
+ cfg.setProperty( Environment.TRANSACTION_STRATEGY, CMTTransactionFactory.class.getName() );
+
configureCacheFactory(cfg);
}
@@ -74,38 +80,16 @@
}
/**
- * The cache provider to be tested.
+ * Apply any region-factory specific configurations.
*
- * @return The cache provider.
+ * @param the Configuration to update.
*/
- protected void configureCacheFactory(Configuration cfg) {
- if (getConfigResourceKey() != null) {
- cfg.setProperty(getConfigResourceKey(), getConfigResourceLocation());
- }
- }
+ protected abstract void configureCacheFactory(Configuration cfg);
protected abstract Class<? extends RegionFactory> getCacheRegionFactory();
protected abstract boolean getUseQueryCache();
- /**
- * For provider-specific configuration, the name of the property key the
- * provider expects.
- *
- * @return The provider-specific config key.
- */
- protected String getConfigResourceKey() {
- return Environment.CACHE_REGION_FACTORY;
- }
-
- /**
- * For provider-specific configuration, the resource location of that config
- * resource.
- *
- * @return The config resource location.
- */
- protected abstract String getConfigResourceLocation();
-
@Override
public void afterConfigurationBuilt(Mappings mappings, Dialect dialect) {
@@ -130,5 +114,14 @@
}
+ protected void sleep(long ms) {
+ try {
+ Thread.sleep(ms);
+ }
+ catch (InterruptedException e) {
+ log.warn("Interrupted during sleep", e);
+ }
+ }
+
}
Modified: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/OptimisticJBossCacheTest.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/OptimisticJBossCacheTest.java 2008-02-25 20:03:07 UTC (rev 14360)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/OptimisticJBossCacheTest.java 2008-02-25 20:14:52 UTC (rev 14361)
@@ -28,19 +28,18 @@
import org.hibernate.cache.RegionFactory;
import org.hibernate.cache.jbc2.JBossCacheRegionFactory;
import org.hibernate.cache.jbc2.builder.SharedCacheInstanceManager;
+import org.hibernate.cfg.Configuration;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
- * FIXME Move to hibernate-testsuite project and rename class x- "Disabled"
+ * Basic functional test of a optimistic locking entity + query cache.
*
* @author Brian Stansberry
*/
public class OptimisticJBossCacheTest extends AbstractQueryCacheFunctionalTestCase {
- // note that a lot of the fucntionality here is intended to be used
- // in creating specific tests for each CacheProvider that would extend
- // from a base test case (this) for common requirement testing...
-
+ private static final String JBC_CONFIG = "org/hibernate/test/cache/jbc2/functional/optimistic-treecache.xml";
+
public OptimisticJBossCacheTest(String x) {
super(x);
}
@@ -51,14 +50,15 @@
protected Class<? extends RegionFactory> getCacheRegionFactory() {
return JBossCacheRegionFactory.class;
- }
+ }
- protected String getConfigResourceKey() {
- return SharedCacheInstanceManager.CACHE_RESOURCE_PROP;
+ /**
+ * Apply any region-factory specific configurations.
+ *
+ * @param the Configuration to update.
+ */
+ protected void configureCacheFactory(Configuration cfg) {
+ cfg.setProperty(SharedCacheInstanceManager.CACHE_RESOURCE_PROP, JBC_CONFIG);
}
- protected String getConfigResourceLocation() {
- return "org/hibernate/test/cache/jbc2/functional/optimistic-treecache.xml";
- }
-
}
Modified: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/PessimisticJBossCacheTest.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/PessimisticJBossCacheTest.java 2008-02-25 20:03:07 UTC (rev 14360)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/PessimisticJBossCacheTest.java 2008-02-25 20:14:52 UTC (rev 14361)
@@ -28,19 +28,18 @@
import org.hibernate.cache.RegionFactory;
import org.hibernate.cache.jbc2.JBossCacheRegionFactory;
import org.hibernate.cache.jbc2.builder.SharedCacheInstanceManager;
+import org.hibernate.cfg.Configuration;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
- * FIXME Move to hibernate-testsuite project and rename class x- "Disabled"
+ * Basic functional test of a pessimistic locking entity + query cache.
*
* @author Brian Stansberry
*/
public class PessimisticJBossCacheTest extends AbstractQueryCacheFunctionalTestCase {
- // note that a lot of the fucntionality here is intended to be used
- // in creating specific tests for each CacheProvider that would extend
- // from a base test case (this) for common requirement testing...
-
+ private static final String JBC_CONFIG = "org/hibernate/test/cache/jbc2/functional/pessimistic-treecache.xml";
+
public PessimisticJBossCacheTest(String x) {
super(x);
}
@@ -51,14 +50,15 @@
protected Class<? extends RegionFactory> getCacheRegionFactory() {
return JBossCacheRegionFactory.class;
- }
+ }
- protected String getConfigResourceKey() {
- return SharedCacheInstanceManager.CACHE_RESOURCE_PROP;
+ /**
+ * Apply any region-factory specific configurations.
+ *
+ * @param the Configuration to update.
+ */
+ protected void configureCacheFactory(Configuration cfg) {
+ cfg.setProperty(SharedCacheInstanceManager.CACHE_RESOURCE_PROP, JBC_CONFIG);
}
- protected String getConfigResourceLocation() {
- return "org/hibernate/test/cache/jbc2/functional/pessimistic-treecache.xml";
- }
-
}
16 years, 9 months
Hibernate SVN: r14360 - core/trunk/documentation/jbosscache2/src/main/docbook/en-US/content.
by hibernate-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-02-25 15:03:07 -0500 (Mon, 25 Feb 2008)
New Revision: 14360
Modified:
core/trunk/documentation/jbosscache2/src/main/docbook/en-US/content/architecture.xml
Log:
Fix typo
Modified: core/trunk/documentation/jbosscache2/src/main/docbook/en-US/content/architecture.xml
===================================================================
--- core/trunk/documentation/jbosscache2/src/main/docbook/en-US/content/architecture.xml 2008-02-25 20:02:41 UTC (rev 14359)
+++ core/trunk/documentation/jbosscache2/src/main/docbook/en-US/content/architecture.xml 2008-02-25 20:03:07 UTC (rev 14360)
@@ -143,7 +143,7 @@
</para>
</listitem>
<listitem>
- <para>As part of its startup process, te region factory delegates
+ <para>As part of its startup process, the region factory delegates
responsibility for providing JBoss Cache instances to an
implementation of the
<literal>org.hibernate.cache.jbc2.CacheInstanceManager</literal>
16 years, 9 months
Hibernate SVN: r14359 - core/trunk/documentation/jbosscache2/src/main/docbook/en-US/content.
by hibernate-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-02-25 15:02:41 -0500 (Mon, 25 Feb 2008)
New Revision: 14359
Modified:
core/trunk/documentation/jbosscache2/src/main/docbook/en-US/content/eviction.xml
Log:
Minor format change
Modified: core/trunk/documentation/jbosscache2/src/main/docbook/en-US/content/eviction.xml
===================================================================
--- core/trunk/documentation/jbosscache2/src/main/docbook/en-US/content/eviction.xml 2008-02-25 20:01:17 UTC (rev 14358)
+++ core/trunk/documentation/jbosscache2/src/main/docbook/en-US/content/eviction.xml 2008-02-25 20:02:41 UTC (rev 14359)
@@ -474,8 +474,8 @@
<attribute name="policyClass">org.jboss.cache.eviction.LRUPolicy</attribute>
<!--
- Default region to pick up anything we miss in the more specific
- regions below.
+ Default region to pick up anything we miss in the more
+ specific regions below.
-->
<region name="/_default_">
<attribute name="maxNodes">500</attribute>
16 years, 9 months
Hibernate SVN: r14358 - core/trunk/documentation/jbosscache2/src/main/docbook/en-US/content.
by hibernate-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-02-25 15:01:17 -0500 (Mon, 25 Feb 2008)
New Revision: 14358
Modified:
core/trunk/documentation/jbosscache2/src/main/docbook/en-US/content/eviction.xml
Log:
Correct collection mapping example
Modified: core/trunk/documentation/jbosscache2/src/main/docbook/en-US/content/eviction.xml
===================================================================
--- core/trunk/documentation/jbosscache2/src/main/docbook/en-US/content/eviction.xml 2008-02-25 18:05:14 UTC (rev 14357)
+++ core/trunk/documentation/jbosscache2/src/main/docbook/en-US/content/eviction.xml 2008-02-25 20:01:17 UTC (rev 14358)
@@ -334,9 +334,11 @@
<programlisting><![CDATA[<class name="org.example.Foo">
<cache usage="transactional"/>
....
- <one-to-many name="bars" class="org.example.Bar">
+ <set name="bars">
<cache usage="transactional" region="foo_region"/>
- </one-to-many>
+ <key column="FOO_ID"/>
+ <one-to-many class="org.example.Bar"/>
+ </set>
</class>]]></programlisting>
<para>
16 years, 9 months
Hibernate SVN: r14357 - core/branches/Branch_3_2/src/org/hibernate/engine.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2008-02-25 13:05:14 -0500 (Mon, 25 Feb 2008)
New Revision: 14357
Modified:
core/branches/Branch_3_2/src/org/hibernate/engine/ActionQueue.java
Log:
HHH-3131 : ActionQueue.hasAfterTransactionActions
Modified: core/branches/Branch_3_2/src/org/hibernate/engine/ActionQueue.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/engine/ActionQueue.java 2008-02-25 18:03:45 UTC (rev 14356)
+++ core/branches/Branch_3_2/src/org/hibernate/engine/ActionQueue.java 2008-02-25 18:05:14 UTC (rev 14357)
@@ -375,6 +375,10 @@
}
}
+ public boolean hasAfterTransactionActions() {
+ return executions.size() > 0;
+ }
+
public boolean hasAnyQueuedActions() {
return updates.size() > 0 ||
insertions.size() > 0 ||
16 years, 9 months
Hibernate SVN: r14356 - core/trunk/core/src/main/java/org/hibernate/engine.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2008-02-25 13:03:45 -0500 (Mon, 25 Feb 2008)
New Revision: 14356
Modified:
core/trunk/core/src/main/java/org/hibernate/engine/ActionQueue.java
Log:
HHH-3131 : ActionQueue.hasAfterTransactionActions
Modified: core/trunk/core/src/main/java/org/hibernate/engine/ActionQueue.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/ActionQueue.java 2008-02-24 16:26:08 UTC (rev 14355)
+++ core/trunk/core/src/main/java/org/hibernate/engine/ActionQueue.java 2008-02-25 18:03:45 UTC (rev 14356)
@@ -375,6 +375,10 @@
}
}
+ public boolean hasAfterTransactionActions() {
+ return executions.size() > 0;
+ }
+
public boolean hasAnyQueuedActions() {
return updates.size() > 0 ||
insertions.size() > 0 ||
16 years, 9 months
Hibernate SVN: r14355 - core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional.
by hibernate-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-02-24 11:26:08 -0500 (Sun, 24 Feb 2008)
New Revision: 14355
Added:
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/OptimisticJBossCacheTest.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/PessimisticJBossCacheTest.java
Removed:
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/OptimisticJBossCacheTestDisabled.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/PessimisticJBossCacheTestDisabled.java
Log:
Reactivate functional tests
Copied: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/OptimisticJBossCacheTest.java (from rev 14334, core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/OptimisticJBossCacheTestDisabled.java)
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/OptimisticJBossCacheTest.java (rev 0)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/OptimisticJBossCacheTest.java 2008-02-24 16:26:08 UTC (rev 14355)
@@ -0,0 +1,64 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program 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 distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.cache.jbc2.functional;
+
+import junit.framework.Test;
+
+import org.hibernate.cache.RegionFactory;
+import org.hibernate.cache.jbc2.JBossCacheRegionFactory;
+import org.hibernate.cache.jbc2.builder.SharedCacheInstanceManager;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
+/**
+ * FIXME Move to hibernate-testsuite project and rename class x- "Disabled"
+ *
+ * @author Brian Stansberry
+ */
+public class OptimisticJBossCacheTest extends AbstractQueryCacheFunctionalTestCase {
+
+ // note that a lot of the fucntionality here is intended to be used
+ // in creating specific tests for each CacheProvider that would extend
+ // from a base test case (this) for common requirement testing...
+
+ public OptimisticJBossCacheTest(String x) {
+ super(x);
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite(OptimisticJBossCacheTest.class);
+ }
+
+ protected Class<? extends RegionFactory> getCacheRegionFactory() {
+ return JBossCacheRegionFactory.class;
+ }
+
+ protected String getConfigResourceKey() {
+ return SharedCacheInstanceManager.CACHE_RESOURCE_PROP;
+ }
+
+ protected String getConfigResourceLocation() {
+ return "org/hibernate/test/cache/jbc2/functional/optimistic-treecache.xml";
+ }
+
+}
Deleted: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/OptimisticJBossCacheTestDisabled.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/OptimisticJBossCacheTestDisabled.java 2008-02-23 23:53:49 UTC (rev 14354)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/OptimisticJBossCacheTestDisabled.java 2008-02-24 16:26:08 UTC (rev 14355)
@@ -1,64 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program 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 distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.test.cache.jbc2.functional;
-
-import junit.framework.Test;
-
-import org.hibernate.cache.RegionFactory;
-import org.hibernate.cache.jbc2.JBossCacheRegionFactory;
-import org.hibernate.cache.jbc2.builder.SharedCacheInstanceManager;
-import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
-
-/**
- * FIXME Move to hibernate-testsuite project and rename class x- "Disabled"
- *
- * @author Brian Stansberry
- */
-public class OptimisticJBossCacheTestDisabled extends AbstractQueryCacheFunctionalTestCase {
-
- // note that a lot of the fucntionality here is intended to be used
- // in creating specific tests for each CacheProvider that would extend
- // from a base test case (this) for common requirement testing...
-
- public OptimisticJBossCacheTestDisabled(String x) {
- super(x);
- }
-
- public static Test suite() {
- return new FunctionalTestClassTestSuite(OptimisticJBossCacheTestDisabled.class);
- }
-
- protected Class<? extends RegionFactory> getCacheRegionFactory() {
- return JBossCacheRegionFactory.class;
- }
-
- protected String getConfigResourceKey() {
- return SharedCacheInstanceManager.CACHE_RESOURCE_PROP;
- }
-
- protected String getConfigResourceLocation() {
- return "org/hibernate/test/cache/jbc2/functional/optimistic-treecache.xml";
- }
-
-}
Copied: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/PessimisticJBossCacheTest.java (from rev 14334, core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/PessimisticJBossCacheTestDisabled.java)
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/PessimisticJBossCacheTest.java (rev 0)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/PessimisticJBossCacheTest.java 2008-02-24 16:26:08 UTC (rev 14355)
@@ -0,0 +1,64 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program 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 distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.cache.jbc2.functional;
+
+import junit.framework.Test;
+
+import org.hibernate.cache.RegionFactory;
+import org.hibernate.cache.jbc2.JBossCacheRegionFactory;
+import org.hibernate.cache.jbc2.builder.SharedCacheInstanceManager;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
+/**
+ * FIXME Move to hibernate-testsuite project and rename class x- "Disabled"
+ *
+ * @author Brian Stansberry
+ */
+public class PessimisticJBossCacheTest extends AbstractQueryCacheFunctionalTestCase {
+
+ // note that a lot of the fucntionality here is intended to be used
+ // in creating specific tests for each CacheProvider that would extend
+ // from a base test case (this) for common requirement testing...
+
+ public PessimisticJBossCacheTest(String x) {
+ super(x);
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite(PessimisticJBossCacheTest.class);
+ }
+
+ protected Class<? extends RegionFactory> getCacheRegionFactory() {
+ return JBossCacheRegionFactory.class;
+ }
+
+ protected String getConfigResourceKey() {
+ return SharedCacheInstanceManager.CACHE_RESOURCE_PROP;
+ }
+
+ protected String getConfigResourceLocation() {
+ return "org/hibernate/test/cache/jbc2/functional/pessimistic-treecache.xml";
+ }
+
+}
Deleted: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/PessimisticJBossCacheTestDisabled.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/PessimisticJBossCacheTestDisabled.java 2008-02-23 23:53:49 UTC (rev 14354)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/PessimisticJBossCacheTestDisabled.java 2008-02-24 16:26:08 UTC (rev 14355)
@@ -1,64 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program 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 distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.test.cache.jbc2.functional;
-
-import junit.framework.Test;
-
-import org.hibernate.cache.RegionFactory;
-import org.hibernate.cache.jbc2.JBossCacheRegionFactory;
-import org.hibernate.cache.jbc2.builder.SharedCacheInstanceManager;
-import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
-
-/**
- * FIXME Move to hibernate-testsuite project and rename class x- "Disabled"
- *
- * @author Brian Stansberry
- */
-public class PessimisticJBossCacheTestDisabled extends AbstractQueryCacheFunctionalTestCase {
-
- // note that a lot of the fucntionality here is intended to be used
- // in creating specific tests for each CacheProvider that would extend
- // from a base test case (this) for common requirement testing...
-
- public PessimisticJBossCacheTestDisabled(String x) {
- super(x);
- }
-
- public static Test suite() {
- return new FunctionalTestClassTestSuite(PessimisticJBossCacheTestDisabled.class);
- }
-
- protected Class<? extends RegionFactory> getCacheRegionFactory() {
- return JBossCacheRegionFactory.class;
- }
-
- protected String getConfigResourceKey() {
- return SharedCacheInstanceManager.CACHE_RESOURCE_PROP;
- }
-
- protected String getConfigResourceLocation() {
- return "org/hibernate/test/cache/jbc2/functional/pessimistic-treecache.xml";
- }
-
-}
16 years, 9 months
Hibernate SVN: r14354 - core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2.
by hibernate-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-02-23 18:53:49 -0500 (Sat, 23 Feb 2008)
New Revision: 14354
Modified:
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractRegionImplTestCase.java
Log:
Reduce use of "multiplexer" in names; use JGroups
Modified: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractRegionImplTestCase.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractRegionImplTestCase.java 2008-02-23 23:53:05 UTC (rev 14353)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractRegionImplTestCase.java 2008-02-23 23:53:49 UTC (rev 14354)
@@ -73,7 +73,7 @@
assertEquals("Cache is REPL_SYNC", "REPL_SYNC", remoteCache.getConfiguration().getCacheModeString());
JChannelFactory channelFactory = new JChannelFactory();
- channelFactory.setMultiplexerConfig(SharedCacheInstanceManager.DEF_MULTIPLEXER_RESOURCE);
+ channelFactory.setMultiplexerConfig(SharedCacheInstanceManager.DEF_JGROUPS_RESOURCE);
remoteCache.getConfiguration().getRuntimeConfig().setMuxChannelFactory(channelFactory);
remoteCache.start();
16 years, 9 months
Hibernate SVN: r14353 - core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/builder.
by hibernate-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-02-23 18:53:05 -0500 (Sat, 23 Feb 2008)
New Revision: 14353
Modified:
core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/builder/SharedCacheInstanceManager.java
Log:
Use the correct JGroups stacks.xml
Reduce use of "multiplexer" in names; use JGroups
Small Javadoc changes
Modified: core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/builder/SharedCacheInstanceManager.java
===================================================================
--- core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/builder/SharedCacheInstanceManager.java 2008-02-23 23:52:40 UTC (rev 14352)
+++ core/trunk/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/builder/SharedCacheInstanceManager.java 2008-02-23 23:53:05 UTC (rev 14353)
@@ -54,7 +54,7 @@
private static final Logger log = LoggerFactory.getLogger(SharedCacheInstanceManager.class);
/**
- * Classpath or filesystem resource identifying containing JBoss Cache
+ * Classpath or filesystem resource containing JBoss Cache
* configuration settings the {@link Cache} should use.
*
* @see #DEFAULT_CACHE_RESOURCE
@@ -66,20 +66,18 @@
*/
public static final String DEFAULT_CACHE_RESOURCE = "treecache.xml";
/**
- * Classpath or filesystem resource identifying containing JGroups protocol
+ * Classpath or filesystem resource containing JGroups protocol
* stack configurations the <code>org.jgroups.ChannelFactory</code>
* should use.
*
- * @see #DEF_MULTIPLEXER_RESOURCE
+ * @see #DEF_JGROUPS_RESOURCE
*/
- public static final String CHANNEL_FACTORY_RESOURCE_PROP = "hibernate.cache.region.jbc2.cfg.multiplexer.stacks";
+ public static final String CHANNEL_FACTORY_RESOURCE_PROP = "hibernate.cache.region.jbc2.cfg.jgroups.stacks";
/**
- * Default value for {@link #CHANNEL_FACTORY_RESOURCE_PROP}. Specifies
- * "stacks.xml", which can be found in the root of the JGroups jar file.
- * Thus, leaving this value at default means using the default protocol
- * stack configs provided by JGroups.
+ * Default value for {@link #CHANNEL_FACTORY_RESOURCE_PROP}. Specifies
+ * the "jgroups-stacks.xml" file in this package.
*/
- public static final String DEF_MULTIPLEXER_RESOURCE = "stacks.xml";
+ public static final String DEF_JGROUPS_RESOURCE = "org/hibernate/cache/jbc2/builder/jgroups-stacks.xml";
private Cache cache;
private ChannelFactory channelFactory;
@@ -136,7 +134,7 @@
if (cache == null) {
if (channelFactory == null) {
- String muxStacks = PropertiesHelper.getString(CHANNEL_FACTORY_RESOURCE_PROP, properties, DEF_MULTIPLEXER_RESOURCE);
+ String muxStacks = PropertiesHelper.getString(CHANNEL_FACTORY_RESOURCE_PROP, properties, DEF_JGROUPS_RESOURCE);
if (muxStacks != null) {
channelFactory = new JChannelFactory();
try {
16 years, 9 months