Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Dockerized Testing Toolkit
Testrunner OpenJDK11 JUnit5-Jupiter
Commits
0a0c6876
Verified
Commit
0a0c6876
authored
4 years ago
by
Lukas Wiest
Browse files
Options
Download
Email Patches
Plain Diff
refactor: dtt transition
parent
a5eb3b67
master
1 merge request
!1
Feat dtt transition
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
Dockerfile
+16
-16
Dockerfile
Jenkinsfile
+1
-1
Jenkinsfile
pom.xml
+2
-2
pom.xml
src/main/java/de/hftstuttgart/dtt/Testrunner.java
+21
-21
src/main/java/de/hftstuttgart/dtt/Testrunner.java
src/main/java/de/hftstuttgart/dtt/model/Result.java
+2
-2
src/main/java/de/hftstuttgart/dtt/model/Result.java
src/main/java/de/hftstuttgart/dtt/model/ResultSummary.java
+3
-3
src/main/java/de/hftstuttgart/dtt/model/ResultSummary.java
src/main/java/de/hftstuttgart/dtt/util/MySummaryGeneratingListener.java
+2
-2
...de/hftstuttgart/dtt/util/MySummaryGeneratingListener.java
src/main/java/de/hftstuttgart/dtt/util/logging/CustomFormatter.java
+1
-1
...ava/de/hftstuttgart/dtt/util/logging/CustomFormatter.java
src/main/resources/logging.properties
+1
-1
src/main/resources/logging.properties
with
49 additions
and
49 deletions
+49
-49
Dockerfile
+
16
-
16
View file @
0a0c6876
from
openjdk:11-jdk-slim
env
MODOCOT_
BASEDIR /
modocot
env
MODOCOT_
TESTDIR $
MODOCOT_
BASEDIR/test
env
MODOCOT_
SOURCEDIR $
MODOCOT_
BASEDIR/src
env
MODOCOT_
RESULTDIR $
MODOCOT_
BASEDIR/result
env
MODOCOT_
LIBSDIR $
MODOCOT_
BASEDIR/libs
env
BASEDIR /
data
env
TESTDIR $BASEDIR/test
env
SOURCEDIR $BASEDIR/src
env
RESULTDIR $BASEDIR/result
env
LIBSDIR $BASEDIR/libs
run
mkdir
-p
$
MODOCOT_
TESTDIR
\
&&
mkdir
$
MODOCOT_
SOURCEDIR
\
&&
mkdir
$
MODOCOT_
RESULTDIR
\
&&
mkdir
-p
/
$
MODOCOT_
LIBSDIR
/additional
run
mkdir
-p
$TESTDIR
\
&&
mkdir
$SOURCEDIR
\
&&
mkdir
$RESULTDIR
\
&&
mkdir
-p
/
$LIBSDIR
/additional
add
target/
modoco
t-openjdk11-junit5-runner-jar-with-dependencies.jar /$
MODOCOT_
BASEDIR/app.jar
add
https://repo1.maven.org/maven2/org/junit/jupiter/junit-jupiter-api/5.7.0/junit-jupiter-api-5.7.0.jar /$
MODOCOT_
LIBSDIR/
add
https://repo1.maven.org/maven2/org/junit/jupiter/junit-jupiter-engine/5.7.0/junit-jupiter-engine-5.7.0.jar /$
MODOCOT_
LIBSDIR/
add
https://repo1.maven.org/maven2/org/apiguardian/apiguardian-api/1.1.1/apiguardian-api-1.1.1.jar /$
MODOCOT_
LIBSDIR/
add
https://repo1.maven.org/maven2/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar /$
MODOCOT_
LIBSDIR/
add
target/
dt
t-openjdk11-junit5-runner-jar-with-dependencies.jar /$BASEDIR/app.jar
add
https://repo1.maven.org/maven2/org/junit/jupiter/junit-jupiter-api/5.7.0/junit-jupiter-api-5.7.0.jar /$LIBSDIR/
add
https://repo1.maven.org/maven2/org/junit/jupiter/junit-jupiter-engine/5.7.0/junit-jupiter-engine-5.7.0.jar /$LIBSDIR/
add
https://repo1.maven.org/maven2/org/apiguardian/apiguardian-api/1.1.1/apiguardian-api-1.1.1.jar /$LIBSDIR/
add
https://repo1.maven.org/maven2/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar /$LIBSDIR/
workdir
/modocot
workdir
$BASEDIR
entrypoint
java -Djava.security.egd=file:/dev/./urandom -jar /
modocot
/app.jar "$
MODOCOT_
SOURCEDIR/src:$
MODOCOT_
TESTDIR/test" "$
MODOCOT_
LIBSDIR/*:$
MODOCOT_
TESTDIR/libs/*" $
MODOCOT_
RESULTDIR
entrypoint
java -Djava.security.egd=file:/dev/./urandom -jar /
$BASEDIR
/app.jar "$SOURCEDIR/src:$TESTDIR/test" "$LIBSDIR/*:$TESTDIR/libs/*" $RESULTDIR
This diff is collapsed.
Click to expand it.
Jenkinsfile
+
1
-
1
View file @
0a0c6876
...
...
@@ -4,7 +4,7 @@ def version = ""
pipeline
{
environment
{
registry
=
"hftstuttgart/
modoco
t-openjdk11-junit5-testrunner"
registry
=
"hftstuttgart/
dt
t-openjdk11-junit5-testrunner"
registryCredential
=
'Dockerhub'
dockerImage
=
''
}
...
...
This diff is collapsed.
Click to expand it.
pom.xml
+
2
-
2
View file @
0a0c6876
...
...
@@ -5,7 +5,7 @@
<modelVersion>
4.0.0
</modelVersion>
<groupId>
de.hftstuttgart
</groupId>
<artifactId>
modoco
t-openjdk11-junit5-runner
</artifactId>
<artifactId>
dt
t-openjdk11-junit5-runner
</artifactId>
<version>
${buildNumber}
</version>
<packaging>
jar
</packaging>
...
...
@@ -72,7 +72,7 @@
<configuration>
<archive>
<manifest>
<mainClass>
de.hftstuttgart.
modoco
t.Testrunner
</mainClass>
<mainClass>
de.hftstuttgart.
dt
t.Testrunner
</mainClass>
</manifest>
</archive>
<descriptorRefs>
...
...
This diff is collapsed.
Click to expand it.
src/main/java/de/hftstuttgart/
modoco
t/Testrunner.java
→
src/main/java/de/hftstuttgart/
dt
t/Testrunner.java
+
21
-
21
View file @
0a0c6876
package
de.hftstuttgart.
modoco
t
;
package
de.hftstuttgart.
dt
t
;
import
de.hftstuttgart.
modoco
t.model.
Modocot
Result
;
import
de.hftstuttgart.
modoco
t.model.
Modocot
ResultSummary
;
import
de.hftstuttgart.
modoco
t.util.M
odocot
SummaryGeneratingListener
;
import
de.hftstuttgart.
dt
t.model.Result
;
import
de.hftstuttgart.
dt
t.model.ResultSummary
;
import
de.hftstuttgart.
dt
t.util.M
y
SummaryGeneratingListener
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
...
...
@@ -71,7 +71,7 @@ public class Testrunner
sourceFolders
=
args
[
0
].
split
(
":"
);
libraryFolders
=
args
[
1
].
split
(
":"
);
resultFolder
=
args
[
2
];
classFolder
=
Files
.
createTempDirectory
(
"
modocot-
testrunner"
).
toAbsolutePath
().
toString
();
classFolder
=
Files
.
createTempDirectory
(
"testrunner"
).
toAbsolutePath
().
toString
();
// finding all source files
Set
<
File
>
sourceFiles
=
new
HashSet
<>();
...
...
@@ -81,10 +81,10 @@ public class Testrunner
}
// call compilation and generate Results for failed compiles
Set
<
Modocot
Result
>
compilationErrors
=
generateCompileResults
(
compile
(
sourceFiles
,
new
File
(
classFolder
)));
Set
<
Result
>
compilationErrors
=
generateCompileResults
(
compile
(
sourceFiles
,
new
File
(
classFolder
)));
// run unit tests found in the compiled class files
Modocot
ResultSummary
resultSummary
=
runTests
();
ResultSummary
resultSummary
=
runTests
();
// add compilation errors to summary
resultSummary
.
results
.
addAll
(
compilationErrors
);
...
...
@@ -208,16 +208,16 @@ public class Testrunner
return
URLClassLoader
.
newInstance
(
urls
,
parentClassLoader
);
}
public
static
Set
<
Modocot
Result
>
generateCompileResults
(
List
<
Diagnostic
>
compilationErrors
)
public
static
Set
<
Result
>
generateCompileResults
(
List
<
Diagnostic
>
compilationErrors
)
{
return
compilationErrors
.
stream
().
map
(
e
->
{
Modocot
Result
result
=
new
Modocot
Result
();
Result
result
=
new
Result
();
Pattern
pattern
=
Pattern
.
compile
(
String
.
format
(
"^.*%s(.*\\.java).*$"
,
File
.
separator
));
Matcher
matcher
=
pattern
.
matcher
(
String
.
valueOf
(
e
.
getSource
()));
result
.
name
=
(
matcher
.
matches
()
&&
matcher
.
group
(
1
)
!=
null
)
?
matcher
.
group
(
1
)
:
String
.
valueOf
(
e
.
getSource
());
result
.
state
=
Modocot
Result
.
State
.
COMPILATIONERROR
.
ordinal
();
result
.
state
=
Result
.
State
.
COMPILATIONERROR
.
ordinal
();
result
.
failureReason
=
e
.
getMessage
(
Locale
.
ENGLISH
);
result
.
failureType
=
"Compilation Failed"
;
result
.
stacktrace
=
e
.
toString
();
...
...
@@ -231,7 +231,7 @@ public class Testrunner
.
collect
(
Collectors
.
toCollection
(
HashSet:
:
new
));
}
public
static
Modocot
ResultSummary
generateResultSummary
(
TestExecutionSummary
summary
,
Set
<
TestIdentifier
>
successes
)
public
static
ResultSummary
generateResultSummary
(
TestExecutionSummary
summary
,
Set
<
TestIdentifier
>
successes
)
{
LOG
.
info
(
"JUnit results:"
);
LOG
.
info
(
String
.
format
(
...
...
@@ -246,12 +246,12 @@ public class Testrunner
.
reduce
((
s1
,
s2
)
->
s1
+
":"
+
s2
).
orElse
(
"-"
)
));
Modocot
ResultSummary
resultSummary
=
new
Modocot
ResultSummary
();
ResultSummary
resultSummary
=
new
ResultSummary
();
resultSummary
.
results
.
addAll
(
successes
.
stream
().
map
(
s
->
{
Modocot
Result
result
=
new
Modocot
Result
();
Result
result
=
new
Result
();
result
.
name
=
s
.
getDisplayName
();
result
.
state
=
Modocot
Result
.
State
.
SUCCESS
.
ordinal
();
result
.
state
=
Result
.
State
.
SUCCESS
.
ordinal
();
return
result
;
})
...
...
@@ -259,9 +259,9 @@ public class Testrunner
resultSummary
.
results
.
addAll
(
summary
.
getFailures
().
stream
().
map
(
f
->
{
Modocot
Result
result
=
new
Modocot
Result
();
Result
result
=
new
Result
();
result
.
name
=
f
.
getTestIdentifier
().
getDisplayName
();
result
.
state
=
Modocot
Result
.
State
.
FAILURE
.
ordinal
();
result
.
state
=
Result
.
State
.
FAILURE
.
ordinal
();
result
.
failureReason
=
f
.
getException
().
getMessage
();
result
.
failureType
=
f
.
getException
().
getClass
().
getName
();
...
...
@@ -308,7 +308,7 @@ public class Testrunner
return
files
;
}
public
static
Modocot
ResultSummary
runTests
()
throws
MalformedURLException
public
static
ResultSummary
runTests
()
throws
MalformedURLException
{
classPathItems
=
buildClassPathItems
(
true
);
LOG
.
info
(
"saving original class loader"
);
...
...
@@ -327,7 +327,7 @@ public class Testrunner
.
selectors
(
DiscoverySelectors
.
selectClasspathRoots
(
Collections
.
singleton
(
Paths
.
get
(
classFolder
).
toAbsolutePath
())))
.
build
();
M
odocot
SummaryGeneratingListener
listener
=
new
M
odocot
SummaryGeneratingListener
();
M
y
SummaryGeneratingListener
listener
=
new
M
y
SummaryGeneratingListener
();
Launcher
launcher
=
LauncherFactory
.
create
();
launcher
.
registerTestExecutionListeners
(
listener
);
...
...
@@ -354,14 +354,14 @@ public class Testrunner
Thread
.
currentThread
().
setContextClassLoader
(
originalClassLoader
);
}
LOG
.
info
(
"generate
modocot
result summary from junit"
);
LOG
.
info
(
"generate result summary from junit"
);
return
generateResultSummary
(
summary
,
successes
);
}
public
static
void
writeResult
(
Modocot
ResultSummary
resultSummary
)
throws
IOException
public
static
void
writeResult
(
ResultSummary
resultSummary
)
throws
IOException
{
Path
fileName
=
Paths
.
get
(
resultFolder
,
"result.json"
);
LOG
.
info
(
String
.
format
(
"serializing
modocdot
result as json into %s"
,
fileName
.
toAbsolutePath
().
toString
()));
LOG
.
info
(
String
.
format
(
"serializing result as json into %s"
,
fileName
.
toAbsolutePath
().
toString
()));
ObjectMapper
objectMapper
=
new
ObjectMapper
();
objectMapper
.
writerWithDefaultPrettyPrinter
()
...
...
This diff is collapsed.
Click to expand it.
src/main/java/de/hftstuttgart/
modoco
t/model/
Modocot
Result.java
→
src/main/java/de/hftstuttgart/
dt
t/model/Result.java
+
2
-
2
View file @
0a0c6876
package
de.hftstuttgart.
modoco
t.model
;
package
de.hftstuttgart.
dt
t.model
;
public
class
Modocot
Result
public
class
Result
{
public
String
name
;
public
int
state
;
...
...
This diff is collapsed.
Click to expand it.
src/main/java/de/hftstuttgart/
modoco
t/model/
Modocot
ResultSummary.java
→
src/main/java/de/hftstuttgart/
dt
t/model/ResultSummary.java
+
3
-
3
View file @
0a0c6876
package
de.hftstuttgart.
modoco
t.model
;
package
de.hftstuttgart.
dt
t.model
;
import
java.util.HashSet
;
import
java.util.Set
;
public
class
Modocot
ResultSummary
public
class
ResultSummary
{
public
long
timestamp
=
System
.
currentTimeMillis
()
/
1000
;
public
String
globalStacktrace
=
null
;
public
Set
<
Modocot
Result
>
results
=
new
HashSet
<>();
public
Set
<
Result
>
results
=
new
HashSet
<>();
}
This diff is collapsed.
Click to expand it.
src/main/java/de/hftstuttgart/
modoco
t/util/M
odocot
SummaryGeneratingListener.java
→
src/main/java/de/hftstuttgart/
dt
t/util/M
y
SummaryGeneratingListener.java
+
2
-
2
View file @
0a0c6876
package
de.hftstuttgart.
modoco
t.util
;
package
de.hftstuttgart.
dt
t.util
;
import
org.junit.platform.engine.TestDescriptor
;
import
org.junit.platform.engine.TestExecutionResult
;
...
...
@@ -8,7 +8,7 @@ import org.junit.platform.launcher.listeners.SummaryGeneratingListener;
import
java.util.HashSet
;
import
java.util.Set
;
public
class
M
odocot
SummaryGeneratingListener
extends
SummaryGeneratingListener
public
class
M
y
SummaryGeneratingListener
extends
org
.
junit
.
platform
.
launcher
.
listeners
.
SummaryGeneratingListener
{
protected
Set
<
TestIdentifier
>
successful
=
new
HashSet
<>();
...
...
This diff is collapsed.
Click to expand it.
src/main/java/de/hftstuttgart/
modoco
t/util/logging/CustomFormatter.java
→
src/main/java/de/hftstuttgart/
dt
t/util/logging/CustomFormatter.java
+
1
-
1
View file @
0a0c6876
package
de.hftstuttgart.
modoco
t.util.logging
;
package
de.hftstuttgart.
dt
t.util.logging
;
import
java.util.Date
;
import
java.util.logging.LogRecord
;
...
...
This diff is collapsed.
Click to expand it.
src/main/resources/logging.properties
+
1
-
1
View file @
0a0c6876
handlers
=
java.util.logging.ConsoleHandler
.level
=
INFO
java.util.logging.ConsoleHandler.level
=
INFO
java.util.logging.ConsoleHandler.formatter
=
de.hftstuttgart.
modoco
t.util.logging.CustomFormatter
java.util.logging.ConsoleHandler.formatter
=
de.hftstuttgart.
dt
t.util.logging.CustomFormatter
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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
Menu
Explore
Projects
Groups
Snippets