mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Cleanup (duplicates)
This commit is contained in:
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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 com.intellij.java.execution
|
||||
|
||||
import com.intellij.execution.configurations.SimpleJavaParameters
|
||||
import com.intellij.execution.util.ExecUtil
|
||||
import com.intellij.openapi.application.PathManager
|
||||
import com.intellij.openapi.projectRoots.JavaSdk
|
||||
import com.intellij.openapi.projectRoots.Sdk
|
||||
import com.intellij.testFramework.fixtures.BareTestFixtureTestCase
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class CommandLineWrapperRunTest : BareTestFixtureTestCase() {
|
||||
private lateinit var sdk: Sdk
|
||||
|
||||
@Before fun setUp() {
|
||||
sdk = JavaSdk.getInstance().createJdk("test jdk", System.getProperty("java.home"), true)
|
||||
}
|
||||
|
||||
@Test fun `no dynamic classpath`() = doTest()
|
||||
@Test fun `dynamic classpath, class loader`() = doTest(true, false)
|
||||
@Test fun `dynamic classpath, classpath JAR`() = doTest(true, true)
|
||||
@Test fun `dynamic parameters, class loader`() = doTest(true, false, true)
|
||||
@Test fun `dynamic parameters, classpath JAR`() = doTest(true, true, true)
|
||||
|
||||
@Suppress("UsePropertyAccessSyntax")
|
||||
private fun doTest(dynamicCp: Boolean = false, classPathJar: Boolean = false, dynamicArgs: Boolean = false) {
|
||||
val parameters = SimpleJavaParameters()
|
||||
parameters.jdk = sdk
|
||||
parameters.vmParametersList.addProperty(Helper.PROPERTY1)
|
||||
parameters.vmParametersList.addProperty(Helper.PROPERTY2, "a value")
|
||||
parameters.classPath.add(PathManager.getJarPathForClass(Helper::class.java))
|
||||
parameters.classPath.add(PathManager.getJarPathForClass(Unit::class.java))
|
||||
parameters.mainClass = Helper::class.java.name
|
||||
parameters.programParametersList.add("first parameter")
|
||||
parameters.programParametersList.add("next parameter")
|
||||
|
||||
parameters.setUseDynamicClasspath(dynamicCp)
|
||||
parameters.setUseClasspathJar(classPathJar)
|
||||
parameters.setUseDynamicVMOptions(dynamicArgs)
|
||||
parameters.setUseDynamicParameters(dynamicArgs)
|
||||
|
||||
val command = parameters.toCommandLine()
|
||||
val out = ExecUtil.execAndGetOutput(command)
|
||||
assertEquals(out.stderr, 0, out.exitCode)
|
||||
assertEquals("${Helper.PROPERTY1}=\n" +
|
||||
"${Helper.PROPERTY2}=a value\n" +
|
||||
"arg[0]=first parameter\n" +
|
||||
"arg[1]=next parameter\n", out.stdout)
|
||||
}
|
||||
}
|
||||
|
||||
internal object Helper {
|
||||
val PROPERTY1 = "idea.wrapper.exec.test.1"
|
||||
val PROPERTY2 = "idea.wrapper.exec.test.2"
|
||||
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) {
|
||||
println(PROPERTY1 + "=" + System.getProperty(PROPERTY1))
|
||||
println(PROPERTY2 + "=" + System.getProperty(PROPERTY2))
|
||||
for (i in args.indices) {
|
||||
println("arg[" + i + "]=" + args[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -36,7 +36,6 @@ import com.intellij.openapi.extensions.PluginId;
|
||||
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.JdkUtil;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.OrderEnumerator;
|
||||
import com.intellij.openapi.util.Key;
|
||||
@@ -186,7 +185,7 @@ public class XsltCommandLineState extends CommandLineState {
|
||||
extension.patchParameters(parameters, myXsltRunConfiguration, myExtensionData);
|
||||
}
|
||||
|
||||
parameters.setUseDynamicClasspath(JdkUtil.useDynamicClasspath(myXsltRunConfiguration.getProject()));
|
||||
parameters.setUseDynamicClasspath(myXsltRunConfiguration.getProject());
|
||||
|
||||
return parameters;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user