Java Code Examples for org.springframework.context.support.ClassPathXmlApplicationContext#setId()

The following examples show how to use org.springframework.context.support.ClassPathXmlApplicationContext#setId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConfigurationDtoPostProcessorLayerTreeTest.java    From geomajas-project-server with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test
public void testLayerTreeCheck() throws Exception {
	try {
		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext();
		context.setId("test");
		context.setDisplayName("test");
		context.setConfigLocation(
				"/org/geomajas/spring/geomajasContext.xml " +
				"/org/geomajas/testdata/beanContext.xml " +
				"/org/geomajas/testdata/layerBeans.xml " +
				"/org/geomajas/internal/configuration/layerTreeInvalid.xml " +
				"");
		context.refresh();
		Assert.fail("Context initialization should have failed.");
	} catch (BeanCreationException bce) {
		Assert.assertTrue(bce.getCause().getMessage().startsWith(
				"A LayerTreeNodeInfo object can only reference layers which are part of the map, layer "));
	}
}
 
Example 2
Source File: ConfigurationDtoPostProcessorRasterLayerTest.java    From geomajas-project-server with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test
public void testNullTileWidth() throws Exception {
	try {
		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext();
		context.setId("test");
		context.setDisplayName("test");
		context.setConfigLocation(
				"/org/geomajas/spring/geomajasContext.xml " +
				"/org/geomajas/internal/configuration/RasterLayerZeroTileWidth.xml " +
				"");
		context.refresh();
		Assert.fail("Context initialization should have failed.");
	} catch (BeanCreationException bce) {
		assertThat(bce.getCause().getCause().getMessage()).startsWith(
				"Layer layerOsm is not correctly configured: tileWidth should not be zero.");
	}
}
 
Example 3
Source File: ConfigurationDtoPostProcessorRasterLayerTest.java    From geomajas-project-server with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test
public void testNullTileHeight() throws Exception {
	try {
		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext();
		context.setId("test");
		context.setDisplayName("test");
		context.setConfigLocation(
				"/org/geomajas/spring/geomajasContext.xml " +
				"/org/geomajas/internal/configuration/RasterLayerZeroTileHeight.xml " +
				"");
		context.refresh();
		Assert.fail("Context initialization should have failed.");
	} catch (BeanCreationException bce) {
		assertThat(bce.getCause().getCause().getMessage()).startsWith(
				"Layer layerOsm is not correctly configured: tileHeight should not be zero.");
	}
}
 
Example 4
Source File: ConfigurationDtoPostProcessorVectorLayerTest.java    From geomajas-project-server with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test
public void testAttributeInvalidNameCheck() {
	try {
		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext();
		context.setId("test");
		context.setDisplayName("test");
		context.setConfigLocation(
				"/org/geomajas/spring/geomajasContext.xml " +
				"/org/geomajas/testdata/beanContext.xml " +
				"/org/geomajas/testdata/layerBeans.xml " +
				"/org/geomajas/internal/configuration/layerBeansInvalid.xml " +
				"");
		context.refresh();
		Assert.fail("Context initialization should have failed.");
	} catch (BeanCreationException bce) {
		assertThat(bce.getCause().getCause().getMessage()).startsWith(
				"Invalid attribute name manyToOne.stringAttr in layer beans.");
	}
}
 
Example 5
Source File: ConfigurationDtoPostProcessorVectorLayerTest.java    From geomajas-project-server with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test
public void testDuplicateAttribute() {
	try {
		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext();
		context.setId("test");
		context.setDisplayName("test");
		context.setConfigLocation(
				"/org/geomajas/spring/geomajasContext.xml " +
				"/org/geomajas/internal/configuration/layerBeansDuplicateAttribute.xml " +
				"");
		context.refresh();
		Assert.fail("Context initialization should have failed.");
	} catch (BeanCreationException bce) {
		assertThat(bce.getCause().getCause().getMessage()).startsWith(
				"Duplicate attribute name stringAttr in layer beans, path .");
	}
}
 
Example 6
Source File: ConfigurationDtoPostProcessorVectorLayerTest.java    From geomajas-project-server with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test
public void testDuplicateAttributeInOneToMany() {
	try {
		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext();
		context.setId("test");
		context.setDisplayName("test");
		context.setConfigLocation(
				"/org/geomajas/spring/geomajasContext.xml " +
				"/org/geomajas/internal/configuration/layerBeansDuplicateAttrOneToMany.xml " +
				"");
		context.refresh();
		Assert.fail("Context initialization should have failed.");
	} catch (BeanCreationException bce) {
		assertThat(bce.getCause().getCause().getMessage()).startsWith(
				"Duplicate attribute name stringAttr in layer beans, path /oneToManyAttr.");
	}
}
 
Example 7
Source File: ConfigurationDtoPostProcessorVectorLayerTest.java    From geomajas-project-server with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test
public void testDuplicateAttributeInManyToOne() {
	try {
		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext();
		context.setId("test");
		context.setDisplayName("test");
		context.setConfigLocation(
				"/org/geomajas/spring/geomajasContext.xml " +
				"/org/geomajas/internal/configuration/layerBeansDuplicateAttrManyToOne.xml " +
				"");
		context.refresh();
		Assert.fail("Context initialization should have failed.");
	} catch (BeanCreationException bce) {
		assertThat(bce.getCause().getCause().getMessage()).startsWith(
				"Duplicate attribute name stringAttr in layer beans, path /manyToOneAttr.");
	}
}
 
Example 8
Source File: ConfigurationDtoPostProcessorVectorLayerTest.java    From geomajas-project-server with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test
public void testDefaultStyle() {
	ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext();
	context.setId("test");
	context.setDisplayName("test");
	context.setConfigLocation(
			"/org/geomajas/spring/geomajasContext.xml "+
			"/org/geomajas/internal/configuration/layerDefaultStyle.xml ");
	context.refresh();
	VectorLayer layerDefaultStyle = (VectorLayer)context.getBean("layerDefaultStyle");
	List<NamedStyleInfo> styles = layerDefaultStyle.getLayerInfo().getNamedStyleInfos();
	Assert.assertEquals(1, styles.size());
	NamedStyleInfo defaultStyle = styles.get(0);
	Assert.assertEquals(NamedStyleInfo.DEFAULT_NAME, defaultStyle.getName());
	Assert.assertEquals(LabelStyleInfo.ATTRIBUTE_NAME_ID, defaultStyle.getLabelStyle().getLabelAttributeName());
}
 
Example 9
Source File: ConfigurationDtoPostProcessorVectorLayerTest.java    From geomajas-project-server with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test
public void testUserStyle() {
	ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext();
	context.setId("test");
	context.setDisplayName("test");
	context.setConfigLocation(
			"/org/geomajas/spring/geomajasContext.xml "+
			"/org/geomajas/internal/configuration/layerDefaultStyle.xml ");
	context.refresh();
	VectorLayer layerDefaultStyle = (VectorLayer)context.getBean("layerDefaultStyle");
	List<NamedStyleInfo> styles = layerDefaultStyle.getLayerInfo().getNamedStyleInfos();
	Assert.assertEquals(1, styles.size());
	NamedStyleInfo defaultStyle = styles.get(0);
	UserStyleInfo userStyle = defaultStyle.getUserStyle();
	List<RuleInfo> rules = userStyle.getFeatureTypeStyleList().get(0).getRuleList();
	Assert.assertEquals(1, rules.size());
	Assert.assertEquals(null, rules.get(0).getName());
}
 
Example 10
Source File: GeotoolsInitializerTest.java    From geomajas-project-server with GNU Affero General Public License v3.0 5 votes vote down vote up
@Test
public void testLogging() {
	ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext();
	context.setId("test");
	context.setDisplayName("test");
	context.setConfigLocation("/org/geomajas/spring/geomajasContext.xml ");
	context.refresh();
	Assert.assertSame(Logging.GEOTOOLS.getLoggerFactory(), Slf4jLoggerFactory.getInstance());
}