@Test public void testWriteOneRemote() { RemoteIC[] ic = {new RemoteIC(true, "name", "host", "/help", "http", "8080")}; PreferenceFileHandler.commitRemoteICs(ic); PreferenceFileHandler handler = new PreferenceFileHandler(); assertEquals(1, handler.getTotalRemoteInfocenters()); assertEquals(1, handler.getHostEntries().length); assertEquals("host", handler.getHostEntries()[0]); assertEquals(1, handler.getPortEntries().length); assertEquals("8080", handler.getPortEntries()[0]); assertEquals(1, handler.getEnabledEntries().length); assertEquals("true", handler.getEnabledEntries()[0].toLowerCase()); assertEquals(1, handler.getPathEntries().length); assertEquals("/help", handler.getPathEntries()[0].toLowerCase()); }
@Test public void testWriteNoRemote() { PreferenceFileHandler.commitRemoteICs(new RemoteIC[0]); PreferenceFileHandler handler = new PreferenceFileHandler(); assertEquals(0, handler.getTotalRemoteInfocenters()); assertEquals(0, handler.getHostEntries().length); assertEquals(0, handler.getPortEntries().length); assertEquals(0, handler.getEnabledEntries().length); assertEquals(0, handler.getPathEntries().length); }
@Test public void testPathOnly() { setPreference("remoteHelpOn", "true"); setPreference("remoteHelpHost", "localhost"); setPreference("remoteHelpPath", ""); setPreference("remoteHelpUseDefaultPort", ""); setPreference("remoteHelpPort", ""); setPreference("remoteHelpName", ""); setPreference("remoteHelpICEnabled", ""); setPreference("remoteHelpICContributed", ""); PreferenceFileHandler handler = new PreferenceFileHandler(); assertEquals(1, handler.getTotalRemoteInfocenters()); assertEquals(1, handler.getHostEntries().length); assertEquals("localhost", handler.getHostEntries()[0]); assertEquals(1, handler.getPortEntries().length); // assertEquals("80", handler.getPortEntries()[0]); assertEquals(1, handler.getEnabledEntries().length); // assertEquals("true", handler.getEnabledEntries()[0].toLowerCase()); assertEquals(1, handler.getPathEntries().length); // assertEquals("/help", handler.getPathEntries()[0].toLowerCase()); }
@Test public void testOnePathTwoOfEverythingElse() { setPreference("remoteHelpOn", "true"); setPreference("remoteHelpHost", "localhost"); setPreference("remoteHelpPath", "/help,/nhelp"); setPreference("remoteHelpUseDefaultPort", "true,false"); setPreference("remoteHelpPort", "8081,8082"); setPreference("remoteHelpName", "local,remote"); setPreference("remoteHelpICEnabled", "true,false"); setPreference("remoteHelpICContributed", "false,true"); PreferenceFileHandler handler = new PreferenceFileHandler(); assertEquals(1, handler.getTotalRemoteInfocenters()); assertEquals(1, handler.getHostEntries().length); assertEquals("localhost", handler.getHostEntries()[0]); assertEquals(1, handler.getPortEntries().length); assertEquals("8081", handler.getPortEntries()[0]); assertEquals(1, handler.getEnabledEntries().length); assertEquals("true", handler.getEnabledEntries()[0].toLowerCase()); assertEquals(1, handler.getPathEntries().length); assertEquals("/help", handler.getPathEntries()[0].toLowerCase()); }
@Test public void testTwoRemoteInfocenters() { setPreference("remoteHelpHost", "localhost,www.eclipse.org"); setPreference("remoteHelpPath", "/help,/eclipse/help"); setPreference("remoteHelpUseDefaultPort", ""); setPreference("remoteHelpPort", "8081,8082"); setPreference("remoteHelpName", "local,remote"); setPreference("remoteHelpICEnabled", "true,false"); setPreference("remoteHelpICContributed", "false,false"); PreferenceFileHandler handler = new PreferenceFileHandler(); assertEquals(2, handler.getTotalRemoteInfocenters()); assertEquals(2, handler.getHostEntries().length); assertEquals("localhost", handler.getHostEntries()[0]); assertEquals("www.eclipse.org", handler.getHostEntries()[1]); assertEquals(2, handler.getPortEntries().length); assertEquals("8081", handler.getPortEntries()[0]); assertEquals("8082", handler.getPortEntries()[1]); assertEquals(2, handler.getEnabledEntries().length); assertEquals("true", handler.getEnabledEntries()[0].toLowerCase()); assertEquals("false", handler.getEnabledEntries()[1].toLowerCase()); assertEquals(2, handler.getPathEntries().length); assertEquals("/help", handler.getPathEntries()[0].toLowerCase()); assertEquals("/eclipse/help", handler.getPathEntries()[1].toLowerCase()); }
@Test public void testZeroRemoteInfocenters() { setPreference("remoteHelpOn", "true"); setPreference("remoteHelpHost", ""); setPreference("remoteHelpPath", ""); setPreference("remoteHelpUseDefaultPort", ""); setPreference("remoteHelpPort", ""); setPreference("remoteHelpName", ""); setPreference("remoteHelpICEnabled", ""); setPreference("remoteHelpICContributed", ""); PreferenceFileHandler handler = new PreferenceFileHandler(); assertEquals(0, handler.getTotalRemoteInfocenters()); assertEquals(0, handler.getHostEntries().length); assertEquals(0, handler.getPortEntries().length); assertEquals(0, handler.getEnabledEntries().length); assertEquals(0, handler.getPathEntries().length); }