summaryrefslogtreecommitdiff
path: root/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/KotlinJpsClasspathProviderTest.kt
blob: 6cbcf990223dd93dde541d4471530b535d1f3534 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.kotlin.idea

import com.intellij.testFramework.LightPlatformTestCase
import org.junit.internal.runners.JUnit38ClassRunner
import org.junit.runner.RunWith
import java.io.File

@RunWith(JUnit38ClassRunner::class)
class KotlinJpsClasspathProviderTest : LightPlatformTestCase() {
    private val KOTLIN_REFLECT_PREFIX = "kotlin-reflect"
    private val KOTLIN_COMPILER_COMMON_FOR_IDE_PREFIX = "kotlin-compiler-common-for-ide"
    private val KOTLIN_COMPILER_FE10_FOR_IDE_PREFIX = "kotlin-compiler-fe10-for-ide"
    private val KOTLIN_COMPILER_IR_FOR_IDE_PREFIX = "kotlin-compiler-ir-for-ide"
    private val INTELLIJ_PLATFORM_CORE = "intellij.platform.core"

    fun testGetClassPath() {
        val inst = KotlinJpsClasspathProvider()
        val jars = inst.classPath

        assertEquals(5, jars.size)
        assertJar(jars[0], KOTLIN_REFLECT_PREFIX)
        assertJar(jars[1], KOTLIN_COMPILER_COMMON_FOR_IDE_PREFIX)
        assertJar(jars[2], KOTLIN_COMPILER_FE10_FOR_IDE_PREFIX)
        assertJar(jars[3], KOTLIN_COMPILER_IR_FOR_IDE_PREFIX)
        assertJar(jars[4], INTELLIJ_PLATFORM_CORE)
    }

    private fun assertJar(jar: String?, prefix: String) {
        val jarName = File(jar!!).name
        assertTrue("Expected jar with prefix: $prefix, but $jarName found.",
                   jarName.startsWith(prefix))
    }
}