Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
5718e574
提交
5718e574
authored
7月 11, 2011
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
assertThrows
上级
5dd0e44e
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
37 行增加
和
22 行删除
+37
-22
LobStorage.java
h2/src/main/org/h2/store/LobStorage.java
+1
-1
TestBase.java
h2/src/test/org/h2/test/TestBase.java
+7
-2
TestOpenClose.java
h2/src/test/org/h2/test/db/TestOpenClose.java
+1
-8
TestLobApi.java
h2/src/test/org/h2/test/jdbc/TestLobApi.java
+2
-2
ProxyCodeGenerator.java
h2/src/test/org/h2/test/utils/ProxyCodeGenerator.java
+26
-9
没有找到文件。
h2/src/main/org/h2/store/LobStorage.java
浏览文件 @
5718e574
...
...
@@ -505,7 +505,7 @@ public class LobStorage {
if
(
lobId
!=
-
1
)
{
removeLob
(
lobId
);
}
throw
DbException
.
convertIOException
(
e
,
"adding blob"
);
throw
DbException
.
convertIOException
(
e
,
null
);
}
}
catch
(
SQLException
e
)
{
throw
DbException
.
convert
(
e
);
...
...
h2/src/test/org/h2/test/TestBase.java
浏览文件 @
5718e574
...
...
@@ -1298,7 +1298,12 @@ public abstract class TestBase {
fail
(
"Expected: SQLException, got: "
+
e
);
}
SQLException
s
=
(
SQLException
)
e
;
assertEquals
(
errorCode
,
s
.
getErrorCode
());
if
(
errorCode
!=
s
.
getErrorCode
())
{
AssertionError
ae
=
new
AssertionError
(
"Expected an SQLException with error code "
+
errorCode
);
ae
.
initCause
(
e
);
throw
ae
;
}
}
},
"SQLException with error code "
+
errorCode
,
obj
);
}
...
...
@@ -1351,7 +1356,7 @@ public abstract class TestBase {
if
(
obj
==
this
)
{
// class proxies
try
{
Class
<?>
pc
=
ProxyCodeGenerator
.
getClassProxy
(
TestBase
.
class
);
Class
<?>
pc
=
ProxyCodeGenerator
.
getClassProxy
(
getClass
()
);
Constructor
cons
=
pc
.
getConstructor
(
new
Class
<?>[]
{
InvocationHandler
.
class
});
return
(
T
)
cons
.
newInstance
(
new
Object
[]
{
ih
});
}
catch
(
Exception
e
)
{
...
...
h2/src/test/org/h2/test/db/TestOpenClose.java
浏览文件 @
5718e574
...
...
@@ -76,15 +76,8 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
FileObject
f
=
FileSystem
.
getInstance
(
getBaseDir
()).
openFileObject
(
getBaseDir
()
+
"/openClose2.h2.db.1.part"
,
"rw"
);
f
.
setFileLength
(
f
.
length
()
*
2
);
f
.
close
();
int
testing
;
assertThrows
(
ErrorCode
.
IO_EXCEPTION_2
,
(
TestBase
)
this
).
assertThrows
(
ErrorCode
.
IO_EXCEPTION_2
,
this
).
getConnection
(
"jdbc:h2:split:18:"
+
getBaseDir
()
+
"/openClose2"
);
// try {
// getConnection("jdbc:h2:split:18:" + getBaseDir() + "/openClose2");
// fail();
// } catch (SQLException e) {
// assertEquals(ErrorCode.IO_EXCEPTION_2, e.getErrorCode());
// }
FileSystem
.
getInstance
(
"split:"
).
delete
(
"split:"
+
getBaseDir
()
+
"/openClose2.h2.db"
);
}
...
...
h2/src/test/org/h2/test/jdbc/TestLobApi.java
浏览文件 @
5718e574
...
...
@@ -67,7 +67,7 @@ public class TestLobApi extends TestBase {
stat
.
execute
(
"create table test(id identity, c clob, b blob)"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"insert into test values(null, ?, ?)"
);
assertThrows
(
ErrorCode
.
IO_EXCEPTION_
2
,
prep
).
assertThrows
(
ErrorCode
.
IO_EXCEPTION_
1
,
prep
).
setCharacterStream
(
1
,
new
Reader
()
{
int
pos
;
public
int
read
(
char
[]
buff
,
int
off
,
int
len
)
throws
IOException
{
...
...
@@ -90,7 +90,7 @@ public class TestLobApi extends TestBase {
prep
.
execute
();
prep
.
setString
(
1
,
""
);
assertThrows
(
ErrorCode
.
IO_EXCEPTION_
2
,
prep
).
assertThrows
(
ErrorCode
.
IO_EXCEPTION_
1
,
prep
).
setBinaryStream
(
2
,
new
InputStream
()
{
int
pos
;
public
int
read
()
throws
IOException
{
...
...
h2/src/test/org/h2/test/utils/ProxyCodeGenerator.java
浏览文件 @
5718e574
...
...
@@ -11,10 +11,9 @@ import java.io.StringWriter;
import
java.lang.reflect.InvocationHandler
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Modifier
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.TreeMap
;
import
java.util.TreeSet
;
import
org.h2.test.TestBase
;
import
org.h2.util.New
;
import
org.h2.util.SourceCompiler
;
...
...
@@ -27,7 +26,7 @@ public class ProxyCodeGenerator {
static
HashMap
<
Class
<?>,
Class
<?>>
proxyMap
=
New
.
hashMap
();
private
TreeSet
<
String
>
imports
=
new
TreeSet
<
String
>();
private
ArrayList
<
Method
>
methods
=
new
ArrayList
<
Method
>();
private
TreeMap
<
String
,
Method
>
methods
=
new
TreeMap
<
String
,
Method
>();
private
String
packageName
;
private
String
className
;
private
Class
<?>
extendsClass
;
...
...
@@ -39,7 +38,7 @@ public class ProxyCodeGenerator {
}
ProxyCodeGenerator
cg
=
new
ProxyCodeGenerator
();
cg
.
setPackageName
(
"bytecode"
);
cg
.
generateClassProxy
(
TestBase
.
class
);
cg
.
generateClassProxy
(
c
);
StringWriter
sw
=
new
StringWriter
();
cg
.
write
(
new
PrintWriter
(
sw
));
String
code
=
sw
.
toString
();
...
...
@@ -76,16 +75,22 @@ public class ProxyCodeGenerator {
addImport
(
clazz
);
className
=
getClassName
(
clazz
)
+
"Proxy"
;
extendsClass
=
clazz
;
for
(
Method
m
:
clazz
.
getDeclaredMethods
())
{
if
(!
Modifier
.
isStatic
(
m
.
getModifiers
()))
{
if
(!
Modifier
.
isPrivate
(
m
.
getModifiers
()))
{
int
finalOrStaticOrPrivate
=
Modifier
.
FINAL
|
Modifier
.
STATIC
|
Modifier
.
PRIVATE
;
while
(
clazz
!=
null
)
{
for
(
Method
m
:
clazz
.
getDeclaredMethods
())
{
if
((
m
.
getModifiers
()
&
finalOrStaticOrPrivate
)
==
0
)
{
addMethod
(
m
);
}
}
clazz
=
clazz
.
getSuperclass
();
}
}
void
addMethod
(
Method
m
)
{
if
(
methods
.
containsKey
(
getMethodName
(
m
)))
{
// already declared in a subclass
return
;
}
addImport
(
m
.
getReturnType
());
for
(
Class
<?>
c
:
m
.
getParameterTypes
())
{
addImport
(
c
);
...
...
@@ -93,9 +98,21 @@ public class ProxyCodeGenerator {
for
(
Class
<?>
c
:
m
.
getExceptionTypes
())
{
addImport
(
c
);
}
methods
.
add
(
m
);
methods
.
put
(
getMethodName
(
m
),
m
);
}
private
String
getMethodName
(
Method
m
)
{
StringBuilder
buff
=
new
StringBuilder
();
buff
.
append
(
m
.
getReturnType
()).
append
(
' '
);
buff
.
append
(
m
.
getName
());
for
(
Class
<?>
p
:
m
.
getParameterTypes
())
{
buff
.
append
(
' '
);
buff
.
append
(
p
.
getName
());
}
return
buff
.
toString
();
}
void
addImport
(
Class
<?>
c
)
{
while
(
c
.
isArray
())
{
c
=
c
.
getComponentType
();
...
...
@@ -144,7 +161,7 @@ public class ProxyCodeGenerator {
writer
.
println
(
" private static <T extends RuntimeException> T convertException(Throwable e) {"
);
writer
.
println
(
" return (T) e;"
);
writer
.
println
(
" }"
);
for
(
Method
m
:
methods
)
{
for
(
Method
m
:
methods
.
values
()
)
{
Class
<?>
retClass
=
m
.
getReturnType
();
writer
.
print
(
" public "
+
getClassName
(
retClass
)
+
" "
+
m
.
getName
()
+
"("
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论