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.spring.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 * @author Erik Brakkee
36 public class HibernateGroupSetTest extends InMemoryGroupSetTest {
38 private static final String GROUP_TABLE = "GROUPS";
40 private static final String GROUP_QUERY = "select * from " + GROUP_TABLE + " where name = ?";
42 public HibernateGroupSetTest() {
43 super(UsermgtSpringConfigFiles.class, UsermgtHibernateMappingFiles.class);
47 * @see org.wamblee.usermgt.InMemoryGroupSetTest#checkGroupCount(int)
50 protected void checkGroupCount(int aSize) throws SQLException {
52 super.checkGroupCount(aSize);
53 assertEquals(aSize, getTableSize(GROUP_TABLE));
57 * @see org.wamblee.usermgt.InMemoryGroupSetTest#checkGroupExists(java.lang.String)
60 protected void checkGroupExists(final String aGroup) throws SQLException {
62 Map<String,Integer> result =
63 executeTransaction(new TestTransactionCallback() {
65 * @see org.wamblee.test.TestTransactionCallback#execute()
68 public Map execute() throws Exception {
69 ResultSet result = executeQuery(GROUP_QUERY, aGroup);
70 Map<String,Integer> res = new HashMap<String,Integer>();
71 res.put("result", countResultSet(result));
76 int count = result.get("result");
77 assertEquals(1, count);
81 * @see org.wamblee.usermgt.InMemoryGroupSetTest#checkGroupNotExists(java.lang.String)
84 protected void checkGroupNotExists(String aGroup) throws SQLException {
86 ResultSet result = executeQuery(GROUP_QUERY, aGroup);
87 assertEquals(0, countResultSet(result));
91 * @see org.wamblee.usermgt.InMemoryGroupSetTest#createGroupSet()
94 protected GroupSet createGroupSet() {
95 return BeanKernel.getBeanFactory().find(GroupSet.class);