[jboss-cvs] JBossAS SVN: r96164 - in projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test: entityoptimisticlocking/unit and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Nov 9 06:08:33 EST 2009
Author: bstansberry at jboss.com
Date: 2009-11-09 06:08:33 -0500 (Mon, 09 Nov 2009)
New Revision: 96164
Removed:
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/clusteredentity/BulkOperationsTest.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/clusteredentity/BulkOperationsTestBean.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/clusteredentity/Contact.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/clusteredentity/Customer.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/clusteredentity/EntityTest.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/clusteredentity/EntityTestBean.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/clusteredentity/classloader/
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/clusteredentity/embeddedid/
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/clusteredentity/unit/
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/entityoptimisticlocking/unit/EntityUnitTestCase.java
Log:
[EJBTHREE-1947] Move out classes
Deleted: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/clusteredentity/BulkOperationsTest.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/clusteredentity/BulkOperationsTest.java 2009-11-09 10:59:47 UTC (rev 96163)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/clusteredentity/BulkOperationsTest.java 2009-11-09 11:08:33 UTC (rev 96164)
@@ -1,46 +0,0 @@
-/*
- * 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.clusteredentity;
-
-import java.util.List;
-
-/**
- * @author Brian Stansberry
- * @version $Revision$
- */
-public interface BulkOperationsTest
-{
- void createContacts();
-
- int deleteContacts();
-
- int updateContacts(String name, String newTLF);
-
- List<Integer> getContactsByCustomer(String customerName);
-
- List<Integer> getContactsByTLF(String tlf);
-
- Contact getContact(Integer id);
-
- void remove();
-}
Deleted: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/clusteredentity/BulkOperationsTestBean.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/clusteredentity/BulkOperationsTestBean.java 2009-11-09 10:59:47 UTC (rev 96163)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/clusteredentity/BulkOperationsTestBean.java 2009-11-09 11:08:33 UTC (rev 96164)
@@ -1,162 +0,0 @@
-/*
- * 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.clusteredentity;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.ejb.Remote;
-import javax.ejb.Remove;
-import javax.ejb.Stateless;
-import javax.persistence.EntityManager;
-import javax.persistence.FlushModeType;
-import javax.persistence.PersistenceContext;
-
-import org.jboss.ejb3.annotation.RemoteBinding;
-
-/**
- * @author Brian Stansberry
- * @version $Revision$
- */
- at Stateless
- at Remote(BulkOperationsTest.class)
- at RemoteBinding(jndiBinding="BulkOperationsTestBean/remote")
-public class BulkOperationsTestBean implements BulkOperationsTest
-{
- @PersistenceContext
- private EntityManager manager;
-
-
- public void createContacts()
- {
- for (int i = 0; i < 10; i++)
- createCustomer(i);
- }
-
- public int deleteContacts()
- {
- String deleteHQL = "delete Contact where customer in ";
- deleteHQL += " (select customer FROM Customer as customer ";
- deleteHQL += " where customer.name = :cName)";
-
- int rowsAffected = manager.createQuery(deleteHQL)
- .setFlushMode(FlushModeType.AUTO)
- .setParameter("cName", "Red Hat")
- .executeUpdate();
- return rowsAffected;
- }
-
- public List<Integer> getContactsByCustomer(String customerName)
- {
- String selectHQL = "select contact.id from Contact contact";
- selectHQL += " where contact.customer.name = :cName";
-
- List results = manager.createQuery(selectHQL)
- .setFlushMode(FlushModeType.AUTO)
- .setParameter("cName", customerName)
- .getResultList();
-
- return results;
- }
-
- public List<Integer> getContactsByTLF(String tlf)
- {
- String selectHQL = "select contact.id from Contact contact";
- selectHQL += " where contact.tlf = :cTLF";
-
- List results = manager.createQuery(selectHQL)
- .setFlushMode(FlushModeType.AUTO)
- .setParameter("cTLF", tlf)
- .getResultList();
-
- return results;
- }
-
- public int updateContacts(String name, String newTLF)
- {
- String updateHQL = "update Contact set tlf = :cNewTLF where name = :cName";
-
- int rowsAffected = manager.createQuery(updateHQL)
- .setFlushMode(FlushModeType.AUTO)
- .setParameter("cNewTLF", newTLF)
- .setParameter("cName", name)
- .executeUpdate();
- return rowsAffected;
- }
-
- public Contact getContact(Integer id)
- {
- return manager.find(Contact.class, id);
- }
-
- @Remove
- public void remove()
- {
-
- }
-
- private Customer createCustomer(int id)
- {
- System.out.println("CREATE CUSTOMER " + id);
- try
- {
- Customer customer = new Customer();
- customer.setId(id);
- customer.setName((id % 2 == 0) ? "JBoss" : "Red Hat");
- Set<Contact> contacts = new HashSet<Contact>();
-
- Contact kabir = new Contact();
- kabir.setId(1000 + id);
- kabir.setCustomer(customer);
- kabir.setName("Kabir");
- kabir.setTlf("1111");
- contacts.add(kabir);
-
- Contact bill = new Contact();
- bill.setId(2000 +id);
- bill.setCustomer(customer);
- bill.setName("Bill");
- bill.setTlf("2222");
- contacts.add(bill);
-
- customer.setContacts(contacts);
-
- manager.persist(customer);
- return customer;
- }
- catch (RuntimeException e)
- {
- throw e;
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- System.out.println("CREATE CUSTOMER " + id + " - END");
- }
- }
-
-}
Deleted: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/clusteredentity/Contact.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/clusteredentity/Contact.java 2009-11-09 10:59:47 UTC (rev 96163)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/clusteredentity/Contact.java 2009-11-09 11:08:33 UTC (rev 96164)
@@ -1,95 +0,0 @@
-/*
- * 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.clusteredentity;
-
-import java.io.Serializable;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-
-import org.hibernate.annotations.Cache;
-import org.hibernate.annotations.CacheConcurrencyStrategy;
-
-/**
- *
- * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
- * @version $Revision$
- */
- at Entity
- at Cache (usage=CacheConcurrencyStrategy.TRANSACTIONAL)
-public class Contact implements Serializable
-{
- 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;
- }
-
-}
Deleted: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/clusteredentity/Customer.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/clusteredentity/Customer.java 2009-11-09 10:59:47 UTC (rev 96163)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/clusteredentity/Customer.java 2009-11-09 11:08:33 UTC (rev 96164)
@@ -1,85 +0,0 @@
-/*
- * 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.clusteredentity;
-
-import java.util.Set;
-import javax.persistence.CascadeType;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.Id;
-import javax.persistence.OneToMany;
-import org.hibernate.annotations.Cache;
-import org.hibernate.annotations.CacheConcurrencyStrategy;
-
-/**
- * Company customer
- *
- * @author Emmanuel Bernard
- * @author Kabir Khan
- */
- at Entity
- at Cache (usage=CacheConcurrencyStrategy.TRANSACTIONAL)
-public class Customer implements java.io.Serializable
-{
- 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;
- }
-
- @Cache (usage=CacheConcurrencyStrategy.TRANSACTIONAL)
- @OneToMany(mappedBy="customer", fetch=FetchType.EAGER, cascade=CascadeType.ALL)
- public Set<Contact> getContacts()
- {
- return contacts;
- }
-
- public void setContacts(Set<Contact> contacts)
- {
- this.contacts = contacts;
- }
-}
-
Deleted: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/clusteredentity/EntityTest.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/clusteredentity/EntityTest.java 2009-11-09 10:59:47 UTC (rev 96163)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/clusteredentity/EntityTest.java 2009-11-09 11:08:33 UTC (rev 96164)
@@ -1,43 +0,0 @@
-/*
- * 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.clusteredentity;
-
-
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public interface EntityTest
-{
- void getCache(String cacheConfigName);
-
- Customer createCustomer();
-
- Customer findByCustomerId(Integer id);
-
- String loadedFromCache();
-
- void cleanup();
-}
Deleted: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/clusteredentity/EntityTestBean.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/clusteredentity/EntityTestBean.java 2009-11-09 10:59:47 UTC (rev 96163)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/clusteredentity/EntityTestBean.java 2009-11-09 11:08:33 UTC (rev 96164)
@@ -1,265 +0,0 @@
-/*
- * 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.clusteredentity;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.annotation.PreDestroy;
-import javax.ejb.Remote;
-import javax.ejb.Remove;
-import javax.ejb.Stateful;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-
-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.jboss.ejb3.annotation.RemoteBinding;
-import org.jboss.ha.framework.server.CacheManagerLocator;
-import org.jboss.logging.Logger;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
- at Stateful
- at Remote(EntityTest.class)
- at RemoteBinding(jndiBinding="EntityTestBean/remote")
-public class EntityTestBean implements EntityTest
-{
- private static final Logger log = Logger.getLogger(EntityTestBean.class);
-
- @PersistenceContext
- private EntityManager manager;
-
- private String cacheConfigName;
-
- private transient Cache<Object, Object> cache;
-
- private transient MyListener listener;
-
- public EntityTestBean()
- {
- }
-
- public void getCache(String cacheConfigName)
- {
- this.cacheConfigName = cacheConfigName;
-
- try
- {
- if (cache == null && cacheConfigName != null)
- {
- CacheManager cm = CacheManagerLocator.getCacheManagerLocator().getCacheManager(null);
- cache = cm.getCache(cacheConfigName, true);
- cache.start();
- }
-
- if (listener == null)
- {
- listener = new MyListener();
- cache.addCacheListener(listener);
- }
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
-
- public Customer createCustomer()
- {
- System.out.println("CREATE CUSTOMER");
- try
- {
- listener.clear();
-
- Customer customer = new Customer();
- customer.setId(new Integer(1));
- customer.setName("JBoss");
- Set<Contact> contacts = new HashSet<Contact>();
-
- Contact kabir = new Contact();
- kabir.setId(new Integer(1));
- kabir.setCustomer(customer);
- kabir.setName("Kabir");
- kabir.setTlf("1111");
- contacts.add(kabir);
-
- Contact bill = new Contact();
- bill.setId(new Integer(2));
- bill.setCustomer(customer);
- bill.setName("Bill");
- bill.setTlf("2222");
- contacts.add(bill);
-
- customer.setContacts(contacts);
-
- manager.persist(customer);
- return customer;
- }
- catch (RuntimeException e)
- {
- throw e;
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- System.out.println("CREATE CUSTOMER - END");
- }
- }
-
- public Customer findByCustomerId(Integer id)
- {
- System.out.println("FIND CUSTOMER");
- listener.clear();
- try
- {
- Customer customer = manager.find(Customer.class, id);
-
- return customer;
- }
- catch (RuntimeException e)
- {
- throw e;
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- System.out.println("FIND CUSTOMER - END");
- }
- }
-
- public String loadedFromCache()
- {
- System.out.println("CHECK CACHE");
- try
- {
- System.out.println("Visited: " + listener.visited);
- if (!listener.visited.contains("Customer#1"))
- return "Customer#1 was not in cache";
- if (!listener.visited.contains("Contact#1"))
- return "Contact#1 was not in cache";
- if (!listener.visited.contains("Contact#2"))
- return "Contact2#1 was not in cache";
- if (!listener.visited.contains("Customer.contacts#1"))
- return "Customer.contacts#1 was not in cache";
- return null;
- }
- finally
- {
- System.out.println("CHECK CACHE - END");
- }
-
- }
-
- @PreDestroy
- @Remove
- public void cleanup()
- {
- try
- {
- if (cache != null && listener != null)
- {
- cache.removeCacheListener(listener);
- }
- }
- catch (Exception e)
- {
- log.error("Caught exception in cleanup", e);
- }
-
- try
- {
- if (manager != null)
- {
- Customer c = findByCustomerId(new Integer(1));
- if (c != null)
- {
- Set contacts = c.getContacts();
- for (Iterator it = contacts.iterator(); it.hasNext();)
- manager.remove(it.next());
- c.setContacts(null);
- manager.remove(c);
- }
- }
- }
- catch (Exception e)
- {
- log.error("Caught exception in cleanup", e);
- }
-
- try
- {
- if (cache != null)
- CacheManagerLocator.getCacheManagerLocator().getCacheManager(null).releaseCache(cacheConfigName);
- }
- catch (Exception e)
- {
- log.error("Caught exception releasing cache", e);
- }
- }
-
- @CacheListener
- public class MyListener
- {
- HashSet<String> visited = new HashSet<String>();
-
- public void clear()
- {
- visited.clear();
- }
-
- @NodeVisited
- public void nodeVisited(NodeVisitedEvent event)
- {
- if (!event.isPre())
- {
- Fqn fqn = event.getFqn();
- System.out.println("MyListener - Visiting node " + fqn.toString());
- String name = fqn.toString();
- String token = ".clusteredentity.";
- 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);
- }
- }
- }
- }
-}
Deleted: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/entityoptimisticlocking/unit/EntityUnitTestCase.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/entityoptimisticlocking/unit/EntityUnitTestCase.java 2009-11-09 10:59:47 UTC (rev 96163)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/entityoptimisticlocking/unit/EntityUnitTestCase.java 2009-11-09 11:08:33 UTC (rev 96164)
@@ -1,212 +0,0 @@
-/*
- * 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.entityoptimisticlocking.unit;
-
-import java.util.Set;
-import org.jboss.ejb3.test.entity.Address;
-import org.jboss.ejb3.test.entity.Company;
-import org.jboss.ejb3.test.entity.Customer;
-import org.jboss.ejb3.test.entity.EntityTest;
-import org.jboss.ejb3.test.entity.FieldAddress;
-import org.jboss.ejb3.test.entity.FieldCompany;
-import org.jboss.ejb3.test.entity.FieldCustomer;
-import org.jboss.ejb3.test.entity.FieldFlight;
-import org.jboss.ejb3.test.entity.FieldTicket;
-import org.jboss.ejb3.test.entity.Flight;
-import org.jboss.ejb3.test.entity.Ticket;
-import org.jboss.test.JBossTestCase;
-import junit.framework.Test;
-
-import org.jboss.logging.Logger;
-
-/**
- * Sample client for the jboss container.
- *
- * @author <a href="mailto:bill at burkecentral.com">Bill Burke</a>
- * @version $Id: EntityUnitTestCase.java 57207 2006-09-26 12:06:13Z dimitris at jboss.org $
- */
-
-public class EntityUnitTestCase
-extends JBossTestCase
-{
- private static final Logger log = Logger.getLogger(EntityUnitTestCase.class);
-
- static boolean deployed = false;
- static int test = 0;
-
- public EntityUnitTestCase(String name)
- {
-
- super(name);
-
- }
-
- public void testOneToMany() throws Exception
- {
- EntityTest test = (EntityTest) this.getInitialContext().lookup("EntityTestBean/remote");
- Customer c = test.oneToManyCreate();
- assertNotNull(c);
- assertNotNull(c.getTickets());
- Set<Ticket> tickets = c.getTickets();
- assertTrue(tickets.size() > 0);
-
- // test find
- c = test.findCustomerById(c.getId());
- assertNotNull(c);
- assertNotNull(c.getTickets());
- tickets = c.getTickets();
- assertTrue(tickets.size() > 0);
-
- // test 1-1
- Address address = c.getAddress();
- assertTrue(address != null);
- assertTrue(address.getCity().equals("Boston"));
- }
-
- public void testManyToOne() throws Exception
- {
- EntityTest test = (EntityTest) this.getInitialContext().lookup("EntityTestBean/remote");
- Flight f = test.manyToOneCreate();
- f = test.findFlightById(f.getId());
- assertTrue(f.getName().equals("AF0101"));
- assertTrue(f.getCompany().getName().equals("Air France"));
-
- Company c = test.findCompanyById(f.getCompany().getId());
- assertTrue(c != null);
- assertTrue(c.getFlights().size() == 1);
- }
-
- public void testManyToMany() throws Exception
- {
- EntityTest test = (EntityTest) this.getInitialContext().lookup("EntityTestBean/remote");
- test.manyToManyCreate();
-
- Flight one = test.findFlightById(new Long(1));
- assertTrue(one.getCompany().getName().equals("Air France"));
-
- Flight two = test.findFlightById(new Long(2));
- assertTrue(two.getCompany().getName().equals("USAir"));
-
- System.out.println("Air France customers");
- for (Customer c : one.getCustomers())
- {
- System.out.println(c.getName());
-
- }
- System.out.println("USAir customers");
-
- for (Customer c : two.getCustomers())
- {
- System.out.println(c.getName());
- }
-
- }
-
- public void testFieldOneToMany() throws Exception
- {
- EntityTest test = (EntityTest) this.getInitialContext().lookup("EntityTestBean/remote");
- FieldCustomer c = test.fieldOneToManyCreate();
- assertNotNull(c);
- assertNotNull(c.getTickets());
- Set<FieldTicket> tickets = c.getTickets();
- assertTrue(tickets.size() > 0);
-
- // test find
- c = test.fieldFindCustomerById(c.getId());
- assertNotNull(c);
- assertNotNull(c.getTickets());
- tickets = c.getTickets();
- assertTrue(tickets.size() > 0);
-
- // test 1-1
- FieldAddress address = c.getAddress();
- assertTrue(address != null);
- assertTrue(address.getCity().equals("Boston"));
- }
-
- public void testFieldManyToOne() throws Exception
- {
- EntityTest test = (EntityTest) this.getInitialContext().lookup("EntityTestBean/remote");
- FieldFlight f = test.fieldManyToOneCreate();
- f = test.fieldFindFlightById(f.getId());
- assertTrue(f.getName().equals("AF0101"));
- assertTrue(f.getCompany().getName().equals("Air France"));
-
- FieldCompany c = test.fieldFindCompanyById(f.getCompany().getId());
- assertTrue(c != null);
- assertTrue(c.getFlights().size() == 1);
- }
-
- public void testFieldManyToMany() throws Exception
- {
- EntityTest test = (EntityTest) this.getInitialContext().lookup("EntityTestBean/remote");
- test.fieldManyToManyCreate();
-
- FieldFlight one = test.fieldFindFlightById(new Long(1));
- assertTrue(one.getCompany().getName().equals("Air France"));
-
- FieldFlight two = test.fieldFindFlightById(new Long(2));
- assertTrue(two.getCompany().getName().equals("USAir"));
-
- System.out.println("Air France customers");
- for (FieldCustomer c : one.getCustomers())
- {
- System.out.println(c.getName());
-
- }
- System.out.println("USAir customers");
-
- for (FieldCustomer c : two.getCustomers())
- {
- System.out.println(c.getName());
- }
-
- }
-
- public void testNamedQueries() throws Exception
- {
- EntityTest test = (EntityTest) this.getInitialContext().lookup("EntityTestBean/remote");
- test.testNamedQueries();
- }
-
- public void testOutsideTx() throws Exception
- {
- EntityTest test = (EntityTest) this.getInitialContext().lookup("EntityTestBean/remote");
- test.testOutsideTransaction();
-
- }
-
- public void testFlush() throws Exception
- {
- EntityTest test = (EntityTest) this.getInitialContext().lookup("EntityTestBean/remote");
- Customer c = test.createCustomer("Emmanuel");
- test.changeCustomer(c.getId(), "Bill");
- Customer c2 = test.loadCustomer(c.getId());
- assertEquals("Bill", c2.getName());
- }
-
- public static Test suite() throws Exception
- {
- return getDeploySetup(EntityUnitTestCase.class, "entityoptimisticlocking-test.jar");
- }
-
-}
More information about the jboss-cvs-commits
mailing list