1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.base;
17
18 import org.apache.log4j.PropertyConfigurator;
19 import org.kuali.ole.docstore.DocStoreConstants;
20 import org.kuali.ole.docstore.discovery.service.SolrServerManager;
21 import org.kuali.ole.docstore.util.DocStoreEnvUtil;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
24
25 import java.io.BufferedReader;
26 import java.io.File;
27 import java.io.FileReader;
28 import java.io.IOException;
29 import java.net.URL;
30 import java.util.Properties;
31
32
33
34
35
36
37
38 public abstract class BaseTestCase {
39 protected DocStoreEnvUtil docStoreEnvUtil = new DocStoreEnvUtil();
40 private static final Logger LOG = LoggerFactory.getLogger(BaseTestCase.class);
41
42 public BaseTestCase() {
43 try {
44 URL resource = getClass().getResource("/org/kuali/ole/log4j.properties");
45 File file = new File(resource.toURI());
46 PropertyConfigurator.configure(resource);
47 System.getProperties().put("app.environment", "local");
48 docStoreEnvUtil.setVendor("derby");
49 docStoreEnvUtil.setProperties(new Properties());
50 docStoreEnvUtil.initTestEnvironment();
51 docStoreEnvUtil.printEnvironment();
52 System.setProperty("OLE_DOCSTORE_USE_DISCOVERY", Boolean.FALSE.toString());
53 } catch (Exception e) {
54 LOG.info("Exception : " + e);
55 }
56 }
57
58 protected void setUp() throws Exception {
59 try {
60 String path = getClass().getClassLoader().getResource(".").getPath();
61
62 docStoreEnvUtil.initTestEnvironment();
63 docStoreEnvUtil.printEnvironment();
64 System.getProperties().put("app.environment", "local");
65
66 System.setProperty("OLE_DOCSTORE_USE_DISCOVERY", Boolean.FALSE.toString());
67
68 }
69 catch (Exception e) {
70 LOG.info(e.getMessage() , e);
71 }
72
73 }
74
75 public String readFile(File file) throws IOException {
76 BufferedReader reader = new BufferedReader(new FileReader(file));
77 String line = null;
78 StringBuilder stringBuilder = new StringBuilder();
79 String ls = System.getProperty("line.separator");
80 while ((line = reader.readLine()) != null) {
81 stringBuilder.append(line);
82 stringBuilder.append(ls);
83 }
84 return stringBuilder.toString();
85 }
86
87 }