You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openaz.apache.org by co...@apache.org on 2015/05/05 14:23:32 UTC
[34/54] [abbrv] [partial] incubator-openaz git commit: Do an eclipse
based "cleanup" on the project
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/38b6d318/openaz-xacml-test/src/test/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionAccessPermittedTest.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-test/src/test/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionAccessPermittedTest.java b/openaz-xacml-test/src/test/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionAccessPermittedTest.java
index 327a3d9..c8cd54a 100644
--- a/openaz-xacml-test/src/test/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionAccessPermittedTest.java
+++ b/openaz-xacml-test/src/test/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionAccessPermittedTest.java
@@ -25,11 +25,6 @@ import com.att.research.xacml.api.XACML3;
import com.att.research.xacml.std.StdMutableRequest;
import com.att.research.xacml.std.datatypes.DataTypes;
import com.att.research.xacml.std.dom.DOMRequest;
-import com.att.research.xacmlatt.pdp.policy.ExpressionResult;
-import com.att.research.xacmlatt.pdp.policy.FunctionArgument;
-import com.att.research.xacmlatt.pdp.policy.FunctionArgumentAttributeValue;
-import com.att.research.xacmlatt.pdp.std.StdEvaluationContext;
-import com.att.research.xacmlatt.pdp.std.StdFunctions;
import org.junit.Ignore;
import org.junit.Test;
@@ -44,15 +39,10 @@ import java.util.List;
import static org.junit.Assert.*;
/**
- * Test of PDP Functions (See XACML core spec section A.3)
- *
- * TO RUN - use jUnit
- * In Eclipse select this file or the enclosing directory, right-click and select Run As/JUnit Test
- *
- * NOT IMPLEMENTED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- * This function is not yet implemented so these tests intentionally fail.
- *
- *
+ * Test of PDP Functions (See XACML core spec section A.3) TO RUN - use jUnit In Eclipse select this file or
+ * the enclosing directory, right-click and select Run As/JUnit Test NOT
+ * IMPLEMENTED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! This
+ * function is not yet implemented so these tests intentionally fail.
*/
public class FunctionDefinitionAccessPermittedTest {
@@ -61,117 +51,89 @@ public class FunctionDefinitionAccessPermittedTest {
//
String reqStrMainStart = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
- + "<Request xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"
- + " http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\""
- + " ReturnPolicyIdList=\"false\""
- + " CombinedDecision=\"false\""
- + " xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\""
- + " xmlns:md=\"http://www.medico.com/schemas/record\""
- + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
- + " <Attributes Category=\"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\">"
- + " <Attribute IncludeInResult=\"false\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject:subject-id\">"
- + " <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Julius Hibbert</AttributeValue>"
- + " </Attribute>"
- + " <Attribute IncludeInResult=\"false\" AttributeId=\"urn:oasis:names:tc:xacml:2.0:conformance-test:test-attr\">"
- + " <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\"> This is IT! </AttributeValue>"
- + " </Attribute>"
- + " <Attribute IncludeInResult=\"false\" AttributeId=\"urn:oasis:names:tc:xacml:2.0:conformance-test:test-attr\">"
- + " <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\"> This is IT! </AttributeValue>"
- + " </Attribute>"
- + "</Attributes>";
-
- String reqStrResourceStart = "<Attributes Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\">";
-
- String reqStrMdRecordSimpson =
- "<md:record>" +
- "<md:hospital_info>" +
- "<md:name>ABC Hospital</md:name>" +
- "<md:department>Surgery</md:department>" +
- "</md:hospital_info>" +
- "<md:patient_info>" +
- "<md:name>Bart Simpson</md:name>" +
- "<md:age>60</md:age>" +
- "<md:sex>male</md:sex>" +
- "<md:health_insurance>123456</md:health_insurance>" +
- "</md:patient_info>" +
- "<md:diagnosis_info>" +
- "<md:diagnosis>" +
- "<md:item type=\"primary\">Gastric Cancer</md:item>" +
- "<md:item type=\"secondary\">Hyper tension</md:item>" +
- "</md:diagnosis>" +
- "<md:pathological_diagnosis>" +
- "<md:diagnosis>" +
- "<md:item type=\"primary\">Well differentiated adeno carcinoma</md:item>" +
- "</md:diagnosis>" +
- "<md:date>2000-10-05</md:date>" +
- "<md:malignancy type=\"yes\"/>" +
- "</md:pathological_diagnosis>" +
- "</md:diagnosis_info>" +
- " </md:record>";
+ + "<Request xsi:schemaLocation=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"
+ + " http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd\""
+ + " ReturnPolicyIdList=\"false\""
+ + " CombinedDecision=\"false\""
+ + " xmlns=\"urn:oasis:names:tc:xacml:3.0:core:schema:wd-17\""
+ + " xmlns:md=\"http://www.medico.com/schemas/record\""
+ + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
+ + " <Attributes Category=\"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject\">"
+ + " <Attribute IncludeInResult=\"false\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject:subject-id\">"
+ + " <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">Julius Hibbert</AttributeValue>"
+ + " </Attribute>"
+ + " <Attribute IncludeInResult=\"false\" AttributeId=\"urn:oasis:names:tc:xacml:2.0:conformance-test:test-attr\">"
+ + " <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\"> This is IT! </AttributeValue>"
+ + " </Attribute>"
+ + " <Attribute IncludeInResult=\"false\" AttributeId=\"urn:oasis:names:tc:xacml:2.0:conformance-test:test-attr\">"
+ + " <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\"> This is IT! </AttributeValue>"
+ + " </Attribute>" + "</Attributes>";
+
+ String reqStrResourceStart = "<Attributes Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\">";
+
+ String reqStrMdRecordSimpson = "<md:record>"
+ + "<md:hospital_info>"
+ + "<md:name>ABC Hospital</md:name>"
+ + "<md:department>Surgery</md:department>"
+ + "</md:hospital_info>"
+ + "<md:patient_info>"
+ + "<md:name>Bart Simpson</md:name>"
+ + "<md:age>60</md:age>"
+ + "<md:sex>male</md:sex>"
+ + "<md:health_insurance>123456</md:health_insurance>"
+ + "</md:patient_info>"
+ + "<md:diagnosis_info>"
+ + "<md:diagnosis>"
+ + "<md:item type=\"primary\">Gastric Cancer</md:item>"
+ + "<md:item type=\"secondary\">Hyper tension</md:item>"
+ + "</md:diagnosis>"
+ + "<md:pathological_diagnosis>"
+ + "<md:diagnosis>"
+ + "<md:item type=\"primary\">Well differentiated adeno carcinoma</md:item>"
+ + "</md:diagnosis>" + "<md:date>2000-10-05</md:date>"
+ + "<md:malignancy type=\"yes\"/>" + "</md:pathological_diagnosis>"
+ + "</md:diagnosis_info>" + " </md:record>";
String reqStrContentMdRecordSimpson = "<Content>" + reqStrMdRecordSimpson + "</Content>";
- String reqStrMalformedContent =
- " <Content>" +
- "<md:record>" +
- "<md:hospital_info>" +
- "<md:name>ABC Hospital</md:name>" +
- "<md:malignancy type=\"yes\"/>" +
- "</Content>";
- String reqStrMdRecordSpringer =
- "<md:record>" +
- "<md:hospital_info>" +
- "<md:name>XYZ Hospital</md:name>" +
- "<md:department>Surgery</md:department>" +
- "</md:hospital_info>" +
- "<md:patient_info>" +
- "<md:name>Jerry Springer</md:name>" +
- "<md:age>65</md:age>" +
- "<md:sex>male</md:sex>" +
- "<md:health_insurance>765432</md:health_insurance>" +
- "</md:patient_info>" +
- "<md:diagnosis_info>" +
- "<md:diagnosis>" +
- "<md:item type=\"primary\">Hyatal Hernia</md:item>" +
- "<md:item type=\"secondary\">Diabetes</md:item>" +
- "<md:item type=\"tertiary\">Neuronal Collapse</md:item>" +
- "</md:diagnosis>" +
- "<md:pathological_diagnosis>" +
- "<md:diagnosis>" +
- "<md:item type=\"primary\">We have no idea</md:item>" +
- "</md:diagnosis>" +
- "<md:date>2012-07-22</md:date>" +
- "<md:malignancy type=\"no\"/>" +
- "</md:pathological_diagnosis>" +
- "</md:diagnosis_info>" +
- " </md:record>";
- String reqStrContentMdRecordSpringer =
- "<Content>" + reqStrMdRecordSpringer + "</Content>";
+ String reqStrMalformedContent = " <Content>" + "<md:record>" + "<md:hospital_info>"
+ + "<md:name>ABC Hospital</md:name>" + "<md:malignancy type=\"yes\"/>"
+ + "</Content>";
+ String reqStrMdRecordSpringer = "<md:record>" + "<md:hospital_info>" + "<md:name>XYZ Hospital</md:name>"
+ + "<md:department>Surgery</md:department>" + "</md:hospital_info>"
+ + "<md:patient_info>" + "<md:name>Jerry Springer</md:name>"
+ + "<md:age>65</md:age>" + "<md:sex>male</md:sex>"
+ + "<md:health_insurance>765432</md:health_insurance>"
+ + "</md:patient_info>" + "<md:diagnosis_info>" + "<md:diagnosis>"
+ + "<md:item type=\"primary\">Hyatal Hernia</md:item>"
+ + "<md:item type=\"secondary\">Diabetes</md:item>"
+ + "<md:item type=\"tertiary\">Neuronal Collapse</md:item>"
+ + "</md:diagnosis>" + "<md:pathological_diagnosis>" + "<md:diagnosis>"
+ + "<md:item type=\"primary\">We have no idea</md:item>"
+ + "</md:diagnosis>" + "<md:date>2012-07-22</md:date>"
+ + "<md:malignancy type=\"no\"/>" + "</md:pathological_diagnosis>"
+ + "</md:diagnosis_info>" + " </md:record>";
+ String reqStrContentMdRecordSpringer = "<Content>" + reqStrMdRecordSpringer + "</Content>";
String reqStrResourceEnd = " <Attribute IncludeInResult=\"false\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:resource:resource-id\">"
- + " <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#anyURI\">http://medico.com/record/patient/BartSimpson</AttributeValue>"
- + " </Attribute>"
- + "</Attributes> ";
- String reqStrActionStart = "<Attributes Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:action\">";
+ + " <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#anyURI\">http://medico.com/record/patient/BartSimpson</AttributeValue>"
+ + " </Attribute>" + "</Attributes> ";
+ String reqStrActionStart = "<Attributes Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:action\">";
String reqStrActionEnd = "<Attribute IncludeInResult=\"false\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:action:action-id\">"
- + "<AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">read</AttributeValue>"
- + "</Attribute>"
- + "</Attributes> ";
+ + "<AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">read</AttributeValue>"
+ + "</Attribute>" + "</Attributes> ";
String reqStrEnvironmentStartEnd = " <Attributes Category=\"urn:oasis:names:tc:xacml:3.0:attribute-category:environment\" />";
String reqStrMainEnd = " </Request>";
-
// combined strings for convenience
String reqStrMainResourceStart = reqStrMainStart + reqStrResourceStart;
- String reqStrResourceAllEnd = reqStrResourceEnd + reqStrActionStart + reqStrActionEnd + reqStrEnvironmentStartEnd + reqStrMainEnd;
-
+ String reqStrResourceAllEnd = reqStrResourceEnd + reqStrActionStart + reqStrActionEnd
+ + reqStrEnvironmentStartEnd + reqStrMainEnd;
/*
* variables useful in the following tests
*/
List<FunctionArgument> arguments = new ArrayList<FunctionArgument>();
-
-
// Name Spaces used in the XML as part of these examples - needed for compiling XPaths
NamespaceContext nameSpaceContext = new NamespaceContext() {
@Override
@@ -186,7 +148,7 @@ public class FunctionDefinitionAccessPermittedTest {
@Override
public String getNamespaceURI(String arg0) {
- if("md".equals(arg0)) {
+ if ("md".equals(arg0)) {
return "http://www.medico.com/schemas/record";
} else if ("xacml-context".equals(arg0)) {
return "urn:oasis:names:tc:xacml:3.0:context:schema:os";
@@ -197,8 +159,6 @@ public class FunctionDefinitionAccessPermittedTest {
}
};
-
-
//
// URIs for attribute categroies
//
@@ -210,8 +170,6 @@ public class FunctionDefinitionAccessPermittedTest {
FunctionArgumentAttributeValue attrUriNotInRequest = null;
FunctionArgumentAttributeValue attrUriNotCategory = null;
-
-
//
// XML Contents
//
@@ -224,11 +182,6 @@ public class FunctionDefinitionAccessPermittedTest {
FunctionArgumentAttributeValue attrXContentSpringer = null;
FunctionArgumentAttributeValue attrXBadXML = null;
-
-
-
-
-
//
// REQUEST objects available for use in tests
//
@@ -239,37 +192,50 @@ public class FunctionDefinitionAccessPermittedTest {
Request requestResourceActionContent = null;
Request requestContentInAction = null;
-
-
-
/**
* Set up all variables in one place because it is complicated (lots of steps needed for each attribute)
*/
public FunctionDefinitionAccessPermittedTest() {
try {
-
// create Function Attributes for URIs
attrUriNull = null;
attrUriEmpty = new FunctionArgumentAttributeValue(DataTypes.DT_ANYURI.createAttributeValue(""));
- attrUriResources = new FunctionArgumentAttributeValue(DataTypes.DT_ANYURI.createAttributeValue("urn:oasis:names:tc:xacml:3.0:attribute-category:resource"));
- attrUriAction = new FunctionArgumentAttributeValue(DataTypes.DT_ANYURI.createAttributeValue("urn:oasis:names:tc:xacml:3.0:attribute-category:action"));
- attrUriNotInRequest = new FunctionArgumentAttributeValue(DataTypes.DT_ANYURI.createAttributeValue("NoSuchURI"));
- attrUriNotCategory = new FunctionArgumentAttributeValue(DataTypes.DT_ANYURI.createAttributeValue("urn:oasis:names:tc:xacml:1.0:resource:resource-id"));
+ attrUriResources = new FunctionArgumentAttributeValue(
+ DataTypes.DT_ANYURI
+ .createAttributeValue("urn:oasis:names:tc:xacml:3.0:attribute-category:resource"));
+ attrUriAction = new FunctionArgumentAttributeValue(
+ DataTypes.DT_ANYURI
+ .createAttributeValue("urn:oasis:names:tc:xacml:3.0:attribute-category:action"));
+ attrUriNotInRequest = new FunctionArgumentAttributeValue(
+ DataTypes.DT_ANYURI
+ .createAttributeValue("NoSuchURI"));
+ attrUriNotCategory = new FunctionArgumentAttributeValue(
+ DataTypes.DT_ANYURI
+ .createAttributeValue("urn:oasis:names:tc:xacml:1.0:resource:resource-id"));
// create Function Attributes for XML Strings
attrXnull = new FunctionArgumentAttributeValue(null);
attrXEmpty = new FunctionArgumentAttributeValue(DataTypes.DT_STRING.createAttributeValue(""));
- attrXSimpson = new FunctionArgumentAttributeValue(DataTypes.DT_STRING.createAttributeValue(reqStrMdRecordSimpson));
- attrXSpringer = new FunctionArgumentAttributeValue(DataTypes.DT_STRING.createAttributeValue(reqStrMdRecordSpringer));
- attrXContentSimpson = new FunctionArgumentAttributeValue(DataTypes.DT_STRING.createAttributeValue(reqStrContentMdRecordSimpson));
- attrXContentSpringer = new FunctionArgumentAttributeValue(DataTypes.DT_STRING.createAttributeValue(reqStrContentMdRecordSpringer));
- attrXBadXML = new FunctionArgumentAttributeValue(DataTypes.DT_STRING.createAttributeValue(reqStrMalformedContent));
-
-
+ attrXSimpson = new FunctionArgumentAttributeValue(
+ DataTypes.DT_STRING
+ .createAttributeValue(reqStrMdRecordSimpson));
+ attrXSpringer = new FunctionArgumentAttributeValue(
+ DataTypes.DT_STRING
+ .createAttributeValue(reqStrMdRecordSpringer));
+ attrXContentSimpson = new FunctionArgumentAttributeValue(
+ DataTypes.DT_STRING
+ .createAttributeValue(reqStrContentMdRecordSimpson));
+ attrXContentSpringer = new FunctionArgumentAttributeValue(
+ DataTypes.DT_STRING
+ .createAttributeValue(reqStrContentMdRecordSpringer));
+ attrXBadXML = new FunctionArgumentAttributeValue(
+ DataTypes.DT_STRING
+ .createAttributeValue(reqStrMalformedContent));
// Request objects
- // to create a Request object the easiest way is to put the xml into a file and use the DOMRequest to load it.
+ // to create a Request object the easiest way is to put the xml into a file and use the DOMRequest
+ // to load it.
// single Content in the Resources section (normal valid request)
String reqString = reqStrMainResourceStart + reqStrContentMdRecordSimpson + reqStrResourceAllEnd;
@@ -282,7 +248,8 @@ public class FunctionDefinitionAccessPermittedTest {
tFile.delete();
// Resources included twice
- reqString = reqStrMainResourceStart + reqStrContentMdRecordSimpson + reqStrResourceEnd + reqStrResourceStart + reqStrContentMdRecordSimpson +reqStrResourceAllEnd;
+ reqString = reqStrMainResourceStart + reqStrContentMdRecordSimpson + reqStrResourceEnd
+ + reqStrResourceStart + reqStrContentMdRecordSimpson + reqStrResourceAllEnd;
tFile = File.createTempFile("functionJunit", "request");
bw = new BufferedWriter(new FileWriter(tFile));
bw.append(reqString);
@@ -292,7 +259,8 @@ public class FunctionDefinitionAccessPermittedTest {
tFile.delete();
// Content included twice - error
- reqString = reqStrMainResourceStart + reqStrContentMdRecordSimpson + reqStrContentMdRecordSimpson +reqStrResourceAllEnd;
+ reqString = reqStrMainResourceStart + reqStrContentMdRecordSimpson + reqStrContentMdRecordSimpson
+ + reqStrResourceAllEnd;
tFile = File.createTempFile("functionJunit", "request");
bw = new BufferedWriter(new FileWriter(tFile));
bw.append(reqString);
@@ -304,11 +272,12 @@ public class FunctionDefinitionAccessPermittedTest {
} catch (com.att.research.xacml.std.dom.DOMStructureException e) {
// this is what it should do, so just continue
} catch (Exception e) {
- fail("Unexpected exception for bad XML, e="+e);
+ fail("Unexpected exception for bad XML, e=" + e);
}
// content included in both Resource and Action - ok
- reqString = reqStrMainResourceStart + reqStrContentMdRecordSimpson + reqStrResourceEnd + reqStrActionStart + reqStrContentMdRecordSimpson + reqStrActionEnd + reqStrMainEnd;
+ reqString = reqStrMainResourceStart + reqStrContentMdRecordSimpson + reqStrResourceEnd
+ + reqStrActionStart + reqStrContentMdRecordSimpson + reqStrActionEnd + reqStrMainEnd;
tFile = File.createTempFile("functionJunit", "request");
bw = new BufferedWriter(new FileWriter(tFile));
bw.append(reqString);
@@ -318,7 +287,8 @@ public class FunctionDefinitionAccessPermittedTest {
tFile.delete();
// Content included only in Action - missing content produces non-error result according to spec
- reqString = reqStrMainResourceStart + reqStrResourceEnd + reqStrActionStart + reqStrContentMdRecordSimpson + reqStrActionEnd + reqStrMainEnd;
+ reqString = reqStrMainResourceStart + reqStrResourceEnd + reqStrActionStart
+ + reqStrContentMdRecordSimpson + reqStrActionEnd + reqStrMainEnd;
tFile = File.createTempFile("functionJunit", "request");
bw = new BufferedWriter(new FileWriter(tFile));
bw.append(reqString);
@@ -327,17 +297,15 @@ public class FunctionDefinitionAccessPermittedTest {
requestContentInAction = DOMRequest.load(tFile);
tFile.delete();
-
-
// Test that Bad XML is caught
@SuppressWarnings("unused")
Request requestContentMisplaced = null;
@SuppressWarnings("unused")
Request requestMalformedContent = null;
-
// Bad XML - Content not under a Category
- reqString = reqStrMainStart + reqStrContentMdRecordSimpson + reqStrResourceStart + reqStrResourceEnd + reqStrActionStart + reqStrActionEnd + reqStrMainEnd;
+ reqString = reqStrMainStart + reqStrContentMdRecordSimpson + reqStrResourceStart
+ + reqStrResourceEnd + reqStrActionStart + reqStrActionEnd + reqStrMainEnd;
tFile = File.createTempFile("functionJunit", "request");
bw = new BufferedWriter(new FileWriter(tFile));
bw.append(reqString);
@@ -349,7 +317,7 @@ public class FunctionDefinitionAccessPermittedTest {
} catch (com.att.research.xacml.std.dom.DOMStructureException e) {
// this is what it should do, so just continue
} catch (Exception e) {
- fail("Unexpected exception for bad XML, e="+e);
+ fail("Unexpected exception for bad XML, e=" + e);
}
// Bad XML - Content is not valid XML
@@ -365,21 +333,15 @@ public class FunctionDefinitionAccessPermittedTest {
} catch (com.att.research.xacml.std.dom.DOMStructureException e) {
// this is what it should do, so just continue
} catch (Exception e) {
- fail("Unexpected exception for bad XML, e="+e);
+ fail("Unexpected exception for bad XML, e=" + e);
}
} catch (Exception e) {
- fail("Constructor initializing variables, e="+ e + " cause="+e.getCause());
+ fail("Constructor initializing variables, e=" + e + " cause=" + e.getCause());
}
}
-
-
-
-
-
-
@Ignore
@Test
public void testAccess_permitted() {
@@ -387,17 +349,15 @@ public class FunctionDefinitionAccessPermittedTest {
ExpressionResult res = null;
Boolean resValue = null;
- FunctionDefinitionAccessPermitted fd = (FunctionDefinitionAccessPermitted) StdFunctions.FD_ACCESS_PERMITTED;
+ FunctionDefinitionAccessPermitted fd = (FunctionDefinitionAccessPermitted)StdFunctions.FD_ACCESS_PERMITTED;
// check identity and type of the thing created
assertEquals(XACML3.ID_FUNCTION_ACCESS_PERMITTED, fd.getId());
assertEquals(DataTypes.DT_BOOLEAN.getId(), fd.getDataTypeId());
- // just to be safe... If tests take too long these can probably be eliminated
+ // just to be safe... If tests take too long these can probably be eliminated
assertFalse(fd.returnsBag());
-
-
// successful invoke returns true
arguments.clear();
arguments.add(attrUriResources);
@@ -407,11 +367,8 @@ public class FunctionDefinitionAccessPermittedTest {
resValue = (Boolean)res.getValue().getValue();
assertTrue(resValue);
-
-
// successful invoke returns false
-
// URI not in Request (ok - evaluate anyway)
// test for infinite loop
@@ -439,8 +396,10 @@ public class FunctionDefinitionAccessPermittedTest {
arguments.add(attrXBadXML);
res = fd.evaluate(null, arguments);
assertFalse(res.getStatus().isOk());
- assertEquals( "function:access-permitted Parsing of XML string failed. Cause='The element type \"md:hospital_info\" must be terminated by the matching end-tag \"</md:hospital_info>\".'", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:syntax-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
+ assertEquals("function:access-permitted Parsing of XML string failed. Cause='The element type \"md:hospital_info\" must be terminated by the matching end-tag \"</md:hospital_info>\".'",
+ res.getStatus().getStatusMessage());
+ assertEquals("urn:oasis:names:tc:xacml:1.0:status:syntax-error", res.getStatus().getStatusCode()
+ .getStatusCodeValue().stringValue());
// null Evaluation Context
arguments.clear();
@@ -448,8 +407,10 @@ public class FunctionDefinitionAccessPermittedTest {
arguments.add(attrXContentSimpson);
res = fd.evaluate(null, arguments);
assertFalse(res.getStatus().isOk());
- assertEquals( "function:access-permitted First argument must be a urn for an attribute-category, not 'urn:oasis:names:tc:xacml:1.0:resource:resource-id", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:syntax-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
+ assertEquals("function:access-permitted First argument must be a urn for an attribute-category, not 'urn:oasis:names:tc:xacml:1.0:resource:resource-id",
+ res.getStatus().getStatusMessage());
+ assertEquals("urn:oasis:names:tc:xacml:1.0:status:syntax-error", res.getStatus().getStatusCode()
+ .getStatusCodeValue().stringValue());
// null Request
arguments.clear();
@@ -457,9 +418,10 @@ public class FunctionDefinitionAccessPermittedTest {
arguments.add(attrXContentSimpson);
res = fd.evaluate(new StdEvaluationContext(null, null, null), arguments);
assertFalse(res.getStatus().isOk());
- assertEquals( "function:access-permitted Got null Request in EvaluationContext", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
-
+ assertEquals("function:access-permitted Got null Request in EvaluationContext", res.getStatus()
+ .getStatusMessage());
+ assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode()
+ .getStatusCodeValue().stringValue());
// first arg not uri
arguments.clear();
@@ -467,8 +429,10 @@ public class FunctionDefinitionAccessPermittedTest {
arguments.add(attrXContentSimpson);
res = fd.evaluate(new StdEvaluationContext(requestMdRecord, null, null), arguments);
assertFalse(res.getStatus().isOk());
- assertEquals( "function:access-permitted First argument must be a urn for an attribute-category, not 'urn:oasis:names:tc:xacml:1.0:resource:resource-id", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:syntax-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
+ assertEquals("function:access-permitted First argument must be a urn for an attribute-category, not 'urn:oasis:names:tc:xacml:1.0:resource:resource-id",
+ res.getStatus().getStatusMessage());
+ assertEquals("urn:oasis:names:tc:xacml:1.0:status:syntax-error", res.getStatus().getStatusCode()
+ .getStatusCodeValue().stringValue());
// first arg not attribute-category urn
arguments.clear();
@@ -476,8 +440,10 @@ public class FunctionDefinitionAccessPermittedTest {
arguments.add(attrXContentSimpson);
res = fd.evaluate(new StdEvaluationContext(requestMdRecord, null, null), arguments);
assertFalse(res.getStatus().isOk());
- assertEquals( "function:access-permitted Expected data type 'anyURI' saw 'string'", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
+ assertEquals("function:access-permitted Expected data type 'anyURI' saw 'string'", res.getStatus()
+ .getStatusMessage());
+ assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode()
+ .getStatusCodeValue().stringValue());
// second arg not string
arguments.clear();
@@ -485,24 +451,28 @@ public class FunctionDefinitionAccessPermittedTest {
arguments.add(attrUriAction);
res = fd.evaluate(new StdEvaluationContext(requestMdRecord, null, null), arguments);
assertFalse(res.getStatus().isOk());
- assertEquals( "function:access-permitted Expected data type 'string' saw 'anyURI'", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
-
+ assertEquals("function:access-permitted Expected data type 'string' saw 'anyURI'", res.getStatus()
+ .getStatusMessage());
+ assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode()
+ .getStatusCodeValue().stringValue());
// too few args
arguments.clear();
res = fd.evaluate(new StdEvaluationContext(requestMdRecord, null, null), arguments);
assertFalse(res.getStatus().isOk());
- assertEquals( "function:access-permitted Expected 2 arguments, got 0", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
+ assertEquals("function:access-permitted Expected 2 arguments, got 0", res.getStatus()
+ .getStatusMessage());
+ assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode()
+ .getStatusCodeValue().stringValue());
arguments.clear();
arguments.add(attrXContentSimpson);
res = fd.evaluate(new StdEvaluationContext(requestMdRecord, null, null), arguments);
assertFalse(res.getStatus().isOk());
- assertEquals( "function:access-permitted Expected 2 arguments, got 1", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
-
+ assertEquals("function:access-permitted Expected 2 arguments, got 1", res.getStatus()
+ .getStatusMessage());
+ assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode()
+ .getStatusCodeValue().stringValue());
// too many args
arguments.clear();
@@ -511,9 +481,10 @@ public class FunctionDefinitionAccessPermittedTest {
arguments.add(attrXContentSimpson);
res = fd.evaluate(new StdEvaluationContext(requestMdRecord, null, null), arguments);
assertFalse(res.getStatus().isOk());
- assertEquals( "function:access-permitted Expected 2 arguments, got 3", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
-
+ assertEquals("function:access-permitted Expected 2 arguments, got 3", res.getStatus()
+ .getStatusMessage());
+ assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode()
+ .getStatusCodeValue().stringValue());
}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/38b6d318/openaz-xacml-test/src/test/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionArithmeticTest.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-test/src/test/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionArithmeticTest.java b/openaz-xacml-test/src/test/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionArithmeticTest.java
index 876da98..b10ce40 100644
--- a/openaz-xacml-test/src/test/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionArithmeticTest.java
+++ b/openaz-xacml-test/src/test/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionArithmeticTest.java
@@ -43,18 +43,10 @@ import org.junit.Test;
import com.att.research.xacml.api.XACML3;
import com.att.research.xacml.std.datatypes.DataTypes;
-import com.att.research.xacmlatt.pdp.policy.ExpressionResult;
-import com.att.research.xacmlatt.pdp.policy.FunctionArgument;
-import com.att.research.xacmlatt.pdp.policy.FunctionArgumentAttributeValue;
-import com.att.research.xacmlatt.pdp.std.StdFunctions;
/**
- * Test of PDP Functions (See XACML core spec section A.3)
- *
- * TO RUN - use jUnit
- * In Eclipse select this file or the enclosing directory, right-click and select Run As/JUnit Test
- *
- *
+ * Test of PDP Functions (See XACML core spec section A.3) TO RUN - use jUnit In Eclipse select this file or
+ * the enclosing directory, right-click and select Run As/JUnit Test
*/
public class FunctionDefinitionArithmeticTest {
@@ -74,21 +66,20 @@ public class FunctionDefinitionArithmeticTest {
attr2 = new FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(1));
attrBadType = new FunctionArgumentAttributeValue(DataTypes.DT_DOUBLE.createAttributeValue(1.1));
} catch (Exception e) {
- fail("creating attributes e="+ e);
+ fail("creating attributes e=" + e);
}
- FunctionDefinitionArithmetic<?> fd = (FunctionDefinitionArithmetic<?>) StdFunctions.FD_INTEGER_ADD;
+ FunctionDefinitionArithmetic<?> fd = (FunctionDefinitionArithmetic<?>)StdFunctions.FD_INTEGER_ADD;
// check identity and type of the thing created
assertEquals(XACML3.ID_FUNCTION_INTEGER_ADD, fd.getId());
assertEquals(DataTypes.DT_INTEGER.getId(), fd.getDataTypeArgs().getId());
assertEquals(DataTypes.DT_INTEGER.getId(), fd.getDataTypeId());
- // just to be safe... If tests take too long these can probably be eliminated
+ // just to be safe... If tests take too long these can probably be eliminated
assertFalse(fd.returnsBag());
assertEquals(new Integer(2), fd.getNumArgs());
-
// test normal add
arguments.add(attr1);
arguments.add(attr2);
@@ -102,37 +93,37 @@ public class FunctionDefinitionArithmeticTest {
arguments.add(attrBadType);
res = fd.evaluate(null, arguments);
assertFalse(res.isOk());
- assertEquals("function:integer-add Expected data type 'integer' saw 'double' at arg index 1", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
+ assertEquals("function:integer-add Expected data type 'integer' saw 'double' at arg index 1", res
+ .getStatus().getStatusMessage());
+ assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode()
+ .getStatusCodeValue().stringValue());
}
-
@Test
public void testDouble_add() {
FunctionArgumentAttributeValue attr1 = null;
- FunctionArgumentAttributeValue attr2 = null;
+ FunctionArgumentAttributeValue attr2 = null;
try {
attr1 = new FunctionArgumentAttributeValue(DataTypes.DT_DOUBLE.createAttributeValue(1.5));
attr2 = new FunctionArgumentAttributeValue(DataTypes.DT_DOUBLE.createAttributeValue(2.5));
} catch (Exception e) {
- fail("creating attributes e="+e);
+ fail("creating attributes e=" + e);
}
- FunctionDefinitionArithmetic<?> fd = (FunctionDefinitionArithmetic<?>) StdFunctions.FD_DOUBLE_ADD;
+ FunctionDefinitionArithmetic<?> fd = (FunctionDefinitionArithmetic<?>)StdFunctions.FD_DOUBLE_ADD;
// check identity and type of the thing created
assertEquals(XACML3.ID_FUNCTION_DOUBLE_ADD, fd.getId());
assertEquals(DataTypes.DT_DOUBLE.getId(), fd.getDataTypeArgs().getId());
assertEquals(DataTypes.DT_DOUBLE.getId(), fd.getDataTypeId());
- // just to be safe... If tests take too long these can probably be eliminated
+ // just to be safe... If tests take too long these can probably be eliminated
assertFalse(fd.returnsBag());
assertEquals(new Integer(2), fd.getNumArgs());
-
// test normal add
arguments.add(attr1);
arguments.add(attr2);
@@ -143,7 +134,6 @@ public class FunctionDefinitionArithmeticTest {
}
-
@Test
public void testInteger_subtract() {
@@ -153,21 +143,20 @@ public class FunctionDefinitionArithmeticTest {
attr1 = new FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(6));
attr2 = new FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(1));
} catch (Exception e) {
- fail("creating attributes e="+ e);
+ fail("creating attributes e=" + e);
}
- FunctionDefinitionArithmetic<?> fd = (FunctionDefinitionArithmetic<?>) StdFunctions.FD_INTEGER_SUBTRACT;
+ FunctionDefinitionArithmetic<?> fd = (FunctionDefinitionArithmetic<?>)StdFunctions.FD_INTEGER_SUBTRACT;
// check identity and type of the thing created
assertEquals(XACML3.ID_FUNCTION_INTEGER_SUBTRACT, fd.getId());
assertEquals(DataTypes.DT_INTEGER.getId(), fd.getDataTypeArgs().getId());
assertEquals(DataTypes.DT_INTEGER.getId(), fd.getDataTypeId());
- // just to be safe... If tests take too long these can probably be eliminated
+ // just to be safe... If tests take too long these can probably be eliminated
assertFalse(fd.returnsBag());
assertEquals(new Integer(2), fd.getNumArgs());
-
// test normal
arguments.add(attr1);
arguments.add(attr2);
@@ -178,32 +167,30 @@ public class FunctionDefinitionArithmeticTest {
}
-
@Test
public void testDouble_subtract() {
FunctionArgumentAttributeValue attr1 = null;
- FunctionArgumentAttributeValue attr2 = null;
+ FunctionArgumentAttributeValue attr2 = null;
try {
attr1 = new FunctionArgumentAttributeValue(DataTypes.DT_DOUBLE.createAttributeValue(8.5));
attr2 = new FunctionArgumentAttributeValue(DataTypes.DT_DOUBLE.createAttributeValue(2.3));
} catch (Exception e) {
- fail("creating attributes e="+e);
+ fail("creating attributes e=" + e);
}
- FunctionDefinitionArithmetic<?> fd = (FunctionDefinitionArithmetic<?>) StdFunctions.FD_DOUBLE_SUBTRACT;
+ FunctionDefinitionArithmetic<?> fd = (FunctionDefinitionArithmetic<?>)StdFunctions.FD_DOUBLE_SUBTRACT;
// check identity and type of the thing created
assertEquals(XACML3.ID_FUNCTION_DOUBLE_SUBTRACT, fd.getId());
assertEquals(DataTypes.DT_DOUBLE.getId(), fd.getDataTypeArgs().getId());
assertEquals(DataTypes.DT_DOUBLE.getId(), fd.getDataTypeId());
- // just to be safe... If tests take too long these can probably be eliminated
+ // just to be safe... If tests take too long these can probably be eliminated
assertFalse(fd.returnsBag());
assertEquals(new Integer(2), fd.getNumArgs());
-
// test normal
arguments.add(attr1);
arguments.add(attr2);
@@ -214,7 +201,6 @@ public class FunctionDefinitionArithmeticTest {
}
-
@Test
public void testInteger_multiply() {
@@ -226,21 +212,20 @@ public class FunctionDefinitionArithmeticTest {
attr1 = new FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(5));
attr2 = new FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(2));
} catch (Exception e) {
- fail("creating attributes e="+ e);
+ fail("creating attributes e=" + e);
}
- FunctionDefinitionArithmetic<?> fd = (FunctionDefinitionArithmetic<?>) StdFunctions.FD_INTEGER_MULTIPLY;
+ FunctionDefinitionArithmetic<?> fd = (FunctionDefinitionArithmetic<?>)StdFunctions.FD_INTEGER_MULTIPLY;
// check identity and type of the thing created
assertEquals(XACML3.ID_FUNCTION_INTEGER_MULTIPLY, fd.getId());
assertEquals(DataTypes.DT_INTEGER.getId(), fd.getDataTypeArgs().getId());
assertEquals(DataTypes.DT_INTEGER.getId(), fd.getDataTypeId());
- // just to be safe... If tests take too long these can probably be eliminated
+ // just to be safe... If tests take too long these can probably be eliminated
assertFalse(fd.returnsBag());
assertEquals(new Integer(2), fd.getNumArgs());
-
// test normal
arguments.add(attr1);
arguments.add(attr2);
@@ -249,7 +234,6 @@ public class FunctionDefinitionArithmeticTest {
BigInteger resValue = (BigInteger)res.getValue().getValue();
assertEquals(new BigInteger("10"), resValue);
-
// test 0
arguments.clear();
arguments.add(attr1);
@@ -260,34 +244,32 @@ public class FunctionDefinitionArithmeticTest {
assertEquals(new BigInteger("0"), resValue);
}
-
@Test
public void testDouble_multiply() {
FunctionArgumentAttributeValue attr0 = null;
FunctionArgumentAttributeValue attr1 = null;
- FunctionArgumentAttributeValue attr2 = null;
+ FunctionArgumentAttributeValue attr2 = null;
try {
attr0 = new FunctionArgumentAttributeValue(DataTypes.DT_DOUBLE.createAttributeValue(0));
attr1 = new FunctionArgumentAttributeValue(DataTypes.DT_DOUBLE.createAttributeValue(1.5));
attr2 = new FunctionArgumentAttributeValue(DataTypes.DT_DOUBLE.createAttributeValue(2.5));
} catch (Exception e) {
- fail("creating attributes e="+e);
+ fail("creating attributes e=" + e);
}
- FunctionDefinitionArithmetic<?> fd = (FunctionDefinitionArithmetic<?>) StdFunctions.FD_DOUBLE_MULTIPLY;
+ FunctionDefinitionArithmetic<?> fd = (FunctionDefinitionArithmetic<?>)StdFunctions.FD_DOUBLE_MULTIPLY;
// check identity and type of the thing created
assertEquals(XACML3.ID_FUNCTION_DOUBLE_MULTIPLY, fd.getId());
assertEquals(DataTypes.DT_DOUBLE.getId(), fd.getDataTypeArgs().getId());
assertEquals(DataTypes.DT_DOUBLE.getId(), fd.getDataTypeId());
- // just to be safe... If tests take too long these can probably be eliminated
+ // just to be safe... If tests take too long these can probably be eliminated
assertFalse(fd.returnsBag());
assertEquals(new Integer(2), fd.getNumArgs());
-
// test normal add
arguments.add(attr1);
arguments.add(attr2);
@@ -306,7 +288,6 @@ public class FunctionDefinitionArithmeticTest {
assertEquals(new Double(0), resValue);
}
-
@Test
public void testInteger_divide() {
@@ -318,21 +299,20 @@ public class FunctionDefinitionArithmeticTest {
attr1 = new FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(5));
attr2 = new FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(2));
} catch (Exception e) {
- fail("creating attributes e="+ e);
+ fail("creating attributes e=" + e);
}
- FunctionDefinitionArithmetic<?> fd = (FunctionDefinitionArithmetic<?>) StdFunctions.FD_INTEGER_DIVIDE;
+ FunctionDefinitionArithmetic<?> fd = (FunctionDefinitionArithmetic<?>)StdFunctions.FD_INTEGER_DIVIDE;
// check identity and type of the thing created
assertEquals(XACML3.ID_FUNCTION_INTEGER_DIVIDE, fd.getId());
assertEquals(DataTypes.DT_INTEGER.getId(), fd.getDataTypeArgs().getId());
assertEquals(DataTypes.DT_INTEGER.getId(), fd.getDataTypeId());
- // just to be safe... If tests take too long these can probably be eliminated
+ // just to be safe... If tests take too long these can probably be eliminated
assertFalse(fd.returnsBag());
assertEquals(new Integer(2), fd.getNumArgs());
-
// test normal
arguments.add(attr1);
arguments.add(attr2);
@@ -341,7 +321,6 @@ public class FunctionDefinitionArithmeticTest {
BigInteger resValue = (BigInteger)res.getValue().getValue();
assertEquals(new BigInteger("2"), resValue);
-
// test 0
arguments.clear();
arguments.add(attr1);
@@ -349,17 +328,17 @@ public class FunctionDefinitionArithmeticTest {
res = fd.evaluate(null, arguments);
assertFalse(res.isOk());
assertEquals("function:integer-divide Divide by 0 error: 5, 0", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
+ assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode()
+ .getStatusCodeValue().stringValue());
}
-
@Test
public void testDouble_divide() {
FunctionArgumentAttributeValue attr0 = null;
FunctionArgumentAttributeValue attr1 = null;
- FunctionArgumentAttributeValue attr2 = null;
+ FunctionArgumentAttributeValue attr2 = null;
try {
attr0 = new FunctionArgumentAttributeValue(DataTypes.DT_DOUBLE.createAttributeValue(0));
@@ -367,20 +346,19 @@ public class FunctionDefinitionArithmeticTest {
attr2 = new FunctionArgumentAttributeValue(DataTypes.DT_DOUBLE.createAttributeValue(2.5));
} catch (Exception e) {
- fail("creating attributes e="+e);
+ fail("creating attributes e=" + e);
}
- FunctionDefinitionArithmetic<?> fd = (FunctionDefinitionArithmetic<?>) StdFunctions.FD_DOUBLE_DIVIDE;
+ FunctionDefinitionArithmetic<?> fd = (FunctionDefinitionArithmetic<?>)StdFunctions.FD_DOUBLE_DIVIDE;
// check identity and type of the thing created
assertEquals(XACML3.ID_FUNCTION_DOUBLE_DIVIDE, fd.getId());
assertEquals(DataTypes.DT_DOUBLE.getId(), fd.getDataTypeArgs().getId());
assertEquals(DataTypes.DT_DOUBLE.getId(), fd.getDataTypeId());
- // just to be safe... If tests take too long these can probably be eliminated
+ // just to be safe... If tests take too long these can probably be eliminated
assertFalse(fd.returnsBag());
assertEquals(new Integer(2), fd.getNumArgs());
-
// test normal
arguments.add(attr1);
arguments.add(attr2);
@@ -396,15 +374,11 @@ public class FunctionDefinitionArithmeticTest {
res = fd.evaluate(null, arguments);
assertFalse(res.isOk());
assertEquals("function:double-divide Divide by 0 error: 1.5, 0.0", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
+ assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode()
+ .getStatusCodeValue().stringValue());
}
-
-
-
-
-
@Test
public void testInteger_mod() {
@@ -416,21 +390,20 @@ public class FunctionDefinitionArithmeticTest {
attr1 = new FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(28));
attr2 = new FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(5));
} catch (Exception e) {
- fail("creating attributes e="+ e);
+ fail("creating attributes e=" + e);
}
- FunctionDefinitionArithmetic<?> fd = (FunctionDefinitionArithmetic<?>) StdFunctions.FD_INTEGER_MOD;
+ FunctionDefinitionArithmetic<?> fd = (FunctionDefinitionArithmetic<?>)StdFunctions.FD_INTEGER_MOD;
// check identity and type of the thing created
assertEquals(XACML3.ID_FUNCTION_INTEGER_MOD, fd.getId());
assertEquals(DataTypes.DT_INTEGER.getId(), fd.getDataTypeArgs().getId());
assertEquals(DataTypes.DT_INTEGER.getId(), fd.getDataTypeId());
- // just to be safe... If tests take too long these can probably be eliminated
+ // just to be safe... If tests take too long these can probably be eliminated
assertFalse(fd.returnsBag());
assertEquals(new Integer(2), fd.getNumArgs());
-
// test normal
arguments.add(attr1);
arguments.add(attr2);
@@ -439,7 +412,6 @@ public class FunctionDefinitionArithmeticTest {
BigInteger resValue = (BigInteger)res.getValue().getValue();
assertEquals(new BigInteger("3"), resValue);
-
// test 0
arguments.clear();
arguments.add(attr1);
@@ -447,11 +419,11 @@ public class FunctionDefinitionArithmeticTest {
res = fd.evaluate(null, arguments);
assertFalse(res.isOk());
assertEquals("function:integer-mod Divide by 0 error: 28, 0", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
+ assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode()
+ .getStatusCodeValue().stringValue());
}
-
@Test
public void testInteger_abs() {
@@ -463,21 +435,20 @@ public class FunctionDefinitionArithmeticTest {
attr1 = new FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(5));
attrM1 = new FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(-7));
} catch (Exception e) {
- fail("creating attributes e="+ e);
+ fail("creating attributes e=" + e);
}
- FunctionDefinitionArithmetic<?> fd = (FunctionDefinitionArithmetic<?>) StdFunctions.FD_INTEGER_ABS;
+ FunctionDefinitionArithmetic<?> fd = (FunctionDefinitionArithmetic<?>)StdFunctions.FD_INTEGER_ABS;
// check identity and type of the thing created
assertEquals(XACML3.ID_FUNCTION_INTEGER_ABS, fd.getId());
assertEquals(DataTypes.DT_INTEGER.getId(), fd.getDataTypeArgs().getId());
assertEquals(DataTypes.DT_INTEGER.getId(), fd.getDataTypeId());
- // just to be safe... If tests take too long these can probably be eliminated
+ // just to be safe... If tests take too long these can probably be eliminated
assertFalse(fd.returnsBag());
assertEquals(new Integer(1), fd.getNumArgs());
-
// test normal
arguments.add(attr1);
ExpressionResult res = fd.evaluate(null, arguments);
@@ -500,13 +471,12 @@ public class FunctionDefinitionArithmeticTest {
assertEquals(new BigInteger("0"), resValue);
}
-
@Test
public void testDouble_abs() {
FunctionArgumentAttributeValue attr0 = null;
FunctionArgumentAttributeValue attr1 = null;
- FunctionArgumentAttributeValue attr2 = null;
+ FunctionArgumentAttributeValue attr2 = null;
try {
attr0 = new FunctionArgumentAttributeValue(DataTypes.DT_DOUBLE.createAttributeValue(0));
@@ -514,21 +484,20 @@ public class FunctionDefinitionArithmeticTest {
attr2 = new FunctionArgumentAttributeValue(DataTypes.DT_DOUBLE.createAttributeValue(-2.5));
} catch (Exception e) {
- fail("creating attributes e="+e);
+ fail("creating attributes e=" + e);
}
- FunctionDefinitionArithmetic<?> fd = (FunctionDefinitionArithmetic<?>) StdFunctions.FD_DOUBLE_ABS;
+ FunctionDefinitionArithmetic<?> fd = (FunctionDefinitionArithmetic<?>)StdFunctions.FD_DOUBLE_ABS;
// check identity and type of the thing created
assertEquals(XACML3.ID_FUNCTION_DOUBLE_ABS, fd.getId());
assertEquals(DataTypes.DT_DOUBLE.getId(), fd.getDataTypeArgs().getId());
assertEquals(DataTypes.DT_DOUBLE.getId(), fd.getDataTypeId());
- // just to be safe... If tests take too long these can probably be eliminated
+ // just to be safe... If tests take too long these can probably be eliminated
assertFalse(fd.returnsBag());
assertEquals(new Integer(1), fd.getNumArgs());
-
// test normal
arguments.add(attr1);
ExpressionResult res = fd.evaluate(null, arguments);
@@ -552,13 +521,12 @@ public class FunctionDefinitionArithmeticTest {
}
-
@Test
public void testDouble_round() {
FunctionArgumentAttributeValue attr0 = null;
FunctionArgumentAttributeValue attr1 = null;
- FunctionArgumentAttributeValue attr2 = null;
+ FunctionArgumentAttributeValue attr2 = null;
FunctionArgumentAttributeValue attr3 = null;
FunctionArgumentAttributeValue attr4 = null;
FunctionArgumentAttributeValue attr5 = null;
@@ -572,23 +540,20 @@ public class FunctionDefinitionArithmeticTest {
attr5 = new FunctionArgumentAttributeValue(DataTypes.DT_DOUBLE.createAttributeValue(-2.49));
attr6 = new FunctionArgumentAttributeValue(DataTypes.DT_DOUBLE.createAttributeValue(-2.51));
} catch (Exception e) {
- fail("creating attributes e="+e);
+ fail("creating attributes e=" + e);
}
-
-
- FunctionDefinitionArithmetic<?> fd = (FunctionDefinitionArithmetic<?>) StdFunctions.FD_ROUND;
+ FunctionDefinitionArithmetic<?> fd = (FunctionDefinitionArithmetic<?>)StdFunctions.FD_ROUND;
// check identity and type of the thing created
assertEquals(XACML3.ID_FUNCTION_ROUND, fd.getId());
assertEquals(DataTypes.DT_DOUBLE.getId(), fd.getDataTypeArgs().getId());
assertEquals(DataTypes.DT_DOUBLE.getId(), fd.getDataTypeId());
- // just to be safe... If tests take too long these can probably be eliminated
+ // just to be safe... If tests take too long these can probably be eliminated
assertFalse(fd.returnsBag());
assertEquals(new Integer(1), fd.getNumArgs());
-
// test normal
arguments.add(attr0);
ExpressionResult res = fd.evaluate(null, arguments);
@@ -639,12 +604,11 @@ public class FunctionDefinitionArithmeticTest {
assertEquals(new Double(-3), resValue);
}
-
@Test
public void testDouble_floor() {
FunctionArgumentAttributeValue attr0 = null;
FunctionArgumentAttributeValue attr1 = null;
- FunctionArgumentAttributeValue attr2 = null;
+ FunctionArgumentAttributeValue attr2 = null;
FunctionArgumentAttributeValue attr3 = null;
FunctionArgumentAttributeValue attr4 = null;
FunctionArgumentAttributeValue attr5 = null;
@@ -658,21 +622,20 @@ public class FunctionDefinitionArithmeticTest {
attr5 = new FunctionArgumentAttributeValue(DataTypes.DT_DOUBLE.createAttributeValue(-2.49));
attr6 = new FunctionArgumentAttributeValue(DataTypes.DT_DOUBLE.createAttributeValue(-2.51));
} catch (Exception e) {
- fail("creating attributes e="+e);
+ fail("creating attributes e=" + e);
}
- FunctionDefinitionArithmetic<?> fd = (FunctionDefinitionArithmetic<?>) StdFunctions.FD_FLOOR;
+ FunctionDefinitionArithmetic<?> fd = (FunctionDefinitionArithmetic<?>)StdFunctions.FD_FLOOR;
// check identity and type of the thing created
assertEquals(XACML3.ID_FUNCTION_FLOOR, fd.getId());
assertEquals(DataTypes.DT_DOUBLE.getId(), fd.getDataTypeArgs().getId());
assertEquals(DataTypes.DT_DOUBLE.getId(), fd.getDataTypeId());
- // just to be safe... If tests take too long these can probably be eliminated
+ // just to be safe... If tests take too long these can probably be eliminated
assertFalse(fd.returnsBag());
assertEquals(new Integer(1), fd.getNumArgs());
-
// test normal
arguments.add(attr0);
ExpressionResult res = fd.evaluate(null, arguments);
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/38b6d318/openaz-xacml-test/src/test/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionBagIsInTest.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-test/src/test/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionBagIsInTest.java b/openaz-xacml-test/src/test/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionBagIsInTest.java
index a300985..f9e35b7 100644
--- a/openaz-xacml-test/src/test/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionBagIsInTest.java
+++ b/openaz-xacml-test/src/test/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionBagIsInTest.java
@@ -33,30 +33,18 @@ import org.junit.Test;
import com.att.research.xacml.api.XACML3;
import com.att.research.xacml.std.StdAttributeValue;
import com.att.research.xacml.std.datatypes.DataTypes;
-import com.att.research.xacmlatt.pdp.policy.Bag;
-import com.att.research.xacmlatt.pdp.policy.ExpressionResult;
-import com.att.research.xacmlatt.pdp.policy.FunctionArgument;
-import com.att.research.xacmlatt.pdp.policy.FunctionArgumentAttributeValue;
-import com.att.research.xacmlatt.pdp.policy.FunctionArgumentBag;
-import com.att.research.xacmlatt.pdp.std.StdFunctions;
/**
- * Test of PDP Functions (See XACML core spec section A.3)
- *
- * TO RUN - use jUnit
- * In Eclipse select this file or the enclosing directory, right-click and select Run As/JUnit Test
- *
- *
+ * Test of PDP Functions (See XACML core spec section A.3) TO RUN - use jUnit In Eclipse select this file or
+ * the enclosing directory, right-click and select Run As/JUnit Test
*/
public class FunctionDefinitionBagIsInTest {
-
/*
* variables useful in the following tests
*/
List<FunctionArgument> arguments = new ArrayList<FunctionArgument>();
-
@Test
public void testString() {
String v1 = new String("abc");
@@ -65,7 +53,6 @@ public class FunctionDefinitionBagIsInTest {
String sameValueV1 = new String("abc");
Integer vOtherType = new Integer(11);
-
FunctionArgumentAttributeValue attrV1 = null;
FunctionArgumentAttributeValue attrV2 = null;
FunctionArgumentAttributeValue attrNotInBag = null;
@@ -74,11 +61,17 @@ public class FunctionDefinitionBagIsInTest {
try {
attrV1 = new FunctionArgumentAttributeValue(DataTypes.DT_STRING.createAttributeValue(v1));
attrV2 = new FunctionArgumentAttributeValue(DataTypes.DT_STRING.createAttributeValue(v2));
- attrNotInBag = new FunctionArgumentAttributeValue(DataTypes.DT_STRING.createAttributeValue(notInBag));
- attrSameValueV1 = new FunctionArgumentAttributeValue(DataTypes.DT_STRING.createAttributeValue(sameValueV1));
- attrOtherType = new FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(vOtherType));
+ attrNotInBag = new FunctionArgumentAttributeValue(
+ DataTypes.DT_STRING
+ .createAttributeValue(notInBag));
+ attrSameValueV1 = new FunctionArgumentAttributeValue(
+ DataTypes.DT_STRING
+ .createAttributeValue(sameValueV1));
+ attrOtherType = new FunctionArgumentAttributeValue(
+ DataTypes.DT_INTEGER
+ .createAttributeValue(vOtherType));
} catch (Exception e) {
- fail("creating attributes e="+ e);
+ fail("creating attributes e=" + e);
}
Bag bag0 = new Bag();
@@ -86,26 +79,22 @@ public class FunctionDefinitionBagIsInTest {
bag1.add(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), v1));
Bag bag2 = new Bag();
bag2.add(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), v1));
- bag2.add(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), v2));;
-
-
+ bag2.add(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), v2));
+ ;
FunctionArgumentBag attrBag0 = new FunctionArgumentBag(bag0);
FunctionArgumentBag attrBag1 = new FunctionArgumentBag(bag1);
FunctionArgumentBag attrBag2 = new FunctionArgumentBag(bag2);
-
-
- FunctionDefinitionBagIsIn<?> fd = (FunctionDefinitionBagIsIn<?>) StdFunctions.FD_STRING_IS_IN;
+ FunctionDefinitionBagIsIn<?> fd = (FunctionDefinitionBagIsIn<?>)StdFunctions.FD_STRING_IS_IN;
// check identity and type of the thing created
assertEquals(XACML3.ID_FUNCTION_STRING_IS_IN, fd.getId());
assertEquals(DataTypes.DT_BOOLEAN.getId(), fd.getDataTypeId());
- // just to be safe... If tests take too long these can probably be eliminated
+ // just to be safe... If tests take too long these can probably be eliminated
assertFalse(fd.returnsBag());
-
// element is in bag
arguments.clear();
arguments.add(attrV1);
@@ -152,7 +141,8 @@ public class FunctionDefinitionBagIsInTest {
res = fd.evaluate(null, arguments);
assertFalse(res.isOk());
assertEquals("function:string-is-in Expected 2 arguments, got 1", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
+ assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode()
+ .getStatusCodeValue().stringValue());
// 1st arg is bag
arguments.clear();
@@ -160,8 +150,10 @@ public class FunctionDefinitionBagIsInTest {
arguments.add(attrBag2);
res = fd.evaluate(null, arguments);
assertFalse(res.isOk());
- assertEquals("function:string-is-in Expected a simple value, saw a bag", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
+ assertEquals("function:string-is-in Expected a simple value, saw a bag", res.getStatus()
+ .getStatusMessage());
+ assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode()
+ .getStatusCodeValue().stringValue());
// 2nd arg not bag
arguments.clear();
@@ -169,8 +161,10 @@ public class FunctionDefinitionBagIsInTest {
arguments.add(attrV2);
res = fd.evaluate(null, arguments);
assertFalse(res.isOk());
- assertEquals("function:string-is-in Expected a bag, saw a simple value", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
+ assertEquals("function:string-is-in Expected a bag, saw a simple value", res.getStatus()
+ .getStatusMessage());
+ assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode()
+ .getStatusCodeValue().stringValue());
// first arg null
arguments.clear();
@@ -179,7 +173,8 @@ public class FunctionDefinitionBagIsInTest {
res = fd.evaluate(null, arguments);
assertFalse(res.isOk());
assertEquals("function:string-is-in Got null argument", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
+ assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode()
+ .getStatusCodeValue().stringValue());
// 2nd arg null
arguments.clear();
@@ -188,7 +183,8 @@ public class FunctionDefinitionBagIsInTest {
res = fd.evaluate(null, arguments);
assertFalse(res.isOk());
assertEquals("function:string-is-in Got null argument", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
+ assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode()
+ .getStatusCodeValue().stringValue());
// first arg type does not match bag elements
arguments.clear();
@@ -196,25 +192,21 @@ public class FunctionDefinitionBagIsInTest {
arguments.add(attrBag2);
res = fd.evaluate(null, arguments);
assertFalse(res.isOk());
- assertEquals("function:string-is-in Expected data type 'string' saw 'integer'", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
+ assertEquals("function:string-is-in Expected data type 'string' saw 'integer'", res.getStatus()
+ .getStatusMessage());
+ assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode()
+ .getStatusCodeValue().stringValue());
// bag has mixed element types
-// behavior not specified for this case in spec. It ASSUMES that all elements in bag are same type.
+ // behavior not specified for this case in spec. It ASSUMES that all elements in bag are same type.
}
-
-
-
//
//
- // REST OF DATA TYPES OMITTED
- // because they "should" all work the same
+ // REST OF DATA TYPES OMITTED
+ // because they "should" all work the same
//
//
-
-
-
}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/38b6d318/openaz-xacml-test/src/test/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionBagOneAndOnlyTest.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-test/src/test/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionBagOneAndOnlyTest.java b/openaz-xacml-test/src/test/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionBagOneAndOnlyTest.java
index d53ef43..02430af 100644
--- a/openaz-xacml-test/src/test/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionBagOneAndOnlyTest.java
+++ b/openaz-xacml-test/src/test/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionBagOneAndOnlyTest.java
@@ -33,29 +33,18 @@ import org.junit.Test;
import com.att.research.xacml.api.XACML3;
import com.att.research.xacml.std.StdAttributeValue;
import com.att.research.xacml.std.datatypes.DataTypes;
-import com.att.research.xacmlatt.pdp.policy.Bag;
-import com.att.research.xacmlatt.pdp.policy.ExpressionResult;
-import com.att.research.xacmlatt.pdp.policy.FunctionArgument;
-import com.att.research.xacmlatt.pdp.policy.FunctionArgumentBag;
-import com.att.research.xacmlatt.pdp.std.StdFunctions;
/**
- * Test of PDP Functions (See XACML core spec section A.3)
- *
- * TO RUN - use jUnit
- * In Eclipse select this file or the enclosing directory, right-click and select Run As/JUnit Test
- *
- *
+ * Test of PDP Functions (See XACML core spec section A.3) TO RUN - use jUnit In Eclipse select this file or
+ * the enclosing directory, right-click and select Run As/JUnit Test
*/
public class FunctionDefinitionBagOneAndOnlyTest {
-
/*
* variables useful in the following tests
*/
List<FunctionArgument> arguments = new ArrayList<FunctionArgument>();
-
@Test
public void testString() {
String v1 = new String("abc");
@@ -76,19 +65,15 @@ public class FunctionDefinitionBagOneAndOnlyTest {
FunctionArgumentBag attrBag2 = new FunctionArgumentBag(bag2);
FunctionArgumentBag attrBagOtherType = new FunctionArgumentBag(bagOtherType);
-
- FunctionDefinitionBagOneAndOnly<?> fd = (FunctionDefinitionBagOneAndOnly<?>) StdFunctions.FD_STRING_ONE_AND_ONLY;
+ FunctionDefinitionBagOneAndOnly<?> fd = (FunctionDefinitionBagOneAndOnly<?>)StdFunctions.FD_STRING_ONE_AND_ONLY;
// check identity and type of the thing created
assertEquals(XACML3.ID_FUNCTION_STRING_ONE_AND_ONLY, fd.getId());
assertEquals(DataTypes.DT_STRING.getId(), fd.getDataTypeId());
- // just to be safe... If tests take too long these can probably be eliminated
+ // just to be safe... If tests take too long these can probably be eliminated
assertFalse(fd.returnsBag());
-
-
-
// bag with only one
arguments.clear();
arguments.add(attrBag1);
@@ -104,35 +89,40 @@ public class FunctionDefinitionBagOneAndOnlyTest {
res = fd.evaluate(null, arguments);
assertFalse(res.isOk());
assertEquals("function:string-one-and-only Got null argument", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
+ assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode()
+ .getStatusCodeValue().stringValue());
// bag with exactly one but of other type in it
arguments.clear();
arguments.add(attrBagOtherType);
res = fd.evaluate(null, arguments);
assertFalse(res.isOk());
- assertEquals("function:string-one-and-only Element in bag of wrong type. Expected string got integer", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
+ assertEquals("function:string-one-and-only Element in bag of wrong type. Expected string got integer",
+ res.getStatus().getStatusMessage());
+ assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode()
+ .getStatusCodeValue().stringValue());
// bag with none
arguments.clear();
arguments.add(attrBag0);
res = fd.evaluate(null, arguments);
assertFalse(res.isOk());
- assertEquals("function:string-one-and-only Expected 1 but Bag has 0 elements", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
+ assertEquals("function:string-one-and-only Expected 1 but Bag has 0 elements", res.getStatus()
+ .getStatusMessage());
+ assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode()
+ .getStatusCodeValue().stringValue());
// bag with multiple
arguments.clear();
arguments.add(attrBag2);
res = fd.evaluate(null, arguments);
assertFalse(res.isOk());
- assertEquals("function:string-one-and-only Expected 1 but Bag has 2 elements", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
+ assertEquals("function:string-one-and-only Expected 1 but Bag has 2 elements", res.getStatus()
+ .getStatusMessage());
+ assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode()
+ .getStatusCodeValue().stringValue());
}
-
-
@Test
public void testBoolean() {
Boolean v1 = new Boolean(true);
@@ -148,25 +138,20 @@ public class FunctionDefinitionBagOneAndOnlyTest {
Bag bagOtherType = new Bag();
bagOtherType.add(new StdAttributeValue<BigInteger>(DataTypes.DT_STRING.getId(), vOtherType));
-
FunctionArgumentBag attrBag0 = new FunctionArgumentBag(bag0);
FunctionArgumentBag attrBag1 = new FunctionArgumentBag(bag1);
FunctionArgumentBag attrBag2 = new FunctionArgumentBag(bag2);
FunctionArgumentBag attrBagOtherType = new FunctionArgumentBag(bagOtherType);
-
- FunctionDefinitionBagOneAndOnly<?> fd = (FunctionDefinitionBagOneAndOnly<?>) StdFunctions.FD_BOOLEAN_ONE_AND_ONLY;
+ FunctionDefinitionBagOneAndOnly<?> fd = (FunctionDefinitionBagOneAndOnly<?>)StdFunctions.FD_BOOLEAN_ONE_AND_ONLY;
// check identity and type of the thing created
assertEquals(XACML3.ID_FUNCTION_BOOLEAN_ONE_AND_ONLY, fd.getId());
assertEquals(DataTypes.DT_BOOLEAN.getId(), fd.getDataTypeId());
- // just to be safe... If tests take too long these can probably be eliminated
+ // just to be safe... If tests take too long these can probably be eliminated
assertFalse(fd.returnsBag());
-
-
-
// bag with only one
arguments.clear();
arguments.add(attrBag1);
@@ -182,42 +167,45 @@ public class FunctionDefinitionBagOneAndOnlyTest {
res = fd.evaluate(null, arguments);
assertFalse(res.isOk());
assertEquals("function:boolean-one-and-only Got null argument", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
+ assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode()
+ .getStatusCodeValue().stringValue());
// bag with exactly one but of other type in it
arguments.clear();
arguments.add(attrBagOtherType);
res = fd.evaluate(null, arguments);
assertFalse(res.isOk());
- assertEquals("function:boolean-one-and-only Element in bag of wrong type. Expected boolean got string", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
+ assertEquals("function:boolean-one-and-only Element in bag of wrong type. Expected boolean got string",
+ res.getStatus().getStatusMessage());
+ assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode()
+ .getStatusCodeValue().stringValue());
// bag with none
arguments.clear();
arguments.add(attrBag0);
res = fd.evaluate(null, arguments);
assertFalse(res.isOk());
- assertEquals("function:boolean-one-and-only Expected 1 but Bag has 0 elements", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
+ assertEquals("function:boolean-one-and-only Expected 1 but Bag has 0 elements", res.getStatus()
+ .getStatusMessage());
+ assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode()
+ .getStatusCodeValue().stringValue());
// bag with multiple
arguments.clear();
arguments.add(attrBag2);
res = fd.evaluate(null, arguments);
assertFalse(res.isOk());
- assertEquals("function:boolean-one-and-only Expected 1 but Bag has 2 elements", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
+ assertEquals("function:boolean-one-and-only Expected 1 but Bag has 2 elements", res.getStatus()
+ .getStatusMessage());
+ assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode()
+ .getStatusCodeValue().stringValue());
}
-
//
//
- // REST OF DATA TYPES OMITTED
- // because they "should" all work the same
+ // REST OF DATA TYPES OMITTED
+ // because they "should" all work the same
//
//
-
-
-
}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/38b6d318/openaz-xacml-test/src/test/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionBagSizeTest.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-test/src/test/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionBagSizeTest.java b/openaz-xacml-test/src/test/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionBagSizeTest.java
index 863d068..77f7767 100644
--- a/openaz-xacml-test/src/test/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionBagSizeTest.java
+++ b/openaz-xacml-test/src/test/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionBagSizeTest.java
@@ -33,37 +33,24 @@ import org.junit.Test;
import com.att.research.xacml.api.XACML3;
import com.att.research.xacml.std.StdAttributeValue;
import com.att.research.xacml.std.datatypes.DataTypes;
-import com.att.research.xacmlatt.pdp.policy.Bag;
-import com.att.research.xacmlatt.pdp.policy.ExpressionResult;
-import com.att.research.xacmlatt.pdp.policy.FunctionArgument;
-import com.att.research.xacmlatt.pdp.policy.FunctionArgumentBag;
-import com.att.research.xacmlatt.pdp.std.StdFunctions;
/**
- * Test of PDP Functions (See XACML core spec section A.3)
- *
- * TO RUN - use jUnit
- * In Eclipse select this file or the enclosing directory, right-click and select Run As/JUnit Test
- *
- *
+ * Test of PDP Functions (See XACML core spec section A.3) TO RUN - use jUnit In Eclipse select this file or
+ * the enclosing directory, right-click and select Run As/JUnit Test
*/
public class FunctionDefinitionBagSizeTest {
-
/*
* variables useful in the following tests
*/
List<FunctionArgument> arguments = new ArrayList<FunctionArgument>();
-
@Test
public void testString() {
String v1 = new String("abc");
String v2 = new String("def");
Integer vOtherType = new Integer(11);
-
-
Bag bag0 = new Bag();
Bag bag1 = new Bag();
bag1.add(new StdAttributeValue<String>(DataTypes.DT_STRING.getId(), v1));
@@ -73,25 +60,20 @@ public class FunctionDefinitionBagSizeTest {
Bag bagOtherType = new Bag();
bagOtherType.add(new StdAttributeValue<Integer>(DataTypes.DT_INTEGER.getId(), vOtherType));
-
FunctionArgumentBag attrBag0 = new FunctionArgumentBag(bag0);
FunctionArgumentBag attrBag1 = new FunctionArgumentBag(bag1);
FunctionArgumentBag attrBag2 = new FunctionArgumentBag(bag2);
FunctionArgumentBag attrBagOtherType = new FunctionArgumentBag(bagOtherType);
-
- FunctionDefinitionBagSize<?> fd = (FunctionDefinitionBagSize<?>) StdFunctions.FD_STRING_BAG_SIZE;
+ FunctionDefinitionBagSize<?> fd = (FunctionDefinitionBagSize<?>)StdFunctions.FD_STRING_BAG_SIZE;
// check identity and type of the thing created
assertEquals(XACML3.ID_FUNCTION_STRING_BAG_SIZE, fd.getId());
assertEquals(DataTypes.DT_INTEGER.getId(), fd.getDataTypeId());
- // just to be safe... If tests take too long these can probably be eliminated
+ // just to be safe... If tests take too long these can probably be eliminated
assertFalse(fd.returnsBag());
-
-
-
// bag with only one
arguments.clear();
arguments.add(attrBag1);
@@ -107,7 +89,8 @@ public class FunctionDefinitionBagSizeTest {
res = fd.evaluate(null, arguments);
assertFalse(res.isOk());
assertEquals("function:string-bag-size Got null argument", res.getStatus().getStatusMessage());
- assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode().getStatusCodeValue().stringValue());
+ assertEquals("urn:oasis:names:tc:xacml:1.0:status:processing-error", res.getStatus().getStatusCode()
+ .getStatusCodeValue().stringValue());
// bag with exactly one but of other type in it
arguments.clear();
@@ -138,20 +121,11 @@ public class FunctionDefinitionBagSizeTest {
assertEquals(BigInteger.valueOf(2), resValue);
}
-
-
-
-
-
-
//
//
- // REST OF DATA TYPES OMITTED
- // because they "should" all work the same
+ // REST OF DATA TYPES OMITTED
+ // because they "should" all work the same
//
//
-
-
-
}