@BeforeClass
public static void setUp() throws Exception {
layoutMapper = new LayoutMapper();
YamlMapFactoryBean yamlMapFactoryBean = new YamlMapFactoryBean();
yamlMapFactoryBean.setResources(new FileSystemResource(LayoutMapperTest.class.getResource("layout.yml").getPath()));
// String layout = "" +
// "category:\n" +
// " _default_: \"category/_layout\"\n" +
// "food:\n" +
// " detail: \"food/_layout\"\n" +
// "boo:\n" +
// " _default_: \"boo/_layout\"\n" +
// " index: \"_boo\"\n" +
// " foo:\n" +
// " detail: \"boo/_detail\"" +
// "";
// yamlMapFactoryBean.setResources(new ByteArrayResource(layout.getBytes("UTF-8")));
yamlMapFactoryBean.afterPropertiesSet();
ReflectionTestUtils.setField(layoutMapper, "layout", yamlMapFactoryBean.getObject());
ReflectionTestUtils.invokeMethod(layoutMapper, "init");
}
java类org.springframework.beans.factory.config.YamlMapFactoryBean的实例源码
LayoutMapperTest.java 文件源码
项目:mustache-showcase
阅读 23
收藏 0
点赞 0
评论 0
IBMMQTestUtils.java 文件源码
项目:spring-cloud-stream-binder-ibm-mq
阅读 22
收藏 0
点赞 0
评论 0
@SuppressWarnings("unchecked")
public static IBMMQConfigurationProperties getIBMMQProperties() throws Exception {
YamlMapFactoryBean factoryBean = new YamlMapFactoryBean();
factoryBean.setResources(new ClassPathResource("application.yml"));
Map<String, Object> mapObject = factoryBean.getObject();
Map<String, Object> ibmMQPropertyMap = (Map<String, Object>) mapObject
.get("ibmmq");
IBMMQConfigurationProperties configurationProperties = new IBMMQConfigurationProperties();
configurationProperties.setHost((String) ibmMQPropertyMap.get("host"));
configurationProperties.setPort((Integer) ibmMQPropertyMap.get("port"));
configurationProperties
.setUsername((String) ibmMQPropertyMap.get("username"));
configurationProperties
.setPassword((String) ibmMQPropertyMap.get("password"));
configurationProperties
.setQueueManager((String) ibmMQPropertyMap.get("queueManager"));
configurationProperties
.setChannel((String) ibmMQPropertyMap.get("channel"));
return configurationProperties;
}
YamlUtils.java 文件源码
项目:micro-service-netflix
阅读 24
收藏 0
点赞 0
评论 0
public static Map<String, Object> convertYamlToMap(String yamlFile) {
YamlMapFactoryBean yamlMapFactoryBean = new YamlMapFactoryBean();
yamlMapFactoryBean.setResources(new ClassPathResource(yamlFile));
yamlMapFactoryBean.setResolutionMethod(ResolutionMethod.FIRST_FOUND);
return yamlMapFactoryBean.getObject();
}
Config.java 文件源码
项目:dcmp
阅读 24
收藏 0
点赞 0
评论 0
@SuppressWarnings("unchecked")
public Config() {
YamlMapFactoryBean yamlMapFactoryBean = new YamlMapFactoryBean();
yamlMapFactoryBean.setResources(new ClassPathResource("config.yml"));
this.dataMap = (Map<String, Object>) yamlMapFactoryBean.getObject().get("config");
this.consulMap = (Map<String, Object>) this.dataMap.get("consul");
this.repoMap = (Map<String, Object>) this.dataMap.get("repo");
}