KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derbyTesting > functionTests > tests > store > Beetle6038


1 /*
2
3    Derby - Class org.apache.derbyTesting.functionTests.tests.store.Beetle6038
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to You under the Apache License, Version 2.0
9    (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 JavaDoc[] args)
37         throws Exception JavaDoc
38     {
39         String JavaDoc driver = "org.apache.derby.jdbc.EmbeddedDriver";
40         Class.forName(driver).newInstance();
41         String JavaDoc dburl = "jdbc:derby:Beetle6038Db;create=true;dataEncryption=true;bootPassword=Thursday;encryptionAlgorithm=DES/CBC/NoPadding";
42
43         Connection conn = DriverManager.getConnection(dburl);
44         conn.close();
45         conn = DriverManager.getConnection(dburl);
46         conn.close();
47
48         // read in the properties in the service.properties file of the db
49
Properties serviceProperties = new Properties();
50         String JavaDoc systemhome = System.getProperty("derby.system.home");
51         File f = new File(systemhome + File.separatorChar + "Beetle6038Db" + File.separatorChar + "service.properties");
52         serviceProperties.load(new FileInputStream(f.getCanonicalPath()));
53
54         // check if the properties are set
55
checkProperty("data_encrypt_algorithm_version",serviceProperties);
56         checkProperty("log_encrypt_algorithm_version",serviceProperties);
57     }
58
59     public static void checkProperty(String JavaDoc name,Properties props)
60     {
61         String JavaDoc value = props.getProperty(name);
62
63         if( value == null )
64             System.out.println("Test failed!! - "+name + " not set in service.properties as expected");
65         else
66             System.out.println(name+"="+value);
67     }
68
69
70 }
71
Popular Tags