Search in sources :

Example 1 with Monitor

use of com.axway.ats.rbv.Monitor in project ats-framework by Axway.

the class Test_SimpleMonitorListener method verifyMatch_IntiallyNoMatch_ButThenFoundAMatch.

@Test
public void verifyMatch_IntiallyNoMatch_ButThenFoundAMatch() throws RbvException {
    DbFieldsRule dbRule = new DbStringFieldRule("", "test_key", "test_value_changed", MatchRelation.EQUALS, "IntiallyNoMatch_ButThenFoundAMatch", true);
    Monitor monitor = new Monitor("monitor1", matchable, dbRule, pollingParams, true, true, false);
    List<Monitor> monitors = new ArrayList<Monitor>();
    monitors.add(monitor);
    changeDBValues(3 * POLLING_INTERVAL);
    SimpleMonitorListener listener = new SimpleMonitorListener(monitors);
    long before = System.currentTimeMillis();
    assertTrue(listener.evaluateMonitors(TIME_END_POLL));
    long after = System.currentTimeMillis();
    System.out.println("IntiallyNoMatch_ButThenFoundAMatch: Actual poll duration: " + (after - before) + "ms.");
    assertTrue(after - before > TIME_AFTER_START_POLL && after - before < TIME_END_POLL);
}
Also used : Monitor(com.axway.ats.rbv.Monitor) SimpleMonitorListener(com.axway.ats.rbv.SimpleMonitorListener) ArrayList(java.util.ArrayList) DbFieldsRule(com.axway.ats.rbv.db.rules.DbFieldsRule) DbStringFieldRule(com.axway.ats.rbv.db.rules.DbStringFieldRule) Test(org.junit.Test)

Example 2 with Monitor

use of com.axway.ats.rbv.Monitor in project ats-framework by Axway.

the class Test_SimpleMonitorListener method evaluateMonitorsMultipleMonitorsEndOnFirstMatchExpectedFalseNegative.

@Test
public void evaluateMonitorsMultipleMonitorsEndOnFirstMatchExpectedFalseNegative() throws RbvException {
    final int pollingAttempts = 4;
    PollingParameters longPollingParams = new PollingParameters(0, POLLING_INTERVAL, pollingAttempts);
    DbStorage storage = new DbStorage(new MockDbProvider());
    Matchable matchable1 = storage.getFolder(new DbSearchTerm(""));
    Matchable matchable2 = storage.getFolder(new DbSearchTerm(""));
    Matchable matchable3 = storage.getFolder(new DbSearchTerm(""));
    DbFieldsRule dbRule = new DbStringFieldRule("", "key1", "value10", MatchRelation.EQUALS, "evaluateMonitorsMultipleMonitorsEndOnFirstMatchExpectedFalseNegative", true);
    Monitor monitor1 = new Monitor("monitor1", matchable1, dbRule, longPollingParams, false, true, false);
    Monitor monitor2 = new Monitor("monitor2", matchable2, dbRule, longPollingParams, false, true, false);
    Monitor monitor3 = new Monitor("monitor3", matchable3, dbRule, longPollingParams, false, true, false);
    List<Monitor> monitors = new ArrayList<Monitor>();
    monitors.add(monitor1);
    monitors.add(monitor2);
    monitors.add(monitor3);
    long timeBefore = System.currentTimeMillis();
    SimpleMonitorListener listener = new SimpleMonitorListener(monitors);
    assertFalse(listener.evaluateMonitors(pollingAttempts * POLLING_INTERVAL));
    long timeAfter = System.currentTimeMillis();
    //make sure more than (3 * poling interval) seconds have passed
    //this means that all iteration ware executed
    assertTrue(timeAfter - timeBefore > (pollingAttempts - 1) * POLLING_INTERVAL - 500);
}
Also used : DbSearchTerm(com.axway.ats.rbv.db.DbSearchTerm) ArrayList(java.util.ArrayList) DbFieldsRule(com.axway.ats.rbv.db.rules.DbFieldsRule) Matchable(com.axway.ats.rbv.storage.Matchable) Monitor(com.axway.ats.rbv.Monitor) DbStorage(com.axway.ats.rbv.db.DbStorage) SimpleMonitorListener(com.axway.ats.rbv.SimpleMonitorListener) PollingParameters(com.axway.ats.rbv.PollingParameters) MockDbProvider(com.axway.ats.rbv.db.MockDbProvider) DbStringFieldRule(com.axway.ats.rbv.db.rules.DbStringFieldRule) Test(org.junit.Test)

Example 3 with Monitor

use of com.axway.ats.rbv.Monitor in project ats-framework by Axway.

the class Test_SimpleMonitorListener method monitorGetAllMachingMetaData.

@Test
public void monitorGetAllMachingMetaData() throws RbvException {
    DbFieldsRule dbRule = new DbStringFieldRule("", "key1", "value101", MatchRelation.EQUALS, "monitorGetAllMachingMetaData", false);
    Monitor monitor = new Monitor("monitor1", matchable, dbRule, pollingParams, true, false, false);
    List<Monitor> monitors = new ArrayList<Monitor>();
    monitors.add(monitor);
    SimpleMonitorListener listener = new SimpleMonitorListener(monitors);
    listener.evaluateMonitors(TIME_END_POLL);
    List<MetaData> matchingMetaData = monitor.getAllMatchedMetaData();
    assertEquals(1, matchingMetaData.size());
    ArrayList<String> results = new ArrayList<String>();
    results.add((String) matchingMetaData.get(0).getProperty("key1"));
    assertTrue(results.contains("value10") || results.contains("value00"));
}
Also used : Monitor(com.axway.ats.rbv.Monitor) SimpleMonitorListener(com.axway.ats.rbv.SimpleMonitorListener) MetaData(com.axway.ats.rbv.MetaData) ArrayList(java.util.ArrayList) DbFieldsRule(com.axway.ats.rbv.db.rules.DbFieldsRule) DbStringFieldRule(com.axway.ats.rbv.db.rules.DbStringFieldRule) Test(org.junit.Test)

Example 4 with Monitor

use of com.axway.ats.rbv.Monitor in project ats-framework by Axway.

the class Test_SimpleMonitorListener method verifyNoMatch_NoMatch.

@Test
public void verifyNoMatch_NoMatch() throws RbvException {
    DbFieldsRule dbRule = new DbStringFieldRule("", "key1", "value00_no_match", MatchRelation.EQUALS, "verifyNoMatch_NoMatch", true);
    Monitor monitor = new Monitor("monitor1", matchable, dbRule, pollingParams, false, true, false);
    List<Monitor> monitors = new ArrayList<Monitor>();
    monitors.add(monitor);
    SimpleMonitorListener listener = new SimpleMonitorListener(monitors);
    long before = System.currentTimeMillis();
    assertTrue(listener.evaluateMonitors(TIME_END_POLL));
    long after = System.currentTimeMillis();
    assertTrue(after - before <= POLLING_INTERVAL);
}
Also used : Monitor(com.axway.ats.rbv.Monitor) SimpleMonitorListener(com.axway.ats.rbv.SimpleMonitorListener) ArrayList(java.util.ArrayList) DbFieldsRule(com.axway.ats.rbv.db.rules.DbFieldsRule) DbStringFieldRule(com.axway.ats.rbv.db.rules.DbStringFieldRule) Test(org.junit.Test)

Example 5 with Monitor

use of com.axway.ats.rbv.Monitor in project ats-framework by Axway.

the class Test_SimpleMonitorListener method evaluateMonitorsMultipleMonitorsNegativeTimeoutExceeded.

@Test
public void evaluateMonitorsMultipleMonitorsNegativeTimeoutExceeded() throws RbvException {
    DbStorage storage = new DbStorage(new MockDbProvider());
    Matchable matchable1 = storage.getFolder(new DbSearchTerm(""));
    Matchable matchable2 = storage.getFolder(new DbSearchTerm(""));
    Matchable matchable3 = storage.getFolder(new DbSearchTerm(""));
    DbFieldsRule dbRule = new DbStringFieldRule("", "key1", "value10", MatchRelation.EQUALS, "evaluateMonitorsMultipleMonitorsNegativeTimeoutExceeded", true);
    PollingParameters longPolling = new PollingParameters(100, 1000, 5);
    Monitor monitor1 = new Monitor("monitor1", matchable1, dbRule, longPolling, true, false, false);
    Monitor monitor2 = new Monitor("monitor2", matchable2, dbRule, longPolling, true, false, false);
    Monitor monitor3 = new Monitor("monitor3", matchable3, dbRule, longPolling, true, false, false);
    List<Monitor> monitors = new ArrayList<Monitor>();
    monitors.add(monitor1);
    monitors.add(monitor2);
    monitors.add(monitor3);
    SimpleMonitorListener listener = new SimpleMonitorListener(monitors);
    assertFalse(listener.evaluateMonitors(1000));
}
Also used : Monitor(com.axway.ats.rbv.Monitor) DbStorage(com.axway.ats.rbv.db.DbStorage) SimpleMonitorListener(com.axway.ats.rbv.SimpleMonitorListener) DbSearchTerm(com.axway.ats.rbv.db.DbSearchTerm) ArrayList(java.util.ArrayList) DbFieldsRule(com.axway.ats.rbv.db.rules.DbFieldsRule) MockDbProvider(com.axway.ats.rbv.db.MockDbProvider) PollingParameters(com.axway.ats.rbv.PollingParameters) DbStringFieldRule(com.axway.ats.rbv.db.rules.DbStringFieldRule) Matchable(com.axway.ats.rbv.storage.Matchable) Test(org.junit.Test)

Aggregations

Monitor (com.axway.ats.rbv.Monitor)34 SimpleMonitorListener (com.axway.ats.rbv.SimpleMonitorListener)33 DbFieldsRule (com.axway.ats.rbv.db.rules.DbFieldsRule)33 DbStringFieldRule (com.axway.ats.rbv.db.rules.DbStringFieldRule)33 ArrayList (java.util.ArrayList)33 Test (org.junit.Test)33 DbSearchTerm (com.axway.ats.rbv.db.DbSearchTerm)8 DbStorage (com.axway.ats.rbv.db.DbStorage)8 MockDbProvider (com.axway.ats.rbv.db.MockDbProvider)8 Matchable (com.axway.ats.rbv.storage.Matchable)8 PollingParameters (com.axway.ats.rbv.PollingParameters)4 MetaData (com.axway.ats.rbv.MetaData)2 ConfigurationException (com.axway.ats.config.exceptions.ConfigurationException)1 RbvException (com.axway.ats.rbv.model.RbvException)1 RbvVerificationException (com.axway.ats.rbv.model.RbvVerificationException)1