Imported Upstream version 5.3.21
[platform/upstream/libdb.git] / test / java / rep / upgrades / test / repmgrtests / AbstractUpgTest.java
1 /*-
2  * See the file LICENSE for redistribution information.
3  * 
4  * Copyright (c) 2010, 2012 Oracle and/or its affiliates.  All rights reserved.
5  *
6  */
7
8 package repmgrtests;
9
10 import org.junit.Before;
11
12 import java.io.File;
13 import java.net.URL;
14 import java.net.URLClassLoader;
15 import java.util.Properties;
16
17 public abstract class AbstractUpgTest {
18     protected Object oldGroup_o, currentGroup_o;
19     private String currentScript, oldScript, oldVersion;
20
21     public AbstractUpgTest(String ov, String os, String cs) {
22         oldVersion = ov;
23         oldScript = os;
24         currentScript = cs;
25     }
26
27     @Before public void create() throws Exception {
28         Properties p = new Properties();
29         p.load(getClass().getResourceAsStream("classpaths.properties"));
30
31         URL[] urls = new URL[2];
32         urls[0] = makeUrl(p.getProperty("db." + oldVersion));
33         urls[1] = makeUrl(p.getProperty("test." + oldVersion));
34         ClassLoader cl = new URLClassLoader(urls);
35
36         oldGroup_o = cl.loadClass(oldScript).newInstance();
37
38         urls[0] = makeUrl(p.getProperty("db"));
39         urls[1] = makeUrl(p.getProperty("test"));
40         cl = new URLClassLoader(urls);
41         currentGroup_o = cl.loadClass(currentScript).newInstance();
42     }
43
44     private URL makeUrl(String fileName) throws Exception {
45         return new File(fileName).toURI().toURL();
46     }
47 }