Simple tests to detect invalid configurations, particularly when the namespace has been updated without applying the spring-security.xsl transformation, which prevents certain elements from appearing at top level.

This commit is contained in:
Luke Taylor 2008-03-31 16:30:28 +00:00
parent b1ae4922d2
commit 53b084e2f9
1 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,35 @@
package org.springframework.security.config;
import org.junit.After;
import org.junit.Test;
import org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException;
import org.springframework.security.util.InMemoryXmlApplicationContext;
/**
* Tests which make sure invalid configurations are rejected by the namespace. In particular invalid top-level
* elements. These are likely to fail after the namespace has been updated using trang, but the spring-security.xsl
* transform has not been applied.
*
* @author Luke Taylor
* @version $Id$
*/
public class InvalidConfigurationTests {
private InMemoryXmlApplicationContext appContext;
@After
public void closeAppContext() {
if (appContext != null) {
appContext.close();
}
}
// Parser should throw a SAXParseException
@Test(expected=XmlBeanDefinitionStoreException.class)
public void passwordEncoderCannotAppearAtTopLevel() {
setContext("<password-encoder hash='md5'/>");
}
private void setContext(String context) {
appContext = new InMemoryXmlApplicationContext(context);
}
}