001: /**
002: * EasyBeans
003: * Copyright (C) 2006 Bull S.A.S.
004: * Contact: easybeans@ow2.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: TestEntityManager01.java 1970 2007-10-16 11:49:25Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.tests.entity;
025:
026: import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.entitymanager.ItfEntityManagerTester01;
027: import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.entitymanager.SLSBEntityManagerTester01;
028: import org.ow2.easybeans.tests.common.helper.EJBHelper;
029: import org.testng.annotations.BeforeMethod;
030: import org.testng.annotations.Test;
031:
032: /**
033: * Verifies if the methods remove and persist from EntityManager are working
034: * properly. The items 3.2.1 e 3.2.2 (Persistence doc)
035: * @reference JSR 220-PROPOSED FINAL
036: * @requirement Application Server must be running; the bean
037: * SLSBEntityManagerTester must be deployed.
038: * @setup gets the reference of SLSBEntityManagerTester
039: * @author Gisele Pinheiro Souza
040: * @author Eduardo Studzinski Estima de Castro
041: */
042: public class TestEntityManager01 {
043:
044: /**
045: * The entity bean primary key that is used during the tests.
046: */
047: public static final int PRIMARY_KEY = 1;
048:
049: /**
050: * The entity bean name that is used during the tests.
051: */
052: public static final String ENTITY_NAME = "test";
053:
054: /**
055: * The entity bean alternative name that is used during the tests.
056: */
057: public static final String ALTERNATIVE_ENTITY_NAME = "test2";
058:
059: /**
060: * The stateless bean used to verify the EntityManager.
061: */
062: private ItfEntityManagerTester01 slsbEntityManagerTester01;
063:
064: /**
065: * Creates the stateless bean used during the tests.
066: * @throws Exception if an error occurs during the lookup.
067: */
068: @BeforeMethod
069: public void setup() throws Exception {
070: slsbEntityManagerTester01 = EJBHelper.getBeanRemoteInstance(
071: SLSBEntityManagerTester01.class,
072: ItfEntityManagerTester01.class);
073: slsbEntityManagerTester01.removeEBStore(PRIMARY_KEY);
074: }
075:
076: /**
077: * Tests if the EntityManager can make a merge with a detached entity.
078: * @input PRIMARY_KEY,ENTITY_NAME and ALTERNATIVE_ENTITY_NAME.
079: * @output the method execution without error.
080: */
081: @Test
082: public void testMerge() {
083: slsbEntityManagerTester01.mergeEBStore(PRIMARY_KEY,
084: ENTITY_NAME, ALTERNATIVE_ENTITY_NAME);
085: }
086:
087: /**
088: * Tests if the EntityManager can make a refresh.
089: * @input PRIMARY_KEY,ENTITY_NAME and ALTERNATIVE_ENTITY_NAME.
090: * @output the method execution without error.
091: */
092: @Test
093: public void testRefresh() {
094: slsbEntityManagerTester01.refreshEBStore(PRIMARY_KEY,
095: ENTITY_NAME, ALTERNATIVE_ENTITY_NAME);
096: }
097:
098: /**
099: * Tests if the contains method in the EntityManager works well.
100: * @input PRIMARY_KEY and ENTITY_NAME.
101: * @output the method execution without error.
102: */
103: @Test
104: public void testContains() {
105: slsbEntityManagerTester01.containsEBStore(PRIMARY_KEY,
106: ENTITY_NAME);
107: }
108:
109: }
|