Search in sources :

Example 6 with Matchable

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

the class Test_DbFolder method getMetaDataCountsSecondPolling.

@Test
public void getMetaDataCountsSecondPolling() throws Exception {
    DbStorage storage = new DbStorage(new MockDbProvider());
    Matchable folder = storage.getFolder(new DbSearchTerm(""));
    folder.open();
    folder.getNewMetaData();
    folder.getNewMetaData();
    assertEquals("Total DB records: 2, new DB records: 0", folder.getMetaDataCounts());
    folder.close();
}
Also used : DbStorage(com.axway.ats.rbv.db.DbStorage) DbSearchTerm(com.axway.ats.rbv.db.DbSearchTerm) Matchable(com.axway.ats.rbv.storage.Matchable) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Example 7 with Matchable

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

the class Test_DbFolder method getMetaDataCounts.

@Test
public void getMetaDataCounts() throws Exception {
    DbStorage storage = new DbStorage(new MockDbProvider());
    Matchable folder = storage.getFolder(new DbSearchTerm(""));
    folder.open();
    folder.getNewMetaData();
    assertEquals("Total DB records: 2, new DB records: 2", folder.getMetaDataCounts());
    folder.close();
}
Also used : DbStorage(com.axway.ats.rbv.db.DbStorage) DbSearchTerm(com.axway.ats.rbv.db.DbSearchTerm) Matchable(com.axway.ats.rbv.storage.Matchable) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Example 8 with Matchable

use of com.axway.ats.rbv.storage.Matchable 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 9 with Matchable

use of com.axway.ats.rbv.storage.Matchable 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)

Example 10 with Matchable

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

the class Test_SimpleMonitorListener method evaluateMonitorsMultipleMonitorsEndOnFirstMatchNegative.

@Test
public void evaluateMonitorsMultipleMonitorsEndOnFirstMatchNegative() 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 dbRuleRight = new DbStringFieldRule("", "key1", "value10", MatchRelation.EQUALS, "evaluateMonitorsMultipleMonitorsEndOnFirstMatchNegative1", true);
    DbFieldsRule dbRuleWrong = new DbStringFieldRule("", "table1", "value10", MatchRelation.EQUALS, "evaluateMonitorsMultipleMonitorsEndOnFirstMatchNegative2", true);
    Monitor monitor1 = new Monitor("monitor1", matchable1, dbRuleRight, pollingParams, true, true, false);
    Monitor monitor2 = new Monitor("monitor2", matchable2, dbRuleRight, pollingParams, true, true, false);
    Monitor monitor3 = new Monitor("monitor3", matchable3, dbRuleWrong, pollingParams, true, true, false);
    List<Monitor> monitors = new ArrayList<Monitor>();
    monitors.add(monitor1);
    monitors.add(monitor2);
    monitors.add(monitor3);
    SimpleMonitorListener listener = new SimpleMonitorListener(monitors);
    assertFalse(listener.evaluateMonitors(TIME_END_POLL));
}
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) DbStringFieldRule(com.axway.ats.rbv.db.rules.DbStringFieldRule) Matchable(com.axway.ats.rbv.storage.Matchable) Test(org.junit.Test)

Aggregations

DbSearchTerm (com.axway.ats.rbv.db.DbSearchTerm)22 DbStorage (com.axway.ats.rbv.db.DbStorage)22 Matchable (com.axway.ats.rbv.storage.Matchable)22 Test (org.junit.Test)22 BaseTest (com.axway.ats.rbv.BaseTest)14 Monitor (com.axway.ats.rbv.Monitor)8 SimpleMonitorListener (com.axway.ats.rbv.SimpleMonitorListener)8 MockDbProvider (com.axway.ats.rbv.db.MockDbProvider)8 DbFieldsRule (com.axway.ats.rbv.db.rules.DbFieldsRule)8 DbStringFieldRule (com.axway.ats.rbv.db.rules.DbStringFieldRule)8 ArrayList (java.util.ArrayList)8 PollingParameters (com.axway.ats.rbv.PollingParameters)3 MetaData (com.axway.ats.rbv.MetaData)2