cleanup: inline
[idea/community.git] / plugins / stream-debugger / test / com / intellij / debugger / streams / exec / LibraryTraceExecutionTestCase.kt
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
3
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.vfs.newvfs.impl.VfsRootAccess
9 import com.intellij.testFramework.PsiTestUtil
10 import java.io.File
11
12 /**
13  * @author Vitaliy.Bibaev
14  */
15 abstract class LibraryTraceExecutionTestCase(private val jarName: String) : TraceExecutionTestCase() {
16   private val libraryDirectory = File(PluginPathManager.getPluginHomePath("stream-debugger") + "/lib").absolutePath
17   override fun setUpModule() {
18     super.setUpModule()
19     ApplicationManager.getApplication().runWriteAction {
20       VfsRootAccess.allowRootAccess(libraryDirectory)
21       PsiTestUtil.addLibrary(myModule, "$libraryDirectory/$jarName")
22     }
23   }
24
25   override fun replaceAdditionalInOutput(str: String): String {
26     return super.replaceAdditionalInOutput(str)
27       .replaceFirst("$libraryDirectory/$jarName", "!LIBRARY_JAR!")
28   }
29
30   override fun createJavaParameters(mainClass: String?): JavaParameters {
31     val parameters = super.createJavaParameters(mainClass)
32     parameters.classPath.add("$libraryDirectory/$jarName")
33     return parameters
34   }
35
36   final override fun getTestAppPath(): String {
37     return File(PluginPathManager.getPluginHomePath("stream-debugger") + "/testData/${getTestAppRelativePath()}").absolutePath
38   }
39
40   abstract fun getTestAppRelativePath(): String
41 }