Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
a7c139bd
Unverified
提交
a7c139bd
authored
1月 18, 2019
作者:
Evgenij Ryazanov
提交者:
GitHub
1月 18, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1679 from katzyn/tests
Use TestScript for testSimple
上级
131734ba
6a46708b
全部展开
显示空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
506 行增加
和
310 行删除
+506
-310
pom.xml
h2/pom.xml
+0
-1
build.html
h2/src/docsrc/html/build.html
+1
-2
Value.java
h2/src/main/org/h2/value/Value.java
+1
-10
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+0
-2
TestScript.java
h2/src/test/org/h2/test/scripts/TestScript.java
+3
-0
TestScriptSimple.java
h2/src/test/org/h2/test/scripts/TestScriptSimple.java
+0
-90
testSimple.sql
h2/src/test/org/h2/test/scripts/testSimple.sql
+500
-204
TestFileSystem.java
h2/src/test/org/h2/test/unit/TestFileSystem.java
+1
-1
没有找到文件。
h2/pom.xml
浏览文件 @
a7c139bd
...
@@ -194,7 +194,6 @@
...
@@ -194,7 +194,6 @@
<testResource>
<testResource>
<directory>
src/test
</directory>
<directory>
src/test
</directory>
<includes>
<includes>
<include>
org/h2/test/scripts/testSimple.in.txt
</include>
<include>
org/h2/test/scripts/**/*.sql
</include>
<include>
org/h2/test/scripts/**/*.sql
</include>
<include>
org/h2/samples/newsfeed.sql
</include>
<include>
org/h2/samples/newsfeed.sql
</include>
<include>
org/h2/samples/optimizations.sql
</include>
<include>
org/h2/samples/optimizations.sql
</include>
...
...
h2/src/docsrc/html/build.html
浏览文件 @
a7c139bd
...
@@ -216,8 +216,7 @@ If you'd like to contribute bug fixes or new features, please consider the follo
...
@@ -216,8 +216,7 @@ If you'd like to contribute bug fixes or new features, please consider the follo
The formatting options (
<code>
eclipseCodeStyle
</code>
) are also included.
The formatting options (
<code>
eclipseCodeStyle
</code>
) are also included.
</li><li>
Please provide test cases and integrate them into the test suite.
</li><li>
Please provide test cases and integrate them into the test suite.
For Java level tests, see
<code>
src/test/org/h2/test/TestAll.java
</code>
.
For Java level tests, see
<code>
src/test/org/h2/test/TestAll.java
</code>
.
For SQL level tests, see
<code>
src/test/org/h2/test/test.in.txt
</code>
or
For SQL level tests, see SQL files in
<code>
src/test/org/h2/test/scripts
</code>
.
<code>
testSimple.in.txt
</code>
.
</li><li>
The test cases should cover at least 90% of the changed and new code;
</li><li>
The test cases should cover at least 90% of the changed and new code;
use a code coverage tool to verify that (see above).
use a code coverage tool to verify that (see above).
or use the build target
<code>
coverage
</code>
.
or use the build target
<code>
coverage
</code>
.
...
...
h2/src/main/org/h2/value/Value.java
浏览文件 @
a7c139bd
...
@@ -489,16 +489,7 @@ public abstract class Value extends VersionedValue {
...
@@ -489,16 +489,7 @@ public abstract class Value extends VersionedValue {
*/
*/
public
static
TypeInfo
getHigherType
(
TypeInfo
type1
,
TypeInfo
type2
)
{
public
static
TypeInfo
getHigherType
(
TypeInfo
type1
,
TypeInfo
type2
)
{
int
t1
=
type1
.
getValueType
(),
t2
=
type2
.
getValueType
();
int
t1
=
type1
.
getValueType
(),
t2
=
type2
.
getValueType
();
if
(
t1
==
Value
.
UNKNOWN
||
t2
==
Value
.
UNKNOWN
)
{
int
dataType
=
getHigherOrder
(
t1
,
t2
);
if
(
t1
==
t2
)
{
throw
DbException
.
get
(
ErrorCode
.
UNKNOWN_DATA_TYPE_1
,
"?, ?"
);
}
else
if
(
t1
==
Value
.
NULL
)
{
throw
DbException
.
get
(
ErrorCode
.
UNKNOWN_DATA_TYPE_1
,
"NULL, ?"
);
}
else
if
(
t2
==
Value
.
NULL
)
{
throw
DbException
.
get
(
ErrorCode
.
UNKNOWN_DATA_TYPE_1
,
"?, NULL"
);
}
}
int
dataType
=
getOrder
(
t1
)
>
getOrder
(
t2
)
?
t1
:
t2
;
long
precision
=
Math
.
max
(
type1
.
getPrecision
(),
type2
.
getPrecision
());
long
precision
=
Math
.
max
(
type1
.
getPrecision
(),
type2
.
getPrecision
());
int
scale
=
Math
.
max
(
type1
.
getScale
(),
type2
.
getScale
());
int
scale
=
Math
.
max
(
type1
.
getScale
(),
type2
.
getScale
());
ExtTypeInfo
ext1
=
type1
.
getExtTypeInfo
();
ExtTypeInfo
ext1
=
type1
.
getExtTypeInfo
();
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
a7c139bd
...
@@ -125,7 +125,6 @@ import org.h2.test.poweroff.TestReorderWrites;
...
@@ -125,7 +125,6 @@ import org.h2.test.poweroff.TestReorderWrites;
import
org.h2.test.recover.RecoverLobTest
;
import
org.h2.test.recover.RecoverLobTest
;
import
org.h2.test.rowlock.TestRowLocks
;
import
org.h2.test.rowlock.TestRowLocks
;
import
org.h2.test.scripts.TestScript
;
import
org.h2.test.scripts.TestScript
;
import
org.h2.test.scripts.TestScriptSimple
;
import
org.h2.test.server.TestAutoServer
;
import
org.h2.test.server.TestAutoServer
;
import
org.h2.test.server.TestInit
;
import
org.h2.test.server.TestInit
;
import
org.h2.test.server.TestNestedLoop
;
import
org.h2.test.server.TestNestedLoop
;
...
@@ -742,7 +741,6 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
...
@@ -742,7 +741,6 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
beforeTest
();
beforeTest
();
// db
// db
addTest
(
new
TestScriptSimple
());
addTest
(
new
TestScript
());
addTest
(
new
TestScript
());
addTest
(
new
TestAlter
());
addTest
(
new
TestAlter
());
addTest
(
new
TestAlterSchemaRename
());
addTest
(
new
TestAlterSchemaRename
());
...
...
h2/src/test/org/h2/test/scripts/TestScript.java
浏览文件 @
a7c139bd
...
@@ -122,6 +122,9 @@ public class TestScript extends TestDb {
...
@@ -122,6 +122,9 @@ public class TestScript extends TestDb {
reconnectOften
=
!
config
.
memory
&&
config
.
big
;
reconnectOften
=
!
config
.
memory
&&
config
.
big
;
testScript
(
"testScript.sql"
);
testScript
(
"testScript.sql"
);
if
(!
config
.
memory
&&
!
config
.
big
&&
!
config
.
networked
)
{
testScript
(
"testSimple.sql"
);
}
testScript
(
"comments.sql"
);
testScript
(
"comments.sql"
);
testScript
(
"derived-column-names.sql"
);
testScript
(
"derived-column-names.sql"
);
testScript
(
"distinct.sql"
);
testScript
(
"distinct.sql"
);
...
...
h2/src/test/org/h2/test/scripts/TestScriptSimple.java
deleted
100644 → 0
浏览文件 @
131734ba
/*
* Copyright 2004-2019 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
test
.
scripts
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.LineNumberReader
;
import
java.nio.charset.StandardCharsets
;
import
java.sql.Connection
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestDb
;
import
org.h2.util.ScriptReader
;
/**
* This test runs a simple SQL script file and compares the output with the
* expected output.
*/
public
class
TestScriptSimple
extends
TestDb
{
private
Connection
conn
;
/**
* Run just this test.
*
* @param a ignored
*/
public
static
void
main
(
String
...
a
)
throws
Exception
{
TestBase
.
createCaller
().
init
().
test
();
}
@Override
public
boolean
isEnabled
()
{
if
(
config
.
memory
||
config
.
big
||
config
.
networked
)
{
return
false
;
}
return
true
;
}
@Override
public
void
test
()
throws
Exception
{
deleteDb
(
"scriptSimple"
);
reconnect
();
String
inFile
=
"org/h2/test/scripts/testSimple.in.txt"
;
InputStream
is
=
getClass
().
getClassLoader
().
getResourceAsStream
(
inFile
);
LineNumberReader
lineReader
=
new
LineNumberReader
(
new
InputStreamReader
(
is
,
StandardCharsets
.
UTF_8
));
try
(
ScriptReader
reader
=
new
ScriptReader
(
lineReader
))
{
while
(
true
)
{
String
sql
=
reader
.
readStatement
();
if
(
sql
==
null
)
{
break
;
}
sql
=
sql
.
trim
();
try
{
if
(
"@reconnect"
.
equals
(
sql
.
toLowerCase
()))
{
reconnect
();
}
else
if
(
sql
.
length
()
==
0
)
{
// ignore
}
else
if
(
sql
.
toLowerCase
().
startsWith
(
"select"
))
{
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
sql
);
while
(
rs
.
next
())
{
String
expected
=
reader
.
readStatement
().
trim
();
String
got
=
"> "
+
rs
.
getString
(
1
);
assertEquals
(
sql
,
expected
,
got
);
}
}
else
{
conn
.
createStatement
().
execute
(
sql
);
}
}
catch
(
SQLException
e
)
{
System
.
out
.
println
(
sql
);
throw
e
;
}
}
}
conn
.
close
();
deleteDb
(
"scriptSimple"
);
}
private
void
reconnect
()
throws
SQLException
{
if
(
conn
!=
null
)
{
conn
.
close
();
}
conn
=
getConnection
(
"scriptSimple"
);
}
}
h2/src/test/org/h2/test/scripts/testSimple.
in.txt
→
h2/src/test/org/h2/test/scripts/testSimple.
sql
浏览文件 @
a7c139bd
差异被折叠。
点击展开。
h2/src/test/org/h2/test/unit/TestFileSystem.java
浏览文件 @
a7c139bd
...
@@ -215,7 +215,7 @@ public class TestFileSystem extends TestDb {
...
@@ -215,7 +215,7 @@ public class TestFileSystem extends TestDb {
}
}
private
void
testClasspath
()
throws
IOException
{
private
void
testClasspath
()
throws
IOException
{
String
resource
=
"org/h2/test/scripts/testSimple.
in.txt
"
;
String
resource
=
"org/h2/test/scripts/testSimple.
sql
"
;
InputStream
in
;
InputStream
in
;
in
=
getClass
().
getResourceAsStream
(
"/"
+
resource
);
in
=
getClass
().
getResourceAsStream
(
"/"
+
resource
);
assertNotNull
(
in
);
assertNotNull
(
in
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论