X-Git-Url: https://gerrit.onap.org/r/gitweb?p=policy%2Fengine.git;a=blobdiff_plain;f=POLICY-SDK-APP%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fadmin%2FRESTfulPAPEngine.java;h=fc1a70466453c0ccf4ac42daaf4500d312028331;hp=a500c1dbe90242d9961f0265ab114c78e4c37354;hb=dfd9c0a09c35e4b5b4b61be08b8424e4a3d0d500;hpb=e1fe7fcff0568f6376c3392ddf761b3aa0601587 diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/RESTfulPAPEngine.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/RESTfulPAPEngine.java index a500c1dbe..fc1a70466 100644 --- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/RESTfulPAPEngine.java +++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/RESTfulPAPEngine.java @@ -29,6 +29,7 @@ import com.att.research.xacml.util.XACMLProperties; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.type.CollectionType; + import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -37,6 +38,7 @@ import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.net.HttpURLConnection; import java.net.URL; +import java.net.URLConnection; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.Arrays; @@ -45,6 +47,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Set; + import org.apache.commons.io.IOUtils; import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; @@ -258,8 +261,6 @@ public class RESTfulPAPEngine extends StdPDPItemSetChangeNotifier implements PAP "policyType=" + policyType); } - - @Override public void publishPolicy(String id, String name, boolean isRoot, InputStream policy, OnapPDPGroup group) throws PAPException { @@ -379,12 +380,10 @@ public class RESTfulPAPEngine extends StdPDPItemSetChangeNotifier implements PAP } } - URL url = new URL(fullURL); - // // Open up the connection // - connection = (HttpURLConnection) url.openConnection(); + connection = (HttpURLConnection) makeConnection(fullURL); // // Setup our method and headers // @@ -527,4 +526,10 @@ public class RESTfulPAPEngine extends StdPDPItemSetChangeNotifier implements PAP LOGGER.info("JSON response from PAP: " + json); return json; } + + // these may be overridden by junit tests + + protected URLConnection makeConnection(String fullURL) throws IOException { + return new URL(fullURL).openConnection(); + } }