forked from junit-team/junit4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change Sorter to no longer extend Ordering.
Change Orderable to no longer extend Sortable.
- Loading branch information
Showing
10 changed files
with
108 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 0 additions & 36 deletions
36
src/main/java/org/junit/runner/manipulation/GenericOrdering.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/org/junit/runner/manipulation/SortBasedOrdering.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.junit.runner.manipulation; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import org.junit.runner.Description; | ||
|
||
class SortBasedOrdering extends Ordering { | ||
private final Sorter sorter; | ||
|
||
public SortBasedOrdering(Sorter sorter) { | ||
this.sorter = sorter; | ||
} | ||
|
||
@Override | ||
public void apply(Object runner) { | ||
if (runner instanceof Sortable) { | ||
// Sorting is more efficient than ordering, so apply the sorter. | ||
sorter.apply(runner); | ||
return; | ||
} | ||
|
||
try { | ||
super.apply(runner); | ||
} catch (InvalidOrderingException e) { | ||
throw new AssertionError("SortBasedOrdering should always produce a valid ordering"); | ||
} | ||
} | ||
|
||
@Override | ||
public List<Description> order(Collection<Description> siblings) { | ||
List<Description> sorted = new ArrayList<Description>(siblings); | ||
Collections.sort(sorted, sorter); | ||
return sorted; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters