View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.juneau.config;
18  
19  import static org.apache.juneau.TestUtils.*;
20  import static org.apache.juneau.common.utils.StringUtils.*;
21  import static org.apache.juneau.internal.FileUtils.*;
22  import static org.junit.jupiter.api.Assertions.*;
23  
24  import java.io.*;
25  
26  import org.apache.juneau.*;
27  import org.apache.juneau.config.store.*;
28  import org.junit.jupiter.api.*;
29  
30  class ConfigBuilder_Test extends TestBase {
31  
32  	private static File tempDir;
33  	private static String TEMP_DIR;
34  
35  	@BeforeAll
36  	static void setup() {
37  		tempDir = new File(System.getProperty("java.io.tmpdir"), random(12));
38  		TEMP_DIR = tempDir.getAbsolutePath();
39  	}
40  
41  	@AfterAll
42  	static void teardown() {
43  		delete(tempDir);
44  	}
45  
46  	@Test void a01_get_LONGRUNNING() throws Exception {
47  		File f;
48  		var cfs = FileStore.create().directory(TEMP_DIR).enableWatcher().watcherSensitivity(WatcherSensitivity.HIGH).build();
49  		var cb = Config.create().store(cfs).name("TestGet.cfg");
50  
51  		var cf = cb.build();
52  		cf.set("Test/A", "a");
53  
54  		f = new File(tempDir, "TestGet.cfg");
55  		assertFalse(f.exists());
56  
57  		cf.commit();
58  		assertJson("{'':{},Test:{A:'a'}}", cf.toMap());
59  
60  		var nl = System.getProperty("line.separator");
61  		cf = cf.load("[Test]"+nl+"A = b"+nl, true);
62  		assertJson("{'':{},Test:{A:'b'}}", cf.toMap());
63  	}
64  }