Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
nreeves5
cosc220-a2-220188955
Commits
6e002aef
Commit
6e002aef
authored
Jul 07, 2021
by
William Billingsley
Committed by
nreeves5
Jul 24, 2021
Browse files
Added log4j and a basic test class
parent
8a5345d8
Changes
5
Hide whitespace changes
Inline
Side-by-side
build.gradle
View file @
6e002aef
...
...
@@ -25,6 +25,10 @@ repositories {
}
dependencies
{
// Log4J does logging. We'll meet it properly in a later week...
implementation
'org.apache.logging.log4j:log4j-api:2.12.0'
implementation
'org.apache.logging.log4j:log4j-core:2.12.0'
testImplementation
'org.junit.jupiter:junit-jupiter-api:5.7.0'
testRuntimeOnly
'org.junit.jupiter:junit-jupiter-engine:5.7.0'
}
...
...
src/main/java/dotsandboxes/DotsAndBoxesUI.java
View file @
6e002aef
...
...
@@ -79,6 +79,10 @@ public class DotsAndBoxesUI {
grid
.
drawHorizontal
(
x
,
y
,
grid
.
getPlayer
());
}
catch
(
IllegalStateException
ex
)
{
// do nothing
// This is a little artificial, as normally we'd implement this with a check that the line isn't
// already "drawn" and then not calling the function. But for the exercise, we wanted students
// to write a test that would ensure an exception is thrown, so we're relying on an exception
// being thrown!
}});
AnchorPane
.
setLeftAnchor
(
line
,
0.0
+
gap
+
dotDiameter
+
col
*
(
gap
+
lineLength
+
gap
+
dotDiameter
));
...
...
src/main/java/module-info.java
View file @
6e002aef
...
...
@@ -14,5 +14,6 @@
module
dotsAndBoxes
{
requires
javafx
.
graphics
;
requires
javafx
.
controls
;
requires
org
.
apache
.
logging
.
log4j
;
exports
dotsandboxes
;
}
\ No newline at end of file
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
0 → 100644
View file @
6e002aef
package
dotsandboxes
;
import
org.junit.jupiter.api.*
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
import
static
org
.
junit
.
jupiter
.
api
.
Assumptions
.*;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
public
class
DotsAndBoxesGridTest
{
/*
* Because Test classes are classes, they can have fields, and can have static fields.
* This field is a logger. Loggers are like a more advanced println, for writing messages out to the console or a log file.
*/
private
static
final
Logger
logger
=
LogManager
.
getLogger
(
DotsAndBoxesGridTest
.
class
);
/*
* Tests are functions that have an @Test annotation before them.
* The typical format of a test is that it contains some code that does something, and then one
* or more assertions to check that a condition holds.
*
* This is a dummy test just to show that the test suite itself runs
*/
@Test
public
void
testTestSuiteRuns
()
{
logger
.
info
(
"Dummy test to show the test suite runs"
);
assertTrue
(
true
);
}
// FIXME: You need to write tests for the two known bugs in the code.
}
src/test/resources/log4j2.xml
0 → 100644
View file @
6e002aef
<?xml version="1.0" encoding="UTF-8"?>
<Configuration
status=
"WARN"
>
<Appenders>
<Console
name=
"Console"
target=
"SYSTEM_OUT"
>
<PatternLayout
pattern=
"%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"
/>
</Console>
</Appenders>
<Loggers>
<Root
level=
"debug"
>
<AppenderRef
ref=
"Console"
/>
</Root>
</Loggers>
</Configuration>
\ No newline at end of file
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