1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.jumpmind.symmetric.test;
21
22 import org.jumpmind.symmetric.common.Constants;
23 import org.jumpmind.symmetric.model.Trigger;
24 import org.jumpmind.symmetric.service.IConfigurationService;
25 import org.jumpmind.symmetric.test.ParameterizedSuite.ParameterMatcher;
26 import org.junit.Assert;
27 import org.junit.Test;
28 import org.springframework.jdbc.core.JdbcTemplate;
29
30 public class CrossCatalogSyncTest extends AbstractDatabaseTest {
31
32 public CrossCatalogSyncTest(String db) {
33 super(db);
34 }
35
36 public CrossCatalogSyncTest() throws Exception {
37 super();
38 }
39
40 @Test
41 @ParameterMatcher("mysql")
42 public void testCrossCatalogSyncOnMySQL() {
43 JdbcTemplate jdbcTemplate = getJdbcTemplate();
44 jdbcTemplate.update("drop database if exists other ");
45 jdbcTemplate.update("create database other");
46 String db = (String) jdbcTemplate.queryForObject("select database()", String.class);
47 jdbcTemplate.update("use other");
48 jdbcTemplate.update("create table other_table (id char(5) not null, name varchar(40), primary key(id))");
49 jdbcTemplate.update("use " + db);
50 IConfigurationService configService = find(Constants.CONFIG_SERVICE);
51 Trigger trigger = new Trigger();
52 trigger.setChannelId("other");
53 trigger.setSourceGroupId(TestConstants.TEST_CONTINUOUS_NODE_GROUP);
54 trigger.setTargetGroupId(TestConstants.TEST_CONTINUOUS_NODE_GROUP);
55 trigger.setSourceCatalogName("other");
56 trigger.setSourceTableName("other_table");
57 trigger.setSyncOnInsert(true);
58 trigger.setSyncOnUpdate(true);
59 trigger.setSyncOnDelete(true);
60 configService.insert(trigger);
61 getSymmetricEngine().syncTriggers();
62 jdbcTemplate.update("insert into other.other_table values('00000','first row')");
63 Assert.assertEquals("The data event from the other database's other_table was not captured.", jdbcTemplate
64 .queryForInt("select count(*) from sym_data_event where channel_id='other'"), 1);
65 }
66 }