-
-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Accept File Paths Containing Spaces.
Updated the uri processing to allow loading files that contain spaces in their paths.
- Loading branch information
Cameron Rollhieser
committed
Feb 13, 2016
1 parent
85fe748
commit 585aadb
Showing
4 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
owner/src/test/java/org/aeonbits/owner/loadstrategies/LoadPathsWithSpacesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.aeonbits.owner.loadstrategies; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.aeonbits.owner.Config; | ||
import org.aeonbits.owner.ConfigFactory; | ||
import org.aeonbits.owner.LoadersManagerForTest; | ||
import org.aeonbits.owner.VariablesExpanderForTest; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.Mock; | ||
import org.mockito.Spy; | ||
import org.mockito.runners.MockitoJUnitRunner; | ||
|
||
import java.util.Properties; | ||
import java.util.concurrent.ScheduledExecutorService; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class LoadPathsWithSpacesTest extends LoadStrategyTestBase { | ||
|
||
@Mock | ||
private ScheduledExecutorService scheduler; | ||
@Spy | ||
private final LoadersManagerForTest loaders = new LoadersManagerForTest(); | ||
private final VariablesExpanderForTest expander = new VariablesExpanderForTest(new Properties()); | ||
|
||
|
||
@Config.Sources({ | ||
"file:${user.dir}/src/test/resources/org/aeonbits/owner/directory with spaces/simple.properties"}) | ||
public static interface FileConfigWithSource extends Config { | ||
String helloWorld(); | ||
} | ||
|
||
@Config.Sources({ | ||
"classpath:org/aeonbits/owner/directory with spaces/simple.properties"}) | ||
public static interface ClasspathConfigWithSource extends Config { | ||
String helloWorld(); | ||
} | ||
|
||
@Test | ||
public void shouldLoadFromFile() throws Exception { | ||
FileConfigWithSource sample = ConfigFactory.create(FileConfigWithSource.class); | ||
assertEquals("Hello World!", sample.helloWorld()); | ||
} | ||
|
||
@Test | ||
public void shouldLoadFromClasspath() throws Exception { | ||
ClasspathConfigWithSource sample = ConfigFactory.create(ClasspathConfigWithSource.class); | ||
assertEquals("Hello World!", sample.helloWorld()); | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
owner/src/test/resources/org/aeonbits/owner/directory with spaces/simple.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# | ||
# Copyright (c) 2012-2015, Luigi R. Viggiano | ||
# All rights reserved. | ||
# | ||
# This software is distributable under the BSD license. | ||
# See the terms of the BSD license in the documentation provided with this software. | ||
# | ||
|
||
helloWorld = Hello World! |