Skip to content

Commit

Permalink
The entire test suite should be working on H2 at this point.
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Jul 18, 2009
1 parent 5bf1a01 commit f9edb31
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,8 @@ public Object doInPreparedStatement(PreparedStatement ps) throws SQLException, D
}

/**
* Select batches to process. Batches that are NOT in error will be returned
* first. They will be ordered by batch id as the batches will have already
* been created by {@link #buildOutgoingBatches(String)} in channel priority
* order.
* Select batches to process. Batches that are NOT in error will be returned first. They will be ordered by batch id
* as the batches will have already been created by {@link #buildOutgoingBatches(String)} in channel priority order.
*/
@SuppressWarnings("unchecked")
public List<OutgoingBatch> getOutgoingBatches(String nodeId) {
Expand Down Expand Up @@ -128,12 +126,14 @@ private List<OutgoingBatch> filterMaxNumberOfOutgoingBatchesByChannel(List<Outgo
if (batches != null && batches.size() > 0) {
List<OutgoingBatch> filtered = new ArrayList<OutgoingBatch>(batches.size());
for (NodeChannel channel : channels) {
int max = channel.getMaxBatchToSend();
int count = 0;
for (OutgoingBatch outgoingBatch : batches) {
if (channel.getId().equals(outgoingBatch.getChannelId()) && count < max) {
filtered.add(outgoingBatch);
count++;
if (channel.isEnabled()) {
int max = channel.getMaxBatchToSend();
int count = 0;
for (OutgoingBatch outgoingBatch : batches) {
if (channel.getId().equals(outgoingBatch.getChannelId()) && count < max) {
filtered.add(outgoingBatch);
count++;
}
}
}
}
Expand Down Expand Up @@ -187,13 +187,13 @@ public boolean isUnsentDataOnChannelForNode(String channelId, String nodeId) {
if (unsentCount > 0) {
return true;
}

// Do we need to check for unbatched data?
// int unbatchedCount = jdbcTemplate.queryForInt(getSql("unbatchedCountForNodeIdChannelIdSql"), new Object[] {
// nodeId, channelId });
// if (unbatchedCount > 0) {
// return true;
// }
// int unbatchedCount = jdbcTemplate.queryForInt(getSql("unbatchedCountForNodeIdChannelIdSql"), new Object[] {
// nodeId, channelId });
// if (unbatchedCount > 0) {
// return true;
// }

return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ protected void routeData(Data data, Map<String, Long> transactionIdDataId, IRout
// TODO We really shouldn't be referencing the bootstrapService from
// here ... maybe this method needs to move to the configurationService
Trigger trigger = bootstrapService.getCachedTriggers(false).get((data.getTriggerHistory().getTriggerId()));
if (trigger == null) {
trigger = configurationService.getTriggerById(data.getTriggerHistory().getTriggerId());
if (trigger == null) {
throw new IllegalStateException(String.format("Could not find trigger with the id of %s", data.getTriggerHistory().getTriggerId()));
}
}
Table table = dbDialect.getMetaDataFor(trigger, true);
DataMetaData dataMetaData = new DataMetaData(data, table, trigger, routingContext.getChannel());
if (trigger != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ public void testFindIdentity() throws Exception {
@Test
public void testFindPullNodes() throws Exception {
List<Node> list = nodeService.findNodesToPull();
assertEquals(list.size(), 4, "Wrong number of pull nodes");
assertEquals(list.size(), 3, "Wrong number of pull nodes");
}

@Test
public void testFindPushNodes() throws Exception {
List<Node> list = nodeService.findNodesToPushTo();
assertEquals(list.size(), 1, "Wrong number of push nodes");
assertEquals(list.size(), 4, "Wrong number of push nodes");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.jumpmind.symmetric.common.Constants;
import org.jumpmind.symmetric.model.Data;
import org.jumpmind.symmetric.model.DataEventType;
import org.jumpmind.symmetric.model.NodeChannel;
import org.jumpmind.symmetric.model.OutgoingBatch;
import org.jumpmind.symmetric.model.TriggerHistory;
import org.jumpmind.symmetric.service.IConfigurationService;
Expand Down Expand Up @@ -73,6 +74,10 @@ public void setUp() {

@Test
public void testDisabledChannel() {
NodeChannel channel = configService.getChannel(TestConstants.TEST_CHANNEL_ID);
channel.setEnabled(false);
configService.saveChannel(channel);

cleanSlate(TestConstants.TEST_PREFIX + "data_event", TestConstants.TEST_PREFIX + "data",
TestConstants.TEST_PREFIX + "outgoing_batch");
int size = 50; // magic number
Expand All @@ -87,6 +92,9 @@ public void testDisabledChannel() {
List<OutgoingBatch> list = batchService.getOutgoingBatches(TestConstants.TEST_CLIENT_EXTERNAL_ID);
assertNotNull(list);
assertEquals(list.size(), 0);

channel.setEnabled(true);
configService.saveChannel(channel);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,6 @@ public void syncIncomingBatchTest() throws Exception {

}

@Test
public void testSyncBackToNode() {

}

@Test
@ParameterExcluder("postgres")
public void validateTransactionFunctionailty() throws Exception {
Expand Down
6 changes: 6 additions & 0 deletions symmetric/src/test/resources/test-database-setup.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ insert into sym_node_group values ('symmetric','a group representing symmetric c
insert into sym_node_group values ('test-root-group','a test config');
insert into sym_node_group values ('test-node-group','a test config');
insert into sym_node_group values ('test-node-group2','another test config');
insert into sym_node_group values ('test-group-for-root-to-pull','another test config');
insert into sym_node_group values ('unit-test-only','a group used for unit testing');
insert into sym_node_group_link values ('test-root-group','test-root-group', 'P');
insert into sym_node_group_link values ('test-root-group','test-node-group2', 'P');
insert into sym_node_group_link values ('test-root-group','test-node-group', 'W');
insert into sym_node_group_link values ('test-group-for-root-to-pull','test-root-group', 'W');
insert into sym_node_group_link values ('test-node-group','test-root-group', 'P');
insert into sym_node_group_link values ('symmetric','test-root-group', 'P');
insert into sym_node values ('00000', 'test-root-group', '00000', 1, 'internal://root', '1', '1.4.0-SNAPSHOT','H2', '1.1', current_timestamp, null, '00000');
Expand All @@ -17,6 +19,10 @@ insert into sym_node values ('00002', 'test-node-group', '00002', 0, null, null,
insert into sym_node values ('00003', 'test-node-group', '00003', 1, 'http://localhost:8080/', '0', '1.4.0-SNAPSHOT', 'H2', '4', current_timestamp, null, '00000');
insert into sym_node values ('00010', 'test-node-group2', '00010', 1, null, null, '1.4.0-SNAPSHOT', null, null, current_timestamp, null, '00000');
insert into sym_node values ('00011', 'test-node-group2', '00011', 1, null, null, '1.4.0-SNAPSHOT', null, null, current_timestamp, null, '00000');
insert into sym_node values ('pull1', 'test-group-for-root-to-pull', 'test', 1, 'http://localhost:8080/sync', '1', '1.4.0-SNAPSHOT', 'H2', '5.0', current_timestamp, null, '00000');
insert into sym_node values ('pull2', 'test-group-for-root-to-pull', 'test', 1, null, null, '1.4.0-SNAPSHOT', null, null, current_timestamp, null, '00000');
insert into sym_node values ('pull3', 'test-group-for-root-to-pull', 'test', 1, 'http://localhost:8080/', '0', '1.4.0-SNAPSHOT', 'H2', '4', current_timestamp, null, '00000');


insert into sym_node values ('55555', 'test-node-group2', '00011', 1, 'http://snoopdog.com', null, '1.4.0-SNAPSHOT', null, null, current_timestamp, null, '00000');

Expand Down

0 comments on commit f9edb31

Please sign in to comment.