KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > examples > TestExample


1 /**
2  * EasyBeans
3  * Copyright (C) 2006 Bull S.A.S.
4  * Contact: easybeans@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: TestExample.java 978 2006-07-28 13:19:14Z studzine $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.examples;
26
27 import static org.objectweb.easybeans.tests.common.helper.EJBHelper.getBeanRemoteInstance;
28 import static org.testng.Assert.assertEquals;
29
30 import org.objectweb.easybeans.tests.common.ejbs.base.ItfExample;
31 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.SLSBExample;
32 import org.testng.annotations.BeforeMethod;
33 import org.testng.annotations.Test;
34
35 /**
36  * This is an example of an EasyBeans Test Suite Class.
37  * @reference It is used to specify the document that the tests cover. Example:
38  * JSR 220-PROPOSED FINAL - Stateless - Method Call
39  * @requirement It is used to specify the classes and files needed to run the
40  * tests. Exampe: EasyBeans must be running and the bean
41  * org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.SFSBExample
42  * must be deployed.
43  * @setup It is used to specify the classes needed to run the test(setup methods).
44  * @author Eduardo Studzinski Estima de Castro
45  * @author Gisele Pinheiro Souza
46  */

47 public class TestExample {
48
49     /**
50      * Constant.
51      */

52     private static final Integer JavaDoc INPUT = new Integer JavaDoc(1);
53
54     /**
55      * Bean used in tests.
56      */

57     private ItfExample<Integer JavaDoc> bean;
58
59     /**
60      * Gets a new bean instance used during the tests.
61      * @throws Exception if an error occurs during the setup.
62      */

63     @SuppressWarnings JavaDoc("unchecked")
64     @BeforeMethod
65     public void setup() throws Exception JavaDoc {
66         // Gets a bean instance.
67
bean = getBeanRemoteInstance(SLSBExample.class, ItfExample.class);
68     }
69
70     /**
71      * Indicates the test description. Example: Tests if the bean can return a
72      * value without modifications.
73      * @input It is used to specify the classes and files needed to run the
74      * test. Example: Integer value.
75      * @output It is used to specify the classes and files needed to run the
76      * test. Example: The same input integer.
77      * @throws Exception if an error occurs during the test.
78      */

79     @Test
80     public void test00() throws Exception JavaDoc {
81         // Output value, it must be the same as the input.
82
Integer JavaDoc output = bean.getValue(INPUT);
83
84         // Test if input and output are equal.
85
assertEquals(INPUT, output, "The input and output values should be equal.");
86     }
87 }
88
Popular Tags