You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openaz.apache.org by pd...@apache.org on 2015/05/13 18:02:26 UTC
[04/56] [abbrv] [partial] incubator-openaz git commit: Merging
re-factoring with PMD work
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-xacml-test/src/test/java/org/apache/openaz/xacml/pdp/test/conformance/Conformance.java
----------------------------------------------------------------------
diff --cc openaz-xacml-test/src/test/java/org/apache/openaz/xacml/pdp/test/conformance/Conformance.java
index 5ec7859,0000000..ffb1f9b
mode 100644,000000..100644
--- a/openaz-xacml-test/src/test/java/org/apache/openaz/xacml/pdp/test/conformance/Conformance.java
+++ b/openaz-xacml-test/src/test/java/org/apache/openaz/xacml/pdp/test/conformance/Conformance.java
@@@ -1,643 -1,0 +1,665 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+/*
+ * 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 org.apache.openaz.xacml.pdp.test.conformance;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.openaz.xacml.api.Advice;
+import org.apache.openaz.xacml.api.Attribute;
+import org.apache.openaz.xacml.api.AttributeAssignment;
+import org.apache.openaz.xacml.api.AttributeCategory;
+import org.apache.openaz.xacml.api.AttributeValue;
+import org.apache.openaz.xacml.api.IdReference;
+import org.apache.openaz.xacml.api.Obligation;
+import org.apache.openaz.xacml.api.Response;
+import org.apache.openaz.xacml.api.Result;
+
+/**
- * Conformance is an application that runs a <code>ConformanceTestSet</code> and dumps results comparing the actual and
- * expected results.
- *
- * TO RUN in Eclipse:
- * This is run as a Java Application.
- * You must first create a Run/Debug Configuration:
- * Under the Argument tab, in Program Arguments you must set the -i or --input command line argument.
- * You should also direct the output to a file using -o or --output. (default is Console)
- * See the init() method in this file for other useful arguments.
- * Example for a Windows machine:
- * -i testsets/conformance/xacml3.0-ct-v.0.4
- * -o \Users\yourLogin\Downloads\conformance.txt
- * You must also set the VM arguments:
- * -Dxacml.properties=testsets/conformance/xacml.properties .
- * -Dlog4j.configuration=.\logging.properties
- *
++ * Conformance is an application that runs a <code>ConformanceTestSet</code> and dumps results comparing the
++ * actual and expected results. TO RUN in Eclipse: This is run as a Java Application. You must first create a
++ * Run/Debug Configuration: Under the Argument tab, in Program Arguments you must set the -i or --input
++ * command line argument. You should also direct the output to a file using -o or --output. (default is
++ * Console) See the init() method in this file for other useful arguments. Example for a Windows machine: -i
++ * testsets/conformance/xacml3.0-ct-v.0.4 -o \Users\yourLogin\Downloads\conformance.txt You must also set the
++ * VM arguments: -Dxacml.properties=testsets/conformance/xacml.properties .
++ * -Dlog4j.configuration=.\logging.properties
+ */
+public class Conformance {
+ private ConformanceScopeResolver scopeResolver;
+ private ConformanceTestEngine testEngine;
- private ConformanceTestSet testSet = new ConformanceTestSet();
++ private ConformanceTestSet testSet = new ConformanceTestSet();
+ private File outputFile;
+ private PrintWriter outputFileWriter;
+
+ private List<String> testNamesToRun = new ArrayList<String>();
+
+ private boolean verbose;
+ private boolean failuresOnly;
+ private boolean strict;
+ private boolean stopOnFirstError;
+
+ private int testsRun;
+ private int decisionsMatch;
+ private int statusCodesMatch;
+ private int attributesMatch;
+ private int policyIdsMatch;
+ private int policySetIdsMatch;
+ private int associatedAdviceMatch;
+ private int obligationsMatch;
+ private int unknownFunctions;
+
-
-
-
+ protected synchronized ConformanceScopeResolver getScopeResolver() {
+ if (this.scopeResolver == null) {
- this.scopeResolver = new ConformanceScopeResolver();
++ this.scopeResolver = new ConformanceScopeResolver();
+
+ /*
- * TODO:
- * Add the known scopes for the 2.0 conformance test. This could be made more general by allowing loading
- * from a properties file eventually.
++ * TODO: Add the known scopes for the 2.0 conformance test. This could be made more general by
++ * allowing loading from a properties file eventually.
+ */
+ try {
- URI ID_SCOPE_ROOT = new URI("urn:root");
- URI ID_SCOPE_CHILD1 = new URI("urn:root:child1");
- URI ID_SCOPE_CHILD2 = new URI("urn:root:child2");
- URI ID_SCOPE_C1D1 = new URI("urn:root:child1:descendant1");
- URI ID_SCOPE_C1D2 = new URI("urn:root:child1:descendant2");
- URI ID_SCOPE_C2D1 = new URI("urn:root:child2:descendant1");
- URI ID_SCOPE_C2D2 = new URI("urn:root:child2:descendant2");
++ URI ID_SCOPE_ROOT = new URI("urn:root");
++ URI ID_SCOPE_CHILD1 = new URI("urn:root:child1");
++ URI ID_SCOPE_CHILD2 = new URI("urn:root:child2");
++ URI ID_SCOPE_C1D1 = new URI("urn:root:child1:descendant1");
++ URI ID_SCOPE_C1D2 = new URI("urn:root:child1:descendant2");
++ URI ID_SCOPE_C2D1 = new URI("urn:root:child2:descendant1");
++ URI ID_SCOPE_C2D2 = new URI("urn:root:child2:descendant2");
+
+ this.scopeResolver.add(ID_SCOPE_ROOT, ID_SCOPE_CHILD1);
+ this.scopeResolver.add(ID_SCOPE_CHILD1, ID_SCOPE_C1D1);
+ this.scopeResolver.add(ID_SCOPE_CHILD1, ID_SCOPE_C1D2);
+ this.scopeResolver.add(ID_SCOPE_ROOT, ID_SCOPE_CHILD2);
+ this.scopeResolver.add(ID_SCOPE_CHILD2, ID_SCOPE_C2D1);
+ this.scopeResolver.add(ID_SCOPE_CHILD2, ID_SCOPE_C2D2);
+ } catch (Exception ex) {
+ ex.printStackTrace(System.err);
+ }
+
+ }
+ return this.scopeResolver;
+ }
+
+ private void close() throws IOException {
+ if (this.outputFileWriter != null) {
+ this.outputFileWriter.close();
+ }
+ }
+
+ private boolean init(String[] args) {
- boolean lenientRequests = true;
- boolean lenientPolicies = false;
++ boolean lenientRequests = true;
++ boolean lenientPolicies = false;
+ // default is to not run any non-first-time iterations
- int iterations = -1;
++ int iterations = -1;
+ String testSetDirectoryNames = "";
- for (int i = 0 ; i < args.length ; ) {
++ for (int i = 0; i < args.length;) {
+
+ if (args[i].equals("-h") || args[i].equals("--help") || args[i].equals("-help")) {
+ printHelp();
+ return false;
+ }
+
-
+ // where the XML Request/Response files are located
+ if (args[i].equals("-i") || args[i].equals("--input")) {
+ i++;
+ while (i < args.length && !args[i].startsWith("-")) {
+ testSetDirectoryNames += " " + args[i];
+ try {
+ testSet.addConformanceTestSet(ConformanceTestSet.loadDirectory(new File(args[i])));
+ } catch (Exception ex) {
+ ex.printStackTrace(System.err);
+ return false;
+ }
+ i++;
+ }
+
+ // File path name where output will be put - default is stdout == Console
+ } else if (args[i].equals("-o") || args[i].equals("--output")) {
- if (i+1 < args.length) {
- this.outputFile = new File(args[i+1]);
- i += 2;
++ if (i + 1 < args.length) {
++ this.outputFile = new File(args[i + 1]);
++ i += 2;
+ } else {
+ System.err.println("Missing argument to " + args[i] + " command line option");
+ return false;
+ }
- // A list of specific test names (e.g.: -t IIA001 IIA007 IIIE301) - default is to run all tests
++ // A list of specific test names (e.g.: -t IIA001 IIA007 IIIE301) - default is to run all
++ // tests
+ } else if (args[i].equals("-t") || args[i].equals("--tests")) {
+ i++;
+ while (i < args.length && !args[i].startsWith("-")) {
+ testNamesToRun.add(args[i]);
+ i++;
+ }
+ if (testNamesToRun.size() == 0) {
+ System.err.println("Missing test names after -t or --tests argument");
+ return false;
+ }
- // Include full details in the response, both the expected reqsponse (from file) and the actual response
++ // Include full details in the response, both the expected reqsponse (from file) and the
++ // actual response
+ } else if (args[i].equals("-v") || args[i].equals("--verbose")) {
- this.verbose = true;
++ this.verbose = true;
+ i++;
+ // Report only failures (success is silent)
+ } else if (args[i].equals("-f") || args[i].equals("--failures")) {
- this.failuresOnly = true;
++ this.failuresOnly = true;
+ i++;
- // When set, the XML must not contain extra attibutes/elements. Default is "lenient" where unexpected entries are ignored
++ // When set, the XML must not contain extra attibutes/elements. Default is "lenient" where
++ // unexpected entries are ignored
+ } else if (args[i].equals("-s") || args[i].equals("--strict")) {
- this.strict = true;
++ this.strict = true;
+ i++;
+ // (self explanatory)
+ } else if (args[i].equals("--stop-on-error")) {
- this.stopOnFirstError = true;
++ this.stopOnFirstError = true;
+ i++;
+ } else if (args[i].equals("--lenient")) {
- lenientPolicies = true;
- lenientRequests = true;
++ lenientPolicies = true;
++ lenientRequests = true;
+ i++;
+ } else if (args[i].equals("--lenient-policies")) {
- lenientPolicies = true;
++ lenientPolicies = true;
+ i++;
+ } else if (args[i].equals("--lenient-requests")) {
- lenientRequests = true;
++ lenientRequests = true;
+ i++;
+ } else if (args[i].equals("--strict-policies")) {
- lenientPolicies = false;
++ lenientPolicies = false;
+ i++;
+ } else if (args[i].equals("--strict-requests")) {
- lenientRequests = false;
++ lenientRequests = false;
+ i++;
+ } else if (args[i].equals("--iterations")) {
+ // this is a count of how many ADDITIONAL times the decide() should be called.
+ // The first time decide() is called it takes a long time to set up,
- // so to get an accurate number for how fast a single Request is handled we need to ignore the time for the first run
++ // so to get an accurate number for how fast a single Request is handled we need to ignore the
++ // time for the first run
+ // and timings for 1 or more non-first-time calls to decide().
- if (i+1 < args.length) {
++ if (i + 1 < args.length) {
+ try {
- iterations = Integer.parseInt(args[i+1]);
- i += 2;
++ iterations = Integer.parseInt(args[i + 1]);
++ i += 2;
+ } catch (NumberFormatException ex) {
- System.err.println("Invalid iteration count '" + args[i+1] + "'");
++ System.err.println("Invalid iteration count '" + args[i + 1] + "'");
+ return false;
+ }
+ } else {
+ System.err.println("Missing argument to " + args[i] + " command line option");
+ return false;
+ }
+ if (iterations < 1) {
- System.err.println("Cannot use --iterations " + iterations + ". Must use an integer greater than 0");
++ System.err.println("Cannot use --iterations " + iterations
++ + ". Must use an integer greater than 0");
+ return false;
+ }
+ } else {
+ System.err.println("Unknown command line option " + args[i]);
+ return false;
+ }
+ }
+
- this.testEngine = new ConformanceTestEngine(this.getScopeResolver(), lenientRequests, lenientPolicies, iterations);
++ this.testEngine = new ConformanceTestEngine(this.getScopeResolver(), lenientRequests,
++ lenientPolicies, iterations);
+
+ if (testSetDirectoryNames.length() == 0) {
+ System.err.println("No test set directory given (need -i or --iniput command line option)");
+ return false;
+ }
+ if (testSet.getListConformanceTests().size() == 0) {
+ System.err.println("No tests in given directories: " + testSetDirectoryNames);
+ }
+
+ if (testNamesToRun.size() > 0) {
+ String s = "";
+ for (String name : testNamesToRun) {
+ s += ", " + name;
+ }
+ System.out.println("Tests limited to: " + s.substring(1));
+ }
+
+ if (this.outputFile == null) {
- this.outputFileWriter = new PrintWriter(System.out);
++ this.outputFileWriter = new PrintWriter(System.out);
+ } else {
+ try {
- this.outputFileWriter = new PrintWriter(new FileOutputStream(this.outputFile));
++ this.outputFileWriter = new PrintWriter(new FileOutputStream(this.outputFile));
+ } catch (IOException ex) {
+ System.err.println("Cannot open " + this.outputFile.getAbsolutePath() + " for writing.");
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private void printHelp() {
+ System.out.println("usage: Conformance --input <tests_directory> OPTIONS");
+ System.out.println("");
- System.out.println(" -f, --failures Only include failed tests in the output. \n"+
- " Default is to include all test's results in the output file.");
++ System.out
++ .println(" -f, --failures Only include failed tests in the output. \n"
++ + " Default is to include all test's results in the output file.");
+ System.out.println("");
- System.out.println(" -h, --help Prints help.");
++ System.out.println(" -h, --help Prints help.");
+
+ System.out.println("");
- System.out.println(" -i, --input <dir> Directory containing the XML Request/Response files. \n"+
- " This may be multiple space-separated directory paths. REQUIRED");
++ System.out
++ .println(" -i, --input <dir> Directory containing the XML Request/Response files. \n"
++ + " This may be multiple space-separated directory paths. REQUIRED");
+
+ System.out.println("");
- System.out.println(" --iterations The number of times to run through the set of tests in the input directory.");
++ System.out
++ .println(" --iterations The number of times to run through the set of tests in the input directory.");
+
+ System.out.println("");
- System.out.println(" --lenient Allow both Requests and Policies to have unexpected elements, no data in <Content>, etc. \n"+
- " Default is to not allow anything that is not explicitly listed in the XACML spec.");
++ System.out
++ .println(" --lenient Allow both Requests and Policies to have unexpected elements, no data in <Content>, etc. \n"
++ + " Default is to not allow anything that is not explicitly listed in the XACML spec.");
+
+ System.out.println("");
- System.out.println(" --lenient-policies Allow Policies to have unexpected elements, no data in <Content>, etc. \n" +
- " Default is to not allow anything that is not explicitly listed in the XACML spec.");
++ System.out
++ .println(" --lenient-policies Allow Policies to have unexpected elements, no data in <Content>, etc. \n"
++ + " Default is to not allow anything that is not explicitly listed in the XACML spec.");
+
+ System.out.println("");
- System.out.println(" --lenient-requests Allow Requests to have unexpected elements, no data in <Content>, etc. \n" +
- " Default is to not allow anything that is not explicitly listed in the XACML spec.");
++ System.out
++ .println(" --lenient-requests Allow Requests to have unexpected elements, no data in <Content>, etc. \n"
++ + " Default is to not allow anything that is not explicitly listed in the XACML spec.");
+
+ System.out.println("");
- System.out.println(" -o, --output <dir> Directory where the output results file will be put.");
++ System.out.println(" -o, --output <dir> Directory where the output results file will be put.");
+
+ System.out.println("");
- System.out.println(" -s, --strict Check both the Decision and all other parts of the Response (Attributes, Obligations and Advice). \n "+
- " Default is to check just the Decision.");
++ System.out
++ .println(" -s, --strict Check both the Decision and all other parts of the Response (Attributes, Obligations and Advice). \n "
++ + " Default is to check just the Decision.");
+
+ System.out.println("");
- System.out.println(" --stop-on-error Stop running conformance tests the first time one fails. Default is to continue through all tests.");
++ System.out
++ .println(" --stop-on-error Stop running conformance tests the first time one fails. Default is to continue through all tests.");
+
+ System.out.println("");
- System.out.println(" --strict-policies Require Policies to have no unexpected elements, data in <Content>, etc. \n" +
- " This is the default, but can be used to override Policies when option --lenient is used.");
++ System.out
++ .println(" --strict-policies Require Policies to have no unexpected elements, data in <Content>, etc. \n"
++ + " This is the default, but can be used to override Policies when option --lenient is used.");
+
+ System.out.println("");
- System.out.println(" --strict-requests Require Requests to have no unexpected elements, data in <Content>, etc. \n" +
- " This is the default, but can be used to override Requests when option --lenient is used.");
++ System.out
++ .println(" --strict-requests Require Requests to have no unexpected elements, data in <Content>, etc. \n"
++ + " This is the default, but can be used to override Requests when option --lenient is used.");
+
+ System.out.println("");
- System.out.println(" -t, --tests <list of test names> A space-separated list of specific tests to be run. \n" +
- " These are just the names of the tests as in 'IIA001 IIC178'. \n" +
- " Default is to run all tests in the input directory.");
++ System.out
++ .println(" -t, --tests <list of test names> A space-separated list of specific tests to be run. \n"
++ + " These are just the names of the tests as in 'IIA001 IIC178'. \n"
++ + " Default is to run all tests in the input directory.");
+
+ System.out.println("");
- System.out.println(" -v, --verbose The entire expected and actual Response objects in the output. \n"+
- " Default is just a summary line.");
++ System.out
++ .println(" -v, --verbose The entire expected and actual Response objects in the output. \n"
++ + " Default is just a summary line.");
+
+ }
+
+ private boolean failed(ConformanceTestResult conformanceTestResult) {
- ResponseMatchResult responseMatchResult = conformanceTestResult.getResponseMatchResult();
++ ResponseMatchResult responseMatchResult = conformanceTestResult.getResponseMatchResult();
+ if (responseMatchResult == null) {
+ return true;
+ }
+ if (!responseMatchResult.decisionsMatch() || !responseMatchResult.statusCodesMatch()) {
+ return true;
+ } else if (this.strict) {
- if (!responseMatchResult.associatedAdviceMatches() ||
- !responseMatchResult.attributesMatch() ||
- !responseMatchResult.obligationsMatch() ||
- !responseMatchResult.policyIdentifiersMatch() ||
- !responseMatchResult.policySetIdentifiersMatch()
- ) {
++ if (!responseMatchResult.associatedAdviceMatches() || !responseMatchResult.attributesMatch()
++ || !responseMatchResult.obligationsMatch() || !responseMatchResult.policyIdentifiersMatch()
++ || !responseMatchResult.policySetIdentifiersMatch()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private void dump(AttributeAssignment attributeAssignment) {
+ this.outputFileWriter.println("\t\t\t\tAttributeAssignment:");
+ if (attributeAssignment.getCategory() != null) {
- this.outputFileWriter.println("\t\t\t\t\tCategory: " + attributeAssignment.getCategory().stringValue());
++ this.outputFileWriter.println("\t\t\t\t\tCategory: "
++ + attributeAssignment.getCategory().stringValue());
+ }
+ if (attributeAssignment.getAttributeId() != null) {
- this.outputFileWriter.println("\t\t\t\t\tAttributeId: " + attributeAssignment.getAttributeId().stringValue());
++ this.outputFileWriter.println("\t\t\t\t\tAttributeId: "
++ + attributeAssignment.getAttributeId().stringValue());
+ }
+ if (attributeAssignment.getDataTypeId() != null) {
- this.outputFileWriter.println("\t\t\t\t\tDataType: " + attributeAssignment.getDataTypeId().stringValue());
++ this.outputFileWriter.println("\t\t\t\t\tDataType: "
++ + attributeAssignment.getDataTypeId().stringValue());
+ }
+ if (attributeAssignment.getIssuer() != null) {
+ this.outputFileWriter.println("\t\t\t\t\tIssuer: " + attributeAssignment.getIssuer());
+ }
- if (attributeAssignment.getAttributeValue() != null && attributeAssignment.getAttributeValue().getValue() != null) {
- this.outputFileWriter.println("\t\t\t\t\tValue: " + attributeAssignment.getAttributeValue().getValue().toString());
++ if (attributeAssignment.getAttributeValue() != null
++ && attributeAssignment.getAttributeValue().getValue() != null) {
++ this.outputFileWriter.println("\t\t\t\t\tValue: "
++ + attributeAssignment.getAttributeValue().getValue().toString());
+ }
+ }
+
+ private void dump(Attribute attribute) {
- this.outputFileWriter.println("\t\t\t\t\tAttribute: " + (attribute.getAttributeId() == null ? "" : attribute.getAttributeId().stringValue()));
++ this.outputFileWriter.println("\t\t\t\t\tAttribute: "
++ + (attribute.getAttributeId() == null ? "" : attribute.getAttributeId()
++ .stringValue()));
+ if (attribute.getIssuer() != null) {
+ this.outputFileWriter.println("\t\t\t\t\t\tIssuer: " + attribute.getIssuer());
+ }
- Iterator<AttributeValue<?>> iterAttributeValues = attribute.getValues().iterator();
++ Iterator<AttributeValue<?>> iterAttributeValues = attribute.getValues().iterator();
+ if (iterAttributeValues.hasNext()) {
+ this.outputFileWriter.println("\t\t\t\t\t\tValues: ");
+ while (iterAttributeValues.hasNext()) {
+ this.outputFileWriter.print("\t\t\t\t\t\t\t");
- AttributeValue<?> attributeValue = iterAttributeValues.next();
++ AttributeValue<?> attributeValue = iterAttributeValues.next();
+ if (attributeValue.getDataTypeId() != null) {
- this.outputFileWriter.print("DataType: " + attributeValue.getDataTypeId().stringValue() + " ");
++ this.outputFileWriter.print("DataType: " + attributeValue.getDataTypeId().stringValue()
++ + " ");
+ }
+ if (attributeValue.getValue() != null) {
+ this.outputFileWriter.print("Value: " + attributeValue.getValue().toString());
+ }
+ this.outputFileWriter.println();
+ }
+ }
+ }
+
+ private void dump(AttributeCategory attributeCategory) {
- this.outputFileWriter.println("\t\t\tAttributeCategory: " + (attributeCategory.getCategory() == null ? "" : attributeCategory.getCategory().stringValue()));
- Collection<Attribute> listAttributes = attributeCategory.getAttributes();
++ this.outputFileWriter.println("\t\t\tAttributeCategory: "
++ + (attributeCategory.getCategory() == null ? "" : attributeCategory
++ .getCategory().stringValue()));
++ Collection<Attribute> listAttributes = attributeCategory.getAttributes();
+ if (listAttributes.size() > 0) {
+ this.outputFileWriter.println("\t\t\t\tAttributes:");
- for (Attribute attribute: listAttributes) {
++ for (Attribute attribute : listAttributes) {
+ this.dump(attribute);
+ }
+ }
+ }
+
+ private void dump(Result result) {
+ this.outputFileWriter.println("\t\t======== Result ==========");
- this.outputFileWriter.println("\t\tDecision: " + (result.getDecision() == null ? "null" : result.getDecision().name()));
++ this.outputFileWriter
++ .println("\t\tDecision: " + (result.getDecision() == null ? "null" : result.getDecision().name()));
+ if (result.getStatus() == null) {
+ this.outputFileWriter.println("\t\tStatus: null");
+ } else {
+ this.outputFileWriter.println("\t\tStatus:");
+ if (result.getStatus().getStatusCode() != null) {
- this.outputFileWriter.println("\t\t\tStatusCode: " + result.getStatus().getStatusCode().toString());
++ this.outputFileWriter.println("\t\t\tStatusCode: "
++ + result.getStatus().getStatusCode().toString());
+ }
+ if (result.getStatus().getStatusMessage() != null) {
- this.outputFileWriter.println("\t\t\tStatusMessage: " + result.getStatus().getStatusMessage());
++ this.outputFileWriter
++ .println("\t\t\tStatusMessage: " + result.getStatus().getStatusMessage());
+ }
+ if (result.getStatus().getStatusDetail() != null) {
- this.outputFileWriter.println("\t\t\tStatusDetail: " + result.getStatus().getStatusDetail().toString());
++ this.outputFileWriter.println("\t\t\tStatusDetail: "
++ + result.getStatus().getStatusDetail().toString());
+ }
+ }
- Collection<Advice> listAdvice = result.getAssociatedAdvice();
++ Collection<Advice> listAdvice = result.getAssociatedAdvice();
+ if (listAdvice.size() > 0) {
+ this.outputFileWriter.println("\t\tAdvice:");
+ for (Advice advice : listAdvice) {
+ if (advice.getId() != null) {
+ this.outputFileWriter.println("\t\t\tId: " + advice.getId().stringValue());
+ }
- Collection<AttributeAssignment> attributeAssignments = advice.getAttributeAssignments();
++ Collection<AttributeAssignment> attributeAssignments = advice.getAttributeAssignments();
+ if (attributeAssignments.size() > 0) {
+ this.outputFileWriter.println("\t\t\tAttributeAssignments:");
- for (AttributeAssignment attributeAssignment: attributeAssignments) {
++ for (AttributeAssignment attributeAssignment : attributeAssignments) {
+ this.dump(attributeAssignment);
+ }
+ }
+ }
+ }
- Collection<Obligation> listObligations = result.getObligations();
++ Collection<Obligation> listObligations = result.getObligations();
+ if (listObligations.size() > 0) {
- for (Obligation obligation: listObligations) {
++ for (Obligation obligation : listObligations) {
+ if (obligation.getId() != null) {
+ this.outputFileWriter.println("\t\t\tId: " + obligation.getId().stringValue());
+ }
- Collection<AttributeAssignment> attributeAssignments = obligation.getAttributeAssignments();
++ Collection<AttributeAssignment> attributeAssignments = obligation.getAttributeAssignments();
+ if (attributeAssignments.size() > 0) {
+ this.outputFileWriter.println("\t\t\tAttributeAssignments:");
+ for (AttributeAssignment attributeAssignment : attributeAssignments) {
+ this.dump(attributeAssignment);
+ }
+ }
+ }
+ }
- Collection<AttributeCategory> listAttributeCategories = result.getAttributes();
++ Collection<AttributeCategory> listAttributeCategories = result.getAttributes();
+ if (listAttributeCategories.size() > 0) {
+ this.outputFileWriter.println("\t\tAttributes:");
+ for (AttributeCategory attributeCategory : listAttributeCategories) {
+ this.dump(attributeCategory);
+ }
+ }
+ Collection<IdReference> listIdReferences;
+ if ((listIdReferences = result.getPolicyIdentifiers()).size() > 0) {
+ this.outputFileWriter.println("\t\tPolicyIds:");
+ for (IdReference idReference : listIdReferences) {
+ this.outputFileWriter.println("\t\t\t" + idReference.toString());
+ }
+ }
+ if ((listIdReferences = result.getPolicySetIdentifiers()).size() > 0) {
+ this.outputFileWriter.println("\t\tPolicySetIds:");
+ for (IdReference idReference : listIdReferences) {
+ this.outputFileWriter.println("\t\t\t" + idReference.toString());
+ }
+ }
+ }
+
+ private void dump(String label, Response response) {
+ this.outputFileWriter.println("\t========== " + label + "==========");
+ if (response == null) {
+ this.outputFileWriter.println("null");
+ return;
+ }
+
+ for (Result result : response.getResults()) {
+ this.dump(result);
+ }
+ }
+
+ private void dump(ConformanceTestResult conformanceTestResult) {
+
- ResponseMatchResult responseMatchResult = conformanceTestResult.getResponseMatchResult();
++ ResponseMatchResult responseMatchResult = conformanceTestResult.getResponseMatchResult();
+ if (this.verbose) {
- this.outputFileWriter.println("========== Test " + conformanceTestResult.getConformanceTest().getTestName() + " ==========");
++ this.outputFileWriter.println("========== Test "
++ + conformanceTestResult.getConformanceTest().getTestName()
++ + " ==========");
+ this.dump("Expected Response", conformanceTestResult.getExpectedResponse());
+ this.dump("Actual Response", conformanceTestResult.getActualResponse());
+ if (responseMatchResult != null) {
+ this.outputFileWriter.println("\t========== Matching ==========");
+ this.outputFileWriter.println("\tDecisions Match? " + responseMatchResult.decisionsMatch());
- this.outputFileWriter.println("\tStatus Codes Match? " + responseMatchResult.statusCodesMatch());
++ this.outputFileWriter.println("\tStatus Codes Match? "
++ + responseMatchResult.statusCodesMatch());
+ this.outputFileWriter.println("\tAttributes Match? " + responseMatchResult.attributesMatch());
- this.outputFileWriter.println("\tPolicyIds Match? " + responseMatchResult.policyIdentifiersMatch());
- this.outputFileWriter.println("\tPolicySetIds Match? " + responseMatchResult.policySetIdentifiersMatch());
- this.outputFileWriter.println("\tAssociated Advice Match? " + responseMatchResult.associatedAdviceMatches());
- this.outputFileWriter.println("\tObligations Match? " + responseMatchResult.obligationsMatch());
++ this.outputFileWriter.println("\tPolicyIds Match? "
++ + responseMatchResult.policyIdentifiersMatch());
++ this.outputFileWriter.println("\tPolicySetIds Match? "
++ + responseMatchResult.policySetIdentifiersMatch());
++ this.outputFileWriter.println("\tAssociated Advice Match? "
++ + responseMatchResult.associatedAdviceMatches());
++ this.outputFileWriter.println("\tObligations Match? "
++ + responseMatchResult.obligationsMatch());
+ this.outputFileWriter.println("========== End ==========");
+ }
+ } else {
- String testName = conformanceTestResult.getConformanceTest().getTestName();
++ String testName = conformanceTestResult.getConformanceTest().getTestName();
+ if (responseMatchResult != null) {
- Iterator<ResultMatchResult> iterResultMatches = responseMatchResult.getResultMatchResults();
++ Iterator<ResultMatchResult> iterResultMatches = responseMatchResult.getResultMatchResults();
+ if (iterResultMatches == null || !iterResultMatches.hasNext()) {
+ this.outputFileWriter.println(testName);
+ } else {
+ while (iterResultMatches.hasNext()) {
- ResultMatchResult resultMatchResult = iterResultMatches.next();
- this.outputFileWriter.printf("%s,%s,%s,%s,%s,%s,%s,%s,%d,%d\n",
- testName,
++ ResultMatchResult resultMatchResult = iterResultMatches.next();
++ this.outputFileWriter.printf("%s,%s,%s,%s,%s,%s,%s,%s,%d,%d\n", testName,
+ resultMatchResult.decisionsMatch(),
+ resultMatchResult.statusCodesMatch(),
+ resultMatchResult.attributesMatch(),
+ resultMatchResult.policyIdentifiersMatch(),
+ resultMatchResult.policySetIdentifiersMatch(),
+ resultMatchResult.associatedAdviceMatches(),
+ resultMatchResult.obligationsMatch(),
+ conformanceTestResult.getFirstCallTime(),
- conformanceTestResult.getAverageTotalLoopTime()
- );
++ conformanceTestResult.getAverageTotalLoopTime());
+ }
+ }
+ }
+ }
+ this.outputFileWriter.flush();
+ }
+
+ private boolean run(ConformanceTest conformanceTest) throws Exception {
+ this.testsRun++;
- ConformanceTestResult conformanceTestResult = this.testEngine.run(conformanceTest);
- boolean bFailed = true;
++ ConformanceTestResult conformanceTestResult = this.testEngine.run(conformanceTest);
++ boolean bFailed = true;
+ if (conformanceTestResult != null) {
- ResponseMatchResult responseMatchResult = conformanceTestResult.getResponseMatchResult();
++ ResponseMatchResult responseMatchResult = conformanceTestResult.getResponseMatchResult();
+ if (responseMatchResult != null) {
+ if (responseMatchResult.decisionsMatch()) {
+ this.decisionsMatch++;
- this.statusCodesMatch += (responseMatchResult.statusCodesMatch() ? 1 : 0);
- this.attributesMatch += (responseMatchResult.attributesMatch() ? 1 : 0);
- this.policyIdsMatch += (responseMatchResult.policyIdentifiersMatch() ? 1 : 0);
- this.policySetIdsMatch += (responseMatchResult.policySetIdentifiersMatch() ? 1 : 0);
- this.associatedAdviceMatch += (responseMatchResult.associatedAdviceMatches() ? 1 : 0);
- this.obligationsMatch += (responseMatchResult.obligationsMatch() ? 1 : 0);
++ this.statusCodesMatch += (responseMatchResult.statusCodesMatch() ? 1 : 0);
++ this.attributesMatch += (responseMatchResult.attributesMatch() ? 1 : 0);
++ this.policyIdsMatch += (responseMatchResult.policyIdentifiersMatch() ? 1 : 0);
++ this.policySetIdsMatch += (responseMatchResult.policySetIdentifiersMatch() ? 1 : 0);
++ this.associatedAdviceMatch += (responseMatchResult.associatedAdviceMatches() ? 1 : 0);
++ this.obligationsMatch += (responseMatchResult.obligationsMatch() ? 1 : 0);
+ }
- this.unknownFunctions += (responseMatchResult.unknownFunction() ? 1 : 0);
- bFailed = this.failed(conformanceTestResult);
++ this.unknownFunctions += (responseMatchResult.unknownFunction() ? 1 : 0);
++ bFailed = this.failed(conformanceTestResult);
+ if (bFailed || !this.failuresOnly) {
+ this.dump(conformanceTestResult);
+ }
+ } else if (conformanceTestResult.getError() != null) {
+ this.outputFileWriter.println(conformanceTestResult.getError());
+ }
+ }
+ return (!bFailed || !this.stopOnFirstError);
+ }
+
+ private void run() throws Exception {
- long tStart = System.currentTimeMillis();
++ long tStart = System.currentTimeMillis();
+
+ if (!this.verbose) {
- this.outputFileWriter.println("Test,Decision,Status,Attributes,PolicyIds,PolicySetIds,Advice,Obligations");
++ this.outputFileWriter
++ .println("Test,Decision,Status,Attributes,PolicyIds,PolicySetIds,Advice,Obligations");
+ }
- Iterator<ConformanceTest> iterConformanceTests = this.testSet.getConformanceTests();
- boolean bContinue = true;
++ Iterator<ConformanceTest> iterConformanceTests = this.testSet.getConformanceTests();
++ boolean bContinue = true;
+ while (bContinue && iterConformanceTests.hasNext()) {
- // bContinue = this.run(iterConformanceTests.next());
++ // bContinue = this.run(iterConformanceTests.next());
+ ConformanceTest test = iterConformanceTests.next();
+ if (testNamesToRun.size() > 0) {
- if ( ! testNamesToRun.contains(test.getTestName())) {
++ if (!testNamesToRun.contains(test.getTestName())) {
+ continue;
+ }
+ }
- bContinue = this.run(test);
++ bContinue = this.run(test);
+ }
+
- long tElapsed = System.currentTimeMillis() - tStart;
++ long tElapsed = System.currentTimeMillis() - tStart;
+
+ if (this.verbose) {
+ this.outputFileWriter.println("Tests run = " + this.testsRun);
+ this.outputFileWriter.println("Decisions match = " + this.decisionsMatch);
+ this.outputFileWriter.println("Status Codes match = " + this.statusCodesMatch);
+ this.outputFileWriter.println("Attributes match = " + this.attributesMatch);
+ this.outputFileWriter.println("PolicyIds match = " + this.policyIdsMatch);
+ this.outputFileWriter.println("PolicySetIds match = " + this.policySetIdsMatch);
+ this.outputFileWriter.println("Associated Advice match = " + this.associatedAdviceMatch);
+ this.outputFileWriter.println("Obligations match = " + this.obligationsMatch);
+ this.outputFileWriter.println("Unknown functions = " + this.unknownFunctions);
+ } else {
- this.outputFileWriter.printf("Total (%d),%d,%d,%d,%d,%d,%d,%d,%d\n",
- this.testsRun,
- this.decisionsMatch,
- this.statusCodesMatch,
- this.attributesMatch,
- this.policyIdsMatch,
- this.policySetIdsMatch,
- this.associatedAdviceMatch,
- this.obligationsMatch,
++ this.outputFileWriter.printf("Total (%d),%d,%d,%d,%d,%d,%d,%d,%d\n", this.testsRun,
++ this.decisionsMatch, this.statusCodesMatch, this.attributesMatch,
++ this.policyIdsMatch, this.policySetIdsMatch,
++ this.associatedAdviceMatch, this.obligationsMatch,
+ this.unknownFunctions);
+ }
+
+ if (tElapsed > 0) {
- long tHours = tElapsed / (60*60*1000);
- tElapsed = tElapsed - tHours * 60 * 60 *1000;
- long tMinutes = tElapsed / (60*1000);
- tElapsed = tElapsed - tMinutes * 60 * 1000;
- long tSeconds = tElapsed / 1000;
- tElapsed = tElapsed - tSeconds * 1000;
-
- this.outputFileWriter.printf("Elapsed time = %02d:%02d:%02d.%03d\n", tHours, tMinutes, tSeconds, tElapsed);
- this.outputFileWriter.printf("First decide time in nano-seconds %d\n", this.testEngine.getFirstDecideTime());
- this.outputFileWriter.printf("Total Multiple decide time in nano-seconds %d\n", this.testEngine.getDecideTimeMultiple());
-
- this.outputFileWriter.printf("\nAverage First decide time in nano-seconds %d\n", this.testEngine.getAvgFirstDecideTime());
- this.outputFileWriter.printf("Average decide time after first call in nano-seconds %d\n", this.testEngine.getAvgDecideTimeMultiple());
++ long tHours = tElapsed / (60 * 60 * 1000);
++ tElapsed = tElapsed - tHours * 60 * 60 * 1000;
++ long tMinutes = tElapsed / (60 * 1000);
++ tElapsed = tElapsed - tMinutes * 60 * 1000;
++ long tSeconds = tElapsed / 1000;
++ tElapsed = tElapsed - tSeconds * 1000;
++
++ this.outputFileWriter.printf("Elapsed time = %02d:%02d:%02d.%03d\n", tHours, tMinutes, tSeconds,
++ tElapsed);
++ this.outputFileWriter.printf("First decide time in nano-seconds %d\n",
++ this.testEngine.getFirstDecideTime());
++ this.outputFileWriter.printf("Total Multiple decide time in nano-seconds %d\n",
++ this.testEngine.getDecideTimeMultiple());
++
++ this.outputFileWriter.printf("\nAverage First decide time in nano-seconds %d\n",
++ this.testEngine.getAvgFirstDecideTime());
++ this.outputFileWriter.printf("Average decide time after first call in nano-seconds %d\n",
++ this.testEngine.getAvgDecideTimeMultiple());
+ }
+ }
+
+ public Conformance() {
+ }
+
+ public static void main(String[] args) {
- Conformance conformance = new Conformance();
++ Conformance conformance = new Conformance();
+ try {
+ if (conformance.init(args)) {
+ conformance.run();
+ }
+
+ } catch (Exception ex) {
+ ex.printStackTrace(System.err);
+ System.exit(1);
+ } finally {
+ try {
+ conformance.close();
+ } catch (IOException ex) {
+ ex.printStackTrace(System.err);
+ }
+ }
+ System.exit(0);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-xacml-test/src/test/java/org/apache/openaz/xacml/pdp/test/conformance/ConformancePIPEngine.java
----------------------------------------------------------------------
diff --cc openaz-xacml-test/src/test/java/org/apache/openaz/xacml/pdp/test/conformance/ConformancePIPEngine.java
index 5edaec2,0000000..37d76d1
mode 100644,000000..100644
--- a/openaz-xacml-test/src/test/java/org/apache/openaz/xacml/pdp/test/conformance/ConformancePIPEngine.java
+++ b/openaz-xacml-test/src/test/java/org/apache/openaz/xacml/pdp/test/conformance/ConformancePIPEngine.java
@@@ -1,250 -1,0 +1,257 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+/*
+ * 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 org.apache.openaz.xacml.pdp.test.conformance;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.openaz.xacml.api.Attribute;
+import org.apache.openaz.xacml.api.AttributeValue;
+import org.apache.openaz.xacml.api.DataType;
+import org.apache.openaz.xacml.api.DataTypeException;
+import org.apache.openaz.xacml.api.DataTypeFactory;
+import org.apache.openaz.xacml.api.Identifier;
+import org.apache.openaz.xacml.api.pip.PIPException;
+import org.apache.openaz.xacml.api.pip.PIPFinder;
+import org.apache.openaz.xacml.api.pip.PIPRequest;
+import org.apache.openaz.xacml.api.pip.PIPResponse;
+import org.apache.openaz.xacml.std.IdentifierImpl;
+import org.apache.openaz.xacml.std.StdMutableAttribute;
+import org.apache.openaz.xacml.std.pip.StdPIPResponse;
+import org.apache.openaz.xacml.std.pip.engines.ConfigurableEngine;
+import org.apache.openaz.xacml.util.FactoryException;
+
+/**
- * ConformancePIPEngine implements the {@link org.apache.openaz.xacml.api.pip.PIPFinder} interface to find attributes
- * loaded from a text file containing the following fields:
- * category-id,attribute-id,datatype-id,issuer,value
- *
++ * ConformancePIPEngine implements the {@link com.att.research.xacml.api.pip.PIPFinder} interface to find
++ * attributes loaded from a text file containing the following fields:
++ * category-id,attribute-id,datatype-id,issuer,value
+ */
+public class ConformancePIPEngine implements ConfigurableEngine {
- public static final String PROP_DESCRIPTION = ".description";
- public static final String PROP_FILE = ".file";
++ public static final String PROP_DESCRIPTION = ".description";
++ public static final String PROP_FILE = ".file";
+
- private static final Log logger = LogFactory.getLog(ConformancePIPEngine.class);
++ private static final Log logger = LogFactory.getLog(ConformancePIPEngine.class);
+
+ private String name;
+ private String description;
- private Map<String,PIPResponse> cache = new HashMap<String,PIPResponse>();
- private List<Attribute> listAttributes = new ArrayList<Attribute>();
++ private Map<String, PIPResponse> cache = new HashMap<String, PIPResponse>();
++ private List<Attribute> listAttributes = new ArrayList<Attribute>();
+ private DataTypeFactory dataTypeFactory;
+
+ public ConformancePIPEngine() {
+
+ }
+
+ protected DataTypeFactory getDataTypeFactory() throws FactoryException {
+ if (this.dataTypeFactory == null) {
- this.dataTypeFactory = DataTypeFactory.newInstance();
++ this.dataTypeFactory = DataTypeFactory.newInstance();
+ }
+ return this.dataTypeFactory;
+ }
+
+ protected static String generateKey(PIPRequest pipRequest) {
- StringBuilder stringBuilder = new StringBuilder(pipRequest.getCategory().toString());
++ StringBuilder stringBuilder = new StringBuilder(pipRequest.getCategory().toString());
+ stringBuilder.append('+');
+ stringBuilder.append(pipRequest.getAttributeId().toString());
+ stringBuilder.append('+');
+ stringBuilder.append(pipRequest.getDataTypeId().toString());
- String issuer = pipRequest.getIssuer();
++ String issuer = pipRequest.getIssuer();
+ if (issuer != null) {
+ stringBuilder.append('+');
+ stringBuilder.append(issuer);
+ }
+ return stringBuilder.toString();
+ }
+
+ protected void store(String[] fields) throws FactoryException {
- DataTypeFactory thisDataTypeFactory = this.getDataTypeFactory();
- Identifier identifierCategory = new IdentifierImpl(fields[0]);
- Identifier identifierAttribute = new IdentifierImpl(fields[1]);
- Identifier identifierDataType = new IdentifierImpl(fields[2]);
- String issuer = (fields.length == 5 ? fields[3] : null);
- String value = fields[fields.length - 1];
-
- DataType<?> dataType = thisDataTypeFactory.getDataType(identifierDataType);
++ DataTypeFactory thisDataTypeFactory = this.getDataTypeFactory();
++ Identifier identifierCategory = new IdentifierImpl(fields[0]);
++ Identifier identifierAttribute = new IdentifierImpl(fields[1]);
++ Identifier identifierDataType = new IdentifierImpl(fields[2]);
++ String issuer = (fields.length == 5 ? fields[3] : null);
++ String value = fields[fields.length - 1];
++
++ DataType<?> dataType = thisDataTypeFactory.getDataType(identifierDataType);
+ if (dataType == null) {
+ logger.error("Unknown data type " + identifierDataType.stringValue());
+ return;
+ }
+
- AttributeValue<?> attributeValue = null;
++ AttributeValue<?> attributeValue = null;
+ try {
- attributeValue = dataType.createAttributeValue(value);
++ attributeValue = dataType.createAttributeValue(value);
+ } catch (DataTypeException ex) {
+ throw new FactoryException("DataTypeException creating AttributeValue", ex);
+ }
- Attribute attribute = new StdMutableAttribute(identifierCategory, identifierAttribute, attributeValue, issuer, false);
++ Attribute attribute = new StdMutableAttribute(identifierCategory, identifierAttribute,
++ attributeValue, issuer, false);
+ this.listAttributes.add(attribute);
+ }
+
+ public void loadAttributes(File fileAttributes) throws IOException, ParseException, FactoryException {
+ if (fileAttributes != null) {
+ if (!fileAttributes.exists()) {
- throw new FileNotFoundException("Attributes file " + fileAttributes.getAbsolutePath() + " not found.");
++ throw new FileNotFoundException("Attributes file " + fileAttributes.getAbsolutePath()
++ + " not found.");
+ } else if (!fileAttributes.canRead()) {
- throw new IOException("Attributes file " + fileAttributes.getAbsolutePath() + " is not readable.");
++ throw new IOException("Attributes file " + fileAttributes.getAbsolutePath()
++ + " is not readable.");
+ }
+
- BufferedReader bufferedReader = null;
++ BufferedReader bufferedReader = null;
+ try {
- bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(fileAttributes)));
++ bufferedReader = new BufferedReader(
++ new InputStreamReader(new FileInputStream(fileAttributes)));
+ String line;
+ while ((line = bufferedReader.readLine()) != null) {
+ if (line.length() > 0) {
- String[] fields = line.split("[|]",-1);
++ String[] fields = line.split("[|]", -1);
+ if (fields.length < 4) {
+ logger.warn("Not enough fields in record \"" + line + "\"");
+ continue;
+ }
+ this.store(fields);
+
+ }
+ }
+ } finally {
+ if (bufferedReader != null) {
+ bufferedReader.close();
+ }
+ }
+ }
+ }
+
+ protected Attribute findAttribute(PIPRequest pipRequest) {
- Attribute attributeResult = null;
- Iterator<Attribute> iterAttributes = this.listAttributes.iterator();
++ Attribute attributeResult = null;
++ Iterator<Attribute> iterAttributes = this.listAttributes.iterator();
+ while ((attributeResult == null) && iterAttributes.hasNext()) {
- Attribute attributeTest = iterAttributes.next();
- if (pipRequest.getCategory().equals(attributeTest.getCategory()) &&
- pipRequest.getAttributeId().equals(attributeTest.getAttributeId()) &&
- (pipRequest.getIssuer() == null || pipRequest.getIssuer().equals(attributeTest.getIssuer()))) {
- attributeResult = attributeTest;
++ Attribute attributeTest = iterAttributes.next();
++ if (pipRequest.getCategory().equals(attributeTest.getCategory())
++ && pipRequest.getAttributeId().equals(attributeTest.getAttributeId())
++ && (pipRequest.getIssuer() == null || pipRequest.getIssuer()
++ .equals(attributeTest.getIssuer()))) {
++ attributeResult = attributeTest;
+ }
+ }
+ return attributeResult;
+ }
+
+ @Override
+ public PIPResponse getAttributes(PIPRequest pipRequest, PIPFinder pipFinder) throws PIPException {
- String pipRequestKey = generateKey(pipRequest);
- PIPResponse pipResponse = this.cache.get(pipRequestKey);
++ String pipRequestKey = generateKey(pipRequest);
++ PIPResponse pipResponse = this.cache.get(pipRequestKey);
+ if (pipResponse != null) {
+ return pipResponse;
+ }
- Attribute attributeMatch = this.findAttribute(pipRequest);
++ Attribute attributeMatch = this.findAttribute(pipRequest);
+ if (attributeMatch == null) {
+ return StdPIPResponse.PIP_RESPONSE_EMPTY;
+ }
+ /*
+ * Iterate through the values and only return the ones that match the requested data type
+ */
- List<AttributeValue<?>> matchingValues = new ArrayList<AttributeValue<?>>();
- Iterator<AttributeValue<?>> iterAttributeValues = attributeMatch.getValues().iterator();
++ List<AttributeValue<?>> matchingValues = new ArrayList<AttributeValue<?>>();
++ Iterator<AttributeValue<?>> iterAttributeValues = attributeMatch.getValues().iterator();
+ while (iterAttributeValues.hasNext()) {
- AttributeValue<?> attributeValue = iterAttributeValues.next();
++ AttributeValue<?> attributeValue = iterAttributeValues.next();
+ if (pipRequest.getDataTypeId().equals(attributeValue.getDataTypeId())) {
+ matchingValues.add(attributeValue);
+ }
+ }
+ if (matchingValues.size() > 0) {
- Attribute attributeResponse = new StdMutableAttribute(attributeMatch.getCategory(), attributeMatch.getAttributeId(), matchingValues, attributeMatch.getIssuer(), false);
- pipResponse = new StdPIPResponse(attributeResponse);
++ Attribute attributeResponse = new StdMutableAttribute(attributeMatch.getCategory(),
++ attributeMatch.getAttributeId(),
++ matchingValues, attributeMatch.getIssuer(),
++ false);
++ pipResponse = new StdPIPResponse(attributeResponse);
+ this.cache.put(pipRequestKey, pipResponse);
+ }
+ return pipResponse;
+ }
+
+ @Override
+ public String getName() {
+ return this.name;
+ }
+
+ @Override
+ public String getDescription() {
+ return this.description;
+ }
+
+ @Override
+ public void configure(String id, Properties properties) throws PIPException {
- this.name = id;
- this.description = properties.getProperty(id + PROP_DESCRIPTION);
++ this.name = id;
++ this.description = properties.getProperty(id + PROP_DESCRIPTION);
+ if (this.description == null) {
- this.description = "PIPEngine for the Conformance tests that loads attributes from a CSV file";
++ this.description = "PIPEngine for the Conformance tests that loads attributes from a CSV file";
+ }
- String pipFile = properties.getProperty(id + PROP_FILE);
++ String pipFile = properties.getProperty(id + PROP_FILE);
+ if (pipFile != null) {
+ try {
+ this.loadAttributes(new File(pipFile));
+ } catch (Exception ex) {
+ logger.error("Exception loading PIP file " + pipFile, ex);
+ throw new PIPException("Exception loading PIP file " + pipFile, ex);
+ }
+ }
+ }
+
+ @Override
+ public Collection<PIPRequest> attributesRequired() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public Collection<PIPRequest> attributesProvided() {
+ //
+ // We could return everything in our list
+ //
+ return Collections.emptyList();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-xacml-test/src/test/java/org/apache/openaz/xacml/pdp/test/conformance/ConformanceRepository.java
----------------------------------------------------------------------
diff --cc openaz-xacml-test/src/test/java/org/apache/openaz/xacml/pdp/test/conformance/ConformanceRepository.java
index 594e693,0000000..9fa31c7
mode 100644,000000..100644
--- a/openaz-xacml-test/src/test/java/org/apache/openaz/xacml/pdp/test/conformance/ConformanceRepository.java
+++ b/openaz-xacml-test/src/test/java/org/apache/openaz/xacml/pdp/test/conformance/ConformanceRepository.java
@@@ -1,136 -1,0 +1,138 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+/*
+ * 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 org.apache.openaz.xacml.pdp.test.conformance;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.openaz.xacml.pdp.std.StdPolicyFinderFactory;
+import org.apache.openaz.xacml.util.StringUtils;
+import org.apache.openaz.xacml.util.XACMLProperties;
+
+/**
- * ConformanceRepository represents one or more policies for a single policy test, which will include one or more root policies, and
- * zero or more referenced policies.
- *
++ * ConformanceRepository represents one or more policies for a single policy test, which will include one or
++ * more root policies, and zero or more referenced policies.
+ */
+public class ConformanceRepository {
- private List<File> rootPolicies = new ArrayList<File>();
- private List<File> referencedPolicies = new ArrayList<File>();
++ private List<File> rootPolicies = new ArrayList<File>();
++ private List<File> referencedPolicies = new ArrayList<File>();
+
+ private void setXACMLProperty(String propertyName, List<File> listFiles) {
- Iterator<File> iterFiles = listFiles.iterator();
- StringBuilder stringBuilderIdList = new StringBuilder();
++ Iterator<File> iterFiles = listFiles.iterator();
++ StringBuilder stringBuilderIdList = new StringBuilder();
+ while (iterFiles.hasNext()) {
- File file = iterFiles.next();
++ File file = iterFiles.next();
+ if (stringBuilderIdList.length() > 0) {
+ stringBuilderIdList.append(',');
+ }
+ stringBuilderIdList.append(file.getName());
+
- XACMLProperties.setProperty(file.getName() + StdPolicyFinderFactory.PROP_FILE, file.getAbsolutePath());
++ XACMLProperties.setProperty(file.getName() + StdPolicyFinderFactory.PROP_FILE,
++ file.getAbsolutePath());
+ }
+ XACMLProperties.setProperty(propertyName, stringBuilderIdList.toString());
+ }
+
+ public ConformanceRepository() {
+ }
+
+ public void setXACMLProperties() {
+ if (this.rootPolicies.size() > 0) {
+ this.setXACMLProperty(XACMLProperties.PROP_ROOTPOLICIES, this.rootPolicies);
+ }
+ if (this.referencedPolicies.size() > 0) {
+ this.setXACMLProperty(XACMLProperties.PROP_REFERENCEDPOLICIES, this.referencedPolicies);
+ }
+ }
+
+ private void loadProperty(File fileDir, Properties properties, String propertyName, List<File> listFiles) {
- String fileNameList = properties.getProperty(propertyName);
++ String fileNameList = properties.getProperty(propertyName);
+ if (fileNameList != null) {
- String[] fileNameArray = fileNameList.split("[,]",0);
++ String[] fileNameArray = fileNameList.split("[,]", 0);
+ if (fileNameArray != null && fileNameArray.length > 0) {
+ for (String fileName : fileNameArray) {
- File file = new File(fileDir, fileName);
++ File file = new File(fileDir, fileName);
+ if (file.exists() && file.canRead()) {
+ listFiles.add(file);
+ }
+ }
+ }
+ }
+ }
+
+ public void load(File fileRepository) throws IOException {
- Properties propertiesRepository = new Properties();
++ Properties propertiesRepository = new Properties();
+ try (InputStream is = new FileInputStream(fileRepository)) {
+ propertiesRepository.load(is);
+ }
- this.loadProperty(fileRepository.getParentFile(), propertiesRepository, XACMLProperties.PROP_ROOTPOLICIES, this.rootPolicies);
- this.loadProperty(fileRepository.getParentFile(), propertiesRepository, XACMLProperties.PROP_REFERENCEDPOLICIES, this.referencedPolicies);
++ this.loadProperty(fileRepository.getParentFile(), propertiesRepository,
++ XACMLProperties.PROP_ROOTPOLICIES, this.rootPolicies);
++ this.loadProperty(fileRepository.getParentFile(), propertiesRepository,
++ XACMLProperties.PROP_REFERENCEDPOLICIES, this.referencedPolicies);
+ }
+
+ public void addRootPolicy(File filePolicy) {
+ this.rootPolicies.add(filePolicy);
+ }
+
+ public boolean hasRootPolicy() {
+ return (this.rootPolicies.size() > 0);
+ }
+
+ @Override
+ public String toString() {
- StringBuilder stringBuilder = new StringBuilder("{");
- boolean needComma = false;
++ StringBuilder stringBuilder = new StringBuilder("{");
++ boolean needComma = false;
+
+ if (this.rootPolicies != null && this.rootPolicies.size() > 0) {
+ stringBuilder.append("rootPolicies=");
+ stringBuilder.append(StringUtils.toString(this.rootPolicies.iterator()));
- needComma = true;
++ needComma = true;
+ }
+ if (this.referencedPolicies != null && this.referencedPolicies.size() > 0) {
+ if (needComma) {
+ stringBuilder.append(',');
+ }
+ stringBuilder.append("referencedPolicies=");
+ stringBuilder.append(StringUtils.toString(this.referencedPolicies.iterator()));
- needComma = true;
++ needComma = true;
+ }
+ stringBuilder.append('}');
+ return stringBuilder.toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-xacml-test/src/test/java/org/apache/openaz/xacml/pdp/test/conformance/ConformanceScopeResolver.java
----------------------------------------------------------------------
diff --cc openaz-xacml-test/src/test/java/org/apache/openaz/xacml/pdp/test/conformance/ConformanceScopeResolver.java
index 9a8404a,0000000..b52dd46
mode 100644,000000..100644
--- a/openaz-xacml-test/src/test/java/org/apache/openaz/xacml/pdp/test/conformance/ConformanceScopeResolver.java
+++ b/openaz-xacml-test/src/test/java/org/apache/openaz/xacml/pdp/test/conformance/ConformanceScopeResolver.java
@@@ -1,129 -1,0 +1,139 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+/*
+ * 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 org.apache.openaz.xacml.pdp.test.conformance;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.openaz.xacml.api.Attribute;
+import org.apache.openaz.xacml.api.AttributeValue;
+import org.apache.openaz.xacml.api.pdp.ScopeQualifier;
+import org.apache.openaz.xacml.api.pdp.ScopeResolver;
+import org.apache.openaz.xacml.api.pdp.ScopeResolverException;
+import org.apache.openaz.xacml.api.pdp.ScopeResolverResult;
+import org.apache.openaz.xacml.std.StdMutableAttribute;
+import org.apache.openaz.xacml.std.StdScopeResolverResult;
+import org.apache.openaz.xacml.std.StdStatus;
+import org.apache.openaz.xacml.std.StdStatusCode;
+import org.apache.openaz.xacml.std.datatypes.DataTypes;
+
+/**
- * ConformanceScopeResolver implements {@link com.att.research.xacml.pdp.ScopeResolver} for the conformance tests
- * using a fixed set of hierarchical resources defined in a map.
- *
++ * ConformanceScopeResolver implements {@link com.att.research.xacml.pdp.ScopeResolver} for the conformance
++ * tests using a fixed set of hierarchical resources defined in a map.
+ */
+public class ConformanceScopeResolver implements ScopeResolver {
- private Log logger = LogFactory.getLog(ConformanceScopeResolver.class);
- private Map<URI, List<URI>> mapIdentifierToChildren = new HashMap<URI,List<URI>>();
++ private Log logger = LogFactory.getLog(ConformanceScopeResolver.class);
++ private Map<URI, List<URI>> mapIdentifierToChildren = new HashMap<URI, List<URI>>();
+
+ public ConformanceScopeResolver() {
+ }
+
+ public void add(URI identifierRoot, URI identifierChild) {
- List<URI> listChildrenRoot = this.mapIdentifierToChildren.get(identifierRoot);
++ List<URI> listChildrenRoot = this.mapIdentifierToChildren.get(identifierRoot);
+ if (listChildrenRoot == null) {
- listChildrenRoot = new ArrayList<URI>();
++ listChildrenRoot = new ArrayList<URI>();
+ this.mapIdentifierToChildren.put(identifierRoot, listChildrenRoot);
+ }
+ listChildrenRoot.add(identifierChild);
+ }
+
- private void addChildren(Attribute attributeResourceId, URI urnResourceIdValue, boolean bDescendants, List<Attribute> listAttributes) {
- List<URI> listChildren = this.mapIdentifierToChildren.get(urnResourceIdValue);
++ private void addChildren(Attribute attributeResourceId, URI urnResourceIdValue, boolean bDescendants,
++ List<Attribute> listAttributes) {
++ List<URI> listChildren = this.mapIdentifierToChildren.get(urnResourceIdValue);
+ if (listChildren != null) {
+ for (URI uriChild : listChildren) {
- AttributeValue<URI> attributeValueURI = null;
++ AttributeValue<URI> attributeValueURI = null;
+ try {
- attributeValueURI = DataTypes.DT_ANYURI.createAttributeValue(uriChild);
++ attributeValueURI = DataTypes.DT_ANYURI.createAttributeValue(uriChild);
+ if (attributeValueURI != null) {
- listAttributes.add(new StdMutableAttribute(attributeResourceId.getCategory(), attributeResourceId.getAttributeId(), attributeValueURI, attributeResourceId.getIssuer(), attributeResourceId.getIncludeInResults()));
++ listAttributes.add(new StdMutableAttribute(attributeResourceId.getCategory(),
++ attributeResourceId.getAttributeId(),
++ attributeValueURI, attributeResourceId
++ .getIssuer(), attributeResourceId
++ .getIncludeInResults()));
+ }
+ } catch (Exception ex) {
+ this.logger.error("Exception converting URI to an AttributeValue");
+ }
+ if (bDescendants) {
+ this.addChildren(attributeResourceId, uriChild, bDescendants, listAttributes);
+ }
+ }
+ }
+ }
+
- private void addChildren(Attribute attributeResourceId, boolean bDescendants, List<Attribute> listAttributes) {
++ private void addChildren(Attribute attributeResourceId, boolean bDescendants,
++ List<Attribute> listAttributes) {
+ /*
+ * Iterate over the values that are URNs
+ */
- Iterator<AttributeValue<URI>> iterAttributeValueURNs = attributeResourceId.findValues(DataTypes.DT_ANYURI);
++ Iterator<AttributeValue<URI>> iterAttributeValueURNs = attributeResourceId
++ .findValues(DataTypes.DT_ANYURI);
+ if (iterAttributeValueURNs != null) {
+ while (iterAttributeValueURNs.hasNext()) {
- this.addChildren(attributeResourceId, iterAttributeValueURNs.next().getValue(), bDescendants, listAttributes);
++ this.addChildren(attributeResourceId, iterAttributeValueURNs.next().getValue(), bDescendants,
++ listAttributes);
+ }
+ }
+ }
+
+ @Override
- public ScopeResolverResult resolveScope(Attribute attributeResourceId, ScopeQualifier scopeQualifier) throws ScopeResolverException {
- List<Attribute> listAttributes = new ArrayList<Attribute>();
- switch(scopeQualifier) {
++ public ScopeResolverResult resolveScope(Attribute attributeResourceId, ScopeQualifier scopeQualifier)
++ throws ScopeResolverException {
++ List<Attribute> listAttributes = new ArrayList<Attribute>();
++ switch (scopeQualifier) {
+ case CHILDREN:
+ listAttributes.add(attributeResourceId);
+ this.addChildren(attributeResourceId, false, listAttributes);
+ break;
+ case DESCENDANTS:
+ listAttributes.add(attributeResourceId);
+ this.addChildren(attributeResourceId, true, listAttributes);
+ break;
+ case IMMEDIATE:
+ listAttributes.add(attributeResourceId);
+ break;
+ default:
+ this.logger.error("Unknown ScopeQualifier: " + scopeQualifier.name());
- return new StdScopeResolverResult(new StdStatus(StdStatusCode.STATUS_CODE_SYNTAX_ERROR, "Unknown ScopeQualifier " + scopeQualifier.name()));
++ return new StdScopeResolverResult(
++ new StdStatus(StdStatusCode.STATUS_CODE_SYNTAX_ERROR,
++ "Unknown ScopeQualifier " + scopeQualifier.name()));
+ }
+ return new StdScopeResolverResult(listAttributes);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-xacml-test/src/test/java/org/apache/openaz/xacml/pdp/test/conformance/ConformanceTest.java
----------------------------------------------------------------------
diff --cc openaz-xacml-test/src/test/java/org/apache/openaz/xacml/pdp/test/conformance/ConformanceTest.java
index 61cccfd,0000000..447c044
mode 100644,000000..100644
--- a/openaz-xacml-test/src/test/java/org/apache/openaz/xacml/pdp/test/conformance/ConformanceTest.java
+++ b/openaz-xacml-test/src/test/java/org/apache/openaz/xacml/pdp/test/conformance/ConformanceTest.java
@@@ -1,113 -1,0 +1,122 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+/*
+ * 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 org.apache.openaz.xacml.pdp.test.conformance;
+
+import java.io.File;
+
+/**
- * ConformanceTest represents a collection of XACML files with a root Policy document, optional referenced Policy documents, a Request, and a Response.
- *
++ * ConformanceTest represents a collection of XACML files with a root Policy document, optional referenced
++ * Policy documents, a Request, and a Response.
+ */
+public class ConformanceTest {
+ private String testName;
+ private File request;
+ private File response;
+ private ConformanceRepository repository;
+
- public ConformanceTest(String name, ConformanceRepository conformanceRepository, File fileRequest, File fileResponse) {
- this.testName = name;
- this.request = fileRequest;
- this.response = fileResponse;
- this.repository = conformanceRepository;
++ public ConformanceTest(String name, ConformanceRepository conformanceRepository, File fileRequest,
++ File fileResponse) {
++ this.testName = name;
++ this.request = fileRequest;
++ this.response = fileResponse;
++ this.repository = conformanceRepository;
+ }
+
+ public ConformanceTest(String name) {
- this.testName = name;
++ this.testName = name;
+ }
+
+ public String getTestName() {
+ return this.testName;
+ }
++
+ public void setTestName(String s) {
- this.testName = s;
++ this.testName = s;
+ }
++
+ public ConformanceRepository getRepository() {
+ if (this.repository == null) {
- this.repository = new ConformanceRepository();
++ this.repository = new ConformanceRepository();
+ }
+ return this.repository;
+ }
++
+ public File getRequest() {
+ return this.request;
+ }
++
+ public void setRequest(File f) {
- this.request = f;
++ this.request = f;
+ }
++
+ public File getResponse() {
+ return this.response;
+ }
++
+ public void setResponse(File f) {
- this.response = f;
++ this.response = f;
+ }
+
+ public boolean isComplete() {
- return this.getTestName() != null && this.getRepository() != null && this.getRepository().hasRootPolicy() && this.getRequest() != null && this.getResponse() != null;
++ return this.getTestName() != null && this.getRepository() != null
++ && this.getRepository().hasRootPolicy() && this.getRequest() != null
++ && this.getResponse() != null;
+ }
+
+ @Override
+ public String toString() {
- StringBuilder stringBuilder = new StringBuilder();
- boolean needColon = false;
++ StringBuilder stringBuilder = new StringBuilder();
++ boolean needColon = false;
+ if (this.getTestName() != null) {
+ stringBuilder.append(this.getTestName());
- needColon = true;
++ needColon = true;
+ }
+ if (this.getRepository() != null) {
+
+ }
+ if (this.getRequest() != null) {
+ if (needColon) {
+ stringBuilder.append(':');
+ }
+ stringBuilder.append(this.getRequest().getName());
- needColon = true;
++ needColon = true;
+ }
+ if (this.getResponse() != null) {
+ if (needColon) {
+ stringBuilder.append(':');
+ }
+ stringBuilder.append(this.getResponse().getName());
- needColon = true;
++ needColon = true;
+ }
+ return stringBuilder.toString();
+ }
+
+}