View Javadoc

1   /*
2    * SymmetricDS is an open source database synchronization solution.
3    *   
4    * Copyright (C) Chris Henson <chenson42@users.sourceforge.net>
5    *
6    * This library is free software; you can redistribute it and/or
7    * modify it under the terms of the GNU Lesser General Public
8    * License as published by the Free Software Foundation; either
9    * version 3 of the License, or (at your option) any later version.
10   *
11   * This library is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   * Lesser General Public License for more details.
15   *
16   * You should have received a copy of the GNU Lesser General Public
17   * License along with this library; if not, see
18   * <http://www.gnu.org/licenses/>.
19   */
20  package org.jumpmind.symmetric.test;
21  
22  import org.apache.commons.logging.Log;
23  import org.apache.commons.logging.LogFactory;
24  import org.jumpmind.symmetric.common.Constants;
25  import org.jumpmind.symmetric.model.Trigger;
26  import org.jumpmind.symmetric.service.IConfigurationService;
27  import org.jumpmind.symmetric.test.ParameterizedSuite.ParameterMatcher;
28  import org.junit.Assert;
29  import org.junit.Test;
30  import org.springframework.jdbc.core.JdbcTemplate;
31  
32  public class FunkyDataTypesTest extends AbstractDatabaseTest {
33  
34      static final Log logger = LogFactory.getLog(FunkyDataTypesTest.class);
35      static final String TABLE_NAME = "test_oracle_dates";
36  
37      public FunkyDataTypesTest(String dbName) {
38          super(dbName);
39      }
40      
41      public FunkyDataTypesTest() throws Exception {
42          super();
43      }
44  
45      @Test
46      @ParameterMatcher("oracle")
47      public void testOraclePrecisionTimestamp() {
48          JdbcTemplate jdbcTemplate = getJdbcTemplate();
49          try {
50              jdbcTemplate.update("drop table " + TABLE_NAME + "");
51          } catch (Exception ex) {
52              logger.info("The table did not exist.");
53          }
54          jdbcTemplate.update("create table " + TABLE_NAME + " (id char(5) not null, ts timestamp(6), ts2 timestamp(9))");
55          IConfigurationService configService = find(Constants.CONFIG_SERVICE);
56          Trigger trigger = new Trigger();
57          trigger.setChannelId("other");
58          trigger.setSourceGroupId(TestConstants.TEST_CONTINUOUS_NODE_GROUP);
59          trigger.setTargetGroupId(TestConstants.TEST_CONTINUOUS_NODE_GROUP);
60          trigger.setSourceTableName(TABLE_NAME);
61          trigger.setSyncOnInsert(true);
62          trigger.setSyncOnUpdate(true);
63          trigger.setSyncOnDelete(true);
64          configService.insert(trigger);
65          getSymmetricEngine().syncTriggers();
66          jdbcTemplate.update("insert into " + TABLE_NAME
67                  + " values('00000',timestamp'2008-01-01 00:00:00.000',timestamp'2008-01-01 00:00:00.000')");
68          Assert.assertEquals("The data event from the other database's other_table was not captured.", jdbcTemplate.queryForInt("select count(*) from sym_data_event where channel_id='other'"),
69                  1);
70      }
71  }