/* * Copyright 2000-2011 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jetbrains.buildServer.tools; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.net.URI; import jetbrains.buildServer.core.runtime.RuntimeUtil; import jetbrains.buildServer.core.runtime.osgx.ToolRepository; public abstract class AbstractToolingTestCase { public static final String LOCAL_REPO_PATH = "repo"; private static ToolRepository ourBundleRepository; public static void loadBundleRepository() throws IOException { if (ourBundleRepository == null) { ourBundleRepository = ToolRepository.getBundleRepository(RuntimeUtil.CONSOLE_MONITOR); } } protected static File getTestDataRoot() { File testDataRoot = new File("testData"); if (testDataRoot.exists()) { return testDataRoot.getAbsoluteFile(); } return new File("tests/testData").getAbsoluteFile(); } protected static File getLocalRepoRoot() { return new File(getTestDataRoot(), LOCAL_REPO_PATH).getAbsoluteFile(); } protected static ToolRepository getBundleRepository() throws IOException { loadBundleRepository(); return ourBundleRepository; } protected URI getTestRepoUri() throws MalformedURLException { return URI.create(String.format("file:////%s/%s", getTestDataRoot().getAbsolutePath().replace("\\", "/"), AbstractToolingTestCase.LOCAL_REPO_PATH)); } }