Ignore reflection usage warnings in outputs for streamex tests
[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.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
13 import java.io.File
14 import java.nio.file.Paths
15
16 /**
17  * @author Vitaliy.Bibaev
18  */
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()
22
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)
28     }
29   }
30
31   override fun setUpModule() {
32     super.setUpModule()
33     ApplicationManager.getApplication().runWriteAction {
34       VfsRootAccess.allowRootAccess(libraryDirectory)
35       PsiTestUtil.addLibrary(myModule, jarPath)
36     }
37   }
38
39   override fun replaceAdditionalInOutput(str: String): String {
40     return super.replaceAdditionalInOutput(str).replaceLibraryPath(jarPath)
41   }
42
43   override fun createJavaParameters(mainClass: String?): JavaParameters {
44     val parameters = super.createJavaParameters(mainClass)
45     parameters.classPath.add(jarPath)
46     return parameters
47   }
48
49   final override fun getTestAppPath(): String {
50     return File(PluginPathManager.getPluginHomePath("stream-debugger") + "/testData/${getTestAppRelativePath()}").absolutePath
51   }
52
53   abstract fun getTestAppRelativePath(): String
54 }