Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lab-starter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SOFT Core
SOFT 160
semesters
fall2024
lab-starter
Commits
88897382
Verified
Commit
88897382
authored
8 months ago
by
Christopher Bohn
Browse files
Options
Downloads
Patches
Plain Diff
Removed deprecated security manager from SortThreePairsTest
parent
16ee3e5a
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
sort_three_pairs/src/test/java/edu/unl/cse/soft160/sort_three_pairs/SortThreePairsTest.java
+0
-67
0 additions, 67 deletions
.../unl/cse/soft160/sort_three_pairs/SortThreePairsTest.java
with
0 additions
and
67 deletions
sort_three_pairs/src/test/java/edu/unl/cse/soft160/sort_three_pairs/SortThreePairsTest.java
+
0
−
67
View file @
88897382
package
edu.unl.cse.soft160.sort_three_pairs
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
java.io.InputStream
;
import
java.io.ByteArrayInputStream
;
import
java.io.PrintStream
;
import
java.security.Permission
;
import
java.io.ByteArrayOutputStream
;
import
static
org
.
junit
.
Assert
.*;
...
...
@@ -29,62 +26,6 @@ public class SortThreePairsTest {
return
collector
.
toString
();
}
@SuppressWarnings
(
"serial"
)
protected
static
class
ExitException
extends
SecurityException
{
public
final
int
status
;
public
ExitException
(
int
status
)
{
super
(
"Exit with status "
+
status
);
this
.
status
=
status
;
}
}
private
static
class
TestingSecurityManager
extends
SecurityManager
{
@Override
public
void
checkPermission
(
Permission
perm
)
{
}
@Override
public
void
checkPermission
(
Permission
perm
,
Object
context
)
{
}
@Override
public
void
checkExit
(
int
status
)
{
super
.
checkExit
(
status
);
throw
new
ExitException
(
status
);
}
}
@Before
public
void
setUp
()
throws
SecurityException
{
System
.
setSecurityManager
(
new
TestingSecurityManager
());
}
@After
public
void
tearDown
()
throws
SecurityException
{
System
.
setSecurityManager
(
null
);
}
protected
static
String
runMainForError
(
int
expectedStatus
,
String
...
arguments
)
{
InputStream
in
=
System
.
in
;
PrintStream
err
=
System
.
err
;
System
.
setIn
(
new
ByteArrayInputStream
(
""
.
getBytes
()));
ByteArrayOutputStream
collector
=
new
ByteArrayOutputStream
();
System
.
setErr
(
new
PrintStream
(
collector
));
boolean
exited
=
false
;
try
{
SortThreePairs
.
main
(
arguments
);
}
catch
(
ExitException
expected
)
{
assertEquals
(
expectedStatus
,
expected
.
status
);
exited
=
true
;
}
finally
{
System
.
setIn
(
in
);
System
.
setErr
(
err
);
}
assertTrue
(
exited
);
return
collector
.
toString
();
}
@Test
public
void
testZeros
()
{
assertEquals
(
assemble
(
"(0.0, 0.0)"
,
"(0.0, 0.0)"
,
"(0.0, 0.0)"
),
...
...
@@ -156,12 +97,4 @@ public class SortThreePairsTest {
assertEquals
(
assemble
(
"(0.0, 0.0)"
,
"(1.0, 1.0)"
,
"(2.0, 2.0)"
),
runMain
(
"1"
,
"1"
,
"0"
,
"0"
,
"2"
,
"2"
));
}
@Test
public
void
testTooFewArguments
()
{
assertEquals
(
assemble
(
"Sorts three points by their x coordinates, breaking ties using y coordinates."
,
"Usage: java edu.unl.cse.soft160.sort_three_pairs.SortThreePairs [X0] [Y0] [X1] [Y1] [X2] [Y2]"
),
runMainForError
(
1
,
"0"
,
"0"
,
"1"
,
"1"
,
"2"
,
"2"
,
"3"
));
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment