aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common/model-impl
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2018-07-11 11:00:58 -0400
committerJim Hahn <jrh3@att.com>2018-07-11 14:45:28 -0400
commit42afe260e4434b4a7311e9bce5ad4675887e11e3 (patch)
treec2dae69698159d3155810c490249efb9842235e4 /controlloop/common/model-impl
parent865dd094c03a145dc0588534263d1a62fef809eb (diff)
Username & password should be optional for VFC
Also updated licenses. Replace tabs with spaces in new junit method. Updated licenses again. Change-Id: Iebff19353c052e59bfd69da1677e9a05c44592a0 Issue-ID: POLICY-869 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'controlloop/common/model-impl')
-rw-r--r--controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java6
-rw-r--r--controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVFCManager.java36
2 files changed, 19 insertions, 23 deletions
diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java
index 175223968..9a7bf8894 100644
--- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java
+++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2017 Intel Corp. All rights reserved.
+ * Copyright (C) 2017-2018 Intel Corp, AT&T. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -54,7 +54,9 @@ public final class VFCManager implements Runnable {
restManager = new RESTManager();
- setVFCParams(getPEManagerEnvProperty("vfc.url"), getPEManagerEnvProperty("vfc.username"), getPEManagerEnvProperty("vfc.password"));
+ // use getPEManagerEnvProperty() for required properties; others are optional
+ setVFCParams(getPEManagerEnvProperty("vfc.url"), PolicyEngine.manager.getEnvironmentProperty("vfc.username"),
+ PolicyEngine.manager.getEnvironmentProperty("vfc.password"));
}
public void setVFCParams(String baseUrl, String name, String pwd) {
diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVFCManager.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVFCManager.java
index 9260430d4..fa2a1ee9f 100644
--- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVFCManager.java
+++ b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVFCManager.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* vfc
* ================================================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
+ * Copyright (C) 2018 Ericsson, AT&T. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@ import java.util.List;
import java.util.UUID;
import org.drools.core.WorkingMemory;
+import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -104,6 +105,13 @@ public class TestVFCManager {
response.setResponseDescriptor(responseDescriptor);
}
+ @After
+ public void tearDown() {
+ PolicyEngine.manager.getEnvironment().remove("vfc.password");
+ PolicyEngine.manager.getEnvironment().remove("vfc.username");
+ PolicyEngine.manager.getEnvironment().remove("vfc.url");
+ }
+
@Test
public void testVFCInitiation() {
try {
@@ -129,31 +137,17 @@ public class TestVFCManager {
catch (IllegalArgumentException e) {
assertEquals("The value of policy engine manager environment property \"vfc.url\" may not be null", e.getMessage());
}
-
+
+ // add url; username & password are not required
PolicyEngine.manager.getEnvironment().put("vfc.url", "http://somewhere.over.the.rainbow");
- try {
- new VFCManager(mockedWorkingMemory, request);
- fail("test should throw an exception here");
- }
- catch (IllegalArgumentException e) {
- assertEquals("The value of policy engine manager environment property \"vfc.username\" may not be null", e.getMessage());
- }
+ new VFCManager(mockedWorkingMemory, request);
+ // url & username, but no password
PolicyEngine.manager.getEnvironment().put("vfc.username", "Dorothy");
- try {
- new VFCManager(mockedWorkingMemory, request);
- fail("test should throw an exception here");
- }
- catch (IllegalArgumentException e) {
- assertEquals("The value of policy engine manager environment property \"vfc.password\" may not be null", e.getMessage());
- }
+ // url, username, and password
PolicyEngine.manager.getEnvironment().put("vfc.password", "Toto");
- assertNotNull(new VFCManager(mockedWorkingMemory, request));
-
- PolicyEngine.manager.getEnvironment().remove("vfc.password");
- PolicyEngine.manager.getEnvironment().remove("vfc.username");
- PolicyEngine.manager.getEnvironment().remove("vfc.url");
+ new VFCManager(mockedWorkingMemory, request);
}
@Test