-
Notifications
You must be signed in to change notification settings - Fork 76
/
JdbcItemWriterTest.java
37 lines (31 loc) · 1.37 KB
/
JdbcItemWriterTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
* Copyright (c) 2015 Red Hat, Inc. and/or its affiliates.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
*/
package org.jberet.support.io;
import org.junit.Test;
import javax.batch.operations.BatchRuntimeException;
import static org.junit.Assert.*;
import static org.jberet.support.io.JdbcItemWriter.determineParameterNames;
@SuppressWarnings("SpellCheckingInspection")
public class JdbcItemWriterTest {
@Test
public void normal() throws Exception {
final String sql = "INSERT INTO forex (symbol, ts, bid_open, bid_high, bid_low, bid_close, volume) " +
"values ('USDJPY', ?, ?, ?, ?, ?, ?)";
final String[] actual = determineParameterNames(sql);
final String[] expected = {"ts", "bid_open", "bid_high", "bid_low", "bid_close", "volume"};
assertArrayEquals(expected, actual);
}
@Test(expected = BatchRuntimeException.class)
public void canNotDetermine() throws Exception {
final String sql = "INSERT INTO forex (symbol, ts, bid_open, bid_high, bid_low, bid_close, volume) " +
"values ('USDJPY', parsedatetime('yyyyMMdd HHmmss', ?), ?, ?, ?, ?, ?)";
determineParameterNames(sql);
}
}