Merge branch 'release-2011-07-18'
This commit is contained in:
commit
d0162134e6
@ -6,10 +6,14 @@ import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.xml.namespace.NamespaceContext;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.xpath.XPath;
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
@ -34,6 +38,7 @@ public class TestDeployConfiguration {
|
||||
private static String repositoryContext = "META-INF"+File.separator+"repositoryContext.xml";
|
||||
private static String baseRepository = "META-INF"+File.separator+"base-repository.xml";
|
||||
private static String webXmlPath = "src"+File.separator+"main"+File.separator+"webapp"+File.separator+"WEB-INF"+File.separator+"web.xml";
|
||||
private static final String applicationContextPath = "applicationContext.xml";
|
||||
|
||||
@Test
|
||||
public void testWicketDeploymentConfiguration() throws XPathExpressionException, IOException, SAXException, ParserConfigurationException {
|
||||
@ -98,6 +103,27 @@ public class TestDeployConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExternalAuthCfg() throws XPathExpressionException, IOException{
|
||||
InputSource applicationContextXml = getInputSource(applicationContextPath);
|
||||
XPath xPath = getApplicationContextXPath();
|
||||
Assert.assertEquals("true", xPath.evaluate("/defaultNS:beans/defaultNS:bean[@id='applicationSettings']/defaultNS:property[@name='acceptExternalAuthentication']/@value", applicationContextXml));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoteUserLookupCfg() throws XPathExpressionException, IOException{
|
||||
InputSource applicationContextXml = getInputSource(applicationContextPath);
|
||||
XPath xPath = getApplicationContextXPath();
|
||||
Assert.assertEquals("true", xPath.evaluate("/defaultNS:beans/defaultNS:bean[@id='applicationSettings']/defaultNS:property[@name='enableRemoteUserLookup']/@value", applicationContextXml));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoteUserRemoteUserLookupUrlCfg() throws XPathExpressionException, IOException{
|
||||
InputSource applicationContextXml = getInputSource(applicationContextPath);
|
||||
XPath xPath = getApplicationContextXPath();
|
||||
Assert.assertEquals("https://thesis.dsv.su.se/match/json", xPath.evaluate("/defaultNS:beans/defaultNS:bean[@id='applicationSettings']/defaultNS:property[@name='remoteLookupUrl']/@value", applicationContextXml));
|
||||
}
|
||||
|
||||
private InputSource getInputSource(String filePath) throws IOException{
|
||||
String theString = readResourceAsString(filePath);
|
||||
InputStream is = new ByteArrayInputStream(theString.getBytes());
|
||||
@ -114,5 +140,30 @@ public class TestDeployConfiguration {
|
||||
IOUtils.copy(in, writer, charset);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
private XPath getApplicationContextXPath(){
|
||||
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||
xPath.setNamespaceContext(new NamespaceContext(){
|
||||
@Override
|
||||
public String getNamespaceURI(String prefix){
|
||||
if(prefix.equals("defaultNS"))
|
||||
return "http://www.springframework.org/schema/beans";
|
||||
else
|
||||
return "";
|
||||
}
|
||||
@Override
|
||||
public Iterator<String> getPrefixes(String val) {
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
list.add(getPrefix(val));
|
||||
return list.iterator();
|
||||
}
|
||||
@Override
|
||||
public String getPrefix(String uri) {
|
||||
if(uri.equals("http://www.springframework.org/schema/beans"))
|
||||
return "defaultNS";
|
||||
else
|
||||
return "";
|
||||
}
|
||||
});
|
||||
return xPath;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user