01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.superbiz.injection.h3jpa;
17:
18: import junit.framework.TestCase;
19:
20: import javax.naming.Context;
21: import javax.naming.InitialContext;
22: import java.util.Properties;
23: import java.util.List;
24:
25: import org.superbiz.injection.h3jpa.Movie;
26: import org.superbiz.injection.h3jpa.Movies;
27:
28: /**
29: * @version $Revision: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
30: */
31: public class MoviesTest extends TestCase {
32:
33: public void test() throws Exception {
34: Properties p = new Properties();
35: p.put(Context.INITIAL_CONTEXT_FACTORY,
36: "org.apache.openejb.client.LocalInitialContextFactory");
37: p.put("movieDatabase", "new://Resource?type=DataSource");
38: p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
39: p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
40:
41: p.put("movieDatabaseUnmanaged",
42: "new://Resource?type=DataSource");
43: p.put("movieDatabaseUnmanaged.JdbcDriver",
44: "org.hsqldb.jdbcDriver");
45: p.put("movieDatabaseUnmanaged.JdbcUrl",
46: "jdbc:hsqldb:mem:moviedb");
47: p.put("movieDatabaseUnmanaged.JtaManaged", "false");
48:
49: Context context = new InitialContext(p);
50:
51: Movies movies = (Movies) context.lookup("MoviesLocal");
52:
53: movies.addMovie(new Movie("Quentin Tarantino",
54: "Reservoir Dogs", 1992));
55: movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
56: movies
57: .addMovie(new Movie("Joel Coen", "The Big Lebowski",
58: 1998));
59:
60: List<Movie> list = movies.getMovies();
61: assertEquals("List.size()", 3, list.size());
62:
63: for (Movie movie : list) {
64: movies.deleteMovie(movie);
65: }
66:
67: assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
68: }
69: }
|