/*-
* ============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.
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) {
* ============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.
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;
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 {
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