Skip to content

Commit

Permalink
fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmcclean committed Jun 26, 2015
1 parent 0721a34 commit af4eafd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@
public class PropertyFileConfig {

private final Logger logger = LoggerFactory.getLogger(getClass());

public PropertyFileConfig(){

}
public PropertyFileConfig(boolean set){
if(set)
new Config().set(); //make sure config instance is set
}
@Bean
public PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() throws IOException {

Expand Down Expand Up @@ -54,7 +60,7 @@ public Properties propertyFactory() throws IOException {
private List<Resource> loadPropertyResource() {
List<Resource> resources = Lists.newArrayList();
loadProperties().ifPresent(it -> resources.add(it));
new Config().set(); //make sure config instance is set

String instancePropertyFileName = new ConfigAccessor().get().getInstancePropertiesName();

URL instanceResource = getClass().getClassLoader().getResource(instancePropertyFileName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

import java.io.IOException;
import java.util.Properties;
import java.util.concurrent.ExecutionException;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.aol.micro.server.MicroserverApp;
import com.aol.micro.server.config.Config;
import com.aol.micro.server.config.Microserver;
import com.aol.micro.server.spring.properties.PropertyFileConfig;
import com.aol.micro.server.testing.RestAgent;

@Microserver
Expand Down Expand Up @@ -42,6 +46,13 @@ public void runAppAndBasicTest() throws InterruptedException, ExecutionException

}

@Test
public void loadProperties() throws IOException{

Properties props = new PropertyFileConfig(true).propertyFactory() ;
assertThat(props.getProperty("test"),is("hello world"));
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
public class Simple {

public static void main(String[] args) throws IOException{
new Config().set() ;
Properties props = new PropertyFileConfig().propertyFactory() ;
System.out.println(props);
// new MicroserverApp(()->"test-app").run();

new MicroserverApp(()->"test-app").run();
}
}

0 comments on commit af4eafd

Please sign in to comment.