package jetbrains.buildServer.tools.installer; import jetbrains.buildServer.core.runtime.RuntimeUtil; import jetbrains.buildServer.core.runtime.osgx.IToolDescriptor; import jetbrains.buildServer.core.runtime.osgx.ToolRepository; import jetbrains.buildServer.tools.AbstractToolingTestCase; import jetbrains.buildServer.tools.ToolsConstants; import junit.framework.Assert; import org.junit.Test; public class ToolsInstallerFeatureTest extends AbstractToolingTestCase { @Test public void load_custom_repo_null() throws Exception { // final String first = String.format("%s/merge/merge.sun.jre.new.version.manifest.xml", getTestRepoUri()); // final String second = String.format("%s/merge/merge.tools.manifest.xml", getTestRepoUri()); try { System.setProperty(ToolsConstants.TEAMCITY_TOOLS_REPOSITORY_LOCATION_URI, ""); final ToolRepository customRepo = ToolsInstallerFeature.loadCustomRepository(); Assert.assertNull(customRepo); } finally { System.setProperty(ToolsConstants.TEAMCITY_TOOLS_REPOSITORY_LOCATION_URI, ""); } } @Test public void load_custom_repo_single() throws Exception { final String first = String.format("%s/merge/merge.sun.jre.new.version.manifest.xml", getTestRepoUri()); try { System.setProperty(ToolsConstants.TEAMCITY_TOOLS_REPOSITORY_LOCATION_URI, String.format("%s", first)); final ToolRepository customRepo = ToolsInstallerFeature.loadCustomRepository(); Assert.assertNotNull(customRepo); IToolDescriptor[] tools = customRepo.tools(RuntimeUtil.CONSOLE_MONITOR); Assert.assertNotNull(tools); Assert.assertTrue(tools.length == 2); } finally { System.setProperty(ToolsConstants.TEAMCITY_TOOLS_REPOSITORY_LOCATION_URI, ""); } } @Test public void load_custom_repo_multiple() throws Exception { final String first = String.format("%s/merge/merge.sun.jre.new.version.manifest.xml", getTestRepoUri()); final String second = String.format("%s/merge/merge.tools.manifest.xml", getTestRepoUri()); try { System.setProperty(ToolsConstants.TEAMCITY_TOOLS_REPOSITORY_LOCATION_URI, String.format("%s;%s", first, second)); final ToolRepository customRepo = ToolsInstallerFeature.loadCustomRepository(); Assert.assertNotNull(customRepo); IToolDescriptor[] tools = customRepo.tools(RuntimeUtil.CONSOLE_MONITOR); Assert.assertNotNull(tools); Assert.assertTrue(tools.length == 4); } finally { System.setProperty(ToolsConstants.TEAMCITY_TOOLS_REPOSITORY_LOCATION_URI, ""); } } @Test public void do_not_load_system_tools() throws Exception { final IToolDescriptor[] uiVisibleTools = ToolsInstallerFeature.tools(); Assert.assertNotNull(uiVisibleTools); Assert.assertTrue(uiVisibleTools.length > 0); for (IToolDescriptor uiTool : uiVisibleTools) { Assert.assertFalse(String.format("Found system tool '%s':", uiTool.getId()), uiTool.isSystem()); } } }