Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
justauth
JustAuth
提交
31c98323
J
JustAuth
项目概览
justauth
/
JustAuth
1 年多 前同步成功
通知
391
Star
15212
Fork
2708
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
JustAuth
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
未验证
提交
31c98323
编写于
8月 06, 2019
作者:
智布道
👁
提交者:
GitHub
8月 06, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #34 from Diffblue-benchmarks/add-tests-for-stringutils-2
Add tests for me.zhyd.oauth.utils.StringUtils
上级
197f15dc
050686d8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
112 addition
and
19 deletion
+112
-19
src/test/java/me/zhyd/oauth/AuthRequestTest.java
src/test/java/me/zhyd/oauth/AuthRequestTest.java
+19
-19
src/test/java/me/zhyd/oauth/utils/StringUtilsTest.java
src/test/java/me/zhyd/oauth/utils/StringUtilsTest.java
+93
-0
未找到文件。
src/test/java/me/zhyd/oauth/AuthRequestTest.java
浏览文件 @
31c98323
...
...
@@ -16,7 +16,7 @@ public class AuthRequestTest {
AuthRequest
authRequest
=
new
AuthGiteeRequest
(
AuthConfig
.
builder
()
.
clientId
(
"clientId"
)
.
clientSecret
(
"clientSecret"
)
.
redirectUri
(
"redirectUri"
)
.
redirectUri
(
"
http://
redirectUri"
)
.
build
());
// 返回授权页面,可自行跳转
authRequest
.
authorize
(
"state"
);
...
...
@@ -30,7 +30,7 @@ public class AuthRequestTest {
AuthRequest
authRequest
=
new
AuthGithubRequest
(
AuthConfig
.
builder
()
.
clientId
(
"clientId"
)
.
clientSecret
(
"clientSecret"
)
.
redirectUri
(
"redirectUri"
)
.
redirectUri
(
"
http://
redirectUri"
)
.
build
());
// 返回授权页面,可自行跳转
authRequest
.
authorize
(
"state"
);
...
...
@@ -44,7 +44,7 @@ public class AuthRequestTest {
AuthRequest
authRequest
=
new
AuthWeiboRequest
(
AuthConfig
.
builder
()
.
clientId
(
"clientId"
)
.
clientSecret
(
"clientSecret"
)
.
redirectUri
(
"redirectUri"
)
.
redirectUri
(
"
http://
redirectUri"
)
.
build
());
// 返回授权页面,可自行跳转
authRequest
.
authorize
(
"state"
);
...
...
@@ -58,7 +58,7 @@ public class AuthRequestTest {
AuthRequest
authRequest
=
new
AuthDingTalkRequest
(
AuthConfig
.
builder
()
.
clientId
(
"clientId"
)
.
clientSecret
(
"clientSecret"
)
.
redirectUri
(
"redirectUri"
)
.
redirectUri
(
"
http://
redirectUri"
)
.
build
());
// 返回授权页面,可自行跳转
authRequest
.
authorize
(
"state"
);
...
...
@@ -72,7 +72,7 @@ public class AuthRequestTest {
AuthRequest
authRequest
=
new
AuthBaiduRequest
(
AuthConfig
.
builder
()
.
clientId
(
"clientId"
)
.
clientSecret
(
"clientSecret"
)
.
redirectUri
(
"redirectUri"
)
.
redirectUri
(
"
http://
redirectUri"
)
.
build
());
// 返回授权页面,可自行跳转
authRequest
.
authorize
(
"state"
);
...
...
@@ -86,7 +86,7 @@ public class AuthRequestTest {
AuthRequest
authRequest
=
new
AuthCodingRequest
(
AuthConfig
.
builder
()
.
clientId
(
"clientId"
)
.
clientSecret
(
"clientSecret"
)
.
redirectUri
(
"redirectUri"
)
.
redirectUri
(
"
http://
redirectUri"
)
.
build
());
// 返回授权页面,可自行跳转
authRequest
.
authorize
(
"state"
);
...
...
@@ -100,7 +100,7 @@ public class AuthRequestTest {
AuthRequest
authRequest
=
new
AuthTencentCloudRequest
(
AuthConfig
.
builder
()
.
clientId
(
"clientId"
)
.
clientSecret
(
"clientSecret"
)
.
redirectUri
(
"redirectUri"
)
.
redirectUri
(
"
http://
redirectUri"
)
.
build
());
// 返回授权页面,可自行跳转
authRequest
.
authorize
(
"state"
);
...
...
@@ -114,7 +114,7 @@ public class AuthRequestTest {
AuthRequest
authRequest
=
new
AuthOschinaRequest
(
AuthConfig
.
builder
()
.
clientId
(
"clientId"
)
.
clientSecret
(
"clientSecret"
)
.
redirectUri
(
"redirectUri"
)
.
redirectUri
(
"
http://
redirectUri"
)
.
build
());
// 返回授权页面,可自行跳转
authRequest
.
authorize
(
"state"
);
...
...
@@ -128,7 +128,7 @@ public class AuthRequestTest {
AuthRequest
authRequest
=
new
AuthAlipayRequest
(
AuthConfig
.
builder
()
.
clientId
(
"clientId"
)
.
clientSecret
(
"clientSecret"
)
.
redirectUri
(
"redirectUri"
)
.
redirectUri
(
"
http://
redirectUri"
)
.
alipayPublicKey
(
"publicKey"
)
.
build
());
// 返回授权页面,可自行跳转
...
...
@@ -143,7 +143,7 @@ public class AuthRequestTest {
AuthRequest
authRequest
=
new
AuthQqRequest
(
AuthConfig
.
builder
()
.
clientId
(
"clientId"
)
.
clientSecret
(
"clientSecret"
)
.
redirectUri
(
"redirectUri"
)
.
redirectUri
(
"
http://
redirectUri"
)
.
build
());
// 返回授权页面,可自行跳转
authRequest
.
authorize
(
"state"
);
...
...
@@ -157,7 +157,7 @@ public class AuthRequestTest {
AuthRequest
authRequest
=
new
AuthWeChatRequest
(
AuthConfig
.
builder
()
.
clientId
(
"clientId"
)
.
clientSecret
(
"clientSecret"
)
.
redirectUri
(
"redirectUri"
)
.
redirectUri
(
"
http://
redirectUri"
)
.
build
());
// 返回授权页面,可自行跳转
authRequest
.
authorize
(
"state"
);
...
...
@@ -171,7 +171,7 @@ public class AuthRequestTest {
AuthRequest
authRequest
=
new
AuthTaobaoRequest
(
AuthConfig
.
builder
()
.
clientId
(
"clientId"
)
.
clientSecret
(
"clientSecret"
)
.
redirectUri
(
"redirectUri"
)
.
redirectUri
(
"
http://
redirectUri"
)
.
build
());
// 返回授权页面,可自行跳转
authRequest
.
authorize
(
"state"
);
...
...
@@ -185,7 +185,7 @@ public class AuthRequestTest {
AuthRequest
authRequest
=
new
AuthGoogleRequest
(
AuthConfig
.
builder
()
.
clientId
(
"clientId"
)
.
clientSecret
(
"clientSecret"
)
.
redirectUri
(
"redirectUri"
)
.
redirectUri
(
"
http://
redirectUri"
)
.
build
());
// 返回授权页面,可自行跳转
authRequest
.
authorize
(
"state"
);
...
...
@@ -199,7 +199,7 @@ public class AuthRequestTest {
AuthRequest
authRequest
=
new
AuthFacebookRequest
(
AuthConfig
.
builder
()
.
clientId
(
"clientId"
)
.
clientSecret
(
"clientSecret"
)
.
redirectUri
(
"redirectUri"
)
.
redirectUri
(
"
https://
redirectUri"
)
.
build
());
// 返回授权页面,可自行跳转
authRequest
.
authorize
(
"state"
);
...
...
@@ -213,7 +213,7 @@ public class AuthRequestTest {
AuthRequest
authRequest
=
new
AuthDouyinRequest
(
AuthConfig
.
builder
()
.
clientId
(
"clientId"
)
.
clientSecret
(
"clientSecret"
)
.
redirectUri
(
"redirectUri"
)
.
redirectUri
(
"
http://
redirectUri"
)
.
build
());
// 返回授权页面,可自行跳转
authRequest
.
authorize
(
"state"
);
...
...
@@ -227,7 +227,7 @@ public class AuthRequestTest {
AuthRequest
authRequest
=
new
AuthLinkedinRequest
(
AuthConfig
.
builder
()
.
clientId
(
"clientId"
)
.
clientSecret
(
"clientSecret"
)
.
redirectUri
(
"redirectUri"
)
.
redirectUri
(
"
http://
redirectUri"
)
.
build
());
// 返回授权页面,可自行跳转
authRequest
.
authorize
(
"state"
);
...
...
@@ -241,7 +241,7 @@ public class AuthRequestTest {
AuthRequest
authRequest
=
new
AuthMicrosoftRequest
(
AuthConfig
.
builder
()
.
clientId
(
"clientId"
)
.
clientSecret
(
"clientSecret"
)
.
redirectUri
(
"redirectUri"
)
.
redirectUri
(
"
http://
redirectUri"
)
.
build
());
// 返回授权页面,可自行跳转
authRequest
.
authorize
(
"state"
);
...
...
@@ -255,7 +255,7 @@ public class AuthRequestTest {
AuthRequest
authRequest
=
new
AuthMiRequest
(
AuthConfig
.
builder
()
.
clientId
(
"clientId"
)
.
clientSecret
(
"clientSecret"
)
.
redirectUri
(
"redirectUri"
)
.
redirectUri
(
"
http://
redirectUri"
)
.
build
());
// 返回授权页面,可自行跳转
authRequest
.
authorize
(
"state"
);
...
...
@@ -269,7 +269,7 @@ public class AuthRequestTest {
AuthRequest
authRequest
=
new
AuthToutiaoRequest
(
AuthConfig
.
builder
()
.
clientId
(
"clientId"
)
.
clientSecret
(
"clientSecret"
)
.
redirectUri
(
"redirectUri"
)
.
redirectUri
(
"
http://
redirectUri"
)
.
build
());
// 返回授权页面,可自行跳转
authRequest
.
authorize
(
"state"
);
...
...
src/test/java/me/zhyd/oauth/utils/StringUtilsTest.java
0 → 100644
浏览文件 @
31c98323
package
me.zhyd.oauth.utils
;
import
org.junit.Assert
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.rules.ExpectedException
;
public
class
StringUtilsTest
{
@Rule
public
final
ExpectedException
thrown
=
ExpectedException
.
none
();
@Test
public
void
isEmptyNonEmptyInput
()
{
Assert
.
assertFalse
(
StringUtils
.
isEmpty
(
"non-empty string"
));
}
@Test
public
void
isEmptyEmptyInput
()
{
Assert
.
assertTrue
(
StringUtils
.
isEmpty
(
""
));
}
@Test
public
void
isEmptyInputNull
()
{
Assert
.
assertTrue
(
StringUtils
.
isEmpty
(
null
));
}
@Test
public
void
isNotEmptyNonEmptyInput
()
{
Assert
.
assertTrue
(
StringUtils
.
isNotEmpty
(
"non-empty string"
));
}
@Test
public
void
isNotEmptyEmptyInput
()
{
Assert
.
assertFalse
(
StringUtils
.
isNotEmpty
(
""
));
}
@Test
public
void
isNotEmptyInputNull
()
{
Assert
.
assertFalse
(
StringUtils
.
isNotEmpty
(
null
));
}
@Test
public
void
appendIfNotContainAppendedStringNotPresent
()
{
// (Check the case where appendStr doesn't occur in str)
final
String
str
=
"Prefix "
;
final
String
appendStr
=
"suffix"
;
final
String
otherwise
=
"should be discarded"
;
final
String
result
=
StringUtils
.
appendIfNotContain
(
str
,
appendStr
,
otherwise
);
Assert
.
assertEquals
(
"Prefix suffix"
,
result
);
}
@Test
public
void
appendIfNotContainAppendedStringPresent
()
{
// (Check the case where appendStr occurs in str)
final
String
str
=
"Prefix "
;
final
String
appendStr
=
"Prefix"
;
final
String
otherwise
=
"should be appended"
;
final
String
result
=
StringUtils
.
appendIfNotContain
(
str
,
appendStr
,
otherwise
);
Assert
.
assertEquals
(
"Prefix should be appended"
,
result
);
}
@Test
public
void
appendIfNotContainEmptyString
()
{
// (Check the special-case for str being empty)
final
String
str
=
""
;
final
String
appendStr
=
"should not be appended"
;
final
String
otherwise
=
"should also not be appended"
;
final
String
result
=
StringUtils
.
appendIfNotContain
(
str
,
appendStr
,
otherwise
);
Assert
.
assertEquals
(
""
,
result
);
}
@Test
public
void
appendIfNotContainAppendingEmptyString
()
{
// (Check the special-case for appendStr being empty)
final
String
str
=
"should be kept"
;
final
String
appendStr
=
""
;
final
String
otherwise
=
"should also not be appended"
;
final
String
result
=
StringUtils
.
appendIfNotContain
(
str
,
appendStr
,
otherwise
);
Assert
.
assertEquals
(
"should be kept"
,
result
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录