blob: 0c8a9e5c3d864dccbe12535de3b71a1e810f4eda (
plain) (
blame)
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
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server;
import com.yahoo.cloud.config.ConfigserverConfig;
import com.yahoo.io.IOUtils;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import java.io.File;
import java.io.IOException;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
/**
* @author Ulf Lilleengen
*/
public class ConfigServerDBTest {
private ConfigServerDB serverDB;
private ConfigserverConfig configserverConfig;
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
@Before
public void setup() throws IOException {
configserverConfig = new ConfigserverConfig(
new ConfigserverConfig.Builder()
.configServerDBDir(temporaryFolder.newFolder("serverdb").getAbsolutePath())
.configDefinitionsDir(temporaryFolder.newFolder("configdefinitions").getAbsolutePath()));
serverDB = new ConfigServerDB(configserverConfig);
}
private void createInitializer() throws IOException {
File existingDef = new File(serverDB.classes(), "test.def");
IOUtils.writeFile(existingDef, "hello", false);
new ConfigServerDB(configserverConfig);
}
@Test
public void require_that_existing_def_files_are_copied() throws IOException {
assertThat(serverDB.serverdefs().listFiles().length, is(0));
createInitializer();
assertThat(serverDB.serverdefs().listFiles().length, is(1));
}
}
|