KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > entity > test > PathologicalUnitTestCase


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.test.entity.test;
23
24 import junit.framework.Test;
25
26 import org.jboss.test.JBossTestCase;
27
28 import org.jboss.test.entity.interfaces.EntitySession;
29 import org.jboss.test.entity.interfaces.EntitySessionHome;
30
31 /**
32  * Some entity bean tests.
33  *
34  * @author Adrian.Brock@HappeningTimes.com
35  * @version $Revision: 37406 $
36  */

37 public class PathologicalUnitTestCase
38    extends JBossTestCase
39 {
40    public PathologicalUnitTestCase(String JavaDoc name)
41    {
42       super(name);
43    }
44
45    public static Test suite()
46       throws Exception JavaDoc
47    {
48       return getDeploySetup(PathologicalUnitTestCase.class, "jboss-test-pathological-entity.jar");
49    }
50
51    public void testErrorFromEjbCreate()
52       throws Exception JavaDoc
53    {
54       getLog().debug("Retrieving session");
55       EntitySession session = getEntitySessionEJB();
56
57       getLog().debug("Testing error from ejbCreate");
58       session.createPathological("ejbCreate", true);
59    }
60
61    public void testErrorFromRemove()
62       throws Exception JavaDoc
63    {
64       getLog().debug("Retrieving session");
65       EntitySession session = getEntitySessionEJB();
66
67       getLog().debug("Creating entity");
68       session.createPathological("remove", false);
69
70       getLog().debug("Testing error from remove");
71       session.removeHomePathological("remove", true);
72    }
73
74    public void testErrorFromEjbRemove()
75       throws Exception JavaDoc
76    {
77       getLog().debug("Retrieving session");
78       EntitySession session = getEntitySessionEJB();
79
80       getLog().debug("Creating entity");
81       session.createPathological("remove", false);
82
83       getLog().debug("Testing error from remove");
84       session.removePathological("remove", true);
85    }
86
87    public void testErrorFromFind()
88       throws Exception JavaDoc
89    {
90       getLog().debug("Retrieving session");
91       EntitySession session = getEntitySessionEJB();
92
93       getLog().debug("Creating entity");
94       session.createPathological("find", false);
95
96       getLog().debug("Testing error from find");
97       session.findPathological("find", true);
98    }
99
100    public void testErrorFromGet()
101       throws Exception JavaDoc
102    {
103       getLog().debug("Retrieving session");
104       EntitySession session = getEntitySessionEJB();
105
106       getLog().debug("Creating entity");
107       session.createPathological("get", false);
108
109       getLog().debug("Testing error from get");
110       session.getPathological("get", true);
111    }
112
113    public void testErrorFromSet()
114       throws Exception JavaDoc
115    {
116       getLog().debug("Retrieving session");
117       EntitySession session = getEntitySessionEJB();
118
119       getLog().debug("Creating entity");
120       session.createPathological("set", false);
121
122       getLog().debug("Testing error from set");
123       session.setPathological("set", true);
124    }
125
126    private EntitySession getEntitySessionEJB()
127       throws Exception JavaDoc
128    {
129       return ((EntitySessionHome) getInitialContext().lookup("EntitySessionEJB")).create();
130    }
131 }
132
Popular Tags