- //@Test
- @SuppressWarnings("deprecation")
- public void testSendEventFail() {
- eventAttributes = null;
- try {
- policyResponse = policyEngine.sendEvent(eventAttributes);
- } catch (PolicyEventException e) {
- logger.warn(e.getMessage());
- }
- assertNull(policyResponse);
- }
-
- //@Test
- @SuppressWarnings("deprecation")
- public void testSendEventFailNull() {
- eventAttributes.put("", "");
- try {
- policyResponse = policyEngine.sendEvent(eventAttributes);
- } catch (PolicyEventException e) {
- logger.warn(e.getMessage());
- }
- assertNull(policyResponse);
- }
-
- // deprecated Test.
- /*@Test
- public void testSendEventFailAttribute() {
- eventAttributes.put("Fail.key", "Value");
- try {
- policyResponse = policyEngine.sendEvent(eventAttributes);
- } catch (PolicyEventException e) {
- logger.warn(e.getMessage());
- }
- assertNull(policyResponse.getPolicyResponseMessage());
- }*/
-
- //@Test
- @SuppressWarnings("deprecation")
- public void testSendEventNotValid() {
- eventAttributes.put("Action.fail", "Value");
- try {
- policyResponse = policyEngine.sendEvent(eventAttributes);
- } catch (PolicyEventException e) {
- logger.warn(e.getMessage());
- }
- for(PolicyResponse policyResponse: this.policyResponse){
- logger.info(policyResponse.getPolicyResponseMessage() + " , " + policyResponse.getPolicyResponseStatus());
- assertNotNull(policyResponse);
- assertEquals(PolicyResponseStatus.NO_ACTION_REQUIRED, policyResponse.getPolicyResponseStatus());
- assertNotNull(policyResponse.getPolicyResponseMessage());
- assertNotNull(policyResponse.getRequestAttributes());
- assertNull(policyResponse.getActionTaken());
- assertNull(policyResponse.getActionAdvised());
- }
- }
-
- //@Test
- @SuppressWarnings("deprecation")
- public void testSendEventActionAdvised() {
- eventAttributes.put("Key", "Value");
- eventAttributes.put("cpu", "80");
- try {
- policyResponse = policyEngine.sendEvent(eventAttributes);
- } catch (PolicyEventException e) {
- logger.warn(e.getMessage());
- }
- for(PolicyResponse policyResponse: this.policyResponse){
- logger.info(policyResponse.getPolicyResponseMessage() + " , " + policyResponse.getPolicyResponseStatus());
- assertNotNull(policyResponse);
- assertEquals(PolicyResponseStatus.ACTION_ADVISED, policyResponse.getPolicyResponseStatus());
- assertNotNull(policyResponse.getPolicyResponseMessage());
- assertNotNull(policyResponse.getRequestAttributes());
- assertNull(policyResponse.getActionTaken());
- assertNotNull(policyResponse.getActionAdvised());
- }
- }
-
- //@Test
- @SuppressWarnings("deprecation")
- public void testSendEventActionTaken() {
- eventAttributes.put("Key", "Value");
- eventAttributes.put("cpu", "91");
- try {
- policyResponse = policyEngine.sendEvent(eventAttributes);
- } catch (PolicyEventException e) {
- logger.warn(e.getMessage());
- }
- for(PolicyResponse policyResponse: this.policyResponse){
- logger.info(policyResponse.getPolicyResponseMessage() + " , " + policyResponse.getPolicyResponseStatus());
- assertNotNull(policyResponse);
- assertEquals(PolicyResponseStatus.ACTION_TAKEN, policyResponse.getPolicyResponseStatus());
- assertNotNull(policyResponse.getPolicyResponseMessage());
- assertNotNull(policyResponse.getRequestAttributes());
- assertNotNull(policyResponse.getActionTaken());
- assertNull(policyResponse.getActionAdvised());
- }
- }
+ private PolicyEngine policyEngine = null;
+ private Map<String, String> eventAttributes = new HashMap<String, String>();
+ private Collection<PolicyResponse> policyResponse = null;
+ private static final Logger logger = FlexLogger.getLogger(SendEventTest.class);
+
+ @Before
+ public void setUp() {
+ try {
+ policyEngine = new PolicyEngine("Test/config_pass.properties");
+ } catch (PolicyEngineException e) {
+ logger.error(e.getMessage());
+ fail("PolicyEngine Instantiation Error" + e);
+ }
+ logger.info("Loaded.. PolicyEngine");
+ }
+
+ // @Test
+ @SuppressWarnings("deprecation")
+ public void testSendEventFail() {
+ eventAttributes = null;
+ try {
+ policyResponse = policyEngine.sendEvent(eventAttributes);
+ } catch (PolicyEventException e) {
+ logger.warn(e.getMessage());
+ }
+ assertNull(policyResponse);
+ }
+
+ // @Test
+ @SuppressWarnings("deprecation")
+ public void testSendEventFailNull() {
+ eventAttributes.put("", "");
+ try {
+ policyResponse = policyEngine.sendEvent(eventAttributes);
+ } catch (PolicyEventException e) {
+ logger.warn(e.getMessage());
+ }
+ assertNull(policyResponse);
+ }
+
+ // @Test
+ @SuppressWarnings("deprecation")
+ public void testSendEventNotValid() {
+ eventAttributes.put("Action.fail", "Value");
+ try {
+ policyResponse = policyEngine.sendEvent(eventAttributes);
+ } catch (PolicyEventException e) {
+ logger.warn(e.getMessage());
+ }
+ for (PolicyResponse policyResponse : this.policyResponse) {
+ logger.info(policyResponse.getPolicyResponseMessage() + " , "
+ + policyResponse.getPolicyResponseStatus());
+ assertNotNull(policyResponse);
+ assertEquals(PolicyResponseStatus.NO_ACTION_REQUIRED,
+ policyResponse.getPolicyResponseStatus());
+ assertNotNull(policyResponse.getPolicyResponseMessage());
+ assertNotNull(policyResponse.getRequestAttributes());
+ assertNull(policyResponse.getActionTaken());
+ assertNull(policyResponse.getActionAdvised());
+ }
+ }
+
+ // @Test
+ @SuppressWarnings("deprecation")
+ public void testSendEventActionAdvised() {
+ eventAttributes.put("Key", "Value");
+ eventAttributes.put("cpu", "80");
+ try {
+ policyResponse = policyEngine.sendEvent(eventAttributes);
+ } catch (PolicyEventException e) {
+ logger.warn(e.getMessage());
+ }
+ for (PolicyResponse policyResponse : this.policyResponse) {
+ logger.info(policyResponse.getPolicyResponseMessage() + " , "
+ + policyResponse.getPolicyResponseStatus());
+ assertNotNull(policyResponse);
+ assertEquals(PolicyResponseStatus.ACTION_ADVISED,
+ policyResponse.getPolicyResponseStatus());
+ assertNotNull(policyResponse.getPolicyResponseMessage());
+ assertNotNull(policyResponse.getRequestAttributes());
+ assertNull(policyResponse.getActionTaken());
+ assertNotNull(policyResponse.getActionAdvised());
+ }
+ }
+
+ // @Test
+ @SuppressWarnings("deprecation")
+ public void testSendEventActionTaken() {
+ eventAttributes.put("Key", "Value");
+ eventAttributes.put("cpu", "91");
+ try {
+ policyResponse = policyEngine.sendEvent(eventAttributes);
+ } catch (PolicyEventException e) {
+ logger.warn(e.getMessage());
+ }
+ for (PolicyResponse policyResponse : this.policyResponse) {
+ logger.info(policyResponse.getPolicyResponseMessage() + " , "
+ + policyResponse.getPolicyResponseStatus());
+ assertNotNull(policyResponse);
+ assertEquals(PolicyResponseStatus.ACTION_TAKEN,
+ policyResponse.getPolicyResponseStatus());
+ assertNotNull(policyResponse.getPolicyResponseMessage());
+ assertNotNull(policyResponse.getRequestAttributes());
+ assertNotNull(policyResponse.getActionTaken());
+ assertNull(policyResponse.getActionAdvised());
+ }
+ }