2 * Copyright 2005 the original author or authors.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.wamblee.usermgt.hibernate;
19 import java.sql.ResultSet;
20 import java.sql.SQLException;
21 import java.util.HashMap;
24 import org.wamblee.general.BeanKernel;
25 import org.wamblee.test.TestTransactionCallback;
26 import org.wamblee.usermgt.GroupSet;
27 import org.wamblee.usermgt.InMemoryGroupSetTest;
28 import org.wamblee.usermgt.UsermgtHibernateMappingFiles;
29 import org.wamblee.usermgt.UsermgtSpringConfigFiles;
32 * Tests for {@link org.wamblee.usermgt.hibernate.HibernateGroupSet}
34 public class HibernateGroupSetTest extends InMemoryGroupSetTest {
36 private static final String GROUP_TABLE = "GROUPS";
38 private static final String GROUP_QUERY = "select * from " + GROUP_TABLE + " where name = ?";
40 public HibernateGroupSetTest() {
41 super(UsermgtSpringConfigFiles.class, UsermgtHibernateMappingFiles.class);
45 * @see org.wamblee.usermgt.InMemoryGroupSetTest#checkGroupCount(int)
48 protected void checkGroupCount(int aSize) throws SQLException {
50 super.checkGroupCount(aSize);
51 assertEquals(aSize, getTableSize(GROUP_TABLE));
55 * @see org.wamblee.usermgt.InMemoryGroupSetTest#checkGroupExists(java.lang.String)
58 protected void checkGroupExists(final String aGroup) throws SQLException {
60 Map<String,Integer> result =
61 executeTransaction(new TestTransactionCallback() {
63 * @see org.wamblee.test.TestTransactionCallback#execute()
66 public Map execute() throws Exception {
67 ResultSet result = executeQuery(GROUP_QUERY, aGroup);
68 Map<String,Integer> res = new HashMap<String,Integer>();
69 res.put("result", countResultSet(result));
74 int count = result.get("result");
75 assertEquals(1, count);
79 * @see org.wamblee.usermgt.InMemoryGroupSetTest#checkGroupNotExists(java.lang.String)
82 protected void checkGroupNotExists(String aGroup) throws SQLException {
84 ResultSet result = executeQuery(GROUP_QUERY, aGroup);
85 assertEquals(0, countResultSet(result));
89 * @see org.wamblee.usermgt.InMemoryGroupSetTest#createGroupSet()
92 protected GroupSet createGroupSet() {
93 return BeanKernel.getBeanFactory().find(GroupSet.class);