tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Romain Manni-Bucau <rmannibu...@gmail.com>
Subject Re: openEJB fail on second test
Date Thu, 23 Feb 2012 14:55:22 GMT
"SELECT m from Movie as m" can be "SELECT m from Movie m"

what i sent you works perfectly, not sure what is the difference....

- Romain


2012/2/23 amber <amber63@hotmail.fr>

> Romain : "as keyword is useless i think " . which keyword?
>
> A made some tests : the assertion pass when I delete movies from the EJB
> injection (localMovies injected with @EJB annotation)  but failed when I
> use
> the Web Service (either by @WebServiceRef or by Ws intrface)
>
> *the Movies EJB :*
>
> @Stateless
> @TransactionAttribute(TransactionAttributeType.REQUIRED)
> @WebService(endpointInterface = "org.superbiz.altdd.IMoviesWS", serviceName
> = "MoviesWebService", targetNamespace = "http://superbiz.org/wsdl")
> public class Movies implements IMoviesWS, MoviesLocal {
>
>        @PersistenceContext(unitName = "movie-unit", type =
> PersistenceContextType.TRANSACTION)
>        private EntityManager entityManager;
>
>         ...
>
>        @SuppressWarnings("unchecked")
>        public List<Movie> getMovies() throws Exception {
>                Query query = entityManager.createQuery("SELECT m from
> Movie as m");
>
>                 List<Movie> list = query.getResultList();
>                //System.out.println("size()= " + list.size());
>                //return query.getResultList();
>                return list;
>        }
> }
>
> *the test :*
>
> @LocalClient
> public class MoviesTest extends TestCase {
>
>        @WebServiceRef(wsdlLocation = "http://127.0.0.1:4204/Movies?wsdl")
>         private IMoviesWS moviesInject;
>
>        @EJB
>        private MoviesLocal localMovies;
>
> ...
>
>        public void test() throws Exception {
>
>                 localMovies.addMovie(new Movie("Quentin Tarantino",
> "Reservoir
> Dogs",1992));
>                localMovies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
>                localMovies.addMovie(new Movie("Joel Coen", "The Big
> Lebowski", 1998));
>
>                List<Movie> list = localMovies.getMovies();
>                 assertEquals("List.size()", 3, list.size());
>                for (Movie movie : list) {
>                         localMovies.deleteMovie(movie);
>                }
>
>                List<Movie> list2 = localMovies.getMovies();
>                System.out.println("size()= " + list2.size());
>                *// works fine*
>                assertEquals("List.size()", 0, list2.size());
>        }
>
>
>        public void testWSInjection() throws Exception {
>                moviesInject.addMovie(new Movie("Quentin Tarantino",
> "Reservoir
> Dogs",1992));
>                moviesInject.addMovie(new Movie("Joel Coen", "Fargo",
> 1996));
>                List<Movie> list = moviesInject.getMovies();
>                for (Movie movie : list) {
>                        moviesInject.deleteMovie(movie);
>                }
>                List<Movie> list2 = moviesInject.getMovies();
> *// the list2 returned is null*
>
>                System.out.println("size()= " + list2.size());
>
>                assertEquals("List.size()", 0, list2.size());
>
>        }
>
>
>
> did I miss something (again) ?
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/openEJB-fail-on-second-test-tp4401889p4414065.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message