|
| 1 | +/* |
| 2 | + * TestHibernatUtils.java |
| 3 | + * Created: 16 May 2017 |
| 4 | + * |
| 5 | + * Copyright 2017 Systemic Pty Ltd |
| 6 | + * |
| 7 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
| 8 | + * in compliance with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, software distributed under the License |
| 13 | + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
| 14 | + * or implied. See the License for the specific language governing permissions and limitations under |
| 15 | + * the License. |
| 16 | + */ |
| 17 | + |
| 18 | +package sif3.common.test.utils; |
| 19 | + |
| 20 | +import java.util.Properties; |
| 21 | + |
| 22 | +import sif3.common.persist.common.HibernateUtil; |
| 23 | + |
| 24 | +/** |
| 25 | + * @author Joerg Huber |
| 26 | + * |
| 27 | + */ |
| 28 | +public class TestHibernateUtils |
| 29 | +{ |
| 30 | + |
| 31 | + public boolean initialiseTest(Properties properties) |
| 32 | + { |
| 33 | + return HibernateUtil.initialise(properties); |
| 34 | + } |
| 35 | + |
| 36 | + public void shutdownTest() |
| 37 | + { |
| 38 | + HibernateUtil.shutdown(); |
| 39 | + } |
| 40 | + |
| 41 | + public Properties getProperties() |
| 42 | + { |
| 43 | + Properties properties = new Properties(); |
| 44 | + properties.setProperty("hibernate.connection.password", ""); |
| 45 | + properties.setProperty("hibernate.c3p0.max_size", "25"); |
| 46 | + |
| 47 | + return properties; |
| 48 | + } |
| 49 | + |
| 50 | + public static void main(String[] args) |
| 51 | + { |
| 52 | + |
| 53 | + TestHibernateUtils tester = new TestHibernateUtils(); |
| 54 | + System.out.println("Start Testing TestHibernateUtils..."); |
| 55 | + try |
| 56 | + { |
| 57 | +// System.out.println("Initilised Hibernate: "+tester.initialiseTest(tester.getProperties())); |
| 58 | + System.out.println("Initilised Hibernate: "+tester.initialiseTest(null)); |
| 59 | + |
| 60 | + tester.shutdownTest(); |
| 61 | + } |
| 62 | + catch (Exception ex) |
| 63 | + { |
| 64 | + ex.printStackTrace(); |
| 65 | + } |
| 66 | + System.out.println("End Testing TestHibernateUtils."); |
| 67 | + } |
| 68 | +} |
0 commit comments