1 // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
2 package com.intellij.debugger.streams.exec
4 import com.intellij.debugger.streams.test.TraceExecutionTestCase
5 import com.intellij.execution.configurations.JavaParameters
6 import com.intellij.openapi.application.ApplicationManager
7 import com.intellij.openapi.application.PluginPathManager
8 import com.intellij.openapi.util.SystemInfo
9 import com.intellij.openapi.util.io.FileUtil
10 import com.intellij.openapi.util.text.StringUtil
11 import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess
12 import com.intellij.testFramework.PsiTestUtil
14 import java.nio.file.Paths
17 * @author Vitaliy.Bibaev
19 abstract class LibraryTraceExecutionTestCase(jarName: String) : TraceExecutionTestCase() {
20 private val libraryDirectory = File(PluginPathManager.getPluginHomePath("stream-debugger") + "/lib").absolutePath
21 private val jarPath = Paths.get(libraryDirectory, jarName).toAbsolutePath().toString()
23 private companion object {
24 fun String.replaceLibraryPath(libraryPath: String): String {
25 val caseSensitive = SystemInfo.isFileSystemCaseSensitive
26 val result = StringUtil.replace(this, FileUtil.toSystemDependentName(libraryPath), "!LIBRARY_JAR!", !caseSensitive)
27 return StringUtil.replace(result, FileUtil.toSystemIndependentName(libraryPath), "!LIBRARY_JAR!", !caseSensitive)
31 override fun setUpModule() {
33 ApplicationManager.getApplication().runWriteAction {
34 VfsRootAccess.allowRootAccess(libraryDirectory)
35 PsiTestUtil.addLibrary(myModule, jarPath)
39 override fun replaceAdditionalInOutput(str: String): String {
40 return super.replaceAdditionalInOutput(str).replaceLibraryPath(jarPath)
43 override fun createJavaParameters(mainClass: String?): JavaParameters {
44 val parameters = super.createJavaParameters(mainClass)
45 parameters.classPath.add(jarPath)
49 final override fun getTestAppPath(): String {
50 return File(PluginPathManager.getPluginHomePath("stream-debugger") + "/testData/${getTestAppRelativePath()}").absolutePath
53 abstract fun getTestAppRelativePath(): String