You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@tomee.apache.org by bu...@apache.org on 2012/12/20 13:10:56 UTC
svn commit: r843230 - in /websites/staging/openejb/trunk: cgi-bin/ content/
content/unit-testing-transactions.html
Author: buildbot
Date: Thu Dec 20 12:10:56 2012
New Revision: 843230
Log:
Staging update by buildbot for openejb
Modified:
websites/staging/openejb/trunk/cgi-bin/ (props changed)
websites/staging/openejb/trunk/content/ (props changed)
websites/staging/openejb/trunk/content/unit-testing-transactions.html
Propchange: websites/staging/openejb/trunk/cgi-bin/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Thu Dec 20 12:10:56 2012
@@ -1 +1 @@
-1423352
+1424426
Propchange: websites/staging/openejb/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Thu Dec 20 12:10:56 2012
@@ -1 +1 @@
-1423352
+1424426
Modified: websites/staging/openejb/trunk/content/unit-testing-transactions.html
==============================================================================
--- websites/staging/openejb/trunk/content/unit-testing-transactions.html (original)
+++ websites/staging/openejb/trunk/content/unit-testing-transactions.html Thu Dec 20 12:10:56 2012
@@ -231,13 +231,10 @@ import java.util.List;
@TransactionAttribute(MANDATORY)
public class MoviesImpl implements Movies {
- @PersistenceContext(unitName = "movie-unit", type =
-</code></pre>
-
-<p>PersistenceContextType.TRANSACTION)
- private EntityManager entityManager;</p>
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.TRANSACTION)
+ private EntityManager entityManager;
-<pre><code> public void addMovie(Movie movie) throws Exception {
+ public void addMovie(Movie movie) throws Exception {
entityManager.persist(movie);
}
@@ -246,14 +243,12 @@ public class MoviesImpl implements Movie
}
public List<Movie> getMovies() throws Exception {
- Query query = entityManager.createQuery("SELECT m from Movie as
+ Query query = entityManager.createQuery("SELECT m from Movie asm");
+ return query.getResultList();
+ }
+}
</code></pre>
-<p>m");
- return query.getResultList();
- }
- }</p>
-
<p>Test code below.</p>
<p><a name="UnitTestingTransactions-Pureinlined"></a></p>
@@ -271,35 +266,26 @@ public class MoviesImpl implements Movie
public void test() throws Exception {
Caller transactionBean = (Caller)
-</code></pre>
-
-<p>context.lookup("TransactionBeanLocal");</p>
+ context.lookup("TransactionBeanLocal");
-<pre><code> transactionBean.call(new Callable() {
+ transactionBean.call(new Callable() {
public Object call() throws Exception {
Movies movies = (Movies) context.lookup("MoviesLocal");
- movies.addMovie(new Movie("Quentin Tarantino", "Reservoir
-</code></pre>
-
-<p>Dogs", 1992));
- movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
- movies.addMovie(new Movie("Joel Coen", "The Big Lebowski",
-1998));</p>
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski",1998));
-<pre><code> List<Movie> list = movies.getMovies();
+ List<Movie> list = movies.getMovies();
assertEquals("List.size()", 3, list.size());
for (Movie movie : list) {
movies.deleteMovie(movie);
}
- assertEquals("Movies.getMovies()", 0,
-</code></pre>
+ assertEquals("Movies.getMovies()", 0,movies.getMovies().size());
-<p>movies.getMovies().size());</p>
-
-<pre><code> return null;
+ return null;
}
});
}
@@ -322,53 +308,44 @@ testing is often a very good way to stom
}
private void doWork() throws Exception {
- Movies movies = (Movies) context.lookup("MoviesLocal");
-
- movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs",
-</code></pre>
+ Movies movies = (Movies) context.lookup("MoviesLocal");
-<p>1992));
- movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
- movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));</p>
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs",1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
-<pre><code> List<Movie> list = movies.getMovies();
- assertEquals("List.size()", 3, list.size());
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
- for (Movie movie : list) {
- movies.deleteMovie(movie);
- }
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
- assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
}
public void testWithTransaction() throws Exception {
- Caller transactionBean = (Caller)
-</code></pre>
-
-<p>context.lookup("TransactionBeanLocal");</p>
+ Caller transactionBean = (Caller)context.lookup("TransactionBeanLocal");
-<pre><code> transactionBean.call(new Callable(){
- public Object call() throws Exception {
- doWork();
- return null;
- }
- });
+ transactionBean.call(new Callable(){
+ public Object call() throws Exception {
+ doWork();
+ return null;
+ }
+ });
}
public void testWithoutTransaction() throws Exception {
- try {
- doWork();
- fail("The Movies bean should be using
+ try {
+ doWork();
+ fail("The Movies bean should be using TransactionAttributeType.MANDATORY");
+ } catch (javax.transaction.TransactionRequiredException e) {
+ // good, our Movies bean is using TransactionAttributeType.MANDATORY as we want
+ }
+ }
+}
</code></pre>
-<p>TransactionAttributeType.MANDATORY");
- } catch (javax.transaction.TransactionRequiredException e) {
- // good, our Movies bean is using
-TransactionAttributeType.MANDATORY as we want
- }
- }
- }</p>
-