use of com.peterphi.std.guice.common.serviceprops.composite.GuiceConfig in project stdlib by petergeneric.
the class ConfigRefTest method testChangingPropertyAtRuntimeAndReinjectingMembersWorks.
@Test
public void testChangingPropertyAtRuntimeAndReinjectingMembersWorks() {
GuiceConfig configuration = new GuiceConfig();
configuration.set("some-name", "initial value");
final Injector injector = Guice.createInjector(new ServicePropertiesModule(configuration));
injector.injectMembers(this);
assertEquals("initial value", name);
configuration.set("some-name", "changed value");
// Re-inject the change
injector.injectMembers(this);
assertEquals("changed value", name);
}
use of com.peterphi.std.guice.common.serviceprops.composite.GuiceConfig in project stdlib by petergeneric.
the class JAXBResourceFactoryTest method testResourceFromClasspathReference.
/**
* This will almost certainly be translated into a File resource
*
* @throws Exception
*/
@Test
public void testResourceFromClasspathReference() throws Exception {
MyType expected = new MyType("from-disk", true);
GuiceConfig config = new GuiceConfig();
config.set("some.xml", "/jaxb-resource-factory/mytype.xml");
JAXBResourceFactory factory = new JAXBResourceFactory(config, SERIALISER_FACTORY);
assertEquals(expected, factory.get(MyType.class, "some.xml"));
}
use of com.peterphi.std.guice.common.serviceprops.composite.GuiceConfig in project stdlib by petergeneric.
the class JAXBResourceFactoryTest method testLiteralPropertyWithInternalVariables.
/**
* Confirm that even if we have what looks like a variable in our XML it doesn't get processed and we get the raw data we
* expect in the xml doc
*
* @throws Exception
*/
@Test
public void testLiteralPropertyWithInternalVariables() throws Exception {
MyType expected = new MyType("${some.custom.ognl}", true);
GuiceConfig config = new GuiceConfig();
config.set("some.xml", "<MyType name=\"${some.custom.ognl}\"/>");
JAXBResourceFactory factory = new JAXBResourceFactory(config, SERIALISER_FACTORY);
assertEquals(expected, factory.get(MyType.class, "some.xml"));
}
use of com.peterphi.std.guice.common.serviceprops.composite.GuiceConfig in project stdlib by petergeneric.
the class JAXBResourceFactoryTest method testCorruptResource.
/**
* This will almost certainly be translated into a File resource
*
* @throws Exception
*/
@Test(expected = JAXBRuntimeException.class)
public void testCorruptResource() throws Exception {
GuiceConfig config = new GuiceConfig();
config.set("some.xml", "/jaxb-resource-factory/invalid.xml");
JAXBResourceFactory factory = new JAXBResourceFactory(config, SERIALISER_FACTORY);
factory.get(MyType.class, "some.xml");
}
use of com.peterphi.std.guice.common.serviceprops.composite.GuiceConfig in project stdlib by petergeneric.
the class JAXBResourceFactoryTest method testLiteralProperty.
@Test
public void testLiteralProperty() throws Exception {
MyType expected = new MyType("test", true);
GuiceConfig config = new GuiceConfig();
config.set("some.xml", "<MyType name=\"test\"/>");
JAXBResourceFactory factory = new JAXBResourceFactory(config, SERIALISER_FACTORY);
assertEquals(expected, factory.get(MyType.class, "some.xml"));
}
Aggregations