Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Hedtke, Moritz
AuD 2021 H05 Tests
Commits
f4bd7c91
Verified
Commit
f4bd7c91
authored
Jun 12, 2021
by
Daniel Mangold
Browse files
Changed test metadata format to JSON
parent
e277b3ed
Changes
1
Show whitespace changes
Inline
Side-by-side
src/test/java/h05/Utils.java
View file @
f4bd7c91
package
h05
;
import
org.json.JSONObject
;
import
org.opentest4j.TestAbortedException
;
import
java.io.*
;
...
...
@@ -213,24 +214,24 @@ public class Utils {
return
false
;
}
try
(
BufferedReader
remoteReader
=
new
BufferedReader
(
new
StringReader
(
response
.
body
())))
{
try
{
JSONObject
remoteData
=
new
JSONObject
(
response
.
body
());
boolean
persistentChanges
=
false
;
String
[]
versionLine
=
remoteReader
.
readLine
().
split
(
" -- "
,
2
);
Version
localVersion
=
new
Version
(
LOCAL_VERSION
),
remoteVersion
=
new
Version
(
versionLine
[
0
]
);
remoteVersion
=
new
Version
(
remoteData
.
getString
(
"version"
)
);
if
(
remoteVersion
.
compareTo
(
localVersion
)
>
0
)
{
System
.
out
.
println
(
"Update available! Local version: "
+
localVersion
+
" -- Remote version: "
+
remoteVersion
);
System
.
out
.
println
(
"Changelog: "
+
REPOSITORY_URL
+
"blob/master/changelog.md"
);
System
.
out
.
println
(
versionLine
[
1
]);
}
System
.
out
.
println
(
remoteData
.
getString
(
"updateMessage"
));
}
else
System
.
out
.
println
(
"Local tests are up to date"
);
for
(
String
line
=
remoteReader
.
readLine
();
(
CHECK_HASHES
||
(
AUTO_UPDATE
&&
remoteVersion
.
compareTo
(
localVersion
)
>
0
))
&&
line
!=
null
&&
line
.
length
()
!=
0
;
line
=
remoteReader
.
readLine
()
)
{
String
fileName
=
line
.
split
(
" +"
)[
0
],
expectedHash
=
line
.
split
(
" +"
)[
1
];
if
(!(
CHECK_HASHES
||
(
AUTO_UPDATE
&&
remoteVersion
.
compareTo
(
localVersion
)
>
0
)))
return
false
;
for
(
Map
.
Entry
<
String
,
Object
>
fileMap
:
remoteData
.
getJSONObject
(
"hashes"
).
toMap
().
entrySet
())
{
String
fileName
=
fileMap
.
getKey
(),
expectedHash
=
(
String
)
fileMap
.
getValue
();
if
(((
List
<?>)
getConfigOrDefault
(
"EXCLUDED_FILES"
,
List
.
of
())).
contains
(
fileName
))
continue
;
...
...
@@ -268,8 +269,6 @@ public class Utils {
}
}
System
.
out
.
println
(
"Local tests are up to date"
);
return
persistentChanges
;
}
catch
(
IOException
|
InterruptedException
|
NoSuchAlgorithmException
e
)
{
e
.
printStackTrace
();
...
...
Write
Preview
Supports
Markdown
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