mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[platform] restores 'missing main class' check
This commit is contained in:
+23
-11
@@ -22,32 +22,38 @@ import com.intellij.execution.process.KillableColoredProcessHandler;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl;
|
||||
import com.intellij.testFramework.LightIdeaTestCase;
|
||||
import junit.framework.Assert;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.intellij.testFramework.fixtures.BareTestFixtureTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
public class JavaCommandLineTest extends LightIdeaTestCase {
|
||||
public void testJdk() {
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class JavaCommandLineTest extends BareTestFixtureTestCase {
|
||||
@Test
|
||||
public void testJdkMissing() {
|
||||
try {
|
||||
new JavaParameters().toCommandLine();
|
||||
fail("CantRunException (main class is not specified) expected");
|
||||
fail("'JDK missing' expected");
|
||||
}
|
||||
catch (CantRunException e) {
|
||||
Assert.assertEquals(ExecutionBundle.message("run.configuration.error.no.jdk.specified"), e.getMessage());
|
||||
assertEquals(ExecutionBundle.message("run.configuration.error.no.jdk.specified"), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void testMainClass() {
|
||||
@Test
|
||||
public void testMainClassMissing() {
|
||||
try {
|
||||
JavaParameters javaParameters = new JavaParameters();
|
||||
javaParameters.setJdk(getProjectJDK());
|
||||
javaParameters.toCommandLine();
|
||||
fail("CantRunException (main class is not specified) expected");
|
||||
fail("'main class missing' expected");
|
||||
}
|
||||
catch (CantRunException e) {
|
||||
assertEquals(ExecutionBundle.message("main.class.is.not.specified.error.message"), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJarParameter() throws CantRunException {
|
||||
JavaParameters javaParameters = new JavaParameters();
|
||||
javaParameters.setJdk(getProjectJDK());
|
||||
@@ -56,12 +62,13 @@ public class JavaCommandLineTest extends LightIdeaTestCase {
|
||||
assertTrue(commandLineString, commandLineString.contains("-jar my-jar-file.jar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClasspath() throws CantRunException {
|
||||
JavaParameters javaParameters;
|
||||
String commandLineString;
|
||||
|
||||
javaParameters = new JavaParameters();
|
||||
final Sdk internalJdk = JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk();
|
||||
Sdk internalJdk = JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk();
|
||||
javaParameters.setJdk(internalJdk);
|
||||
javaParameters.getClassPath().add("my-jar-file.jar");
|
||||
javaParameters.setMainClass("Main");
|
||||
@@ -99,13 +106,18 @@ public class JavaCommandLineTest extends LightIdeaTestCase {
|
||||
return commandLineString;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateProcess() {
|
||||
try {
|
||||
new KillableColoredProcessHandler(new GeneralCommandLine());
|
||||
fail("ExecutionException (executable is not specified) expected");
|
||||
fail("'executable missing' expected");
|
||||
}
|
||||
catch (ExecutionException e) {
|
||||
assertEquals(IdeBundle.message("run.configuration.error.executable.not.specified"), e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Sdk getProjectJDK() {
|
||||
return IdeaTestUtil.getMockJdk17();
|
||||
}
|
||||
}
|
||||
@@ -198,6 +198,9 @@ public class JdkUtil {
|
||||
commandLine.addParameter("-jar");
|
||||
commandLine.addParameter(jarPath);
|
||||
}
|
||||
else {
|
||||
throw new CantRunException(ExecutionBundle.message("main.class.is.not.specified.error.message"));
|
||||
}
|
||||
|
||||
if (!passProgramParametersViaClassPathJar) {
|
||||
commandLine.addParameters(javaParameters.getProgramParametersList().getList());
|
||||
|
||||
@@ -14,7 +14,7 @@ run.configuration.error.dialog.title=Run Configuration Error
|
||||
no.jdk.specified..error.message=No JDK specified
|
||||
home.directory.not.specified.for.jdk.error.message=Home directory is not specified for JDK
|
||||
run.configuration.pause.output.action.name=Pause Output
|
||||
main.class.is.not.specified.error.message=Main class is not specified
|
||||
main.class.is.not.specified.error.message=Neither main class nor JAR path is specified
|
||||
close.tab.action.name=Close
|
||||
run.configuration.show.command.line.action.name=Show Console Prompt
|
||||
|
||||
|
||||
Reference in New Issue
Block a user