Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
5abe94fc
Shardingsphere
项目概览
apache
/
Shardingsphere
通知
56
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Shardingsphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5abe94fc
编写于
5月 04, 2018
作者:
T
terrymanu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
for #601: remove FileUtil
上级
9969d1c6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
87 deletion
+23
-87
sharding-jdbc-core/src/test/java/io/shardingjdbc/dbtest/StartTest.java
...-core/src/test/java/io/shardingjdbc/dbtest/StartTest.java
+23
-4
sharding-jdbc-core/src/test/java/io/shardingjdbc/dbtest/common/FileUtil.java
...src/test/java/io/shardingjdbc/dbtest/common/FileUtil.java
+0
-83
未找到文件。
sharding-jdbc-core/src/test/java/io/shardingjdbc/dbtest/StartTest.java
浏览文件 @
5abe94fc
...
...
@@ -18,7 +18,6 @@
package
io.shardingjdbc.dbtest
;
import
io.shardingjdbc.dbtest.asserts.AssertEngine
;
import
io.shardingjdbc.dbtest.common.FileUtil
;
import
io.shardingjdbc.dbtest.config.AnalyzeConfig
;
import
io.shardingjdbc.dbtest.config.bean.AssertDDLDefinition
;
import
io.shardingjdbc.dbtest.config.bean.AssertDMLDefinition
;
...
...
@@ -37,11 +36,17 @@ import org.junit.runners.Parameterized;
import
org.junit.runners.Parameterized.Parameters
;
import
javax.xml.bind.JAXBException
;
import
java.io.File
;
import
java.io.IOException
;
import
java.net.URL
;
import
java.nio.file.FileVisitResult
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.nio.file.SimpleFileVisitor
;
import
java.nio.file.attribute.BasicFileAttributes
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.LinkedList
;
import
java.util.List
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
...
...
@@ -66,8 +71,7 @@ public final class StartTest {
public
static
Collection
<
String
[]>
getParameters
()
throws
IOException
,
JAXBException
{
URL
integrateResources
=
StartTest
.
class
.
getClassLoader
().
getResource
(
INTEGRATION_RESOURCES_PATH
);
assertNotNull
(
integrateResources
);
List
<
String
>
paths
=
FileUtil
.
getAllFilePaths
(
new
File
(
integrateResources
.
getPath
()),
"assert-"
,
"xml"
);
for
(
String
each
:
paths
)
{
for
(
String
each
:
getAssertFiles
(
integrateResources
))
{
AssertsDefinition
assertsDefinition
=
AnalyzeConfig
.
analyze
(
each
);
if
(
StringUtils
.
isNotBlank
(
assertsDefinition
.
getBaseConfig
()))
{
String
[]
dbs
=
StringUtils
.
split
(
assertsDefinition
.
getBaseConfig
(),
","
);
...
...
@@ -90,6 +94,21 @@ public final class StartTest {
return
RESULT_ASSERT
;
}
private
static
List
<
String
>
getAssertFiles
(
final
URL
integrateResources
)
throws
IOException
{
final
List
<
String
>
result
=
new
LinkedList
<>();
Files
.
walkFileTree
(
Paths
.
get
(
integrateResources
.
getPath
()),
new
SimpleFileVisitor
<
Path
>()
{
@Override
public
FileVisitResult
visitFile
(
final
Path
file
,
final
BasicFileAttributes
basicFileAttributes
)
{
if
(
file
.
getFileName
().
toString
().
startsWith
(
"assert-"
)
&&
file
.
getFileName
().
toString
().
endsWith
(
".xml"
))
{
result
.
add
(
file
.
toFile
().
getPath
());
}
return
FileVisitResult
.
CONTINUE
;
}
});
return
result
;
}
private
static
<
T
extends
AssertDefinition
>
void
collateData
(
final
List
<
String
[]>
result
,
final
String
path
,
final
List
<
T
>
asserts
)
{
if
(
asserts
==
null
)
{
return
;
...
...
sharding-jdbc-core/src/test/java/io/shardingjdbc/dbtest/common/FileUtil.java
已删除
100644 → 0
浏览文件 @
9969d1c6
/*
* Copyright 1999-2015 dangdang.com.
* <p>
* 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.
* </p>
*/
package
io.shardingjdbc.dbtest.common
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
FileUtil
{
/**
* Get all the files in the directory.
* @param filePath File path
* @param prefixFile File name prefix
* @param suffix File name suffix
* @return All file paths
*/
public
static
List
<
String
>
getAllFilePaths
(
final
File
filePath
,
final
String
prefixFile
,
final
String
suffix
)
{
List
<
String
>
result
=
new
ArrayList
<>();
File
[]
files
=
filePath
.
listFiles
();
if
(
files
==
null
)
{
return
result
;
}
for
(
File
each
:
files
)
{
if
(
each
.
isDirectory
())
{
getSubFilePaths
(
each
,
result
,
prefixFile
,
suffix
);
}
else
{
getFiles
(
prefixFile
,
suffix
,
result
,
each
);
}
}
return
result
;
}
private
static
void
getFiles
(
final
String
prefixFile
,
final
String
suffix
,
final
List
<
String
>
filePaths
,
final
File
f
)
{
if
(
prefixFile
!=
null
)
{
if
(
f
.
getName
().
startsWith
(
prefixFile
))
{
if
(
suffix
!=
null
)
{
if
(
f
.
getName
().
endsWith
(
"."
+
suffix
))
{
filePaths
.
add
(
f
.
getPath
());
}
}
else
{
filePaths
.
add
(
f
.
getPath
());
}
}
}
else
{
filePaths
.
add
(
f
.
getPath
());
}
}
private
static
List
<
String
>
getSubFilePaths
(
final
File
filePath
,
final
List
<
String
>
filePaths
,
final
String
prefixFile
,
final
String
suffix
)
{
File
[]
files
=
filePath
.
listFiles
();
List
<
String
>
result
=
filePaths
;
if
(
files
==
null
)
{
return
result
;
}
for
(
File
each
:
files
)
{
if
(
each
.
isDirectory
())
{
getSubFilePaths
(
each
,
result
,
prefixFile
,
suffix
);
}
else
{
getFiles
(
prefixFile
,
suffix
,
result
,
each
);
}
}
return
result
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录