File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
src/test/java/org/scijava/display Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ package org .scijava .display ;
2+
3+ public class CustomTextDisplay extends AbstractDisplay <String > implements
4+ TextDisplay
5+ {
6+
7+ public CustomTextDisplay () {
8+ super (String .class );
9+ }
10+
11+ @ Override
12+ public void append (final String text ) {
13+ add (text );
14+ }
15+
16+ }
Original file line number Diff line number Diff line change 3939
4040import org .junit .Test ;
4141import org .scijava .Context ;
42+ import org .scijava .Priority ;
43+ import org .scijava .plugin .PluginInfo ;
44+ import org .scijava .plugin .PluginService ;
45+
46+ import java .util .List ;
4247
4348/**
4449 * Unit tests for core {@link Display} classes.
@@ -132,4 +137,20 @@ public void testText() {
132137 assertEquals (value , result );
133138 }
134139
140+ @ Test
141+ public void testMultipleDisplaysPriorityMatch () {
142+ final Context context = new Context (DisplayService .class );
143+ PluginInfo <Display > info = PluginInfo .create (CustomTextDisplay .class , Display .class );
144+ info .setPriority (Priority .HIGH );
145+ context .service (PluginService .class ).addPlugin (info );
146+ final DefaultDisplayService displayService =
147+ context .getService (DefaultDisplayService .class );
148+ final String name = "Text" ;
149+ final String value = "Hello" ;
150+ List <Display <?>> matchingDisplays = displayService .getMatchingDisplays (value );
151+ assertNotNull (matchingDisplays );
152+ assertTrue (matchingDisplays .size () > 1 );
153+ Display <?> display = displayService .createDisplay (name , value );
154+ assertEquals (CustomTextDisplay .class , display .getClass ());
155+ }
135156}
You can’t perform that action at this time.
0 commit comments