http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/94fcdd90/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
new file mode 100755
index 0000000..c7844a8
--- /dev/null
+++ 
b/openaz-xacml-test/src/test/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionAccessPermittedTest.java
@@ -0,0 +1,497 @@
+package com.att.research.xacmlatt.pdp.std.functions;
+
+import com.att.research.xacml.api.Request;
+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;
+
+import javax.xml.namespace.NamespaceContext;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.util.ArrayList;
+import java.util.Iterator;
+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.
+ * 
+ * @author glenngriffin
+ *
+ */
+public class FunctionDefinitionAccessPermittedTest {
+       
+       //
+       // Strings for the Request contents
+       //
+       
+       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>";
+       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 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\">";
+
+       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> ";
+       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;
+       
+       
+       /*
+        * 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
+           public Iterator<?> getPrefixes(String arg0) { return null;}
+
+           @Override
+           public String getPrefix(String arg0) {return null;}
+
+           @Override
+           public String getNamespaceURI(String 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";
+               } else if ("xsi".equals(arg0)) {
+                       return "http://www.w3.org/2001/XMLSchema-instance";;
+               }
+               return null;
+           }
+       };
+       
+       
+       
+       //
+       // URIs for attribute categroies
+       //
+       
+       FunctionArgumentAttributeValue attrUriNull = null;
+       FunctionArgumentAttributeValue attrUriEmpty = null;
+       FunctionArgumentAttributeValue attrUriResources = null;
+       FunctionArgumentAttributeValue attrUriAction = null;
+       FunctionArgumentAttributeValue attrUriNotInRequest = null;
+       FunctionArgumentAttributeValue attrUriNotCategory = null;
+
+       
+       
+       //
+       // XML Contents 
+       //
+       
+       FunctionArgumentAttributeValue attrXnull = null;
+       FunctionArgumentAttributeValue attrXEmpty = null;
+       FunctionArgumentAttributeValue attrXSimpson = null;
+       FunctionArgumentAttributeValue attrXSpringer = null;
+       FunctionArgumentAttributeValue attrXContentSimpson = null;
+       FunctionArgumentAttributeValue attrXContentSpringer = null;
+       FunctionArgumentAttributeValue attrXBadXML = null;
+       
+
+       
+
+       
+       
+       //
+       // REQUEST objects available for use in tests
+       //
+       Request requestEmpty = new StdMutableRequest();
+       Request requestMdRecord = null;
+       Request requestDoubleResources = null;
+       Request requestDoubleContent = null;
+       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"));
+                       
+                       // 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));
+
+
+                       
+                       // 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.
+                       
+                       // single Content in the Resources section (normal 
valid request)
+                       String reqString = reqStrMainResourceStart + 
reqStrContentMdRecordSimpson + reqStrResourceAllEnd;
+                               File tFile = 
File.createTempFile("functionJunit", "request");
+                               BufferedWriter bw = new BufferedWriter(new 
FileWriter(tFile));
+                               bw.append(reqString);
+                               bw.flush();
+                               bw.close();
+                       requestMdRecord = DOMRequest.load(tFile);
+                               tFile.delete();
+                               
+                       // Resources included twice
+                       reqString = reqStrMainResourceStart + 
reqStrContentMdRecordSimpson + reqStrResourceEnd + reqStrResourceStart + 
reqStrContentMdRecordSimpson +reqStrResourceAllEnd;
+                               tFile = File.createTempFile("functionJunit", 
"request");
+                               bw = new BufferedWriter(new FileWriter(tFile));
+                               bw.append(reqString);
+                               bw.flush();
+                               bw.close();
+                       requestDoubleResources = DOMRequest.load(tFile);
+                               tFile.delete();
+                                       
+                       // Content included twice - error
+                       reqString = reqStrMainResourceStart + 
reqStrContentMdRecordSimpson + reqStrContentMdRecordSimpson 
+reqStrResourceAllEnd;
+                               tFile = File.createTempFile("functionJunit", 
"request");
+                               bw = new BufferedWriter(new FileWriter(tFile));
+                               bw.append(reqString);
+                               bw.flush();
+                               bw.close();
+                       try {
+                               requestDoubleContent = DOMRequest.load(tFile);
+                                       tFile.delete();
+                       } 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);
+                       }
+                       
+                       // content included in both Resource and Action - ok
+                       reqString = reqStrMainResourceStart + 
reqStrContentMdRecordSimpson + reqStrResourceEnd + reqStrActionStart + 
reqStrContentMdRecordSimpson + reqStrActionEnd + reqStrMainEnd;
+                               tFile = File.createTempFile("functionJunit", 
"request");
+                               bw = new BufferedWriter(new FileWriter(tFile));
+                               bw.append(reqString);
+                               bw.flush();
+                               bw.close();     
+                       requestResourceActionContent = DOMRequest.load(tFile);
+                               tFile.delete();
+                               
+                       // Content included only in Action - missing content 
produces non-error result according to spec
+                       reqString = reqStrMainResourceStart + reqStrResourceEnd 
+ reqStrActionStart + reqStrContentMdRecordSimpson + reqStrActionEnd + 
reqStrMainEnd;
+                               tFile = File.createTempFile("functionJunit", 
"request");
+                               bw = new BufferedWriter(new FileWriter(tFile));
+                               bw.append(reqString);
+                               bw.flush();
+                               bw.close();             
+                       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;
+                               tFile = File.createTempFile("functionJunit", 
"request");
+                               bw = new BufferedWriter(new FileWriter(tFile));
+                               bw.append(reqString);
+                               bw.flush();
+                               bw.close();
+                       try {
+                               requestContentMisplaced = 
DOMRequest.load(tFile);
+                                       tFile.delete();
+                       } 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);
+                       }
+                               
+                       // Bad XML - Content is not valid XML
+                       reqString = reqStrMainResourceStart + 
reqStrMalformedContent + reqStrResourceAllEnd;
+                               tFile = File.createTempFile("functionJunit", 
"request");
+                               bw = new BufferedWriter(new FileWriter(tFile));
+                               bw.append(reqString);
+                               bw.flush();
+                               bw.close();
+                       try {
+                               requestMalformedContent = 
DOMRequest.load(tFile);
+                                       tFile.delete();
+                       } 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);
+                       }
+                       
+               } catch (Exception e) {
+                       fail("Constructor initializing variables, e="+ e + "  
cause="+e.getCause());
+               }
+               
+       }
+       
+
+       
+       
+       
+       
+       
+       @Ignore
+       @Test
+       public void testAccess_permitted() {
+
+               ExpressionResult res = null;
+               Boolean resValue = null;
+               
+               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
+               assertFalse(fd.returnsBag());
+
+               
+
+               // successful invoke returns true
+               arguments.clear();
+               arguments.add(attrUriResources);
+               arguments.add(attrXEmpty);
+               res = fd.evaluate(new StdEvaluationContext(requestMdRecord, 
null, null), arguments);
+               assertTrue(res.isOk());
+               resValue = (Boolean)res.getValue().getValue();
+               assertTrue(resValue);
+
+
+                               
+               // successful invoke returns false
+               
+               
+               // URI not in Request (ok - evaluate anyway)
+       
+               // test for infinite loop
+               
+               // second arg ok both with and without <Content> tag
+               arguments.clear();
+               arguments.add(attrUriResources);
+               arguments.add(attrXContentSpringer);
+               res = fd.evaluate(new StdEvaluationContext(requestMdRecord, 
null, null), arguments);
+               assertTrue(res.isOk());
+               resValue = (Boolean)res.getValue().getValue();
+               assertTrue(resValue);
+               
+               arguments.clear();
+               arguments.add(attrUriResources);
+               arguments.add(attrXSpringer);
+               res = fd.evaluate(new StdEvaluationContext(requestMdRecord, 
null, null), arguments);
+               assertTrue(res.isOk());
+               resValue = (Boolean)res.getValue().getValue();
+               assertTrue(resValue);
+               
+               // second arg not valid XML
+               arguments.clear();
+               arguments.add(attrUriResources);
+               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());   
+               
+               // null Evaluation Context
+               arguments.clear();
+               arguments.add(attrUriNotCategory);
+               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());
+               
+               // null Request
+               arguments.clear();
+               arguments.add(attrUriAction);
+               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());
+               
+       
+               // first arg not uri
+               arguments.clear();
+               arguments.add(attrUriNotCategory);
+               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());
+               
+               // first arg not attribute-category urn
+               arguments.clear();
+               arguments.add(attrXContentSimpson);
+               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());
+               
+               // second arg not string
+               arguments.clear();
+               arguments.add(attrUriAction);
+               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());
+               
+
+               // 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());
+               
+               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());
+               
+               
+               // too many args
+               arguments.clear();
+               arguments.add(attrUriEmpty);
+               arguments.add(attrXContentSimpson);
+               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());
+               
+               
+       }
+       
+}

http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/94fcdd90/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
new file mode 100755
index 0000000..3887198
--- /dev/null
+++ 
b/openaz-xacml-test/src/test/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionArithmeticTest.java
@@ -0,0 +1,707 @@
+/*
+ *                        AT&T - PROPRIETARY
+ *          THIS FILE CONTAINS PROPRIETARY INFORMATION OF
+ *        AT&T AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN
+ *             ACCORDANCE WITH APPLICABLE AGREEMENTS.
+ *
+ *          Copyright (c) 2013 AT&T Knowledge Ventures
+ *              Unpublished and Not for Publication
+ *                     All Rights Reserved
+ */
+package com.att.research.xacmlatt.pdp.std.functions;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+
+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
+ * 
+ * @author glenngriffin
+ *
+ */
+public class FunctionDefinitionArithmeticTest {
+
+       /*
+        * variables useful in the following tests
+        */
+       List<FunctionArgument> arguments = new ArrayList<FunctionArgument>();
+       
+       @Test
+       public void testInteger_add() {
+               
+               FunctionArgumentAttributeValue attr1 = null;
+               FunctionArgumentAttributeValue attr2 = null;
+               FunctionArgumentAttributeValue attrBadType = null;
+               try {
+                       attr1 = new 
FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(1));
+                       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);
+               }
+               
+               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
+               assertFalse(fd.returnsBag());
+               assertEquals(new Integer(2), fd.getNumArgs());
+               
+               
+               // test normal add
+               arguments.add(attr1);
+               arguments.add(attr2);
+               ExpressionResult res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               BigInteger resValue = (BigInteger)res.getValue().getValue();
+               assertEquals(new BigInteger("2"), resValue);
+               
+               arguments.clear();
+               arguments.add(attr1);
+               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());
+               
+       }
+
+       
+       @Test
+       public void testDouble_add() {
+               
+               FunctionArgumentAttributeValue attr1 = 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);
+               }
+               
+               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
+               assertFalse(fd.returnsBag());
+               assertEquals(new Integer(2), fd.getNumArgs());
+               
+               
+               // test normal add
+               arguments.add(attr1);
+               arguments.add(attr2);
+               ExpressionResult res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               Double resValue = (Double)res.getValue().getValue();
+               assertEquals(new Double(4.0), resValue);
+               
+       }
+       
+       
+       @Test
+       public void testInteger_subtract() {
+               
+               FunctionArgumentAttributeValue attr1 = null;
+               FunctionArgumentAttributeValue attr2 = null;
+               try {
+                       attr1 = new 
FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(6));
+                       attr2 = new 
FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(1));
+               } catch (Exception e) {
+                       fail("creating attributes e="+ e);
+               }
+               
+               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
+               assertFalse(fd.returnsBag());
+               assertEquals(new Integer(2), fd.getNumArgs());
+               
+               
+               // test normal 
+               arguments.add(attr1);
+               arguments.add(attr2);
+               ExpressionResult res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               BigInteger resValue = (BigInteger)res.getValue().getValue();
+               assertEquals(new BigInteger("5"), resValue);
+               
+       }
+
+       
+       @Test
+       public void testDouble_subtract() {
+               
+               FunctionArgumentAttributeValue attr1 = 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);
+               }
+               
+               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
+               assertFalse(fd.returnsBag());
+               assertEquals(new Integer(2), fd.getNumArgs());
+               
+               
+               // test normal 
+               arguments.add(attr1);
+               arguments.add(attr2);
+               ExpressionResult res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               Double resValue = (Double)res.getValue().getValue();
+               assertEquals(new Double(6.2), resValue);
+               
+       }
+       
+       
+       @Test
+       public void testInteger_multiply() {
+               
+               FunctionArgumentAttributeValue attr0 = null;
+               FunctionArgumentAttributeValue attr1 = null;
+               FunctionArgumentAttributeValue attr2 = null;
+               try {
+                       attr0 = new 
FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(0));
+                       attr1 = new 
FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(5));
+                       attr2 = new 
FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(2));
+               } catch (Exception e) {
+                       fail("creating attributes e="+ e);
+               }
+               
+               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
+               assertFalse(fd.returnsBag());
+               assertEquals(new Integer(2), fd.getNumArgs());
+               
+               
+               // test normal 
+               arguments.add(attr1);
+               arguments.add(attr2);
+               ExpressionResult res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               BigInteger resValue = (BigInteger)res.getValue().getValue();
+               assertEquals(new BigInteger("10"), resValue);
+               
+               
+               // test 0
+               arguments.clear();
+               arguments.add(attr1);
+               arguments.add(attr0);
+               res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               resValue = (BigInteger)res.getValue().getValue();
+               assertEquals(new BigInteger("0"), resValue);
+       }
+
+       
+       @Test
+       public void testDouble_multiply() {
+               
+               FunctionArgumentAttributeValue attr0 = null;
+               FunctionArgumentAttributeValue attr1 = 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);
+               }
+               
+               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
+               assertFalse(fd.returnsBag());
+               assertEquals(new Integer(2), fd.getNumArgs());
+               
+               
+               // test normal add
+               arguments.add(attr1);
+               arguments.add(attr2);
+               ExpressionResult res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               Double resValue = (Double)res.getValue().getValue();
+               assertEquals(new Double(3.75), resValue);
+               
+               // test multiply by 0
+               arguments.clear();
+               arguments.add(attr1);
+               arguments.add(attr0);
+               res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               resValue = (Double)res.getValue().getValue();
+               assertEquals(new Double(0), resValue);
+       }
+       
+       
+       @Test
+       public void testInteger_divide() {
+               
+               FunctionArgumentAttributeValue attr0 = null;
+               FunctionArgumentAttributeValue attr1 = null;
+               FunctionArgumentAttributeValue attr2 = null;
+               try {
+                       attr0 = new 
FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(0));
+                       attr1 = new 
FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(5));
+                       attr2 = new 
FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(2));
+               } catch (Exception e) {
+                       fail("creating attributes e="+ e);
+               }
+               
+               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
+               assertFalse(fd.returnsBag());
+               assertEquals(new Integer(2), fd.getNumArgs());
+               
+               
+               // test normal 
+               arguments.add(attr1);
+               arguments.add(attr2);
+               ExpressionResult res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               BigInteger resValue = (BigInteger)res.getValue().getValue();
+               assertEquals(new BigInteger("2"), resValue);
+               
+               
+               // test 0
+               arguments.clear();
+               arguments.add(attr1);
+               arguments.add(attr0);
+               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());
+
+       }
+
+       
+       @Test
+       public void testDouble_divide() {
+               
+               FunctionArgumentAttributeValue attr0 = null;
+               FunctionArgumentAttributeValue attr1 = 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);
+               }
+               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
+               assertFalse(fd.returnsBag());
+               assertEquals(new Integer(2), fd.getNumArgs());
+               
+               
+               // test normal 
+               arguments.add(attr1);
+               arguments.add(attr2);
+               ExpressionResult res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               Double resValue = (Double)res.getValue().getValue();
+               assertEquals(new Double(0.6), resValue);
+               
+               // test multiply by 0
+               arguments.clear();
+               arguments.add(attr1);
+               arguments.add(attr0);
+               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());
+
+       }
+       
+       
+       
+       
+       
+       
+       @Test
+       public void testInteger_mod() {
+               
+               FunctionArgumentAttributeValue attr0 = null;
+               FunctionArgumentAttributeValue attr1 = null;
+               FunctionArgumentAttributeValue attr2 = null;
+               try {
+                       attr0 = new 
FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(0));
+                       attr1 = new 
FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(28));
+                       attr2 = new 
FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(5));
+               } catch (Exception e) {
+                       fail("creating attributes e="+ e);
+               }
+               
+               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
+               assertFalse(fd.returnsBag());
+               assertEquals(new Integer(2), fd.getNumArgs());
+               
+               
+               // test normal 
+               arguments.add(attr1);
+               arguments.add(attr2);
+               ExpressionResult res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               BigInteger resValue = (BigInteger)res.getValue().getValue();
+               assertEquals(new BigInteger("3"), resValue);
+               
+               
+               // test 0
+               arguments.clear();
+               arguments.add(attr1);
+               arguments.add(attr0);
+               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());
+
+       }
+       
+
+       @Test
+       public void testInteger_abs() {
+
+               FunctionArgumentAttributeValue attr0 = null;
+               FunctionArgumentAttributeValue attr1 = null;
+               FunctionArgumentAttributeValue attrM1 = null;
+               try {
+                       attr0 = new 
FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(0));
+                       attr1 = new 
FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(5));
+                       attrM1 = new 
FunctionArgumentAttributeValue(DataTypes.DT_INTEGER.createAttributeValue(-7));
+               } catch (Exception e) {
+                       fail("creating attributes e="+ e);
+               }
+               
+               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
+               assertFalse(fd.returnsBag());
+               assertEquals(new Integer(1), fd.getNumArgs());
+               
+               
+               // test normal 
+               arguments.add(attr1);
+               ExpressionResult res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               BigInteger resValue = (BigInteger)res.getValue().getValue();
+               assertEquals(new BigInteger("5"), resValue);
+               
+               arguments.clear();
+               arguments.add(attrM1);
+               res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               resValue = (BigInteger)res.getValue().getValue();
+               assertEquals(new BigInteger("7"), resValue);
+
+               arguments.clear();
+               arguments.add(attr0);
+               res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               resValue = (BigInteger)res.getValue().getValue();
+               assertEquals(new BigInteger("0"), resValue);
+       }
+
+       
+       @Test
+       public void testDouble_abs() {
+               
+               FunctionArgumentAttributeValue attr0 = null;
+               FunctionArgumentAttributeValue attr1 = 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);
+               }
+               
+               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
+               assertFalse(fd.returnsBag());
+               assertEquals(new Integer(1), fd.getNumArgs());
+               
+               
+               // test normal 
+               arguments.add(attr1);
+               ExpressionResult res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               Double resValue = (Double)res.getValue().getValue();
+               assertEquals(new Double(1.5), resValue);
+               
+               arguments.clear();
+               arguments.add(attr2);
+               res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               resValue = (Double)res.getValue().getValue();
+               assertEquals(new Double(2.5), resValue);
+               
+               arguments.clear();
+               arguments.add(attr0);
+               res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               resValue = (Double)res.getValue().getValue();
+               assertEquals(new Double(0), resValue);
+
+       }
+       
+       
+       @Test
+       public void testDouble_round() {
+
+               FunctionArgumentAttributeValue attr0 = null;
+               FunctionArgumentAttributeValue attr1 = null;
+               FunctionArgumentAttributeValue attr2  = null;
+               FunctionArgumentAttributeValue attr3 = null;
+               FunctionArgumentAttributeValue attr4 = null;
+               FunctionArgumentAttributeValue attr5 = null;
+               FunctionArgumentAttributeValue attr6 = 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(1.49));
+                       attr3 = new 
FunctionArgumentAttributeValue(DataTypes.DT_DOUBLE.createAttributeValue(1.51));
+                       attr4 = new 
FunctionArgumentAttributeValue(DataTypes.DT_DOUBLE.createAttributeValue(-2.5));
+                       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);
+               }
+               
+               
+               
+               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
+               assertFalse(fd.returnsBag());
+               assertEquals(new Integer(1), fd.getNumArgs());
+               
+               
+               // test normal 
+               arguments.add(attr0);
+               ExpressionResult res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               Double resValue = (Double)res.getValue().getValue();
+               assertEquals(new Double(0), resValue);
+               
+               arguments.clear();
+               arguments.add(attr1);
+               res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               resValue = (Double)res.getValue().getValue();
+               assertEquals(new Double(2), resValue);
+               
+               arguments.clear();
+               arguments.add(attr2);
+               res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               resValue = (Double)res.getValue().getValue();
+               assertEquals(new Double(1), resValue);
+               
+               arguments.clear();
+               arguments.add(attr3);
+               res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               resValue = (Double)res.getValue().getValue();
+               assertEquals(new Double(2), resValue);
+               
+               arguments.clear();
+               arguments.add(attr4);
+               res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               resValue = (Double)res.getValue().getValue();
+               assertEquals(new Double(-2), resValue);
+       
+               arguments.clear();
+               arguments.add(attr5);
+               res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               resValue = (Double)res.getValue().getValue();
+               assertEquals(new Double(-2), resValue);
+               
+               arguments.clear();
+               arguments.add(attr6);
+               res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               resValue = (Double)res.getValue().getValue();
+               assertEquals(new Double(-3), resValue);
+       }
+       
+       
+       @Test
+       public void testDouble_floor() {
+               FunctionArgumentAttributeValue attr0 = null;
+               FunctionArgumentAttributeValue attr1 = null;
+               FunctionArgumentAttributeValue attr2  = null;
+               FunctionArgumentAttributeValue attr3 = null;
+               FunctionArgumentAttributeValue attr4 = null;
+               FunctionArgumentAttributeValue attr5 = null;
+               FunctionArgumentAttributeValue attr6 = 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(1.49));
+                       attr3 = new 
FunctionArgumentAttributeValue(DataTypes.DT_DOUBLE.createAttributeValue(1.51));
+                       attr4 = new 
FunctionArgumentAttributeValue(DataTypes.DT_DOUBLE.createAttributeValue(-2.5));
+                       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);
+               }
+               
+               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
+               assertFalse(fd.returnsBag());
+               assertEquals(new Integer(1), fd.getNumArgs());
+               
+               
+               // test normal 
+               arguments.add(attr0);
+               ExpressionResult res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               Double resValue = (Double)res.getValue().getValue();
+               assertEquals(new Double(0), resValue);
+               
+               arguments.clear();
+               arguments.add(attr1);
+               res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               resValue = (Double)res.getValue().getValue();
+               assertEquals(new Double(1), resValue);
+               
+               arguments.clear();
+               arguments.add(attr2);
+               res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               resValue = (Double)res.getValue().getValue();
+               assertEquals(new Double(1), resValue);
+               
+               arguments.clear();
+               arguments.add(attr3);
+               res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               resValue = (Double)res.getValue().getValue();
+               assertEquals(new Double(1), resValue);
+               
+               arguments.clear();
+               arguments.add(attr4);
+               res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               resValue = (Double)res.getValue().getValue();
+               assertEquals(new Double(-3), resValue);
+       
+               arguments.clear();
+               arguments.add(attr5);
+               res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               resValue = (Double)res.getValue().getValue();
+               assertEquals(new Double(-3), resValue);
+               
+               arguments.clear();
+               arguments.add(attr6);
+               res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               resValue = (Double)res.getValue().getValue();
+               assertEquals(new Double(-3), resValue);
+       }
+       
+}

http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/94fcdd90/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
new file mode 100755
index 0000000..d097122
--- /dev/null
+++ 
b/openaz-xacml-test/src/test/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionBagIsInTest.java
@@ -0,0 +1,201 @@
+package com.att.research.xacmlatt.pdp.std.functions;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+
+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
+ * 
+ * @author glenngriffin
+ *
+ */
+public class FunctionDefinitionBagIsInTest {
+
+
+       /*
+        * 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");
+               String notInBag = new String("lmnop");
+               String sameValueV1 = new String("abc");
+               Integer vOtherType = new Integer(11);
+               
+               
+               FunctionArgumentAttributeValue attrV1 = null;
+               FunctionArgumentAttributeValue attrV2 = null;
+               FunctionArgumentAttributeValue attrNotInBag = null;
+               FunctionArgumentAttributeValue attrSameValueV1 = null;
+               FunctionArgumentAttributeValue attrOtherType = null;
+               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));
+               } catch (Exception e) {
+                       fail("creating attributes e="+ e);
+               }
+               
+               Bag bag0 = new Bag();
+               Bag bag1 = new Bag();
+                       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));;
+
+               
+               
+               FunctionArgumentBag attrBag0 = new FunctionArgumentBag(bag0);
+               FunctionArgumentBag attrBag1 = new FunctionArgumentBag(bag1);
+               FunctionArgumentBag attrBag2 = new FunctionArgumentBag(bag2);
+
+               
+               
+               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
+               assertFalse(fd.returnsBag());
+
+               
+               // element is in bag
+               arguments.clear();
+               arguments.add(attrV1);
+               arguments.add(attrBag2);
+               ExpressionResult res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               assertEquals(Boolean.class, 
res.getValue().getValue().getClass());
+               Boolean resValue = (Boolean)res.getValue().getValue();
+               assertEquals(true, resValue);
+               
+               // element not in bag
+               arguments.clear();
+               arguments.add(attrNotInBag);
+               arguments.add(attrBag2);
+               res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               assertEquals(Boolean.class, 
res.getValue().getValue().getClass());
+               resValue = (Boolean)res.getValue().getValue();
+               assertEquals(false, resValue);
+               
+               // different element with the same value is in bag
+               arguments.clear();
+               arguments.add(attrSameValueV1);
+               arguments.add(attrBag2);
+               res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               assertEquals(Boolean.class, 
res.getValue().getValue().getClass());
+               resValue = (Boolean)res.getValue().getValue();
+               assertEquals(true, resValue);
+               
+               // empty bag
+               arguments.clear();
+               arguments.add(attrV1);
+               arguments.add(attrBag0);
+               res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               assertEquals(Boolean.class, 
res.getValue().getValue().getClass());
+               resValue = (Boolean)res.getValue().getValue();
+               assertEquals(false, resValue);
+               
+               // missing arg
+               arguments.clear();
+               arguments.add(attrSameValueV1);
+               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());
+               
+               // 1st arg is bag
+               arguments.clear();
+               arguments.add(attrBag1);
+               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());
+               
+               // 2nd arg not bag
+               arguments.clear();
+               arguments.add(attrV1);
+               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());
+               
+               // first arg null
+               arguments.clear();
+               arguments.add(null);
+               arguments.add(attrBag2);
+               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());
+               
+               // 2nd arg null
+               arguments.clear();
+               arguments.add(attrV1);
+               arguments.add(null);
+               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());
+               
+               // first arg type does not match bag elements
+               arguments.clear();
+               arguments.add(attrOtherType);
+               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());
+               
+               // bag has mixed element types
+// 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
+       //
+       //
+       
+       
+       
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/94fcdd90/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
new file mode 100755
index 0000000..13c5161
--- /dev/null
+++ 
b/openaz-xacml-test/src/test/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionBagOneAndOnlyTest.java
@@ -0,0 +1,204 @@
+package com.att.research.xacmlatt.pdp.std.functions;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.math.BigInteger;
+
+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
+ * 
+ * @author glenngriffin
+ *
+ */
+public class FunctionDefinitionBagOneAndOnlyTest {
+
+
+       /*
+        * 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");
+               BigInteger vOtherType = BigInteger.valueOf(11);
+               
+               Bag bag0 = new Bag();
+               Bag bag1 = new Bag();
+                       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));
+               Bag bagOtherType = new Bag();
+                       bagOtherType.add(new 
StdAttributeValue<BigInteger>(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);
+               
+               
+               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
+               assertFalse(fd.returnsBag());
+
+               
+               
+               
+               // bag with only one
+               arguments.clear();
+               arguments.add(attrBag1);
+               ExpressionResult res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               assertEquals(String.class, 
res.getValue().getValue().getClass());
+               String resValue = (String)res.getValue().getValue();
+               assertEquals(v1, resValue);
+               
+               // null bag
+               arguments.clear();
+               arguments.add(null);
+               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());
+               
+               // 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());
+               
+               // 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());
+               
+               // 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());
+       }
+       
+       
+       
+       @Test
+       public void testBoolean() {
+               Boolean v1 = new Boolean(true);
+               Boolean v2 = new Boolean(false);
+               BigInteger vOtherType = BigInteger.valueOf(11);
+               
+               Bag bag0 = new Bag();
+               Bag bag1 = new Bag();
+                       bag1.add(new 
StdAttributeValue<Boolean>(DataTypes.DT_BOOLEAN.getId(), v1));  
+               Bag bag2 = new Bag();
+                       bag2.add(new 
StdAttributeValue<Boolean>(DataTypes.DT_BOOLEAN.getId(), v1));  
+                       bag2.add(new 
StdAttributeValue<Boolean>(DataTypes.DT_BOOLEAN.getId(), v2)); 
+               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;
+
+               // 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
+               assertFalse(fd.returnsBag());
+
+               
+               
+               
+               // bag with only one
+               arguments.clear();
+               arguments.add(attrBag1);
+               ExpressionResult res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               assertEquals(Boolean.class, 
res.getValue().getValue().getClass());
+               Boolean resValue = (Boolean)res.getValue().getValue();
+               assertEquals(new Boolean(true), resValue);
+               
+               // null bag
+               arguments.clear();
+               arguments.add(null);
+               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());
+               
+               // 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());
+               
+               // 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());
+               
+               // 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());
+       }
+       
+       
+       //
+       //
+       //  REST OF DATA TYPES OMITTED 
+       //      because they "should" all work the same
+       //
+       //
+       
+       
+       
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/94fcdd90/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
new file mode 100755
index 0000000..afc5e09
--- /dev/null
+++ 
b/openaz-xacml-test/src/test/java/com/att/research/xacmlatt/pdp/std/functions/FunctionDefinitionBagSizeTest.java
@@ -0,0 +1,138 @@
+package com.att.research.xacmlatt.pdp.std.functions;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+
+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
+ * 
+ * @author glenngriffin
+ *
+ */
+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));  
+               Bag bag2 = new Bag();
+                       bag2.add(new 
StdAttributeValue<String>(DataTypes.DT_STRING.getId(), v1));  
+                       bag2.add(new 
StdAttributeValue<String>(DataTypes.DT_STRING.getId(), v2)); 
+               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;
+
+               // 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
+               assertFalse(fd.returnsBag());
+
+               
+               
+               
+               // bag with only one
+               arguments.clear();
+               arguments.add(attrBag1);
+               ExpressionResult res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               assertEquals(BigInteger.class, 
res.getValue().getValue().getClass());
+               BigInteger resValue = (BigInteger)res.getValue().getValue();
+               assertEquals(BigInteger.valueOf(1), resValue);
+               
+               // null bag
+               arguments.clear();
+               arguments.add(null);
+               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());
+               
+               // bag with exactly one but of other type in it
+               arguments.clear();
+               arguments.add(attrBagOtherType);
+               res = fd.evaluate(null, arguments);
+               // NOTE: Size does not care about content type!
+               assertTrue(res.isOk());
+               assertEquals(BigInteger.class, 
res.getValue().getValue().getClass());
+               resValue = (BigInteger)res.getValue().getValue();
+               assertEquals(BigInteger.valueOf(1), resValue);
+               
+               // bag with none
+               arguments.clear();
+               arguments.add(attrBag0);
+               res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               assertEquals(BigInteger.class, 
res.getValue().getValue().getClass());
+               resValue = (BigInteger)res.getValue().getValue();
+               assertEquals(BigInteger.valueOf(0), resValue);
+               
+               // bag with multiple
+               arguments.clear();
+               arguments.add(attrBag2);
+               res = fd.evaluate(null, arguments);
+               assertTrue(res.isOk());
+               assertEquals(BigInteger.class, 
res.getValue().getValue().getClass());
+               resValue = (BigInteger)res.getValue().getValue();
+               assertEquals(BigInteger.valueOf(2), resValue);
+       }
+       
+       
+
+       
+       
+       
+       
+       //
+       //
+       //  REST OF DATA TYPES OMITTED 
+       //      because they "should" all work the same
+       //
+       //
+       
+       
+       
+
+}

Reply via email to