01: /*
02:
03: Derby - Class org.apache.derbyTesting.functionTests.tests.store.Beetle6038
04:
05: Licensed to the Apache Software Foundation (ASF) under one or more
06: contributor license agreements. See the NOTICE file distributed with
07: this work for additional information regarding copyright ownership.
08: The ASF licenses this file to You under the Apache License, Version 2.0
09: (the "License"); you may not use this file except in compliance with
10: the License. You may obtain a copy of the License at
11:
12: http://www.apache.org/licenses/LICENSE-2.0
13:
14: Unless required by applicable law or agreed to in writing, software
15: distributed under the License is distributed on an "AS IS" BASIS,
16: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: See the License for the specific language governing permissions and
18: limitations under the License.
19:
20: */
21:
22: package org.apache.derbyTesting.functionTests.tests.store;
23:
24: import java.sql.*;
25: import java.io.*;
26: import java.util.*;
27:
28: /**
29: * Test that the two new encryption properties
30: * DATA_ENCRYPT_ALGORITHM_VERSION="data_encrypt_algorithm_version"
31: * LOG_ENCRYPT_ALGORITHM_VERSION="log_encrypt_algorithm_version"
32: * exist and verify the version. Note, these values start off with 1.
33: */
34: public class Beetle6038 {
35:
36: public static void main(String[] args) throws Exception {
37: String driver = "org.apache.derby.jdbc.EmbeddedDriver";
38: Class.forName(driver).newInstance();
39: String dburl = "jdbc:derby:Beetle6038Db;create=true;dataEncryption=true;bootPassword=Thursday;encryptionAlgorithm=DES/CBC/NoPadding";
40:
41: Connection conn = DriverManager.getConnection(dburl);
42: conn.close();
43: conn = DriverManager.getConnection(dburl);
44: conn.close();
45:
46: // read in the properties in the service.properties file of the db
47: Properties serviceProperties = new Properties();
48: String systemhome = System.getProperty("derby.system.home");
49: File f = new File(systemhome + File.separatorChar
50: + "Beetle6038Db" + File.separatorChar
51: + "service.properties");
52: serviceProperties
53: .load(new FileInputStream(f.getCanonicalPath()));
54:
55: // check if the properties are set
56: checkProperty("data_encrypt_algorithm_version",
57: serviceProperties);
58: checkProperty("log_encrypt_algorithm_version",
59: serviceProperties);
60: }
61:
62: public static void checkProperty(String name, Properties props) {
63: String value = props.getProperty(name);
64:
65: if (value == null)
66: System.out.println("Test failed!! - " + name
67: + " not set in service.properties as expected");
68: else
69: System.out.println(name + "=" + value);
70: }
71:
72: }
|