[java-identity-provider COMMIT] /trunk/idp-profile-api/src/test/java/net/shibboleth/idp/profile/logic/ScriptedPredica...
noreply at shibboleth.net
noreply at shibboleth.net
Sun Aug 16 11:42:41 EDT 2015
Author: rdw
Date: Sun Aug 16 11:42:41 2015
New Revision: 7684
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=7684&view=rev
Log:
IDP-542 Teardown application contexts after tests
https://issues.shibboleth.net/jira/browse/IDP-542
Single test in idp-profile-api that uses spring.
Modified:
trunk/idp-profile-api/src/test/java/net/shibboleth/idp/profile/logic/ScriptedPredicateTest.java
Modified: trunk/idp-profile-api/src/test/java/net/shibboleth/idp/profile/logic/ScriptedPredicateTest.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-profile-api/src/test/java/net/shibboleth/idp/profile/logic/ScriptedPredicateTest.java?rev=7684&r1=7683&r2=7684&view=diff
==============================================================================
--- trunk/idp-profile-api/src/test/java/net/shibboleth/idp/profile/logic/ScriptedPredicateTest.java (original)
+++ trunk/idp-profile-api/src/test/java/net/shibboleth/idp/profile/logic/ScriptedPredicateTest.java Sun Aug 16 11:42:41 2015
@@ -21,7 +21,6 @@
import net.shibboleth.ext.spring.util.SchemaTypeAwareXMLBeanDefinitionReader;
import net.shibboleth.idp.profile.context.RelyingPartyContext;
-import net.shibboleth.idp.profile.logic.ScriptedPredicate;
import org.opensaml.profile.context.ProfileRequestContext;
import org.springframework.context.support.GenericApplicationContext;
@@ -34,59 +33,71 @@
* Tests for {@link ScriptedPredicate}.
*/
public class ScriptedPredicateTest {
-
+
private ProfileRequestContext withChild;
-
+
private ProfileRequestContext noChild;
-
- @BeforeClass public void setup(){
+
+ @BeforeClass public void setup() {
withChild = new ProfileRequestContext<>();
withChild.getSubcontext(RelyingPartyContext.class, true);
noChild = new ProfileRequestContext<>();
}
-
+
@Test public void simple() throws ScriptException {
ScriptedPredicate test = ScriptedPredicate.inlineScript("new java.lang.Boolean(true);");
Assert.assertTrue(test.apply(withChild));
-
+
test = ScriptedPredicate.inlineScript("true");
Assert.assertTrue(test.apply(withChild));
test = ScriptedPredicate.inlineScript("false");
Assert.assertFalse(test.apply(withChild));
-
+
test = ScriptedPredicate.inlineScript("\"thirty\"");
Assert.assertFalse(test.apply(withChild));
}
@Test public void inlineBean() throws ScriptException {
-
+
GenericApplicationContext ctx = new GenericApplicationContext();
- SchemaTypeAwareXMLBeanDefinitionReader beanDefinitionReader = new SchemaTypeAwareXMLBeanDefinitionReader(ctx);
+ try {
+ SchemaTypeAwareXMLBeanDefinitionReader beanDefinitionReader =
+ new SchemaTypeAwareXMLBeanDefinitionReader(ctx);
- beanDefinitionReader.loadBeanDefinitions(new ClassPathResource("/net/shibboleth/idp/profile/logic/inlineBean.xml"));
+ beanDefinitionReader.loadBeanDefinitions(new ClassPathResource(
+ "/net/shibboleth/idp/profile/logic/inlineBean.xml"));
- ctx.refresh();
- final ScriptedPredicate rule = ctx.getBean(ScriptedPredicate.class);
+ ctx.refresh();
+ final ScriptedPredicate rule = ctx.getBean(ScriptedPredicate.class);
- Assert.assertTrue(rule.apply(withChild));
+ Assert.assertTrue(rule.apply(withChild));
- Assert.assertFalse(rule.apply(noChild));
+ Assert.assertFalse(rule.apply(noChild));
+ } finally {
+ ctx.close();
+ }
}
-
+
@Test public void resourceBean() throws ScriptException {
-
+
GenericApplicationContext ctx = new GenericApplicationContext();
- SchemaTypeAwareXMLBeanDefinitionReader beanDefinitionReader = new SchemaTypeAwareXMLBeanDefinitionReader(ctx);
+ try {
+ SchemaTypeAwareXMLBeanDefinitionReader beanDefinitionReader =
+ new SchemaTypeAwareXMLBeanDefinitionReader(ctx);
- beanDefinitionReader.loadBeanDefinitions(new ClassPathResource("/net/shibboleth/idp/profile/logic/resourceBean.xml"));
+ beanDefinitionReader.loadBeanDefinitions(new ClassPathResource(
+ "/net/shibboleth/idp/profile/logic/resourceBean.xml"));
- ctx.refresh();
- final ScriptedPredicate rule = ctx.getBean(ScriptedPredicate.class);
+ ctx.refresh();
+ final ScriptedPredicate rule = ctx.getBean(ScriptedPredicate.class);
- Assert.assertTrue(rule.apply(withChild));
+ Assert.assertTrue(rule.apply(withChild));
- Assert.assertFalse(rule.apply(noChild));
+ Assert.assertFalse(rule.apply(noChild));
+ } finally {
+ ctx.close();
+ }
}
}
More information about the commits
mailing list