1 19 20 package org.netbeans.modules.navigator; 21 22 import java.net.URL ; 23 import java.util.List ; 24 import java.util.Map ; 25 import javax.swing.JComponent ; 26 import org.netbeans.junit.NbTest; 27 import org.netbeans.junit.NbTestCase; 28 import org.netbeans.junit.NbTestSuite; 29 import org.netbeans.spi.navigator.NavigatorPanel; 30 import org.openide.filesystems.FileObject; 31 import org.openide.util.Lookup; 32 33 34 38 public class ProviderRegistryTest extends NbTestCase { 39 40 41 private static final String MARVELOUS_DATA_TYPE_NAME = "MarvelousDataType"; 42 private static final String MARVELOUS_DATA_TYPE = "text/marvelous/data_type"; 43 44 45 public ProviderRegistryTest() { 46 super(""); 47 } 48 49 public ProviderRegistryTest(String testName) { 50 super(testName); 51 } 52 53 public static void main(java.lang.String [] args) { 54 junit.textui.TestRunner.run(suite()); 55 } 56 57 public static NbTest suite() { 58 NbTestSuite suite = new NbTestSuite(ProviderRegistryTest.class); 59 return suite; 60 } 61 62 public void testGetProviders () throws Exception { 63 UnitTestUtils.prepareTest(new String [] { "/org/netbeans/modules/navigator/resources/testGetProvidersLayer.xml" }); 64 65 ProviderRegistry providerReg = ProviderRegistry.getInstance(); 66 67 System.out.println("Asking for non-existent type..."); 68 assertEquals(0, providerReg.getProviders("image/non_existent_type").size()); 69 70 System.out.println("Asking for non-existent class..."); 71 assertEquals(0, providerReg.getProviders("text/plain").size()); 72 73 System.out.println("Asking for valid type and provider..."); 74 List result = providerReg.getProviders(MARVELOUS_DATA_TYPE); 75 assertEquals(1, result.size()); 76 assertTrue(result.get(0) instanceof MarvelousDataTypeProvider); 77 MarvelousDataTypeProvider provider = (MarvelousDataTypeProvider)result.get(0); 78 assertEquals(MARVELOUS_DATA_TYPE_NAME, provider.getDisplayName()); 79 } 80 81 82 85 public static final class MarvelousDataTypeProvider implements NavigatorPanel { 86 87 public String getDisplayName () { 88 return MARVELOUS_DATA_TYPE_NAME; 89 } 90 91 public String getDisplayHint () { 92 return null; 93 } 94 95 public JComponent getComponent () { 96 return null; 97 } 98 99 public void panelActivated (Lookup context) { 100 } 101 102 public void panelDeactivated () { 103 } 104 105 public Lookup getLookup () { 106 return null; 107 } 108 109 } 110 111 112 } 113 | Popular Tags |