01: /*-
02: * See the file LICENSE for redistribution information.
03: *
04: * Copyright (c) 2000,2008 Oracle. All rights reserved.
05: *
06: * $Id: PersistTestUtils.java,v 1.1.2.2 2008/01/07 15:14:35 cwl Exp $
07: */
08: package com.sleepycat.persist.test;
09:
10: import java.util.List;
11:
12: import junit.framework.TestCase;
13:
14: import com.sleepycat.je.DatabaseException;
15: import com.sleepycat.je.Environment;
16:
17: class PersistTestUtils {
18:
19: /**
20: * Asserts than a database expectExists or does not exist. If keyName is
21: * null, checks an entity database. If keyName is non-null, checks a
22: * secondary database.
23: */
24: static void assertDbExists(boolean expectExists, Environment env,
25: String storeName, String entityClassName, String keyName) {
26: String dbName = "persist#" + storeName + '#' + entityClassName;
27: if (keyName != null) {
28: dbName += "#" + keyName;
29: }
30: List allDbNames;
31: try {
32: allDbNames = env.getDatabaseNames();
33: } catch (DatabaseException e) {
34: throw new RuntimeException(e);
35: }
36: if (expectExists != allDbNames.contains(dbName)) {
37: TestCase.fail((expectExists ? "Does not exist: "
38: : "Does exist: ")
39: + dbName);
40: }
41: }
42: }
|