use of org.robolectric.pluginapi.config.ConfigurationStrategy in project robolectric by robolectric.
the class HierarchicalConfigurationStrategyTest method testBigOAndCaching.
@Test
public void testBigOAndCaching() throws Exception {
SpyConfigurer spyConfigurer = new SpyConfigurer();
ConfigurationStrategy configStrategy = new HierarchicalConfigurationStrategy(spyConfigurer);
computeConfig(configStrategy, Test1A.class, "withoutAnnotation");
assertThat(spyConfigurer.log).containsExactly("default", "withoutAnnotation", Test1A.class.getName(), Test1.class.getName(), "org.robolectric.plugins", "org.robolectric", "org", "(top)").inOrder();
spyConfigurer.log.clear();
computeConfig(configStrategy, Test1.class, "withoutAnnotation");
assertThat(spyConfigurer.log).containsExactly("withoutAnnotation").inOrder();
spyConfigurer.log.clear();
computeConfig(configStrategy, Test2A.class, "withOverrideAnnotation");
assertThat(spyConfigurer.log).containsExactly("withOverrideAnnotation", Test2A.class.getName(), Test2.class.getName()).inOrder();
}
use of org.robolectric.pluginapi.config.ConfigurationStrategy in project robolectric by robolectric.
the class HierarchicalConfigurationStrategyTest method testTestClassMatters.
@Test
public void testTestClassMatters() throws Exception {
SpyConfigurer spyConfigurer = new SpyConfigurer();
ConfigurationStrategy configStrategy = new HierarchicalConfigurationStrategy(spyConfigurer);
assertThat(computeConfig(configStrategy, Test1.class, "withoutAnnotation")).isEqualTo("default:(top):org:org.robolectric:org.robolectric.plugins" + ":" + Test1.class.getName() + ":withoutAnnotation");
assertThat(computeConfig(configStrategy, Test1A.class, "withoutAnnotation")).isEqualTo("default:(top):org:org.robolectric:org.robolectric.plugins" + ":" + Test1.class.getName() + ":" + Test1A.class.getName() + ":withoutAnnotation");
}
use of org.robolectric.pluginapi.config.ConfigurationStrategy in project robolectric by robolectric.
the class HierarchicalConfigurationStrategyTest method testPrecedence.
@Test
public void testPrecedence() throws Exception {
SpyConfigurer spyConfigurer = new SpyConfigurer();
ConfigurationStrategy configStrategy = new HierarchicalConfigurationStrategy(spyConfigurer);
assertThat(computeConfig(configStrategy, Test1.class, "withoutAnnotation")).isEqualTo("default:(top):org:org.robolectric:org.robolectric.plugins" + ":" + Test1.class.getName() + ":withoutAnnotation");
assertThat(computeConfig(configStrategy, Test1A.class, "withOverrideAnnotation")).isEqualTo("default:(top):org:org.robolectric:org.robolectric.plugins" + ":" + Test1.class.getName() + ":" + Test1A.class.getName() + ":withOverrideAnnotation");
}
use of org.robolectric.pluginapi.config.ConfigurationStrategy in project robolectric by robolectric.
the class HierarchicalConfigurationStrategyTest method configFor.
private Config configFor(Class<?> testClass, String methodName, final Map<String, String> configProperties, Config.Implementation globalConfig) {
Method info = getMethod(testClass, methodName);
PackagePropertiesLoader packagePropertiesLoader = new PackagePropertiesLoader() {
@Override
InputStream getResourceAsStream(String resourceName) {
String properties = configProperties.get(resourceName);
return properties == null ? null : new ByteArrayInputStream(properties.getBytes(UTF_8));
}
};
ConfigurationStrategy defaultConfigStrategy = new HierarchicalConfigurationStrategy(new ConfigConfigurer(packagePropertiesLoader, () -> globalConfig == null ? Config.Builder.defaults().build() : globalConfig));
Configuration config = defaultConfigStrategy.getConfig(testClass, info);
return config.get(Config.class);
}
Aggregations