Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
automatic-test
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟涨钱
automatic-test
Commits
4cc9f59d
Commit
4cc9f59d
authored
Sep 10, 2021
by
朽木不可雕也
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复未来N小时内,随机错误
parent
1747ed9b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
3 deletions
+14
-3
barrage-crawler-server/src/main/java/com/zhiweidata/automatictest/barragecrawlerserver/util/TimeUtil.java
+1
-1
barrage-crawler-server/src/test/java/com/zhiweidata/automatictest/barragecrawlerserver/util/TimeUtilTest.java
+13
-2
No files found.
barrage-crawler-server/src/main/java/com/zhiweidata/automatictest/barragecrawlerserver/util/TimeUtil.java
View file @
4cc9f59d
...
@@ -34,7 +34,7 @@ public class TimeUtil {
...
@@ -34,7 +34,7 @@ public class TimeUtil {
public
static
Date
randomHour
(
int
hour
)
{
public
static
Date
randomHour
(
int
hour
)
{
long
openInterval
=
System
.
currentTimeMillis
();
long
openInterval
=
System
.
currentTimeMillis
();
long
closeInterval
=
openInterval
+
hour
*
60
*
60
*
1000L
;
long
closeInterval
=
openInterval
+
hour
*
60
*
60
*
1000L
;
long
randomTime
=
openInterval
+
(
long
)
(
Math
.
random
()
*
(
openInterval
-
close
Interval
+
1
));
long
randomTime
=
openInterval
+
(
long
)
(
Math
.
random
()
*
(
closeInterval
-
open
Interval
+
1
));
return
new
Date
(
randomTime
);
return
new
Date
(
randomTime
);
}
}
}
}
barrage-crawler-server/src/test/java/com/zhiweidata/automatictest/barragecrawlerserver/util/TimeUtilTest.java
View file @
4cc9f59d
...
@@ -3,7 +3,9 @@ package com.zhiweidata.automatictest.barragecrawlerserver.util;
...
@@ -3,7 +3,9 @@ package com.zhiweidata.automatictest.barragecrawlerserver.util;
import
java.util.Date
;
import
java.util.Date
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
import
static
com
.
zhiweidata
.
automatictest
.
publics
.
BeanContainer
.
STANDARD_DATE_FORMAT
;
import
static
com
.
zhiweidata
.
automatictest
.
publics
.
BeanContainer
.
STANDARD_DATE_FORMAT
;
import
static
com
.
zhiweidata
.
automatictest
.
barragecrawlerserver
.
util
.
TimeUtil
.
randomDay
;
/**
/**
* @author aszswaz
* @author aszswaz
...
@@ -15,8 +17,16 @@ import static com.zhiweidata.automatictest.publics.BeanContainer.STANDARD_DATE_F
...
@@ -15,8 +17,16 @@ import static com.zhiweidata.automatictest.publics.BeanContainer.STANDARD_DATE_F
class
TimeUtilTest
{
class
TimeUtilTest
{
@Test
@Test
void
randmoDate
()
{
void
randomDate
()
{
Date
date
=
TimeUtil
.
randomDay
(
7
);
Date
date
=
randomDay
(
7
);
log
.
info
(
STANDARD_DATE_FORMAT
.
format
(
date
));
}
@Test
void
randomHour
()
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
Date
date
=
TimeUtil
.
randomHour
(
5
);
log
.
info
(
STANDARD_DATE_FORMAT
.
format
(
date
));
log
.
info
(
STANDARD_DATE_FORMAT
.
format
(
date
));
}
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment