[java-identity-provider COMMIT] in /trunk/idp-attribute-resolver-impl/src/test: java/net/shibboleth/idp/attribute/res...
noreply at shibboleth.net
noreply at shibboleth.net
Wed Apr 3 10:18:40 EDT 2013
Author: rdw
Date: Wed Apr 3 10:18:40 2013
New Revision: 4387
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=4387&view=rev
Log:
Enhanced code coverage for Scripted attribute definition
Added:
trunk/idp-attribute-resolver-impl/src/test/resources/data/net/shibboleth/idp/attribute/resolver/impl/ad/addAfterGetValues.script
trunk/idp-attribute-resolver-impl/src/test/resources/data/net/shibboleth/idp/attribute/resolver/impl/ad/attributes2.script
trunk/idp-attribute-resolver-impl/src/test/resources/data/net/shibboleth/idp/attribute/resolver/impl/ad/fail1.script
- copied, changed from r4375, trunk/idp-attribute-resolver-impl/src/test/resources/data/net/shibboleth/idp/attribute/resolver/impl/ad/fails.script
trunk/idp-attribute-resolver-impl/src/test/resources/data/net/shibboleth/idp/attribute/resolver/impl/ad/fail2.script
trunk/idp-attribute-resolver-impl/src/test/resources/data/net/shibboleth/idp/attribute/resolver/impl/ad/fail3.script
trunk/idp-attribute-resolver-impl/src/test/resources/data/net/shibboleth/idp/attribute/resolver/impl/ad/fail4.script
trunk/idp-attribute-resolver-impl/src/test/resources/data/net/shibboleth/idp/attribute/resolver/impl/ad/fail5.script
trunk/idp-attribute-resolver-impl/src/test/resources/data/net/shibboleth/idp/attribute/resolver/impl/ad/fail6.script
trunk/idp-attribute-resolver-impl/src/test/resources/data/net/shibboleth/idp/attribute/resolver/impl/ad/fail7.script
Modified:
trunk/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/ad/ScriptedAttributeTest.java
trunk/idp-attribute-resolver-impl/src/test/resources/data/net/shibboleth/idp/attribute/resolver/impl/ad/fails.script
Modified: trunk/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/ad/ScriptedAttributeTest.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/ad/ScriptedAttributeTest.java?rev=4387&r1=4386&r2=4387&view=diff
==============================================================================
--- trunk/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/ad/ScriptedAttributeTest.java (original)
+++ trunk/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/ad/ScriptedAttributeTest.java Wed Apr 3 10:18:40 2013
@@ -30,6 +30,7 @@
import net.shibboleth.idp.attribute.Attribute;
import net.shibboleth.idp.attribute.AttributeValue;
import net.shibboleth.idp.attribute.StringAttributeValue;
+import net.shibboleth.idp.attribute.XMLObjectAttributeValue;
import net.shibboleth.idp.attribute.resolver.AttributeResolutionContext;
import net.shibboleth.idp.attribute.resolver.AttributeResolver;
import net.shibboleth.idp.attribute.resolver.BaseAttributeDefinition;
@@ -63,7 +64,7 @@
/** Simple result. */
private static final String SIMPLE_VALUE = "simple";
-
+
private String fileNameToPath(String fileName) {
return "/data/net/shibboleth/idp/attribute/resolver/impl/ad/" + fileName;
}
@@ -136,8 +137,9 @@
ScriptException, IOException {
final Attribute test = new Attribute(TEST_ATTRIBUTE_NAME);
-
- test.getValues().add(new StringAttributeValue(SIMPLE_VALUE));
+ final AttributeValue attributeValue = new StringAttributeValue(SIMPLE_VALUE);
+
+ test.getValues().add(attributeValue);
final ScriptedAttributeDefinition attr = new ScriptedAttributeDefinition();
Assert.assertNull(attr.getScript());
@@ -151,16 +153,11 @@
Assert.assertTrue(test.equals(val), "Scripted result is the same as bases");
Assert.assertEquals(results.size(), 1, "Scripted result value count");
- Assert.assertEquals(results.iterator().next().getValue(), SIMPLE_VALUE, "Scripted result contains known value");
- }
-
- @Test public void testFails() throws ResolutionException, ComponentInitializationException, ScriptException,
- IOException {
-
- final Attribute test = new Attribute(TEST_ATTRIBUTE_NAME);
-
- test.getValues().add(new StringAttributeValue(SIMPLE_VALUE));
-
+ Assert.assertEquals(results.iterator().next(), attributeValue, "Scripted result contains known value");
+ }
+
+ private ScriptedAttributeDefinition buildTest(String failingScript) throws ScriptException, IOException,
+ ComponentInitializationException {
final ScriptedAttributeDefinition attr = new ScriptedAttributeDefinition();
attr.setId(TEST_ATTRIBUTE_NAME);
try {
@@ -170,15 +167,44 @@
// OK
}
- attr.setScript(new EvaluableScript(SCRIPT_LANGUAGE, getScript("fails.script")));
+ attr.setScript(new EvaluableScript(SCRIPT_LANGUAGE, getScript(failingScript)));
attr.initialize();
+ return attr;
+ }
+
+ private void failureTest(String failingScript, String failingMessage) throws ScriptException, IOException,
+ ComponentInitializationException {
try {
[... 226 lines stripped ...]
More information about the commits
mailing list