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: */
17: package org.bpmscript.db;
18:
19: import java.util.Properties;
20:
21: import junit.framework.TestCase;
22:
23: import org.apache.commons.dbcp.BasicDataSource;
24: import org.hibernate.SessionFactory;
25: import org.hibernate.cfg.Configuration;
26:
27: public class HnProcessManagerTest extends TestCase {
28:
29: protected void setUp() throws Exception {
30: super .setUp();
31: }
32:
33: protected void tearDown() throws Exception {
34: super .tearDown();
35: }
36:
37: public void testTheWholeShebang() throws Exception {
38:
39: Properties properties = new Properties();
40: properties.setProperty("hibernate.hbm2ddl.auto", "update");
41: properties.setProperty("hibernate.dialect",
42: "org.hibernate.dialect.DerbyDialect");
43: properties.setProperty("hibernate.query.substitutions",
44: "true 1, false 0");
45: properties.setProperty("hibernate.show_sql", "false");
46: properties.setProperty("hibernate.c3p0.minPoolSize", "5");
47: properties.setProperty("hibernate.c3p0.maxPoolSize", "20");
48: properties.setProperty("hibernate.c3p0.timeout", "600");
49: properties.setProperty("hibernate.c3p0.max_statement", "50");
50: properties.setProperty(
51: "hibernate.c3p0.testConnectionOnCheckout", "false");
52:
53: Configuration cfg = new Configuration().addClass(
54: DbProcess.class).addClass(DbProcessInstance.class)
55: .addClass(DbProcessInstanceState.class).addClass(
56: DbProcessSource.class)
57: .setProperties(properties);
58:
59: SessionFactory sessionFactory = null;
60: try {
61: sessionFactory = cfg.buildSessionFactory();
62:
63: BasicDataSource dataSource = new BasicDataSource();
64: dataSource
65: .setDriverClassName("org.apache.derby.jdbc.EmbeddedDriver");
66: dataSource.setUrl("jdbc:derby:bpmscript;create=true");
67:
68: HnProcessManager processManager = new HnProcessManager();
69: processManager.setDataSource(dataSource);
70: processManager.setSessionFactory(sessionFactory);
71:
72: String id = processManager.createProcess("bob", "bob",
73: false);
74: assertNotNull(id);
75: } finally {
76: try {
77: sessionFactory.close();
78: } catch (Throwable t) {
79: }
80: }
81:
82: }
83:
84: }
|