org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver Java Examples

The following examples show how to use org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver. 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: DefaultNamespaceHandlerResolverTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testResolvedMappedHandler() {
	DefaultNamespaceHandlerResolver resolver = new DefaultNamespaceHandlerResolver(getClass().getClassLoader());
	NamespaceHandler handler = resolver.resolve("http://www.springframework.org/schema/util");
	assertNotNull("Handler should not be null.", handler);
	assertEquals("Incorrect handler loaded", UtilNamespaceHandler.class, handler.getClass());
}
 
Example #2
Source File: DefaultNamespaceHandlerResolverTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testResolveInvalidHandler() throws Exception {
	String mappingPath = "org/springframework/beans/factory/xml/support/invalid.properties";
	try {
		new DefaultNamespaceHandlerResolver(getClass().getClassLoader(), mappingPath);
		fail("Should not be able to map a class that doesn't implement NamespaceHandler");
	}
	catch (Throwable expected) {
	}
}
 
Example #3
Source File: DefaultNamespaceHandlerResolverTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testNonExistentHandlerClass() throws Exception {
	String mappingPath = "org/springframework/beans/factory/xml/support/nonExistent.properties";
	try {
		new DefaultNamespaceHandlerResolver(getClass().getClassLoader(), mappingPath);
		// pass
	}
	catch (Throwable ex) {
		fail("Non-existent handler classes must be ignored: " + ex);
	}
}
 
Example #4
Source File: DefaultNamespaceHandlerResolverTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testResolvedMappedHandlerWithNoArgCtor() {
	DefaultNamespaceHandlerResolver resolver = new DefaultNamespaceHandlerResolver();
	NamespaceHandler handler = resolver.resolve("http://www.springframework.org/schema/util");
	assertNotNull("Handler should not be null.", handler);
	assertEquals("Incorrect handler loaded", UtilNamespaceHandler.class, handler.getClass());
}
 
Example #5
Source File: DefaultNamespaceHandlerResolverTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testResolvedMappedHandler() {
	DefaultNamespaceHandlerResolver resolver = new DefaultNamespaceHandlerResolver(getClass().getClassLoader());
	NamespaceHandler handler = resolver.resolve("http://www.springframework.org/schema/util");
	assertNotNull("Handler should not be null.", handler);
	assertEquals("Incorrect handler loaded", UtilNamespaceHandler.class, handler.getClass());
}
 
Example #6
Source File: CustomNamespaceHandlerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
	NamespaceHandlerResolver resolver = new DefaultNamespaceHandlerResolver(CLASS.getClassLoader(), NS_PROPS);
	this.beanFactory = new GenericApplicationContext();
	XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory);
	reader.setNamespaceHandlerResolver(resolver);
	reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD);
	reader.setEntityResolver(new DummySchemaResolver());
	reader.loadBeanDefinitions(getResource());
	this.beanFactory.refresh();
}
 
Example #7
Source File: DefaultNamespaceHandlerResolverTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testResolveInvalidHandler() throws Exception {
	String mappingPath = "org/springframework/beans/factory/xml/support/invalid.properties";
	try {
		new DefaultNamespaceHandlerResolver(getClass().getClassLoader(), mappingPath);
		fail("Should not be able to map a class that doesn't implement NamespaceHandler");
	}
	catch (Throwable expected) {
	}
}
 
Example #8
Source File: DefaultNamespaceHandlerResolverTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testNonExistentHandlerClass() throws Exception {
	String mappingPath = "org/springframework/beans/factory/xml/support/nonExistent.properties";
	try {
		new DefaultNamespaceHandlerResolver(getClass().getClassLoader(), mappingPath);
		// pass
	}
	catch (Throwable ex) {
		fail("Non-existent handler classes must be ignored: " + ex);
	}
}
 
Example #9
Source File: DefaultNamespaceHandlerResolverTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testResolvedMappedHandlerWithNoArgCtor() {
	DefaultNamespaceHandlerResolver resolver = new DefaultNamespaceHandlerResolver();
	NamespaceHandler handler = resolver.resolve("http://www.springframework.org/schema/util");
	assertNotNull("Handler should not be null.", handler);
	assertEquals("Incorrect handler loaded", UtilNamespaceHandler.class, handler.getClass());
}
 
Example #10
Source File: DefaultNamespaceHandlerResolverTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testResolvedMappedHandler() {
	DefaultNamespaceHandlerResolver resolver = new DefaultNamespaceHandlerResolver(getClass().getClassLoader());
	NamespaceHandler handler = resolver.resolve("http://www.springframework.org/schema/util");
	assertNotNull("Handler should not be null.", handler);
	assertEquals("Incorrect handler loaded", UtilNamespaceHandler.class, handler.getClass());
}
 
Example #11
Source File: CustomNamespaceHandlerTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Before
public void setUp() throws Exception {
	NamespaceHandlerResolver resolver = new DefaultNamespaceHandlerResolver(CLASS.getClassLoader(), NS_PROPS);
	this.beanFactory = new GenericApplicationContext();
	XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory);
	reader.setNamespaceHandlerResolver(resolver);
	reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD);
	reader.setEntityResolver(new DummySchemaResolver());
	reader.loadBeanDefinitions(getResource());
	this.beanFactory.refresh();
}
 
Example #12
Source File: DefaultNamespaceHandlerResolverTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testResolveInvalidHandler() throws Exception {
	String mappingPath = "org/springframework/beans/factory/xml/support/invalid.properties";
	try {
		new DefaultNamespaceHandlerResolver(getClass().getClassLoader(), mappingPath);
		fail("Should not be able to map a class that doesn't implement NamespaceHandler");
	}
	catch (Throwable expected) {
	}
}
 
Example #13
Source File: DefaultNamespaceHandlerResolverTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testNonExistentHandlerClass() throws Exception {
	String mappingPath = "org/springframework/beans/factory/xml/support/nonExistent.properties";
	try {
		new DefaultNamespaceHandlerResolver(getClass().getClassLoader(), mappingPath);
		// pass
	}
	catch (Throwable ex) {
		fail("Non-existent handler classes must be ignored: " + ex);
	}
}
 
Example #14
Source File: DefaultNamespaceHandlerResolverTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testResolvedMappedHandlerWithNoArgCtor() {
	DefaultNamespaceHandlerResolver resolver = new DefaultNamespaceHandlerResolver();
	NamespaceHandler handler = resolver.resolve("http://www.springframework.org/schema/util");
	assertNotNull("Handler should not be null.", handler);
	assertEquals("Incorrect handler loaded", UtilNamespaceHandler.class, handler.getClass());
}
 
Example #15
Source File: CustomNamespaceHandlerTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Before
public void setUp() throws Exception {
	NamespaceHandlerResolver resolver = new DefaultNamespaceHandlerResolver(CLASS.getClassLoader(), NS_PROPS);
	this.beanFactory = new GenericApplicationContext();
	XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory);
	reader.setNamespaceHandlerResolver(resolver);
	reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD);
	reader.setEntityResolver(new DummySchemaResolver());
	reader.loadBeanDefinitions(getResource());
	this.beanFactory.refresh();
}
 
Example #16
Source File: DefaultNamespaceHandlerResolverTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Test
public void testCtorWithNonExistentMappingLocationArgument() throws Exception {
	// simply must not bail; we don't want non-existent resources to result in an Exception
	new DefaultNamespaceHandlerResolver(null, "738trbc bobabloobop871");
}
 
Example #17
Source File: DefaultNamespaceHandlerResolverTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void testCtorWithNullClassLoaderArgumentAndNullMappingLocationArgument() throws Exception {
	new DefaultNamespaceHandlerResolver(null, null);
}
 
Example #18
Source File: DefaultNamespaceHandlerResolverTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Test
public void testCtorWithNullClassLoaderArgument() throws Exception {
	// simply must not bail...
	new DefaultNamespaceHandlerResolver(null);
}
 
Example #19
Source File: DefaultNamespaceHandlerResolverTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void testCtorWithNullClassLoaderArgumentAndNullMappingLocationArgument() throws Exception {
	new DefaultNamespaceHandlerResolver(null, null);
}
 
Example #20
Source File: DefaultNamespaceHandlerResolverTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Test
public void testCtorWithNonExistentMappingLocationArgument() throws Exception {
	// simply must not bail; we don't want non-existent resources to result in an Exception
	new DefaultNamespaceHandlerResolver(null, "738trbc bobabloobop871");
}
 
Example #21
Source File: DefaultNamespaceHandlerResolverTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Test
public void testCtorWithNullClassLoaderArgument() throws Exception {
	// simply must not bail...
	new DefaultNamespaceHandlerResolver(null);
}
 
Example #22
Source File: DefaultNamespaceHandlerResolverTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Test
public void testCtorWithNullClassLoaderArgument() throws Exception {
	// simply must not bail...
	new DefaultNamespaceHandlerResolver(null);
}
 
Example #23
Source File: DefaultNamespaceHandlerResolverTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Test(expected=IllegalArgumentException.class)
public void testCtorWithNullClassLoaderArgumentAndNullMappingLocationArgument() throws Exception {
	new DefaultNamespaceHandlerResolver(null, null);
}
 
Example #24
Source File: DefaultNamespaceHandlerResolverTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Test
public void testCtorWithNonExistentMappingLocationArgument() throws Exception {
	// simply must not bail; we don't want non-existent resources to result in an Exception
	new DefaultNamespaceHandlerResolver(null, "738trbc bobabloobop871");
}