use of org.apache.cxf.bus.spring.BusApplicationContext in project cxf by apache.
the class ConfigurerImplTest method testConfigureSimpleMatchingStarBeanId.
@Test
public void testConfigureSimpleMatchingStarBeanId() {
SimpleBean sb = new SimpleBean("simple2");
BusApplicationContext ac = new BusApplicationContext("/org/apache/cxf/configuration/spring/test-beans.xml", false);
ConfigurerImpl configurer = new ConfigurerImpl();
configurer.setApplicationContext(ac);
configurer.configureBean(sb);
assertTrue("Unexpected value for attribute booleanAttr", !sb.getBooleanAttr());
assertEquals("Unexpected value for attribute integerAttr", BigInteger.TEN, sb.getIntegerAttr());
assertEquals("Unexpected value for attribute stringAttr", "StarHallo", sb.getStringAttr());
}
use of org.apache.cxf.bus.spring.BusApplicationContext in project cxf by apache.
the class ConfigurerImplTest method testConfigureSimpleNoMatchingBean.
@Test
public void testConfigureSimpleNoMatchingBean() {
SimpleBean sb = new SimpleBean("unknown");
BusApplicationContext ac = new BusApplicationContext("/org/apache/cxf/configuration/spring/test-beans.xml", false);
ConfigurerImpl configurer = new ConfigurerImpl(ac);
configurer.configureBean(sb);
assertEquals("Unexpected value for attribute stringAttr", "hello", sb.getStringAttr());
assertTrue("Unexpected value for attribute booleanAttr", sb.getBooleanAttr());
assertEquals("Unexpected value for attribute integerAttr", BigInteger.ONE, sb.getIntegerAttr());
assertEquals("Unexpected value for attribute intAttr", Integer.valueOf(2), sb.getIntAttr());
assertEquals("Unexpected value for attribute longAttr", Long.valueOf(3L), sb.getLongAttr());
assertEquals("Unexpected value for attribute shortAttr", Short.valueOf((short) 4), sb.getShortAttr());
assertEquals("Unexpected value for attribute decimalAttr", new BigDecimal("5"), sb.getDecimalAttr());
assertEquals("Unexpected value for attribute floatAttr", Float.valueOf(6F), sb.getFloatAttr());
assertEquals("Unexpected value for attribute doubleAttr", Double.valueOf(7.0D), sb.getDoubleAttr());
assertEquals("Unexpected value for attribute byteAttr", Byte.valueOf((byte) 8), sb.getByteAttr());
QName qn = sb.getQnameAttr();
assertEquals("Unexpected value for attribute qnameAttrNoDefault", "schema", qn.getLocalPart());
assertEquals("Unexpected value for attribute qnameAttrNoDefault", "http://www.w3.org/2001/XMLSchema", qn.getNamespaceURI());
byte[] expected = DatatypeConverter.parseBase64Binary("abcd");
byte[] val = sb.getBase64BinaryAttr();
assertEquals("Unexpected value for attribute base64BinaryAttrNoDefault", expected.length, val.length);
for (int i = 0; i < expected.length; i++) {
assertEquals("Unexpected value for attribute base64BinaryAttrNoDefault", expected[i], val[i]);
}
expected = new HexBinaryAdapter().unmarshal("aaaa");
val = sb.getHexBinaryAttr();
assertEquals("Unexpected value for attribute hexBinaryAttrNoDefault", expected.length, val.length);
for (int i = 0; i < expected.length; i++) {
assertEquals("Unexpected value for attribute hexBinaryAttrNoDefault", expected[i], val[i]);
}
assertEquals("Unexpected value for attribute unsignedIntAttrNoDefault", Long.valueOf(9L), sb.getUnsignedIntAttr());
assertEquals("Unexpected value for attribute unsignedShortAttrNoDefault", Integer.valueOf(10), sb.getUnsignedShortAttr());
assertEquals("Unexpected value for attribute unsignedByteAttrNoDefault", Short.valueOf((short) 11), sb.getUnsignedByteAttr());
}
use of org.apache.cxf.bus.spring.BusApplicationContext in project cxf by apache.
the class ConfigurerImplTest method verifyConfigureSimple.
public void verifyConfigureSimple(String beanName) {
SimpleBean sb = new SimpleBean(beanName);
BusApplicationContext ac = new BusApplicationContext("/org/apache/cxf/configuration/spring/test-beans.xml", false);
ConfigurerImpl configurer = new ConfigurerImpl();
configurer.setApplicationContext(ac);
configurer.configureBean(sb);
assertEquals("Unexpected value for attribute stringAttr", "hallo", sb.getStringAttr());
assertTrue("Unexpected value for attribute booleanAttr", !sb.getBooleanAttr());
assertEquals("Unexpected value for attribute integerAttr", BigInteger.TEN, sb.getIntegerAttr());
assertEquals("Unexpected value for attribute intAttr", Integer.valueOf(12), sb.getIntAttr());
assertEquals("Unexpected value for attribute longAttr", Long.valueOf(13L), sb.getLongAttr());
assertEquals("Unexpected value for attribute shortAttr", Short.valueOf((short) 14), sb.getShortAttr());
assertEquals("Unexpected value for attribute decimalAttr", new BigDecimal("15"), sb.getDecimalAttr());
assertEquals("Unexpected value for attribute floatAttr", Float.valueOf(16F), sb.getFloatAttr());
assertEquals("Unexpected value for attribute doubleAttr", Double.valueOf(17D), sb.getDoubleAttr());
assertEquals("Unexpected value for attribute byteAttr", Byte.valueOf((byte) 18), sb.getByteAttr());
assertEquals("Unexpected value for attribute unsignedIntAttrNoDefault", Long.valueOf(19L), sb.getUnsignedIntAttr());
assertEquals("Unexpected value for attribute unsignedShortAttrNoDefault", Integer.valueOf(20), sb.getUnsignedShortAttr());
assertEquals("Unexpected value for attribute unsignedByteAttrNoDefault", Short.valueOf((short) 21), sb.getUnsignedByteAttr());
}
use of org.apache.cxf.bus.spring.BusApplicationContext in project cxf by apache.
the class ConfigurerImplTest method testConfigureSimpleMatchingStarBeanIdWithChildInstance.
@Test
public void testConfigureSimpleMatchingStarBeanIdWithChildInstance() {
SimpleBean sb = new ChildBean("simple2");
BusApplicationContext ac = new BusApplicationContext("/org/apache/cxf/configuration/spring/test-beans.xml", false);
ConfigurerImpl configurer = new ConfigurerImpl();
configurer.setApplicationContext(ac);
configurer.configureBean(sb);
assertTrue("Unexpected value for attribute booleanAttr", !sb.getBooleanAttr());
assertEquals("Unexpected value for attribute integerAttr", BigInteger.TEN, sb.getIntegerAttr());
assertEquals("Unexpected value for attribute stringAttr", "StarHallo", sb.getStringAttr());
}
use of org.apache.cxf.bus.spring.BusApplicationContext in project cxf by apache.
the class SpringServiceBuilderFactory method getApplicationContext.
/**
* This is factored out to permit use in a unit test.
*
* @param bus
* @return
*/
public static ApplicationContext getApplicationContext(List<String> additionalFilePathnames) {
BusApplicationContext busApplicationContext = BusFactory.getDefaultBus().getExtension(BusApplicationContext.class);
GenericApplicationContext appContext = new GenericApplicationContext(busApplicationContext);
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(appContext);
List<URL> urls = ClassLoaderUtils.getResources("META-INF/cxf/java2wsbeans.xml", SpringServiceBuilderFactory.class);
for (URL url : urls) {
reader.loadBeanDefinitions(new UrlResource(url));
}
for (String pathname : additionalFilePathnames) {
try {
reader.loadBeanDefinitions(new FileSystemResource(pathname));
} catch (BeanDefinitionStoreException bdse) {
throw new ToolException("Unable to open bean definition file " + pathname, bdse.getCause());
}
}
appContext.refresh();
return appContext;
}
Aggregations