Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
沉迷打码的小凳子
glide
提交
1be3a6c9
G
glide
项目概览
沉迷打码的小凳子
/
glide
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
glide
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
1be3a6c9
编写于
5月 29, 2019
作者:
S
Sam Judd
提交者:
Glide
5月 29, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove apache/fest dependencies in dislrucache tests.
PiperOrigin-RevId: 250595542
上级
cb22ae2c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
80 addition
and
33 deletion
+80
-33
third_party/disklrucache/build.gradle
third_party/disklrucache/build.gradle
+2
-3
third_party/disklrucache/src/test/java/com/bumptech/glide/disklrucache/DiskLruCacheTest.java
...ava/com/bumptech/glide/disklrucache/DiskLruCacheTest.java
+78
-30
未找到文件。
third_party/disklrucache/build.gradle
浏览文件 @
1be3a6c9
...
@@ -14,9 +14,8 @@ checkstyle {
...
@@ -14,9 +14,8 @@ checkstyle {
dependencies
{
dependencies
{
def
junitVersion
=
hasProperty
(
'JUNIT_VERSION'
)
?
JUNIT_VERSION
:
'4.11'
;
def
junitVersion
=
hasProperty
(
'JUNIT_VERSION'
)
?
JUNIT_VERSION
:
'4.11'
;
testCompile
"junit:junit:${junitVersion}"
testImplementation
"junit:junit:${junitVersion}"
testCompile
'commons-io:commons-io:2.4'
testImplementation
"com.google.truth:truth:${TRUTH_VERSION}"
testCompile
'org.easytesting:fest-assert-core:2.0M10'
}
}
android
{
android
{
...
...
third_party/disklrucache/src/test/java/com/bumptech/glide/disklrucache/DiskLruCacheTest.java
浏览文件 @
1be3a6c9
...
@@ -20,22 +20,15 @@ import static com.bumptech.glide.disklrucache.DiskLruCache.JOURNAL_FILE;
...
@@ -20,22 +20,15 @@ import static com.bumptech.glide.disklrucache.DiskLruCache.JOURNAL_FILE;
import
static
com
.
bumptech
.
glide
.
disklrucache
.
DiskLruCache
.
JOURNAL_FILE_BACKUP
;
import
static
com
.
bumptech
.
glide
.
disklrucache
.
DiskLruCache
.
JOURNAL_FILE_BACKUP
;
import
static
com
.
bumptech
.
glide
.
disklrucache
.
DiskLruCache
.
MAGIC
;
import
static
com
.
bumptech
.
glide
.
disklrucache
.
DiskLruCache
.
MAGIC
;
import
static
com
.
bumptech
.
glide
.
disklrucache
.
DiskLruCache
.
VERSION_1
;
import
static
com
.
bumptech
.
glide
.
disklrucache
.
DiskLruCache
.
VERSION_1
;
import
static
org
.
fest
.
assertions
.
api
.
Assertions
.
assertThat
;
import
static
com
.
google
.
common
.
truth
.
Fact
.
simpleFact
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
static
org
.
hamcrest
.
core
.
IsNot
.
not
;
import
static
org
.
hamcrest
.
core
.
IsNot
.
not
;
import
static
org
.
junit
.
Assume
.
assumeThat
;
import
static
org
.
junit
.
Assume
.
assumeThat
;
import
org.apache.commons.io.FileUtils
;
import
com.google.common.truth.ComparableSubject
;
import
org.hamcrest.core.StringStartsWith
;
import
com.google.common.truth.FailureMetadata
;
import
org.junit.After
;
import
com.google.common.truth.Subject
;
import
org.junit.Assert
;
import
com.google.common.truth.Truth
;
import
org.junit.Before
;
import
org.junit.BeforeClass
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.rules.TemporaryFolder
;
import
org.junit.runner.RunWith
;
import
org.junit.runners.JUnit4
;
import
java.io.BufferedReader
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileReader
;
import
java.io.FileReader
;
...
@@ -43,10 +36,21 @@ import java.io.FileWriter;
...
@@ -43,10 +36,21 @@ import java.io.FileWriter;
import
java.io.Reader
;
import
java.io.Reader
;
import
java.io.StringWriter
;
import
java.io.StringWriter
;
import
java.io.Writer
;
import
java.io.Writer
;
import
java.nio.file.Files
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
import
org.hamcrest.core.StringStartsWith
;
import
org.junit.After
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.BeforeClass
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.rules.TemporaryFolder
;
import
org.junit.runner.RunWith
;
import
org.junit.runners.JUnit4
;
@RunWith
(
JUnit4
.
class
)
@RunWith
(
JUnit4
.
class
)
public
final
class
DiskLruCacheTest
{
public
final
class
DiskLruCacheTest
{
...
@@ -630,7 +634,7 @@ public final class DiskLruCacheTest {
...
@@ -630,7 +634,7 @@ public final class DiskLruCacheTest {
creator
.
commit
();
creator
.
commit
();
cache
.
flush
();
cache
.
flush
();
File
Utils
.
copyFile
(
journalFile
,
journalBkpFile
);
File
s
.
copy
(
journalFile
.
toPath
(),
journalBkpFile
.
toPath
()
);
creator
=
cache
.
edit
(
"k2"
);
creator
=
cache
.
edit
(
"k2"
);
creator
.
set
(
0
,
"F"
);
creator
.
set
(
0
,
"F"
);
...
@@ -730,7 +734,7 @@ public final class DiskLruCacheTest {
...
@@ -730,7 +734,7 @@ public final class DiskLruCacheTest {
/** @see <a href="https://github.com/JakeWharton/DiskLruCache/issues/2">Issue #2</a> */
/** @see <a href="https://github.com/JakeWharton/DiskLruCache/issues/2">Issue #2</a> */
@Test
public
void
aggressiveClearingHandlesWrite
()
throws
Exception
{
@Test
public
void
aggressiveClearingHandlesWrite
()
throws
Exception
{
FileUtils
.
deleteDirectory
(
cacheDir
);
deleteDirectory
(
cacheDir
);
set
(
"a"
,
"a"
,
"a"
);
set
(
"a"
,
"a"
,
"a"
);
assertValue
(
"a"
,
"a"
,
"a"
);
assertValue
(
"a"
,
"a"
,
"a"
);
}
}
...
@@ -739,7 +743,7 @@ public final class DiskLruCacheTest {
...
@@ -739,7 +743,7 @@ public final class DiskLruCacheTest {
@Test
public
void
aggressiveClearingHandlesEdit
()
throws
Exception
{
@Test
public
void
aggressiveClearingHandlesEdit
()
throws
Exception
{
set
(
"a"
,
"a"
,
"a"
);
set
(
"a"
,
"a"
,
"a"
);
DiskLruCache
.
Editor
a
=
cache
.
get
(
"a"
).
edit
();
DiskLruCache
.
Editor
a
=
cache
.
get
(
"a"
).
edit
();
FileUtils
.
deleteDirectory
(
cacheDir
);
deleteDirectory
(
cacheDir
);
a
.
set
(
1
,
"a2"
);
a
.
set
(
1
,
"a2"
);
a
.
commit
();
a
.
commit
();
}
}
...
@@ -756,7 +760,7 @@ public final class DiskLruCacheTest {
...
@@ -756,7 +760,7 @@ public final class DiskLruCacheTest {
set
(
"b"
,
"b"
,
"b"
);
set
(
"b"
,
"b"
,
"b"
);
DiskLruCache
.
Editor
a
=
cache
.
get
(
"a"
).
edit
();
DiskLruCache
.
Editor
a
=
cache
.
get
(
"a"
).
edit
();
a
.
set
(
0
,
"a1"
);
a
.
set
(
0
,
"a1"
);
FileUtils
.
deleteDirectory
(
cacheDir
);
deleteDirectory
(
cacheDir
);
a
.
set
(
1
,
"a2"
);
a
.
set
(
1
,
"a2"
);
a
.
commit
();
a
.
commit
();
assertThat
(
cache
.
get
(
"a"
)).
isNull
();
assertThat
(
cache
.
get
(
"a"
)).
isNull
();
...
@@ -764,7 +768,7 @@ public final class DiskLruCacheTest {
...
@@ -764,7 +768,7 @@ public final class DiskLruCacheTest {
/** @see <a href="https://github.com/JakeWharton/DiskLruCache/issues/2">Issue #2</a> */
/** @see <a href="https://github.com/JakeWharton/DiskLruCache/issues/2">Issue #2</a> */
@Test
public
void
aggressiveClearingHandlesRead
()
throws
Exception
{
@Test
public
void
aggressiveClearingHandlesRead
()
throws
Exception
{
FileUtils
.
deleteDirectory
(
cacheDir
);
deleteDirectory
(
cacheDir
);
assertThat
(
cache
.
get
(
"a"
)).
isNull
();
assertThat
(
cache
.
get
(
"a"
)).
isNull
();
}
}
...
@@ -878,12 +882,12 @@ public final class DiskLruCacheTest {
...
@@ -878,12 +882,12 @@ public final class DiskLruCacheTest {
}
}
private
void
assertGarbageFilesAllDeleted
()
throws
Exception
{
private
void
assertGarbageFilesAllDeleted
()
throws
Exception
{
assertThat
(
getCleanFile
(
"g1"
,
0
)).
doesNotExist
();
FileSubject
.
assertThat
(
getCleanFile
(
"g1"
,
0
)).
doesNotExist
();
assertThat
(
getCleanFile
(
"g1"
,
1
)).
doesNotExist
();
FileSubject
.
assertThat
(
getCleanFile
(
"g1"
,
1
)).
doesNotExist
();
assertThat
(
getCleanFile
(
"g2"
,
0
)).
doesNotExist
();
FileSubject
.
assertThat
(
getCleanFile
(
"g2"
,
0
)).
doesNotExist
();
assertThat
(
getCleanFile
(
"g2"
,
1
)).
doesNotExist
();
FileSubject
.
assertThat
(
getCleanFile
(
"g2"
,
1
)).
doesNotExist
();
assertThat
(
new
File
(
cacheDir
,
"otherFile0"
)).
doesNotExist
();
FileSubject
.
assertThat
(
new
File
(
cacheDir
,
"otherFile0"
)).
doesNotExist
();
assertThat
(
new
File
(
cacheDir
,
"dir1"
)).
doesNotExist
();
FileSubject
.
assertThat
(
new
File
(
cacheDir
,
"dir1"
)).
doesNotExist
();
}
}
private
void
set
(
String
key
,
String
value0
,
String
value1
)
throws
Exception
{
private
void
set
(
String
key
,
String
value0
,
String
value1
)
throws
Exception
{
...
@@ -898,10 +902,10 @@ public final class DiskLruCacheTest {
...
@@ -898,10 +902,10 @@ public final class DiskLruCacheTest {
if
(
value
!=
null
)
{
if
(
value
!=
null
)
{
Assert
.
fail
();
Assert
.
fail
();
}
}
assertThat
(
getCleanFile
(
key
,
0
)).
doesNotExist
();
FileSubject
.
assertThat
(
getCleanFile
(
key
,
0
)).
doesNotExist
();
assertThat
(
getCleanFile
(
key
,
1
)).
doesNotExist
();
FileSubject
.
assertThat
(
getCleanFile
(
key
,
1
)).
doesNotExist
();
assertThat
(
getDirtyFile
(
key
,
0
)).
doesNotExist
();
FileSubject
.
assertThat
(
getDirtyFile
(
key
,
0
)).
doesNotExist
();
assertThat
(
getDirtyFile
(
key
,
1
)).
doesNotExist
();
FileSubject
.
assertThat
(
getDirtyFile
(
key
,
1
)).
doesNotExist
();
}
}
private
void
assertValue
(
String
key
,
String
value0
,
String
value1
)
throws
Exception
{
private
void
assertValue
(
String
key
,
String
value0
,
String
value1
)
throws
Exception
{
...
@@ -910,7 +914,51 @@ public final class DiskLruCacheTest {
...
@@ -910,7 +914,51 @@ public final class DiskLruCacheTest {
assertThat
(
value
.
getLength
(
0
)).
isEqualTo
(
value0
.
length
());
assertThat
(
value
.
getLength
(
0
)).
isEqualTo
(
value0
.
length
());
assertThat
(
value
.
getString
(
1
)).
isEqualTo
(
value1
);
assertThat
(
value
.
getString
(
1
)).
isEqualTo
(
value1
);
assertThat
(
value
.
getLength
(
1
)).
isEqualTo
(
value1
.
length
());
assertThat
(
value
.
getLength
(
1
)).
isEqualTo
(
value1
.
length
());
assertThat
(
getCleanFile
(
key
,
0
)).
exists
();
FileSubject
.
assertThat
(
getCleanFile
(
key
,
0
)).
exists
();
assertThat
(
getCleanFile
(
key
,
1
)).
exists
();
FileSubject
.
assertThat
(
getCleanFile
(
key
,
1
)).
exists
();
}
private
static
void
deleteDirectory
(
File
file
)
{
if
(
file
.
isDirectory
())
{
File
[]
children
=
file
.
listFiles
();
if
(
children
!=
null
&&
children
.
length
>
0
)
{
for
(
File
child
:
children
)
{
deleteDirectory
(
child
);
}
}
}
assertThat
(!
file
.
exists
()
||
file
.
delete
()).
isTrue
();
}
static
final
class
FileSubject
extends
ComparableSubject
<
FileSubject
,
File
>
{
private
static
final
Subject
.
Factory
<
FileSubject
,
File
>
FACTORY
=
new
Subject
.
Factory
<
FileSubject
,
File
>()
{
@Override
public
FileSubject
createSubject
(
FailureMetadata
metadata
,
File
actual
)
{
return
new
FileSubject
(
metadata
,
actual
);
}
};
private
final
File
actual
;
static
FileSubject
assertThat
(
File
file
)
{
return
Truth
.
assertAbout
(
FACTORY
).
that
(
file
);
}
protected
FileSubject
(
FailureMetadata
metadata
,
File
actual
)
{
super
(
metadata
,
actual
);
this
.
actual
=
actual
;
}
public
void
doesNotExist
()
{
if
(
actual
.
exists
())
{
failWithActual
(
simpleFact
(
"expected to not exist"
));
}
}
public
void
exists
()
{
if
(!
actual
.
exists
())
{
failWithActual
(
simpleFact
(
"expected to exist"
));
}
}
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录