Remove trailing whitespace in source files
find . -type f -name "*.java" -or -name "*.aj" | \
xargs perl -p -i -e "s/[ \t]*$//g" {} \;
Issue: SPR-10127
This commit is contained in:
committed by
Chris Beams
parent
44a474a014
commit
1762157ad1
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2002-2005 the original author or authors.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
|
||||
/*
|
||||
* Copyright 2002-2005 the original author or authors.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2002-2005 the original author or authors.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
*/
|
||||
/*
|
||||
* Copyright 2002-2005 the original author or authors.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@@ -37,7 +37,7 @@ public abstract class AbstractJdbcTests extends TestCase {
|
||||
protected DataSource mockDataSource;
|
||||
protected MockControl ctrlConnection;
|
||||
protected Connection mockConnection;
|
||||
|
||||
|
||||
/**
|
||||
* Set to true if the user wants verification, indicated
|
||||
* by a call to replay(). We need to make this optional,
|
||||
|
||||
@@ -110,16 +110,16 @@ public class InitializeDatabaseIntegrationTests {
|
||||
JdbcTemplate t = new JdbcTemplate(dataSource);
|
||||
assertEquals(1, t.queryForInt("select count(*) from T_TEST"));
|
||||
}
|
||||
|
||||
|
||||
public static class CacheData implements InitializingBean {
|
||||
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
private List<Map<String,Object>> cache;
|
||||
|
||||
|
||||
public void setDataSource(DataSource dataSource) {
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
|
||||
public List<Map<String,Object>> getCachedData() {
|
||||
return cache;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ public class InitializeDatabaseIntegrationTests {
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
cache = jdbcTemplate.queryForList("SELECT * FROM T_TEST");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@ public class JdbcTemplateQueryTests extends AbstractJdbcTests {
|
||||
|
||||
public void testQueryForObjectThrowsIncorrectResultSizeForMoreThanOneRow() throws Exception {
|
||||
String sql = "select pass from t_account where first_name='Alef'";
|
||||
|
||||
|
||||
mockResultSetMetaData.getColumnCount();
|
||||
ctrlResultSetMetaData.setReturnValue(1);
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ import org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor;
|
||||
import org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractorAdapter;
|
||||
import org.springframework.util.LinkedCaseInsensitiveMap;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Mock object based tests for JdbcTemplate.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
@@ -737,12 +737,12 @@ public class JdbcTemplateTests extends AbstractJdbcTests {
|
||||
try {
|
||||
template.batchUpdate(sql);
|
||||
fail("Shouldn't have executed batch statement with a select");
|
||||
}
|
||||
}
|
||||
catch (DataAccessException ex) {
|
||||
// pass
|
||||
assertTrue("Check exception type", ex.getClass() == InvalidDataAccessApiUsageException.class);
|
||||
}
|
||||
|
||||
|
||||
ctrlStatement.verify();
|
||||
ctrlDatabaseMetaData.verify();
|
||||
}
|
||||
@@ -1189,7 +1189,7 @@ public class JdbcTemplateTests extends AbstractJdbcTests {
|
||||
|
||||
BatchUpdateTestHelper.verifyBatchUpdateMocks(ctrlPreparedStatement, ctrlDatabaseMetaData);
|
||||
}
|
||||
|
||||
|
||||
public void testBatchUpdateWithCollectionOfObjects() throws Exception {
|
||||
final String sql = "UPDATE NOSUCHTABLE SET DATE_DISPATCHED = SYSDATE WHERE ID = ?";
|
||||
final List<Integer> ids = new ArrayList<Integer>();
|
||||
@@ -1275,12 +1275,12 @@ public class JdbcTemplateTests extends AbstractJdbcTests {
|
||||
RowCountCallbackHandler rcch = new RowCountCallbackHandler();
|
||||
template.query("SELECT ID, FORENAME FROM CUSTMR WHERE ID < 3", rcch);
|
||||
fail("Shouldn't have executed query without a connection");
|
||||
}
|
||||
}
|
||||
catch (CannotGetJdbcConnectionException ex) {
|
||||
// pass
|
||||
assertTrue("Check root cause", ex.getCause() == sex);
|
||||
}
|
||||
|
||||
|
||||
ctrlDataSource.verify();
|
||||
}
|
||||
|
||||
@@ -1348,7 +1348,7 @@ public class JdbcTemplateTests extends AbstractJdbcTests {
|
||||
//mockConnection.close();
|
||||
//ctrlConnection.setVoidCallable(1);
|
||||
ctrlConnection.replay();
|
||||
|
||||
|
||||
// Change behaviour in setUp() because we only expect one call to getConnection():
|
||||
// none is necessary to get metadata for exception translator
|
||||
ctrlDataSource = MockControl.createControl(DataSource.class);
|
||||
@@ -1366,26 +1366,26 @@ public class JdbcTemplateTests extends AbstractJdbcTests {
|
||||
RowCountCallbackHandler rcch = new RowCountCallbackHandler();
|
||||
template.query("SELECT ID, FORENAME FROM CUSTMR WHERE ID < 3", rcch);
|
||||
fail("Shouldn't have executed query without a connection");
|
||||
}
|
||||
}
|
||||
catch (CannotGetJdbcConnectionException ex) {
|
||||
// pass
|
||||
assertTrue("Check root cause", ex.getCause() == sex);
|
||||
}
|
||||
|
||||
|
||||
ctrlDataSource.verify();
|
||||
ctrlConnection.verify();
|
||||
}
|
||||
|
||||
|
||||
public void testCouldntGetConnectionInOperationWithExceptionTranslatorInitializedViaBeanProperty()
|
||||
throws Exception {
|
||||
doTestCouldntGetConnectionInOperationWithExceptionTranslatorInitialized(true);
|
||||
}
|
||||
|
||||
|
||||
public void testCouldntGetConnectionInOperationWithExceptionTranslatorInitializedInAfterPropertiesSet()
|
||||
throws Exception {
|
||||
doTestCouldntGetConnectionInOperationWithExceptionTranslatorInitialized(false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If beanProperty is true, initialize via exception translator bean property;
|
||||
* if false, use afterPropertiesSet().
|
||||
@@ -1402,7 +1402,7 @@ public class JdbcTemplateTests extends AbstractJdbcTests {
|
||||
//mockConnection.close();
|
||||
//ctrlConnection.setVoidCallable(1);
|
||||
ctrlConnection.replay();
|
||||
|
||||
|
||||
// Change behaviour in setUp() because we only expect one call to getConnection():
|
||||
// none is necessary to get metadata for exception translator
|
||||
ctrlDataSource = MockControl.createControl(DataSource.class);
|
||||
@@ -1434,7 +1434,7 @@ public class JdbcTemplateTests extends AbstractJdbcTests {
|
||||
"SELECT ID, FORENAME FROM CUSTMR WHERE ID < 3",
|
||||
rcch);
|
||||
fail("Shouldn't have executed query without a connection");
|
||||
}
|
||||
}
|
||||
catch (CannotGetJdbcConnectionException ex) {
|
||||
// pass
|
||||
assertTrue("Check root cause", ex.getCause() == sex);
|
||||
@@ -1778,7 +1778,7 @@ public class JdbcTemplateTests extends AbstractJdbcTests {
|
||||
|
||||
mockConnection.createStatement();
|
||||
ctrlConnection.setReturnValue(mockStatement);
|
||||
|
||||
|
||||
// Change behaviour in setUp() because we only expect one call to getConnection():
|
||||
// none is necessary to get metadata for exception translator
|
||||
ctrlConnection = MockControl.createControl(Connection.class);
|
||||
@@ -1817,11 +1817,11 @@ public class JdbcTemplateTests extends AbstractJdbcTests {
|
||||
assertTrue(
|
||||
"Wanted same exception back, not " + ex,
|
||||
sex == ex.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
ctrlResultSet.verify();
|
||||
ctrlStatement.verify();
|
||||
|
||||
|
||||
// We didn't call superclass replay() so we need to check these ourselves
|
||||
ctrlDataSource.verify();
|
||||
ctrlConnection.verify();
|
||||
@@ -2139,7 +2139,7 @@ public class JdbcTemplateTests extends AbstractJdbcTests {
|
||||
|
||||
template.setResultsMapCaseInsensitive(true);
|
||||
assertTrue("now it should have been set to case insensitive", template.isResultsMapCaseInsensitive());
|
||||
|
||||
|
||||
List params = new ArrayList();
|
||||
params.add(new SqlOutParameter("a", 12));
|
||||
|
||||
|
||||
@@ -227,7 +227,7 @@ public class NamedParameterUtilsTests {
|
||||
assertEquals(0, parsedSql.getParameterNames().size());
|
||||
String finalSql = NamedParameterUtils.substituteNamedParameters(parsedSql, null);
|
||||
assertEquals(expectedSql, finalSql);
|
||||
|
||||
|
||||
String expectedSql2 = "select foo from bar where baz = 'b:{p1}z'";
|
||||
String sql2 = "select foo from bar where baz = 'b:{p1}z'";
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ public class SimpleJdbcInsertTests extends TestCase {
|
||||
ctrlResultSet.setReturnValue(false);
|
||||
mockResultSet.close();
|
||||
ctrlResultSet.setVoidCallable();
|
||||
|
||||
|
||||
mockDatabaseMetaData.getDatabaseProductName();
|
||||
ctrlDatabaseMetaData.setReturnValue("MyDB");
|
||||
mockDatabaseMetaData.supportsGetGeneratedKeys();
|
||||
|
||||
@@ -144,12 +144,12 @@ public class TableMetaDataContextTests extends TestCase {
|
||||
ctrlMetaDataResultSet.replay();
|
||||
ctrlColumnsResultSet.replay();
|
||||
replay();
|
||||
|
||||
|
||||
MapSqlParameterSource map = new MapSqlParameterSource();
|
||||
map.addValue("id", 1);
|
||||
map.addValue("name", "Sven");
|
||||
map.addValue("customersince", new Date());
|
||||
map.addValue("version", 0);
|
||||
map.addValue("version", 0);
|
||||
map.registerSqlType("customersince", Types.DATE);
|
||||
map.registerSqlType("version", Types.NUMERIC);
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2002-2005 the original author or authors.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2002-2005 the original author or authors.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@@ -34,62 +34,62 @@ import org.springframework.jdbc.support.lob.LobHandler;
|
||||
* @author Alef Arendsen
|
||||
*/
|
||||
public class LobSupportTests extends TestCase {
|
||||
|
||||
|
||||
public void testCreatingPreparedStatementCallback() throws SQLException {
|
||||
// - return value should match
|
||||
// - lob creator should be closed
|
||||
// - set return value should be called
|
||||
// - execute update should be called
|
||||
|
||||
|
||||
MockControl lobHandlerControl = MockControl.createControl(LobHandler.class);
|
||||
LobHandler handler = (LobHandler)lobHandlerControl.getMock();
|
||||
|
||||
LobHandler handler = (LobHandler)lobHandlerControl.getMock();
|
||||
|
||||
MockControl lobCreatorControl = MockControl.createControl(LobCreator.class);
|
||||
LobCreator creator = (LobCreator)lobCreatorControl.getMock();
|
||||
|
||||
|
||||
MockControl psControl = MockControl.createControl(PreparedStatement.class);
|
||||
PreparedStatement ps = (PreparedStatement)psControl.getMock();
|
||||
|
||||
|
||||
handler.getLobCreator();
|
||||
lobHandlerControl.setReturnValue(creator);
|
||||
ps.executeUpdate();
|
||||
psControl.setReturnValue(3);
|
||||
creator.close();
|
||||
|
||||
|
||||
lobHandlerControl.replay();
|
||||
lobCreatorControl.replay();
|
||||
psControl.replay();
|
||||
|
||||
|
||||
class SetValuesCalled {
|
||||
boolean b = false;
|
||||
}
|
||||
|
||||
|
||||
final SetValuesCalled svc = new SetValuesCalled();
|
||||
|
||||
AbstractLobCreatingPreparedStatementCallback psc =
|
||||
|
||||
AbstractLobCreatingPreparedStatementCallback psc =
|
||||
new AbstractLobCreatingPreparedStatementCallback(handler) {
|
||||
|
||||
|
||||
protected void setValues(PreparedStatement ps, LobCreator lobCreator)
|
||||
throws SQLException, DataAccessException {
|
||||
svc.b = true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
assertEquals(new Integer(3), psc.doInPreparedStatement(ps));
|
||||
|
||||
|
||||
lobHandlerControl.verify();
|
||||
lobCreatorControl.verify();
|
||||
psControl.verify();
|
||||
assertTrue(svc.b);
|
||||
}
|
||||
|
||||
|
||||
public void testAbstractLobStreamingResultSetExtractorNoRows() throws SQLException {
|
||||
MockControl rsetControl = MockControl.createControl(ResultSet.class);
|
||||
ResultSet rset = (ResultSet)rsetControl.getMock();
|
||||
rset.next();
|
||||
rsetControl.setReturnValue(false);
|
||||
rsetControl.replay();
|
||||
|
||||
|
||||
AbstractLobStreamingResultSetExtractor lobRse = getResultSetExtractor(false);
|
||||
try {
|
||||
lobRse.extractData(rset);
|
||||
@@ -98,7 +98,7 @@ public class LobSupportTests extends TestCase {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void testAbstractLobStreamingResultSetExtractorOneRow() throws SQLException {
|
||||
MockControl rsetControl = MockControl.createControl(ResultSet.class);
|
||||
ResultSet rset = (ResultSet)rsetControl.getMock();
|
||||
@@ -109,7 +109,7 @@ public class LobSupportTests extends TestCase {
|
||||
rset.next();
|
||||
rsetControl.setReturnValue(false);
|
||||
rsetControl.replay();
|
||||
|
||||
|
||||
AbstractLobStreamingResultSetExtractor lobRse = getResultSetExtractor(false);
|
||||
lobRse.extractData(rset);
|
||||
rsetControl.verify();
|
||||
@@ -125,7 +125,7 @@ public class LobSupportTests extends TestCase {
|
||||
rset.next();
|
||||
rsetControl.setReturnValue(true);
|
||||
rsetControl.replay();
|
||||
|
||||
|
||||
AbstractLobStreamingResultSetExtractor lobRse = getResultSetExtractor(false);
|
||||
try {
|
||||
lobRse.extractData(rset);
|
||||
@@ -135,14 +135,14 @@ public class LobSupportTests extends TestCase {
|
||||
}
|
||||
rsetControl.verify();
|
||||
}
|
||||
|
||||
|
||||
public void testAbstractLobStreamingResultSetExtractorCorrectException() throws SQLException {
|
||||
MockControl rsetControl = MockControl.createControl(ResultSet.class);
|
||||
ResultSet rset = (ResultSet)rsetControl.getMock();
|
||||
rset.next();
|
||||
rsetControl.setReturnValue(true);
|
||||
rsetControl.replay();
|
||||
|
||||
|
||||
AbstractLobStreamingResultSetExtractor lobRse = getResultSetExtractor(true);
|
||||
try {
|
||||
lobRse.extractData(rset);
|
||||
@@ -152,7 +152,7 @@ public class LobSupportTests extends TestCase {
|
||||
}
|
||||
rsetControl.verify();
|
||||
}
|
||||
|
||||
|
||||
private AbstractLobStreamingResultSetExtractor getResultSetExtractor(final boolean ex) {
|
||||
AbstractLobStreamingResultSetExtractor lobRse = new AbstractLobStreamingResultSetExtractor() {
|
||||
protected void streamData(ResultSet rs) throws SQLException, IOException {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2002-2005 the original author or authors.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@@ -33,7 +33,7 @@ import org.springframework.jdbc.support.lob.LobHandler;
|
||||
/**
|
||||
* Test cases for the sql lob value:
|
||||
*
|
||||
* BLOB:
|
||||
* BLOB:
|
||||
* 1. Types.BLOB: setBlobAsBytes (byte[])
|
||||
* 2. String: setBlobAsBytes (byte[])
|
||||
* 3. else: IllegalArgumentException
|
||||
@@ -43,44 +43,44 @@ import org.springframework.jdbc.support.lob.LobHandler;
|
||||
* 5. InputStream: setClobAsAsciiStream (InputStream)
|
||||
* 6. Reader: setClobAsCharacterStream (Reader)
|
||||
* 7. else: IllegalArgumentException
|
||||
*
|
||||
*
|
||||
* @author Alef Arendsen
|
||||
*/
|
||||
public class SqlLobValueTests extends TestCase {
|
||||
|
||||
|
||||
private MockControl psControl;
|
||||
private PreparedStatement ps;
|
||||
|
||||
|
||||
private MockControl lobHandlerControl;
|
||||
private LobHandler handler;
|
||||
|
||||
|
||||
private MockControl lobCreatorControl;
|
||||
private LobCreator creator;
|
||||
|
||||
|
||||
public void setUp() {
|
||||
// create preparedstatement
|
||||
psControl = MockControl.createControl(PreparedStatement.class);
|
||||
ps = (PreparedStatement) psControl.getMock();
|
||||
|
||||
|
||||
// create handler controler
|
||||
lobHandlerControl = MockControl.createControl(LobHandler.class);
|
||||
handler = (LobHandler) lobHandlerControl.getMock();
|
||||
|
||||
|
||||
// create creator control
|
||||
lobCreatorControl = MockControl.createControl(LobCreator.class);
|
||||
creator = (LobCreator) lobCreatorControl.getMock();
|
||||
|
||||
|
||||
// set initial state
|
||||
handler.getLobCreator();
|
||||
lobHandlerControl.setReturnValue(creator);
|
||||
}
|
||||
|
||||
|
||||
private void replay() {
|
||||
psControl.replay();
|
||||
lobHandlerControl.replay();
|
||||
lobCreatorControl.replay();
|
||||
}
|
||||
|
||||
|
||||
public void test1() throws SQLException {
|
||||
byte[] testBytes = "Bla".getBytes();
|
||||
creator.setBlobAsBytes(ps, 1, testBytes);
|
||||
@@ -88,40 +88,40 @@ public class SqlLobValueTests extends TestCase {
|
||||
SqlLobValue lob = new SqlLobValue(testBytes, handler);
|
||||
lob.setTypeValue(ps, 1, Types.BLOB, "test");
|
||||
lobHandlerControl.verify();
|
||||
lobCreatorControl.verify();
|
||||
lobCreatorControl.verify();
|
||||
}
|
||||
|
||||
|
||||
public void test2() throws SQLException {
|
||||
String testString = "Bla";
|
||||
|
||||
|
||||
creator.setBlobAsBytes(ps, 1, testString.getBytes());
|
||||
// set a matcher to match the byte array!
|
||||
lobCreatorControl.setMatcher(new ArgumentsMatcher() {
|
||||
lobCreatorControl.setMatcher(new ArgumentsMatcher() {
|
||||
public boolean matches(Object[] arg0, Object[] arg1) {
|
||||
byte[] one = (byte[]) arg0[2];
|
||||
byte[] two = (byte[]) arg1[2];
|
||||
return Arrays.equals(one, two);
|
||||
}
|
||||
public String toString(Object[] arg0) {
|
||||
public String toString(Object[] arg0) {
|
||||
return "bla";
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
replay();
|
||||
|
||||
SqlLobValue lob = new SqlLobValue(testString, handler);
|
||||
lob.setTypeValue(ps, 1, Types.BLOB, "test");
|
||||
lobHandlerControl.verify();
|
||||
lobCreatorControl.verify();
|
||||
|
||||
lobCreatorControl.verify();
|
||||
|
||||
}
|
||||
|
||||
public void test3()
|
||||
|
||||
public void test3()
|
||||
throws SQLException {
|
||||
|
||||
|
||||
Date testContent = new Date();
|
||||
|
||||
SqlLobValue lob =
|
||||
|
||||
SqlLobValue lob =
|
||||
new SqlLobValue(new InputStreamReader(new ByteArrayInputStream("Bla".getBytes())), 12);
|
||||
try {
|
||||
lob.setTypeValue(ps, 1, Types.BLOB, "test");
|
||||
@@ -131,19 +131,19 @@ public class SqlLobValueTests extends TestCase {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void test4() throws SQLException {
|
||||
String testContent = "Bla";
|
||||
creator.setClobAsString(ps, 1, testContent);
|
||||
|
||||
|
||||
replay();
|
||||
|
||||
|
||||
SqlLobValue lob = new SqlLobValue(testContent, handler);
|
||||
lob.setTypeValue(ps, 1, Types.CLOB, "test");
|
||||
lobHandlerControl.verify();
|
||||
lobCreatorControl.verify();
|
||||
lobCreatorControl.verify();
|
||||
}
|
||||
|
||||
|
||||
public void test5() throws SQLException {
|
||||
byte[] testContent = "Bla".getBytes();
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(testContent);
|
||||
@@ -157,15 +157,15 @@ public class SqlLobValueTests extends TestCase {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
replay();
|
||||
|
||||
|
||||
SqlLobValue lob = new SqlLobValue(new ByteArrayInputStream(testContent), 3, handler);
|
||||
lob.setTypeValue(ps, 1, Types.CLOB, "test");
|
||||
lobHandlerControl.verify();
|
||||
lobCreatorControl.verify();
|
||||
lobCreatorControl.verify();
|
||||
}
|
||||
|
||||
|
||||
public void test6()throws SQLException {
|
||||
byte[] testContent = "Bla".getBytes();
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(testContent);
|
||||
@@ -180,19 +180,19 @@ public class SqlLobValueTests extends TestCase {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
replay();
|
||||
|
||||
|
||||
SqlLobValue lob = new SqlLobValue(reader, 3, handler);
|
||||
lob.setTypeValue(ps, 1, Types.CLOB, "test");
|
||||
lobHandlerControl.verify();
|
||||
lobCreatorControl.verify();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void test7() throws SQLException {
|
||||
Date testContent = new Date();
|
||||
|
||||
|
||||
SqlLobValue lob = new SqlLobValue("bla".getBytes());
|
||||
try {
|
||||
lob.setTypeValue(ps, 1, Types.CLOB, "test");
|
||||
@@ -202,13 +202,13 @@ public class SqlLobValueTests extends TestCase {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void testOtherConstructors() throws SQLException {
|
||||
// a bit BS, but we need to test them, as long as they don't throw exceptions
|
||||
|
||||
|
||||
SqlLobValue lob = new SqlLobValue("bla");
|
||||
lob.setTypeValue(ps, 1, Types.CLOB, "test");
|
||||
|
||||
|
||||
try {
|
||||
lob = new SqlLobValue("bla".getBytes());
|
||||
lob.setTypeValue(ps, 1, Types.CLOB, "test");
|
||||
@@ -220,24 +220,24 @@ public class SqlLobValueTests extends TestCase {
|
||||
|
||||
lob = new SqlLobValue(new ByteArrayInputStream("bla".getBytes()), 3);
|
||||
lob.setTypeValue(ps, 1, Types.CLOB, "test");
|
||||
|
||||
|
||||
lob = new SqlLobValue(new InputStreamReader(
|
||||
new ByteArrayInputStream("bla".getBytes())), 3);
|
||||
lob.setTypeValue(ps, 1, Types.CLOB, "test");
|
||||
|
||||
// same for BLOB
|
||||
|
||||
// same for BLOB
|
||||
lob = new SqlLobValue("bla");
|
||||
lob.setTypeValue(ps, 1, Types.BLOB, "test");
|
||||
|
||||
|
||||
lob = new SqlLobValue("bla".getBytes());
|
||||
lob.setTypeValue(ps, 1, Types.BLOB, "test");
|
||||
|
||||
|
||||
lob = new SqlLobValue(new ByteArrayInputStream("bla".getBytes()), 3);
|
||||
lob.setTypeValue(ps, 1, Types.BLOB, "test");
|
||||
|
||||
|
||||
lob = new SqlLobValue(new InputStreamReader(
|
||||
new ByteArrayInputStream("bla".getBytes())), 3);
|
||||
|
||||
|
||||
try {
|
||||
lob.setTypeValue(ps, 1, Types.BLOB, "test");
|
||||
fail("IllegalArgumentException should have been thrown");
|
||||
@@ -246,19 +246,19 @@ public class SqlLobValueTests extends TestCase {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void testCorrectCleanup() throws SQLException {
|
||||
creator.setClobAsString(ps, 1, "Bla");
|
||||
creator.close();
|
||||
|
||||
|
||||
replay();
|
||||
SqlLobValue lob = new SqlLobValue("Bla", handler);
|
||||
lob.setTypeValue(ps, 1, Types.CLOB, "test");
|
||||
lob.cleanup();
|
||||
|
||||
|
||||
lobCreatorControl.verify();
|
||||
}
|
||||
|
||||
|
||||
public void testOtherSqlType() throws SQLException {
|
||||
replay();
|
||||
SqlLobValue lob = new SqlLobValue("Bla", handler);
|
||||
|
||||
@@ -48,11 +48,11 @@ import org.springframework.transaction.support.TransactionTemplate;
|
||||
* @since 04.07.2003
|
||||
*/
|
||||
public class DataSourceTransactionManagerTests extends TestCase {
|
||||
|
||||
|
||||
public void testTransactionCommitWithAutoCommitTrue() throws Exception {
|
||||
doTestTransactionCommitRestoringAutoCommit(true, false, false);
|
||||
}
|
||||
|
||||
|
||||
public void testTransactionCommitWithAutoCommitFalse() throws Exception {
|
||||
doTestTransactionCommitRestoringAutoCommit(false, false, false);
|
||||
}
|
||||
@@ -159,11 +159,11 @@ public class DataSourceTransactionManagerTests extends TestCase {
|
||||
conControl.verify();
|
||||
dsControl.verify();
|
||||
}
|
||||
|
||||
|
||||
public void testTransactionRollbackWithAutoCommitTrue() throws Exception {
|
||||
doTestTransactionRollbackRestoringAutoCommit(true, false, false);
|
||||
}
|
||||
|
||||
|
||||
public void testTransactionRollbackWithAutoCommitFalse() throws Exception {
|
||||
doTestTransactionRollbackRestoringAutoCommit(false, false, false);
|
||||
}
|
||||
@@ -1509,7 +1509,7 @@ public class DataSourceTransactionManagerTests extends TestCase {
|
||||
// Must restore
|
||||
con.setAutoCommit(false);
|
||||
conControl.setVoidCallable(1);
|
||||
|
||||
|
||||
con.rollback();
|
||||
conControl.setThrowable(new SQLException("Cannot rollback"), 1);
|
||||
con.setAutoCommit(true);
|
||||
|
||||
@@ -8,9 +8,9 @@ import org.junit.Test;
|
||||
import org.springframework.jdbc.datasource.init.DatabasePopulator;
|
||||
|
||||
public class EmbeddedDatabaseFactoryTests {
|
||||
|
||||
|
||||
private EmbeddedDatabaseFactory factory = new EmbeddedDatabaseFactory();
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetDataSource() {
|
||||
StubDatabasePopulator populator = new StubDatabasePopulator();
|
||||
@@ -19,14 +19,14 @@ public class EmbeddedDatabaseFactoryTests {
|
||||
assertTrue(populator.populateCalled);
|
||||
db.shutdown();
|
||||
}
|
||||
|
||||
|
||||
private static class StubDatabasePopulator implements DatabasePopulator {
|
||||
|
||||
private boolean populateCalled;
|
||||
|
||||
|
||||
public void populate(Connection connection) {
|
||||
this.populateCalled = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class BeanFactoryDataSourceLookupTests {
|
||||
@Test
|
||||
public void testLookupSunnyDay() {
|
||||
BeanFactory beanFactory = createMock(BeanFactory.class);
|
||||
|
||||
|
||||
StubDataSource expectedDataSource = new StubDataSource();
|
||||
expect(beanFactory.getBean(DATASOURCE_BEAN_NAME, DataSource.class)).andReturn(expectedDataSource);
|
||||
|
||||
|
||||
@@ -23,9 +23,9 @@ import org.springframework.jdbc.datasource.AbstractDataSource;
|
||||
|
||||
/**
|
||||
* Stub, do-nothing DataSource implementation.
|
||||
*
|
||||
*
|
||||
* <p>All methods throw {@link UnsupportedOperationException}.
|
||||
*
|
||||
*
|
||||
* @author Rick Evans
|
||||
*/
|
||||
class StubDataSource extends AbstractDataSource {
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.sql.SQLException;
|
||||
public class CustomerMapper implements RowMapper<Customer> {
|
||||
|
||||
private static final String[] COLUMN_NAMES = new String[] {"id", "forename"};
|
||||
|
||||
|
||||
public Customer mapRow(ResultSet rs, int rownum) throws SQLException {
|
||||
Customer cust = new Customer();
|
||||
cust.setId(rs.getInt(COLUMN_NAMES[0]));
|
||||
|
||||
@@ -60,7 +60,7 @@ public class GenericSqlQueryTests extends AbstractJdbcTests {
|
||||
|
||||
private BeanFactory bf;
|
||||
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
@@ -84,7 +84,7 @@ public class RdbmsOperationTests extends TestCase {
|
||||
operation.setTypes(new int[] { Types.INTEGER });
|
||||
try {
|
||||
operation.validateParameters((Object[]) null);
|
||||
fail("Shouldn't validate without enough parameters");
|
||||
fail("Shouldn't validate without enough parameters");
|
||||
}
|
||||
catch (InvalidDataAccessApiUsageException idaauex) {
|
||||
// OK
|
||||
@@ -123,7 +123,7 @@ public class RdbmsOperationTests extends TestCase {
|
||||
operation.setSql("select * from mytable");
|
||||
try {
|
||||
operation.validateParameters(new Object[] {new Integer(1), new Integer(2)});
|
||||
fail("Shouldn't validate with too many parameters");
|
||||
fail("Shouldn't validate with too many parameters");
|
||||
}
|
||||
catch (InvalidDataAccessApiUsageException idaauex) {
|
||||
// OK
|
||||
|
||||
@@ -969,7 +969,7 @@ public class SqlQueryTests extends AbstractJdbcTests {
|
||||
Assert.assertEquals("Second customer id was assigned correctly", ((Customer)cust.get(1)).getId(), 2);
|
||||
Assert.assertEquals("Second customer forename was assigned correctly", ((Customer)cust.get(1)).getForename(), "juergen");
|
||||
}
|
||||
|
||||
|
||||
public void testNamedParameterQueryReusingParameter() throws SQLException {
|
||||
mockResultSet.next();
|
||||
ctrlResultSet.setReturnValue(true);
|
||||
|
||||
@@ -272,7 +272,7 @@ public class SqlUpdateTests extends AbstractJdbcTests {
|
||||
ctrlResultSet.setReturnValue(false);
|
||||
mockResultSet.close();
|
||||
ctrlResultSet.setVoidCallable();
|
||||
|
||||
|
||||
mockPreparedStatement.setString(1, "rod");
|
||||
ctrlPreparedStatement.setVoidCallable();
|
||||
mockPreparedStatement.executeUpdate();
|
||||
|
||||
@@ -213,13 +213,13 @@ public class StoredProcedureTests extends AbstractJdbcTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Confirm no connection was used to get metadata.
|
||||
* Does not use superclass replay mechanism.
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testStoredProcedureConfiguredViaJdbcTemplateWithCustomExceptionTranslator() throws Exception {
|
||||
public void testStoredProcedureConfiguredViaJdbcTemplateWithCustomExceptionTranslator() throws Exception {
|
||||
mockCallable.setObject(1, new Integer(11), Types.INTEGER);
|
||||
ctrlCallable.setVoidCallable(1);
|
||||
mockCallable.registerOutParameter(2, Types.INTEGER);
|
||||
@@ -246,7 +246,7 @@ public class StoredProcedureTests extends AbstractJdbcTests {
|
||||
mockConnection.close();
|
||||
ctrlConnection.setVoidCallable(1);
|
||||
ctrlConnection.replay();
|
||||
|
||||
|
||||
MockControl dsControl = MockControl.createControl(DataSource.class);
|
||||
DataSource localDs = (DataSource) dsControl.getMock();
|
||||
localDs.getConnection();
|
||||
@@ -267,15 +267,15 @@ public class StoredProcedureTests extends AbstractJdbcTests {
|
||||
// DataSource here if we need to to create an ExceptionTranslator
|
||||
t.setExceptionTranslator(new SQLStateSQLExceptionTranslator());
|
||||
StoredProcedureConfiguredViaJdbcTemplate sp = new StoredProcedureConfiguredViaJdbcTemplate(t);
|
||||
|
||||
|
||||
assertEquals(sp.execute(11), 5);
|
||||
assertEquals(1, t.calls);
|
||||
|
||||
|
||||
dsControl.verify();
|
||||
ctrlCallable.verify();
|
||||
ctrlConnection.verify();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Confirm our JdbcTemplate is used
|
||||
* @throws Exception
|
||||
@@ -301,11 +301,11 @@ public class StoredProcedureTests extends AbstractJdbcTests {
|
||||
mockConnection.prepareCall("{call " + StoredProcedureConfiguredViaJdbcTemplate.SQL + "(?, ?)}");
|
||||
ctrlConnection.setReturnValue(mockCallable);
|
||||
|
||||
replay();
|
||||
replay();
|
||||
JdbcTemplate t = new JdbcTemplate();
|
||||
t.setDataSource(mockDataSource);
|
||||
StoredProcedureConfiguredViaJdbcTemplate sp = new StoredProcedureConfiguredViaJdbcTemplate(t);
|
||||
|
||||
|
||||
assertEquals(sp.execute(1106), 4);
|
||||
}
|
||||
|
||||
@@ -429,7 +429,7 @@ public class StoredProcedureTests extends AbstractJdbcTests {
|
||||
ctrlResultSet.verify();
|
||||
assertEquals(2, sproc.getCount());
|
||||
}
|
||||
|
||||
|
||||
public void testStoredProcedureWithResultSetMapped() throws Exception {
|
||||
MockControl ctrlResultSet = MockControl.createControl(ResultSet.class);
|
||||
ResultSet mockResultSet = (ResultSet) ctrlResultSet.getMock();
|
||||
@@ -473,11 +473,11 @@ public class StoredProcedureTests extends AbstractJdbcTests {
|
||||
Map res = sproc.execute();
|
||||
|
||||
ctrlResultSet.verify();
|
||||
|
||||
|
||||
List rs = (List) res.get("rs");
|
||||
assertEquals(2, rs.size());
|
||||
assertEquals("Foo", rs.get(0));
|
||||
assertEquals("Bar", rs.get(1));
|
||||
assertEquals("Bar", rs.get(1));
|
||||
|
||||
}
|
||||
|
||||
@@ -958,12 +958,12 @@ public class StoredProcedureTests extends AbstractJdbcTests {
|
||||
out = execute(new TestParameterMapper());
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
private static class TestParameterMapper implements ParameterMapper {
|
||||
|
||||
|
||||
private TestParameterMapper() {
|
||||
}
|
||||
|
||||
|
||||
public Map createMap(Connection conn) throws SQLException {
|
||||
Map inParms = new HashMap();
|
||||
String testValue = conn.toString();
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2002-2005 the original author or authors.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2002-2005 the original author or authors.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2002-2005 the original author or authors.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2002-2005 the original author or authors.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@@ -34,7 +34,7 @@ import junit.framework.TestCase;
|
||||
*/
|
||||
public class KeyHolderTests extends TestCase {
|
||||
private KeyHolder kh;
|
||||
|
||||
|
||||
public void setUp() {
|
||||
kh = new GeneratedKeyHolder();
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2002-2005 the original author or authors.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@@ -35,7 +35,7 @@ import org.springframework.jdbc.InvalidResultSetAccessException;
|
||||
* @author Rod Johnson
|
||||
*/
|
||||
public class SQLErrorCodeSQLExceptionTranslatorTests extends TestCase {
|
||||
|
||||
|
||||
private static SQLErrorCodes ERROR_CODES = new SQLErrorCodes();
|
||||
static {
|
||||
ERROR_CODES.setBadSqlGrammarCodes(new String[] { "1", "2" });
|
||||
@@ -116,19 +116,19 @@ public class SQLErrorCodeSQLExceptionTranslatorTests extends TestCase {
|
||||
}
|
||||
};
|
||||
sext.setSqlErrorCodes(ERROR_CODES);
|
||||
|
||||
|
||||
// Shouldn't custom translate this
|
||||
assertEquals(customDex, sext.translate(TASK, SQL, badSqlEx));
|
||||
DataIntegrityViolationException diex = (DataIntegrityViolationException) sext.translate(TASK, SQL, intVioEx);
|
||||
assertEquals(intVioEx, diex.getCause());
|
||||
}
|
||||
|
||||
|
||||
public void testCustomExceptionTranslation() {
|
||||
final String TASK = "TASK";
|
||||
final String SQL = "SQL SELECT *";
|
||||
final SQLErrorCodes customErrorCodes = new SQLErrorCodes();
|
||||
final CustomSQLErrorCodesTranslation customTranslation = new CustomSQLErrorCodesTranslation();
|
||||
|
||||
|
||||
customErrorCodes.setBadSqlGrammarCodes(new String[] {"1", "2"});
|
||||
customErrorCodes.setDataIntegrityViolationCodes(new String[] {"3", "4"});
|
||||
customTranslation.setErrorCodes(new String[] {"1"});
|
||||
@@ -137,7 +137,7 @@ public class SQLErrorCodeSQLExceptionTranslatorTests extends TestCase {
|
||||
|
||||
SQLErrorCodeSQLExceptionTranslator sext = new SQLErrorCodeSQLExceptionTranslator();
|
||||
sext.setSqlErrorCodes(customErrorCodes);
|
||||
|
||||
|
||||
// Should custom translate this
|
||||
SQLException badSqlEx = new SQLException("", "", 1);
|
||||
assertEquals(CustomErrorCodeException.class, sext.translate(TASK, SQL, badSqlEx).getClass());
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2002-2005 the original author or authors.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@@ -24,12 +24,12 @@ import org.springframework.jdbc.BadSqlGrammarException;
|
||||
import org.springframework.jdbc.UncategorizedSQLException;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @since 13-Jan-03
|
||||
*/
|
||||
public class SQLStateExceptionTranslatorTests extends TestCase {
|
||||
|
||||
|
||||
private SQLStateSQLExceptionTranslator trans = new SQLStateSQLExceptionTranslator();
|
||||
|
||||
// ALSO CHECK CHAIN of SQLExceptions!?
|
||||
@@ -39,7 +39,7 @@ public class SQLStateExceptionTranslatorTests extends TestCase {
|
||||
String sql = "SELECT FOO FROM BAR";
|
||||
SQLException sex = new SQLException("Message", "42001", 1);
|
||||
try {
|
||||
throw this.trans.translate("task", sql, sex);
|
||||
throw this.trans.translate("task", sql, sex);
|
||||
}
|
||||
catch (BadSqlGrammarException ex) {
|
||||
// OK
|
||||
@@ -47,7 +47,7 @@ public class SQLStateExceptionTranslatorTests extends TestCase {
|
||||
assertTrue("Exception matches", sex.equals(ex.getSQLException()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void testInvalidSqlStateCode() {
|
||||
String sql = "SELECT FOO FROM BAR";
|
||||
SQLException sex = new SQLException("Message", "NO SUCH CODE", 1);
|
||||
@@ -60,26 +60,26 @@ public class SQLStateExceptionTranslatorTests extends TestCase {
|
||||
assertTrue("Exception matches", sex.equals(ex.getSQLException()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PostgreSQL can return null
|
||||
* SAP DB can apparently return empty SQL code
|
||||
* Bug 729170
|
||||
* Bug 729170
|
||||
*/
|
||||
public void testMalformedSqlStateCodes() {
|
||||
String sql = "SELECT FOO FROM BAR";
|
||||
SQLException sex = new SQLException("Message", null, 1);
|
||||
testMalformedSqlStateCode(sex);
|
||||
|
||||
|
||||
sex = new SQLException("Message", "", 1);
|
||||
testMalformedSqlStateCode(sex);
|
||||
|
||||
|
||||
// One char's not allowed
|
||||
sex = new SQLException("Message", "I", 1);
|
||||
testMalformedSqlStateCode(sex);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void testMalformedSqlStateCode(SQLException sex) {
|
||||
String sql = "SELECT FOO FROM BAR";
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user