forked from jbake-org/jbake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ContentStoreIntegrationTest.java
74 lines (59 loc) · 2.2 KB
/
ContentStoreIntegrationTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package org.jbake.app;
import org.apache.commons.vfs2.util.Os;
import org.jbake.TestUtils;
import org.jbake.app.configuration.ConfigUtil;
import org.jbake.app.configuration.DefaultJBakeConfiguration;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.rules.TemporaryFolder;
import java.io.File;
public abstract class ContentStoreIntegrationTest {
@ClassRule
public static TemporaryFolder folder = new TemporaryFolder();
protected static ContentStore db;
protected static DefaultJBakeConfiguration config;
protected static StorageType storageType = StorageType.MEMORY;
protected static File sourceFolder;
@BeforeClass
public static void setUpClass() throws Exception {
sourceFolder = TestUtils.getTestResourcesAsSourceFolder();
Assert.assertTrue("Cannot find sample data structure!", sourceFolder.exists());
config = (DefaultJBakeConfiguration) new ConfigUtil().loadConfig(sourceFolder);
config.setSourceFolder(sourceFolder);
Assert.assertEquals(".html", config.getOutputExtension());
config.setDatabaseStore(storageType.toString());
// OrientDB v3.1.x doesn't allow DB name to be a path even though docs say it's allowed
String dbPath = folder.newFolder("documents" + System.currentTimeMillis()).getName();
// setting the database path with a colon creates an invalid url for OrientDB.
// only one colon is expected. there is no documentation about proper url path for windows available :(
if (Os.isFamily(Os.OS_FAMILY_WINDOWS)) {
dbPath = dbPath.replace(":","");
}
config.setDatabasePath(dbPath);
db = DBUtil.createDataStore(config);
}
@AfterClass
public static void cleanUpClass() {
db.close();
db.shutdown();
}
@Before
public void setUp() {
db.startup();
}
@After
public void tearDown() {
db.drop();
}
protected enum StorageType {
MEMORY, PLOCAL;
@Override
public String toString() {
return this.name().toLowerCase();
}
}
}