Skip to content
Permalink
Browse files

SAML: Unable to find resource '/templates/saml2-post-binding.vm' fix p…

  • Loading branch information
jknack authored and leleuj committed Jan 5, 2017
1 parent 8a51847 commit 16f1ad7739dd81b81c5fc3e81a0576279d9a8565
@@ -11,7 +11,7 @@
/**
* Factory returning a well configured {@link VelocityEngine} instance required for
* generating an HTML form used to POST SAML messages.
*
*
* @author Michael Remond
*
*/
@@ -22,7 +22,8 @@ public static VelocityEngine getEngine() {
try {

final Properties props =
new Properties(net.shibboleth.utilities.java.support.velocity.VelocityEngine.getDefaultProperties());
new Properties();
props.putAll(net.shibboleth.utilities.java.support.velocity.VelocityEngine.getDefaultProperties());
props.setProperty(RuntimeConstants.INPUT_ENCODING, "UTF-8");
props.setProperty(RuntimeConstants.OUTPUT_ENCODING, "UTF-8");
props.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
@@ -0,0 +1,30 @@
package org.pac4j.saml.util;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import java.util.Arrays;
import java.util.Vector;

import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.runtime.RuntimeConstants;
import org.junit.Test;

public class VelocityEngineFactoryTest {

@Test
public void defaultProperties() {
VelocityEngine engine = VelocityEngineFactory.getEngine();
assertNotNull(engine);
assertEquals("org.apache.velocity.runtime.resource.loader.StringResourceLoader", engine.getProperty("string.resource.loader.class"));
assertEquals("org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader", engine.getProperty("classpath.resource.loader.class"));
assertEquals(vector("classpath"), engine.getProperty("resource.loader"));
assertEquals("UTF-8", engine.getProperty(RuntimeConstants.INPUT_ENCODING));
assertEquals("UTF-8", engine.getProperty(RuntimeConstants.OUTPUT_ENCODING));
assertEquals("net.shibboleth.utilities.java.support.velocity.SLF4JLogChute", engine.getProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS));
}

private Vector<String> vector(final String... values) {
return new Vector<String>(Arrays.asList(values));
}
}

0 comments on commit 16f1ad7

Please sign in to comment.
You can’t perform that action at this time.