Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
ed27e04a
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ed27e04a
编写于
12月 16, 2008
作者:
C
Chris Beams
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
moving unit tests from .testsuite -> .jdbc
上级
f2e9abf6
变更
31
隐藏空白更改
内联
并排
Showing
31 changed file
with
108 addition
and
741 deletion
+108
-741
org.springframework.jdbc/src/test/java/org/springframework/jdbc/AbstractJdbcTests.java
...test/java/org/springframework/jdbc/AbstractJdbcTests.java
+2
-2
org.springframework.jdbc/src/test/java/org/springframework/jdbc/Customer.java
...jdbc/src/test/java/org/springframework/jdbc/Customer.java
+1
-1
org.springframework.jdbc/src/test/java/org/springframework/jdbc/core/AbstractRowMapperTests.java
...org/springframework/jdbc/core/AbstractRowMapperTests.java
+9
-10
org.springframework.jdbc/src/test/java/org/springframework/jdbc/core/SimpleRowCountCallbackHandler.java
...ingframework/jdbc/core/SimpleRowCountCallbackHandler.java
+1
-1
org.springframework.jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplateTests.java
...jdbc/core/namedparam/NamedParameterJdbcTemplateTests.java
+9
-11
org.springframework.jdbc/src/test/java/org/springframework/jdbc/core/simple/CallMetaDataContextTests.java
...gframework/jdbc/core/simple/CallMetaDataContextTests.java
+0
-0
org.springframework.jdbc/src/test/java/org/springframework/jdbc/core/simple/ParameterizedBeanPropertyRowMapperTests.java
.../core/simple/ParameterizedBeanPropertyRowMapperTests.java
+0
-0
org.springframework.jdbc/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcCallTests.java
...springframework/jdbc/core/simple/SimpleJdbcCallTests.java
+0
-0
org.springframework.jdbc/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcInsertTests.java
...ringframework/jdbc/core/simple/SimpleJdbcInsertTests.java
+0
-0
org.springframework.jdbc/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcTemplateTests.java
...ngframework/jdbc/core/simple/SimpleJdbcTemplateTests.java
+0
-0
org.springframework.jdbc/src/test/java/org/springframework/jdbc/core/simple/TableMetaDataContextTests.java
...framework/jdbc/core/simple/TableMetaDataContextTests.java
+0
-0
org.springframework.jdbc/src/test/java/org/springframework/jdbc/datasource/lookup/BeanFactoryDataSourceLookupTests.java
...c/datasource/lookup/BeanFactoryDataSourceLookupTests.java
+28
-30
org.springframework.jdbc/src/test/java/org/springframework/jdbc/datasource/lookup/JndiDataSourceLookupTests.java
...ork/jdbc/datasource/lookup/JndiDataSourceLookupTests.java
+15
-15
org.springframework.jdbc/src/test/java/org/springframework/jdbc/datasource/lookup/MapDataSourceLookupTests.java
...work/jdbc/datasource/lookup/MapDataSourceLookupTests.java
+26
-29
org.springframework.jdbc/src/test/java/org/springframework/jdbc/datasource/lookup/StubDataSource.java
...pringframework/jdbc/datasource/lookup/StubDataSource.java
+0
-0
org.springframework.jdbc/src/test/java/org/springframework/jdbc/support/CustomErrorCodeException.java
...pringframework/jdbc/support/CustomErrorCodeException.java
+2
-1
org.springframework.jdbc/src/test/java/org/springframework/jdbc/support/SQLExceptionSubclassFactory.java
...ngframework/jdbc/support/SQLExceptionSubclassFactory.java
+1
-1
org.springframework.jdbc/src/test/java/org/springframework/jdbc/support/SQLStateSQLExceptionTranslatorTests.java
...ork/jdbc/support/SQLStateSQLExceptionTranslatorTests.java
+14
-10
org.springframework.jdbc/src/test/java/org/springframework/jdbc/support/custom-error-codes.xml
...a/org/springframework/jdbc/support/custom-error-codes.xml
+0
-0
org.springframework.jdbc/src/test/java/org/springframework/jdbc/support/test-error-codes.xml
...ava/org/springframework/jdbc/support/test-error-codes.xml
+0
-0
org.springframework.jdbc/src/test/java/org/springframework/jdbc/support/wildcard-error-codes.xml
...org/springframework/jdbc/support/wildcard-error-codes.xml
+0
-0
org.springframework.testsuite/src/test/java/org/springframework/jdbc/AbstractJdbcTests.java
...test/java/org/springframework/jdbc/AbstractJdbcTests.java
+0
-85
org.springframework.testsuite/src/test/java/org/springframework/jdbc/Customer.java
...uite/src/test/java/org/springframework/jdbc/Customer.java
+0
-50
org.springframework.testsuite/src/test/java/org/springframework/jdbc/core/AbstractRowMapperTests.java
...org/springframework/jdbc/core/AbstractRowMapperTests.java
+0
-145
org.springframework.testsuite/src/test/java/org/springframework/jdbc/core/SimpleRowCountCallbackHandler.java
...ingframework/jdbc/core/SimpleRowCountCallbackHandler.java
+0
-42
org.springframework.testsuite/src/test/java/org/springframework/jdbc/core/test/AbstractPerson.java
...va/org/springframework/jdbc/core/test/AbstractPerson.java
+0
-57
org.springframework.testsuite/src/test/java/org/springframework/jdbc/core/test/ConcretePerson.java
...va/org/springframework/jdbc/core/test/ConcretePerson.java
+0
-37
org.springframework.testsuite/src/test/java/org/springframework/jdbc/core/test/ExtendedPerson.java
...va/org/springframework/jdbc/core/test/ExtendedPerson.java
+0
-35
org.springframework.testsuite/src/test/java/org/springframework/jdbc/core/test/Person.java
.../test/java/org/springframework/jdbc/core/test/Person.java
+0
-67
org.springframework.testsuite/src/test/java/org/springframework/jdbc/support/CustomErrorCodeException.java
...pringframework/jdbc/support/CustomErrorCodeException.java
+0
-34
org.springframework.testsuite/src/test/java/org/springframework/jdbc/support/SQLExceptionSubclassFactory.java
...ngframework/jdbc/support/SQLExceptionSubclassFactory.java
+0
-78
未找到文件。
org.springframework.jdbc/src/test/java/org/springframework/jdbc/AbstractJdbcTests.java
浏览文件 @
ed27e04a
...
...
@@ -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,
...
...
@@ -82,4 +82,4 @@ public abstract class AbstractJdbcTests extends TestCase {
return
this
.
shouldVerify
;
}
}
\ No newline at end of file
}
org.springframework.jdbc/src/test/java/org/springframework/jdbc/Customer.java
浏览文件 @
ed27e04a
...
...
@@ -47,4 +47,4 @@ public class Customer {
return
"Customer: id="
+
id
+
"; forename="
+
forename
;
}
}
\ No newline at end of file
}
org.springframework.jdbc/src/test/java/org/springframework/jdbc/core/AbstractRowMapperTests.java
浏览文件 @
ed27e04a
...
...
@@ -26,7 +26,6 @@ import java.sql.Timestamp;
import
java.sql.Types
;
import
junit.framework.TestCase
;
import
junit.framework.Assert
;
import
org.easymock.MockControl
;
import
org.apache.commons.logging.LogFactory
;
...
...
@@ -122,18 +121,18 @@ public abstract class AbstractRowMapperTests extends TestCase {
protected
void
verifyPerson
(
Person
bean
)
{
verify
();
Assert
.
assertEquals
(
"Bubba"
,
bean
.
getName
());
Assert
.
assertEquals
(
22L
,
bean
.
getAge
());
Assert
.
assertEquals
(
new
java
.
util
.
Date
(
1221222L
),
bean
.
getBirth_date
());
Assert
.
assertEquals
(
new
BigDecimal
(
"1234.56"
),
bean
.
getBalance
());
assertEquals
(
"Bubba"
,
bean
.
getName
());
assertEquals
(
22L
,
bean
.
getAge
());
assertEquals
(
new
java
.
util
.
Date
(
1221222L
),
bean
.
getBirth_date
());
assertEquals
(
new
BigDecimal
(
"1234.56"
),
bean
.
getBalance
());
}
protected
void
verifyConcretePerson
(
ConcretePerson
bean
)
{
verify
();
Assert
.
assertEquals
(
"Bubba"
,
bean
.
getName
());
Assert
.
assertEquals
(
22L
,
bean
.
getAge
());
Assert
.
assertEquals
(
new
java
.
util
.
Date
(
1221222L
),
bean
.
getBirth_date
());
Assert
.
assertEquals
(
new
BigDecimal
(
"1234.56"
),
bean
.
getBalance
());
assertEquals
(
"Bubba"
,
bean
.
getName
());
assertEquals
(
22L
,
bean
.
getAge
());
assertEquals
(
new
java
.
util
.
Date
(
1221222L
),
bean
.
getBirth_date
());
assertEquals
(
new
BigDecimal
(
"1234.56"
),
bean
.
getBalance
());
}
private
void
verify
()
{
...
...
@@ -143,4 +142,4 @@ public abstract class AbstractRowMapperTests extends TestCase {
stmtControl
.
verify
();
}
}
\ No newline at end of file
}
org.springframework.jdbc/src/test/java/org/springframework/jdbc/core/SimpleRowCountCallbackHandler.java
浏览文件 @
ed27e04a
...
...
@@ -39,4 +39,4 @@ public class SimpleRowCountCallbackHandler implements RowCallbackHandler {
return
count
;
}
}
\ No newline at end of file
}
org.springframework.
testsuite
/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplateTests.java
→
org.springframework.
jdbc
/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplateTests.java
浏览文件 @
ed27e04a
...
...
@@ -40,11 +40,11 @@ import org.springframework.jdbc.core.RowCallbackHandler;
import
org.springframework.jdbc.core.RowMapper
;
import
org.springframework.jdbc.core.SqlParameterValue
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.test.AssertThrows
;
/**
* @author Rick Evans
* @author Juergen Hoeller
* @author Chris Beams
*/
public
class
NamedParameterJdbcTemplateTests
extends
AbstractJdbcTests
{
...
...
@@ -91,19 +91,17 @@ public class NamedParameterJdbcTemplateTests extends AbstractJdbcTests {
public
void
testNullDataSourceProvidedToCtor
()
throws
Exception
{
new
AssertThrows
(
IllegalArgumentException
.
class
)
{
public
void
test
()
throws
Exception
{
new
NamedParameterJdbcTemplate
((
DataSource
)
null
);
}
}.
runTest
();
try
{
new
NamedParameterJdbcTemplate
((
DataSource
)
null
);
fail
(
"should have thrown IllegalArgumentException"
);
}
catch
(
IllegalArgumentException
ex
)
{
/* expected */
}
}
public
void
testNullJdbcTemplateProvidedToCtor
()
throws
Exception
{
new
AssertThrows
(
IllegalArgumentException
.
class
)
{
public
void
test
()
throws
Exception
{
new
NamedParameterJdbcTemplate
((
JdbcOperations
)
null
);
}
}.
runTest
();
try
{
new
NamedParameterJdbcTemplate
((
JdbcOperations
)
null
);
fail
(
"should have thrown IllegalArgumentException"
);
}
catch
(
IllegalArgumentException
ex
)
{
/* expected */
}
}
public
void
testExecute
()
throws
SQLException
{
...
...
org.springframework.
testsuite
/src/test/java/org/springframework/jdbc/core/simple/CallMetaDataContextTests.java
→
org.springframework.
jdbc
/src/test/java/org/springframework/jdbc/core/simple/CallMetaDataContextTests.java
浏览文件 @
ed27e04a
文件已移动
org.springframework.
testsuite
/src/test/java/org/springframework/jdbc/core/simple/ParameterizedBeanPropertyRowMapperTests.java
→
org.springframework.
jdbc
/src/test/java/org/springframework/jdbc/core/simple/ParameterizedBeanPropertyRowMapperTests.java
浏览文件 @
ed27e04a
文件已移动
org.springframework.
testsuite
/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcCallTests.java
→
org.springframework.
jdbc
/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcCallTests.java
浏览文件 @
ed27e04a
文件已移动
org.springframework.
testsuite
/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcInsertTests.java
→
org.springframework.
jdbc
/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcInsertTests.java
浏览文件 @
ed27e04a
文件已移动
org.springframework.
testsuite
/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcTemplateTests.java
→
org.springframework.
jdbc
/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcTemplateTests.java
浏览文件 @
ed27e04a
文件已移动
org.springframework.
testsuite
/src/test/java/org/springframework/jdbc/core/simple/TableMetaDataContextTests.java
→
org.springframework.
jdbc
/src/test/java/org/springframework/jdbc/core/simple/TableMetaDataContextTests.java
浏览文件 @
ed27e04a
文件已移动
org.springframework.
testsuite
/src/test/java/org/springframework/jdbc/datasource/lookup/BeanFactoryDataSourceLookupTests.java
→
org.springframework.
jdbc
/src/test/java/org/springframework/jdbc/datasource/lookup/BeanFactoryDataSourceLookupTests.java
浏览文件 @
ed27e04a
...
...
@@ -16,69 +16,67 @@
package
org.springframework.jdbc.datasource.lookup
;
import
javax.sql.DataSource
;
import
static
org
.
easymock
.
EasyMock
.*;
import
static
org
.
junit
.
Assert
.*;
import
junit.framework.TestCase
;
import
org.easymock.MockControl
;
import
javax.sql.DataSource
;
import
org.junit.Test
;
import
org.springframework.beans.factory.BeanFactory
;
import
org.springframework.beans.factory.BeanNotOfRequiredTypeException
;
import
org.springframework.test.AssertThrows
;
/**
* @author Rick Evans
* @author Juergen Hoeller
* @author Chris Beams
*/
public
class
BeanFactoryDataSourceLookupTests
extends
TestCase
{
public
class
BeanFactoryDataSourceLookupTests
{
private
static
final
String
DATASOURCE_BEAN_NAME
=
"dataSource"
;
public
void
testLookupSunnyDay
()
throws
Exception
{
MockControl
mockBeanFactory
=
MockControl
.
createControl
(
BeanFactory
.
class
);
BeanFactory
beanFactory
=
(
BeanFactory
)
mockBeanFactory
.
getMock
();
beanFactory
.
getBean
(
DATASOURCE_BEAN_NAME
,
DataSource
.
class
);
@Test
public
void
testLookupSunnyDay
()
{
BeanFactory
beanFactory
=
createMock
(
BeanFactory
.
class
);
StubDataSource
expectedDataSource
=
new
StubDataSource
();
mockBeanFactory
.
setReturnValue
(
expectedDataSource
);
expect
(
beanFactory
.
getBean
(
DATASOURCE_BEAN_NAME
,
DataSource
.
class
)).
andReturn
(
expectedDataSource
);
mockBeanFactory
.
replay
(
);
replay
(
beanFactory
);
BeanFactoryDataSourceLookup
lookup
=
new
BeanFactoryDataSourceLookup
();
lookup
.
setBeanFactory
(
beanFactory
);
DataSource
dataSource
=
lookup
.
getDataSource
(
DATASOURCE_BEAN_NAME
);
assertNotNull
(
"A DataSourceLookup implementation must *never* return null from getDataSource(): this one obviously (and incorrectly) is"
,
dataSource
);
assertNotNull
(
"A DataSourceLookup implementation must *never* return null from "
+
"getDataSource(): this one obviously (and incorrectly) is"
,
dataSource
);
assertSame
(
expectedDataSource
,
dataSource
);
mockBeanFactory
.
verify
(
);
verify
(
beanFactory
);
}
@Test
public
void
testLookupWhereBeanFactoryYieldsNonDataSourceType
()
throws
Exception
{
MockControl
mockBeanFactory
=
MockControl
.
createControl
(
BeanFactory
.
class
);
final
BeanFactory
beanFactory
=
(
BeanFactory
)
mockBeanFactory
.
getMock
();
final
BeanFactory
beanFactory
=
createMock
(
BeanFactory
.
class
);
beanFactory
.
getBean
(
DATASOURCE_BEAN_NAME
,
DataSource
.
class
);
mockBeanFactory
.
setThrowable
(
new
BeanNotOfRequiredTypeException
(
DATASOURCE_BEAN_NAME
,
DataSource
.
class
,
String
.
class
));
expect
(
beanFactory
.
getBean
(
DATASOURCE_BEAN_NAME
,
DataSource
.
class
)
).
andThrow
(
new
BeanNotOfRequiredTypeException
(
DATASOURCE_BEAN_NAME
,
DataSource
.
class
,
String
.
class
));
mockBeanFactory
.
replay
(
);
replay
(
beanFactory
);
new
AssertThrows
(
DataSourceLookupFailureException
.
class
)
{
public
void
test
()
throws
Exception
{
try
{
BeanFactoryDataSourceLookup
lookup
=
new
BeanFactoryDataSourceLookup
(
beanFactory
);
lookup
.
getDataSource
(
DATASOURCE_BEAN_NAME
);
}
}
.
runTest
();
fail
(
"should have thrown DataSourceLookupFailureException"
);
}
catch
(
DataSourceLookupFailureException
ex
)
{
/* expected */
}
mockBeanFactory
.
verify
(
);
verify
(
beanFactory
);
}
@Test
(
expected
=
IllegalStateException
.
class
)
public
void
testLookupWhereBeanFactoryHasNotBeenSupplied
()
throws
Exception
{
new
AssertThrows
(
IllegalStateException
.
class
)
{
public
void
test
()
throws
Exception
{
BeanFactoryDataSourceLookup
lookup
=
new
BeanFactoryDataSourceLookup
();
lookup
.
getDataSource
(
DATASOURCE_BEAN_NAME
);
}
}.
runTest
();
BeanFactoryDataSourceLookup
lookup
=
new
BeanFactoryDataSourceLookup
();
lookup
.
getDataSource
(
DATASOURCE_BEAN_NAME
);
}
}
org.springframework.
testsuite
/src/test/java/org/springframework/jdbc/datasource/lookup/JndiDataSourceLookupTests.java
→
org.springframework.
jdbc
/src/test/java/org/springframework/jdbc/datasource/lookup/JndiDataSourceLookupTests.java
浏览文件 @
ed27e04a
...
...
@@ -16,24 +16,26 @@
package
org.springframework.jdbc.datasource.lookup
;
import
static
org
.
junit
.
Assert
.*;
import
javax.naming.NamingException
;
import
javax.sql.DataSource
;
import
junit.framework.TestCase
;
import
org.springframework.test.AssertThrows
;
import
org.junit.Test
;
/**
* @author Rick Evans
* @author Chris Beams
*/
public
final
class
JndiDataSourceLookupTests
extends
TestCase
{
public
final
class
JndiDataSourceLookupTests
{
private
static
final
String
DATA_SOURCE_NAME
=
"Love is like a stove, burns you when it's hot"
;
@Test
public
void
testSunnyDay
()
throws
Exception
{
final
DataSource
expectedDataSource
=
new
StubDataSource
();
JndiDataSourceLookup
lookup
=
new
JndiDataSourceLookup
()
{
@SuppressWarnings
(
"unchecked"
)
protected
Object
lookup
(
String
jndiName
,
Class
requiredType
)
{
assertEquals
(
DATA_SOURCE_NAME
,
jndiName
);
return
expectedDataSource
;
...
...
@@ -44,18 +46,16 @@ public final class JndiDataSourceLookupTests extends TestCase {
assertSame
(
expectedDataSource
,
dataSource
);
}
@Test
(
expected
=
DataSourceLookupFailureException
.
class
)
public
void
testNoDataSourceAtJndiLocation
()
throws
Exception
{
new
AssertThrows
(
DataSourceLookupFailureException
.
class
)
{
public
void
test
()
throws
Exception
{
JndiDataSourceLookup
lookup
=
new
JndiDataSourceLookup
()
{
protected
Object
lookup
(
String
jndiName
,
Class
requiredType
)
throws
NamingException
{
assertEquals
(
DATA_SOURCE_NAME
,
jndiName
);
throw
new
NamingException
();
}
};
lookup
.
getDataSource
(
DATA_SOURCE_NAME
);
JndiDataSourceLookup
lookup
=
new
JndiDataSourceLookup
()
{
@SuppressWarnings
(
"unchecked"
)
protected
Object
lookup
(
String
jndiName
,
Class
requiredType
)
throws
NamingException
{
assertEquals
(
DATA_SOURCE_NAME
,
jndiName
);
throw
new
NamingException
();
}
}.
runTest
();
};
lookup
.
getDataSource
(
DATA_SOURCE_NAME
);
}
}
org.springframework.
testsuite
/src/test/java/org/springframework/jdbc/datasource/lookup/MapDataSourceLookupTests.java
→
org.springframework.
jdbc
/src/test/java/org/springframework/jdbc/datasource/lookup/MapDataSourceLookupTests.java
浏览文件 @
ed27e04a
...
...
@@ -16,35 +16,35 @@
package
org.springframework.jdbc.datasource.lookup
;
import
static
org
.
junit
.
Assert
.*;
import
java.util.HashMap
;
import
java.util.Map
;
import
javax.sql.DataSource
;
import
junit.framework.TestCase
;
import
org.springframework.test.AssertThrows
;
import
org.junit.Test
;
/**
* @author Rick Evans
* @author Chris Beams
*/
public
final
class
MapDataSourceLookupTests
extends
TestCase
{
public
final
class
MapDataSourceLookupTests
{
private
static
final
String
DATA_SOURCE_NAME
=
"dataSource"
;
@SuppressWarnings
(
"unchecked"
)
@Test
(
expected
=
UnsupportedOperationException
.
class
)
public
void
testGetDataSourcesReturnsUnmodifiableMap
()
throws
Exception
{
new
AssertThrows
(
UnsupportedOperationException
.
class
,
"The Map returned from getDataSources() *must* be unmodifiable"
)
{
public
void
test
()
throws
Exception
{
MapDataSourceLookup
lookup
=
new
MapDataSourceLookup
(
new
HashMap
());
Map
dataSources
=
lookup
.
getDataSources
();
dataSources
.
put
(
""
,
""
);
}
}.
runTest
();
MapDataSourceLookup
lookup
=
new
MapDataSourceLookup
(
new
HashMap
());
Map
dataSources
=
lookup
.
getDataSources
();
dataSources
.
put
(
""
,
""
);
}
@Test
public
void
testLookupSunnyDay
()
throws
Exception
{
Map
dataSources
=
new
HashMap
();
Map
<
String
,
DataSource
>
dataSources
=
new
HashMap
<
String
,
DataSource
>
();
StubDataSource
expectedDataSource
=
new
StubDataSource
();
dataSources
.
put
(
DATA_SOURCE_NAME
,
expectedDataSource
);
MapDataSourceLookup
lookup
=
new
MapDataSourceLookup
();
...
...
@@ -54,8 +54,9 @@ public final class MapDataSourceLookupTests extends TestCase {
assertSame
(
expectedDataSource
,
dataSource
);
}
@Test
public
void
testSettingDataSourceMapToNullIsAnIdempotentOperation
()
throws
Exception
{
Map
dataSources
=
new
HashMap
();
Map
<
String
,
DataSource
>
dataSources
=
new
HashMap
<
String
,
DataSource
>
();
StubDataSource
expectedDataSource
=
new
StubDataSource
();
dataSources
.
put
(
DATA_SOURCE_NAME
,
expectedDataSource
);
MapDataSourceLookup
lookup
=
new
MapDataSourceLookup
();
...
...
@@ -66,8 +67,9 @@ public final class MapDataSourceLookupTests extends TestCase {
assertSame
(
expectedDataSource
,
dataSource
);
}
@Test
public
void
testAddingDataSourcePermitsOverride
()
throws
Exception
{
Map
dataSources
=
new
HashMap
();
Map
<
String
,
DataSource
>
dataSources
=
new
HashMap
<
String
,
DataSource
>
();
StubDataSource
overridenDataSource
=
new
StubDataSource
();
StubDataSource
expectedDataSource
=
new
StubDataSource
();
dataSources
.
put
(
DATA_SOURCE_NAME
,
overridenDataSource
);
...
...
@@ -79,25 +81,20 @@ public final class MapDataSourceLookupTests extends TestCase {
assertSame
(
expectedDataSource
,
dataSource
);
}
@SuppressWarnings
(
"unchecked"
)
@Test
(
expected
=
ClassCastException
.
class
)
public
void
testGetDataSourceWhereSuppliedMapHasNonDataSourceTypeUnderSpecifiedKey
()
throws
Exception
{
new
AssertThrows
(
ClassCastException
.
class
)
{
public
void
test
()
throws
Exception
{
Map
dataSources
=
new
HashMap
();
dataSources
.
put
(
DATA_SOURCE_NAME
,
new
Object
());
MapDataSourceLookup
lookup
=
new
MapDataSourceLookup
();
lookup
.
setDataSources
(
dataSources
);
lookup
.
getDataSource
(
DATA_SOURCE_NAME
);
}
}.
runTest
();
Map
dataSources
=
new
HashMap
();
dataSources
.
put
(
DATA_SOURCE_NAME
,
new
Object
());
MapDataSourceLookup
lookup
=
new
MapDataSourceLookup
();
lookup
.
setDataSources
(
dataSources
);
lookup
.
getDataSource
(
DATA_SOURCE_NAME
);
}
@Test
(
expected
=
DataSourceLookupFailureException
.
class
)
public
void
testGetDataSourceWhereSuppliedMapHasNoEntryForSpecifiedKey
()
throws
Exception
{
new
AssertThrows
(
DataSourceLookupFailureException
.
class
)
{
public
void
test
()
throws
Exception
{
MapDataSourceLookup
lookup
=
new
MapDataSourceLookup
();
lookup
.
getDataSource
(
DATA_SOURCE_NAME
);
}
}.
runTest
();
MapDataSourceLookup
lookup
=
new
MapDataSourceLookup
();
lookup
.
getDataSource
(
DATA_SOURCE_NAME
);
}
}
org.springframework.
testsuite
/src/test/java/org/springframework/jdbc/datasource/lookup/StubDataSource.java
→
org.springframework.
jdbc
/src/test/java/org/springframework/jdbc/datasource/lookup/StubDataSource.java
浏览文件 @
ed27e04a
文件已移动
org.springframework.jdbc/src/test/java/org/springframework/jdbc/support/CustomErrorCodeException.java
浏览文件 @
ed27e04a
...
...
@@ -21,6 +21,7 @@ import org.springframework.dao.DataAccessException;
/**
* @author Thomas Risberg
*/
@SuppressWarnings
(
"serial"
)
public
class
CustomErrorCodeException
extends
DataAccessException
{
public
CustomErrorCodeException
(
String
msg
)
{
...
...
@@ -31,4 +32,4 @@ public class CustomErrorCodeException extends DataAccessException {
super
(
msg
,
ex
);
}
}
\ No newline at end of file
}
org.springframework.jdbc/src/test/java/org/springframework/jdbc/support/SQLExceptionSubclassFactory.java
浏览文件 @
ed27e04a
...
...
@@ -75,4 +75,4 @@ public class SQLExceptionSubclassFactory {
return
new
SQLRecoverableException
(
reason
,
SQLState
,
vendorCode
);
}
}
\ No newline at end of file
}
org.springframework.
testsuite
/src/test/java/org/springframework/jdbc/support/SQLStateSQLExceptionTranslatorTests.java
→
org.springframework.
jdbc
/src/test/java/org/springframework/jdbc/support/SQLStateSQLExceptionTranslatorTests.java
浏览文件 @
ed27e04a
...
...
@@ -16,10 +16,11 @@
package
org.springframework.jdbc.support
;
import
java.sql.SQLException
;
import
static
org
.
junit
.
Assert
.*
;
import
j
unit.framework.TestCase
;
import
j
ava.sql.SQLException
;
import
org.junit.Test
;
import
org.springframework.dao.ConcurrencyFailureException
;
import
org.springframework.dao.DataAccessException
;
import
org.springframework.dao.DataAccessResourceFailureException
;
...
...
@@ -27,13 +28,13 @@ import org.springframework.dao.DataIntegrityViolationException;
import
org.springframework.dao.TransientDataAccessResourceException
;
import
org.springframework.jdbc.BadSqlGrammarException
;
import
org.springframework.jdbc.UncategorizedSQLException
;
import
org.springframework.test.AssertThrows
;
/**
* @author Rick Evans
* @author Juergen Hoeller
* @author Chris Beams
*/
public
class
SQLStateSQLExceptionTranslatorTests
extends
TestCase
{
public
class
SQLStateSQLExceptionTranslatorTests
{
private
static
final
String
REASON
=
"The game is afoot!"
;
...
...
@@ -42,40 +43,43 @@ public class SQLStateSQLExceptionTranslatorTests extends TestCase {
private
static
final
String
SQL
=
"select count(0) from t_sheep where over_fence = ... yawn... 1"
;
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testTranslateNullException
()
throws
Exception
{
new
AssertThrows
(
IllegalArgumentException
.
class
)
{
public
void
test
()
throws
Exception
{
new
SQLStateSQLExceptionTranslator
().
translate
(
""
,
""
,
null
);
}
}.
runTest
();
new
SQLStateSQLExceptionTranslator
().
translate
(
""
,
""
,
null
);
}
@Test
public
void
testTranslateBadSqlGrammar
()
throws
Exception
{
doTest
(
"07"
,
BadSqlGrammarException
.
class
);
}
@Test
public
void
testTranslateDataIntegrityViolation
()
throws
Exception
{
doTest
(
"23"
,
DataIntegrityViolationException
.
class
);
}
@Test
public
void
testTranslateDataAccessResourceFailure
()
throws
Exception
{
doTest
(
"53"
,
DataAccessResourceFailureException
.
class
);
}
@Test
public
void
testTranslateTransientDataAccessResourceFailure
()
throws
Exception
{
doTest
(
"S1"
,
TransientDataAccessResourceException
.
class
);
}
@Test
public
void
testTranslateConcurrencyFailure
()
throws
Exception
{
doTest
(
"40"
,
ConcurrencyFailureException
.
class
);
}
@Test
public
void
testTranslateUncategorized
()
throws
Exception
{
doTest
(
"00000000"
,
UncategorizedSQLException
.
class
);
}
private
void
doTest
(
String
sqlState
,
Class
dataAccessExceptionType
)
{
private
void
doTest
(
String
sqlState
,
Class
<?>
dataAccessExceptionType
)
{
SQLException
ex
=
new
SQLException
(
REASON
,
sqlState
);
SQLExceptionTranslator
translator
=
new
SQLStateSQLExceptionTranslator
();
DataAccessException
dax
=
translator
.
translate
(
TASK
,
SQL
,
ex
);
...
...
org.springframework.
testsuite
/src/test/java/org/springframework/jdbc/support/custom-error-codes.xml
→
org.springframework.
jdbc
/src/test/java/org/springframework/jdbc/support/custom-error-codes.xml
浏览文件 @
ed27e04a
文件已移动
org.springframework.
testsuite
/src/test/java/org/springframework/jdbc/support/test-error-codes.xml
→
org.springframework.
jdbc
/src/test/java/org/springframework/jdbc/support/test-error-codes.xml
浏览文件 @
ed27e04a
文件已移动
org.springframework.
testsuite
/src/test/java/org/springframework/jdbc/support/wildcard-error-codes.xml
→
org.springframework.
jdbc
/src/test/java/org/springframework/jdbc/support/wildcard-error-codes.xml
浏览文件 @
ed27e04a
文件已移动
org.springframework.testsuite/src/test/java/org/springframework/jdbc/AbstractJdbcTests.java
已删除
100644 → 0
浏览文件 @
f2e9abf6
/*
* AbstractJdbcTests.java
*
* Copyright (C) 2002 by Interprise Software. All rights reserved.
*/
/*
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.jdbc
;
import
java.sql.Connection
;
import
javax.sql.DataSource
;
import
junit.framework.TestCase
;
import
org.easymock.MockControl
;
/**
* @author Trevor D. Cook
*/
public
abstract
class
AbstractJdbcTests
extends
TestCase
{
protected
MockControl
ctrlDataSource
;
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,
* otherwise we setUp() will always result in verification failures
*/
private
boolean
shouldVerify
;
protected
void
setUp
()
throws
Exception
{
this
.
shouldVerify
=
false
;
super
.
setUp
();
ctrlConnection
=
MockControl
.
createControl
(
Connection
.
class
);
mockConnection
=
(
Connection
)
ctrlConnection
.
getMock
();
mockConnection
.
getMetaData
();
ctrlConnection
.
setDefaultReturnValue
(
null
);
mockConnection
.
close
();
ctrlConnection
.
setDefaultVoidCallable
();
ctrlDataSource
=
MockControl
.
createControl
(
DataSource
.
class
);
mockDataSource
=
(
DataSource
)
ctrlDataSource
.
getMock
();
mockDataSource
.
getConnection
();
ctrlDataSource
.
setDefaultReturnValue
(
mockConnection
);
}
protected
void
replay
()
{
ctrlDataSource
.
replay
();
ctrlConnection
.
replay
();
this
.
shouldVerify
=
true
;
}
protected
void
tearDown
()
throws
Exception
{
super
.
tearDown
();
// we shouldn't verify unless the user called replay()
if
(
shouldVerify
())
{
ctrlDataSource
.
verify
();
//ctrlConnection.verify();
}
}
protected
boolean
shouldVerify
()
{
return
this
.
shouldVerify
;
}
}
org.springframework.testsuite/src/test/java/org/springframework/jdbc/Customer.java
已删除
100644 → 0
浏览文件 @
f2e9abf6
/*
* Copyright 2002-2007 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.jdbc
;
/**
* @author Juergen Hoeller
*/
public
class
Customer
{
private
int
id
;
private
String
forename
;
public
int
getId
()
{
return
id
;
}
public
void
setId
(
int
id
)
{
this
.
id
=
id
;
}
public
String
getForename
()
{
return
forename
;
}
public
void
setForename
(
String
forename
)
{
this
.
forename
=
forename
;
}
public
String
toString
()
{
return
"Customer: id="
+
id
+
"; forename="
+
forename
;
}
}
org.springframework.testsuite/src/test/java/org/springframework/jdbc/core/AbstractRowMapperTests.java
已删除
100644 → 0
浏览文件 @
f2e9abf6
/*
* Copyright 2002-2008 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.jdbc.core
;
import
java.math.BigDecimal
;
import
java.sql.Connection
;
import
java.sql.ResultSet
;
import
java.sql.ResultSetMetaData
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.sql.Timestamp
;
import
java.sql.Types
;
import
junit.framework.TestCase
;
import
org.easymock.MockControl
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.jdbc.core.test.ConcretePerson
;
import
org.springframework.jdbc.core.test.Person
;
import
org.springframework.jdbc.datasource.SingleConnectionDataSource
;
import
org.springframework.jdbc.support.SQLStateSQLExceptionTranslator
;
/**
* Mock object based abstract class for RowMapper tests.
* Initializes mock objects and verifies results.
*
* @author Thomas Risberg
*/
public
abstract
class
AbstractRowMapperTests
extends
TestCase
{
private
final
boolean
debugEnabled
=
LogFactory
.
getLog
(
JdbcTemplate
.
class
).
isDebugEnabled
();
protected
MockControl
conControl
;
protected
Connection
con
;
protected
MockControl
rsmdControl
;
protected
ResultSetMetaData
rsmd
;
protected
MockControl
rsControl
;
protected
ResultSet
rs
;
protected
MockControl
stmtControl
;
protected
Statement
stmt
;
protected
JdbcTemplate
jdbcTemplate
;
protected
void
setUp
()
throws
SQLException
{
conControl
=
MockControl
.
createControl
(
Connection
.
class
);
con
=
(
Connection
)
conControl
.
getMock
();
con
.
isClosed
();
conControl
.
setDefaultReturnValue
(
false
);
rsmdControl
=
MockControl
.
createControl
(
ResultSetMetaData
.
class
);
rsmd
=
(
ResultSetMetaData
)
rsmdControl
.
getMock
();
rsmd
.
getColumnCount
();
rsmdControl
.
setReturnValue
(
4
,
1
);
rsmd
.
getColumnLabel
(
1
);
rsmdControl
.
setReturnValue
(
"name"
,
1
);
rsmd
.
getColumnLabel
(
2
);
rsmdControl
.
setReturnValue
(
"age"
,
1
);
rsmd
.
getColumnLabel
(
3
);
rsmdControl
.
setReturnValue
(
"birth_date"
,
1
);
rsmd
.
getColumnLabel
(
4
);
rsmdControl
.
setReturnValue
(
"balance"
,
1
);
rsmdControl
.
replay
();
rsControl
=
MockControl
.
createControl
(
ResultSet
.
class
);
rs
=
(
ResultSet
)
rsControl
.
getMock
();
rs
.
getMetaData
();
rsControl
.
setReturnValue
(
rsmd
,
1
);
rs
.
next
();
rsControl
.
setReturnValue
(
true
,
1
);
rs
.
getString
(
1
);
rsControl
.
setReturnValue
(
"Bubba"
,
1
);
rs
.
wasNull
();
rsControl
.
setReturnValue
(
false
,
1
);
rs
.
getLong
(
2
);
rsControl
.
setReturnValue
(
22
,
1
);
rs
.
getTimestamp
(
3
);
rsControl
.
setReturnValue
(
new
Timestamp
(
1221222L
),
1
);
rs
.
getBigDecimal
(
4
);
rsControl
.
setReturnValue
(
new
BigDecimal
(
"1234.56"
),
1
);
rs
.
next
();
rsControl
.
setReturnValue
(
false
,
1
);
rs
.
close
();
rsControl
.
setVoidCallable
(
1
);
rsControl
.
replay
();
stmtControl
=
MockControl
.
createControl
(
Statement
.
class
);
stmt
=
(
Statement
)
stmtControl
.
getMock
();
con
.
createStatement
();
conControl
.
setReturnValue
(
stmt
,
1
);
stmt
.
executeQuery
(
"select name, age, birth_date, balance from people"
);
stmtControl
.
setReturnValue
(
rs
,
1
);
if
(
debugEnabled
)
{
stmt
.
getWarnings
();
stmtControl
.
setReturnValue
(
null
,
1
);
}
stmt
.
close
();
stmtControl
.
setVoidCallable
(
1
);
conControl
.
replay
();
stmtControl
.
replay
();
jdbcTemplate
=
new
JdbcTemplate
();
jdbcTemplate
.
setDataSource
(
new
SingleConnectionDataSource
(
con
,
false
));
jdbcTemplate
.
setExceptionTranslator
(
new
SQLStateSQLExceptionTranslator
());
jdbcTemplate
.
afterPropertiesSet
();
}
protected
void
verifyPerson
(
Person
bean
)
{
verify
();
assertEquals
(
"Bubba"
,
bean
.
getName
());
assertEquals
(
22L
,
bean
.
getAge
());
assertEquals
(
new
java
.
util
.
Date
(
1221222L
),
bean
.
getBirth_date
());
assertEquals
(
new
BigDecimal
(
"1234.56"
),
bean
.
getBalance
());
}
protected
void
verifyConcretePerson
(
ConcretePerson
bean
)
{
verify
();
assertEquals
(
"Bubba"
,
bean
.
getName
());
assertEquals
(
22L
,
bean
.
getAge
());
assertEquals
(
new
java
.
util
.
Date
(
1221222L
),
bean
.
getBirth_date
());
assertEquals
(
new
BigDecimal
(
"1234.56"
),
bean
.
getBalance
());
}
private
void
verify
()
{
conControl
.
verify
();
rsControl
.
verify
();
rsmdControl
.
verify
();
stmtControl
.
verify
();
}
}
org.springframework.testsuite/src/test/java/org/springframework/jdbc/core/SimpleRowCountCallbackHandler.java
已删除
100644 → 0
浏览文件 @
f2e9abf6
/*
* Copyright 2002-2006 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.jdbc.core
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
/**
* Simple row count callback handler for testing purposes.
* Does not call any JDBC methods on the given ResultSet.
*
* @author Juergen Hoeller
* @since 2.0
*/
public
class
SimpleRowCountCallbackHandler
implements
RowCallbackHandler
{
private
int
count
;
public
void
processRow
(
ResultSet
rs
)
throws
SQLException
{
count
++;
}
public
int
getCount
()
{
return
count
;
}
}
org.springframework.testsuite/src/test/java/org/springframework/jdbc/core/test/AbstractPerson.java
已删除
100644 → 0
浏览文件 @
f2e9abf6
/*
* Copyright 2002-2008 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.jdbc.core.test
;
import
java.util.Date
;
/**
* @author Thomas Risberg
*/
public
abstract
class
AbstractPerson
{
private
String
name
;
private
long
age
;
private
java
.
util
.
Date
birth_date
;
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
long
getAge
()
{
return
age
;
}
public
void
setAge
(
long
age
)
{
this
.
age
=
age
;
}
public
Date
getBirth_date
()
{
return
birth_date
;
}
public
void
setBirth_date
(
Date
birth_date
)
{
this
.
birth_date
=
birth_date
;
}
}
org.springframework.testsuite/src/test/java/org/springframework/jdbc/core/test/ConcretePerson.java
已删除
100644 → 0
浏览文件 @
f2e9abf6
/*
* Copyright 2002-2008 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.jdbc.core.test
;
import
java.math.BigDecimal
;
/**
* @author Thomas Risberg
*/
public
class
ConcretePerson
extends
AbstractPerson
{
private
BigDecimal
balance
;
public
BigDecimal
getBalance
()
{
return
balance
;
}
public
void
setBalance
(
BigDecimal
balance
)
{
this
.
balance
=
balance
;
}
}
org.springframework.testsuite/src/test/java/org/springframework/jdbc/core/test/ExtendedPerson.java
已删除
100644 → 0
浏览文件 @
f2e9abf6
/*
* Copyright 2002-2008 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.jdbc.core.test
;
/**
* @author Juergen Hoeller
*/
public
class
ExtendedPerson
extends
ConcretePerson
{
private
Object
someField
;
public
Object
getSomeField
()
{
return
someField
;
}
public
void
setSomeField
(
Object
someField
)
{
this
.
someField
=
someField
;
}
}
org.springframework.testsuite/src/test/java/org/springframework/jdbc/core/test/Person.java
已删除
100644 → 0
浏览文件 @
f2e9abf6
/*
* Copyright 2002-2008 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.jdbc.core.test
;
import
java.math.BigDecimal
;
/**
* @author Thomas Risberg
*/
public
class
Person
{
private
String
name
;
private
long
age
;
private
java
.
util
.
Date
birth_date
;
private
BigDecimal
balance
;
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
long
getAge
()
{
return
age
;
}
public
void
setAge
(
long
age
)
{
this
.
age
=
age
;
}
public
java
.
util
.
Date
getBirth_date
()
{
return
birth_date
;
}
public
void
setBirth_date
(
java
.
util
.
Date
birth_date
)
{
this
.
birth_date
=
birth_date
;
}
public
BigDecimal
getBalance
()
{
return
balance
;
}
public
void
setBalance
(
BigDecimal
balanace
)
{
this
.
balance
=
balanace
;
}
}
org.springframework.testsuite/src/test/java/org/springframework/jdbc/support/CustomErrorCodeException.java
已删除
100644 → 0
浏览文件 @
f2e9abf6
/*
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.jdbc.support
;
import
org.springframework.dao.DataAccessException
;
/**
* @author Thomas Risberg
*/
public
class
CustomErrorCodeException
extends
DataAccessException
{
public
CustomErrorCodeException
(
String
msg
)
{
super
(
msg
);
}
public
CustomErrorCodeException
(
String
msg
,
Throwable
ex
)
{
super
(
msg
,
ex
);
}
}
org.springframework.testsuite/src/test/java/org/springframework/jdbc/support/SQLExceptionSubclassFactory.java
已删除
100644 → 0
浏览文件 @
f2e9abf6
/*
* Copyright 2002-2008 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.jdbc.support
;
import
java.sql.SQLDataException
;
import
java.sql.SQLException
;
import
java.sql.SQLFeatureNotSupportedException
;
import
java.sql.SQLIntegrityConstraintViolationException
;
import
java.sql.SQLInvalidAuthorizationSpecException
;
import
java.sql.SQLNonTransientConnectionException
;
import
java.sql.SQLRecoverableException
;
import
java.sql.SQLSyntaxErrorException
;
import
java.sql.SQLTimeoutException
;
import
java.sql.SQLTransactionRollbackException
;
import
java.sql.SQLTransientConnectionException
;
/**
* Class to generate Java 6 SQLException subclasses for testing purposes.
*
* @author Thomas Risberg
*/
public
class
SQLExceptionSubclassFactory
{
public
static
SQLException
newSQLDataException
(
String
reason
,
String
SQLState
,
int
vendorCode
)
{
return
new
SQLDataException
(
reason
,
SQLState
,
vendorCode
);
}
public
static
SQLException
newSQLFeatureNotSupportedException
(
String
reason
,
String
SQLState
,
int
vendorCode
)
{
return
new
SQLFeatureNotSupportedException
(
reason
,
SQLState
,
vendorCode
);
}
public
static
SQLException
newSQLIntegrityConstraintViolationException
(
String
reason
,
String
SQLState
,
int
vendorCode
)
{
return
new
SQLIntegrityConstraintViolationException
(
reason
,
SQLState
,
vendorCode
);
}
public
static
SQLException
newSQLInvalidAuthorizationSpecException
(
String
reason
,
String
SQLState
,
int
vendorCode
)
{
return
new
SQLInvalidAuthorizationSpecException
(
reason
,
SQLState
,
vendorCode
);
}
public
static
SQLException
newSQLNonTransientConnectionException
(
String
reason
,
String
SQLState
,
int
vendorCode
)
{
return
new
SQLNonTransientConnectionException
(
reason
,
SQLState
,
vendorCode
);
}
public
static
SQLException
newSQLSyntaxErrorException
(
String
reason
,
String
SQLState
,
int
vendorCode
)
{
return
new
SQLSyntaxErrorException
(
reason
,
SQLState
,
vendorCode
);
}
public
static
SQLException
newSQLTransactionRollbackException
(
String
reason
,
String
SQLState
,
int
vendorCode
)
{
return
new
SQLTransactionRollbackException
(
reason
,
SQLState
,
vendorCode
);
}
public
static
SQLException
newSQLTransientConnectionException
(
String
reason
,
String
SQLState
,
int
vendorCode
)
{
return
new
SQLTransientConnectionException
(
reason
,
SQLState
,
vendorCode
);
}
public
static
SQLException
newSQLTimeoutException
(
String
reason
,
String
SQLState
,
int
vendorCode
)
{
return
new
SQLTimeoutException
(
reason
,
SQLState
,
vendorCode
);
}
public
static
SQLException
newSQLRecoverableException
(
String
reason
,
String
SQLState
,
int
vendorCode
)
{
return
new
SQLRecoverableException
(
reason
,
SQLState
,
vendorCode
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录