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: TestEntityManagerQueries.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.stateful.containermanaged.entitymanager.ItfEntityManagerQueriesTester;
027: import org.ow2.easybeans.tests.common.ejbs.stateful.containermanaged.entitymanager.SFSBEntityManagerQueriesTester;
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 related with queries of the Entitymanager are working
034: * properly. The items 3.1.1, 3.5.4 e 3.5.6 (Persistence doc)
035: * @reference JSR 220-PROPOSED FINAL
036: * @requirement Application Server must be running; the bean
037: * SLSBEntityManagerQueriesTester must be deployed.
038: * @setup gets the reference of SLSBEntityManagerQueriesTester
039: * @author Gisele Pinheiro Souza
040: * @author Eduardo Studzinski Estima de Castro
041: */
042: public class TestEntityManagerQueries {
043:
044: /**
045: * The bean used during the tests.
046: */
047: private ItfEntityManagerQueriesTester sfsbQueryTester;
048:
049: /**
050: * Creates the stateful bean used during the tests.
051: * @throws Exception if an error occurs during the lookup.
052: */
053: @BeforeMethod
054: public void setup() throws Exception {
055: sfsbQueryTester = EJBHelper.getBeanRemoteInstance(
056: SFSBEntityManagerQueriesTester.class,
057: ItfEntityManagerQueriesTester.class);
058: sfsbQueryTester.startup();
059: }
060:
061: /**
062: * Tests if the EntityManager can call a named query that is write in EJB
063: * QL.
064: * @input -
065: * @output the correct method execution.
066: */
067: @Test
068: public void testCallNamedQueryEJBQL() {
069: sfsbQueryTester.callNamedQuery();
070: }
071:
072: /**
073: * Tests if the EntityManager can call a named query that is write in native
074: * SQL.
075: * @input -
076: * @output the correct method execution.
077: */
078: @Test
079: public void testCallNamedQueryNative() {
080: sfsbQueryTester.callNamedNativeQuery();
081: }
082:
083: /**
084: * Tests if the EntityManager can create a EJB QL query.
085: * @input -
086: * @output the correct method execution.
087: */
088: @Test
089: public void testCreateQueryEJBQL() {
090: sfsbQueryTester.callCreateQuery();
091: }
092:
093: /**
094: * Tests if the EntityManager can create a native query without choosing the
095: * result class.
096: * @input -
097: * @output the correct method execution.
098: */
099: @Test
100: public void testCreateQueryNative00() {
101: sfsbQueryTester.callCreateNativeQuery00();
102: }
103:
104: /**
105: * Tests if the EntityManager can create a native query when the result
106: * class is choosen.
107: * @input -
108: * @output the correct method execution.
109: */
110: @Test
111: public void testCreateQueryNative01() {
112: sfsbQueryTester.callCreateNativeQuery01();
113: }
114:
115: /**
116: * Tests if the EntityManager can create a native query when the
117: * resultSetMapping is choosen.
118: * @input -
119: * @output the correct method execution.
120: */
121: @Test
122: public void testCreateQueryNative02() {
123: sfsbQueryTester.callCreateNativeQuery02();
124: }
125: }
|