Skip to content

Commit fd0095e

Browse files
committed
Adds test for DefaultDisplayService choosing the matching display with the highest priority
1 parent cf77318 commit fd0095e

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.scijava.display;
2+
3+
import org.scijava.Priority;
4+
import org.scijava.plugin.Plugin;
5+
6+
@Plugin(type = Display.class, priority = Priority.HIGH)
7+
public class CustomTextDisplay extends AbstractDisplay<String> implements
8+
TextDisplay
9+
{
10+
11+
public CustomTextDisplay() {
12+
super(String.class);
13+
}
14+
15+
@Override
16+
public void append(final String text) {
17+
add(text);
18+
}
19+
20+
}

src/test/java/org/scijava/display/DisplayTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,14 @@ public void testText() {
132132
assertEquals(value, result);
133133
}
134134

135+
@Test
136+
public void testMultipleDisplaysPriorityMatch() {
137+
final Context context = new Context(DisplayService.class);
138+
final DisplayService displayService =
139+
context.getService(DisplayService.class);
140+
final String name = "Text";
141+
final String value = "Hello";
142+
Display<?> display = displayService.createDisplay(name, value);
143+
assertEquals(CustomTextDisplay.class, display.getClass());
144+
}
135145
}

0 commit comments

Comments
 (0)