Search in sources :

Example 6 with ApplicationConfiguration

use of com.intellij.execution.application.ApplicationConfiguration in project intellij-community by JetBrains.

the class ContextConfigurationTest method testApplication.

public void testApplication() {
    PsiClass psiClass = findClass(getModule1(), CLASS_NAME);
    PsiMethod psiMethod = psiClass.findMethodsByName("main", false)[0];
    ApplicationConfiguration configuration = createConfiguration(psiMethod);
    assertEquals(CLASS_NAME, configuration.MAIN_CLASS_NAME);
    assertEquals(configuration.suggestedName(), configuration.getName());
    assertEquals(SHORT_CLASS_NAME, configuration.getName());
}
Also used : PsiMethod(com.intellij.psi.PsiMethod) PsiClass(com.intellij.psi.PsiClass) ApplicationConfiguration(com.intellij.execution.application.ApplicationConfiguration)

Example 7 with ApplicationConfiguration

use of com.intellij.execution.application.ApplicationConfiguration in project intellij-community by JetBrains.

the class ConfigurationsTest method testRunThirdPartyApplication.

public void testRunThirdPartyApplication() throws ExecutionException {
    ApplicationConfiguration configuration = new ApplicationConfiguration("Third party", myProject, ApplicationConfigurationType.getInstance());
    configuration.setModule(getModule1());
    configuration.MAIN_CLASS_NAME = "third.party.Main";
    checkCanRun(configuration);
}
Also used : ApplicationConfiguration(com.intellij.execution.application.ApplicationConfiguration)

Example 8 with ApplicationConfiguration

use of com.intellij.execution.application.ApplicationConfiguration in project azure-tools-for-java by Microsoft.

the class Connection method isApplicableFor.

/**
 * is this connection applicable for the specified {@code configuration}.<br>
 * - the {@code Connect Azure Resource} before run task will take effect if
 * applicable: the {@link #prepareBeforeRun} & {@link #updateJavaParametersAtRun}
 * will be called.
 *
 * @return true if this connection should intervene the specified {@code configuration}.
 */
public boolean isApplicableFor(@Nonnull RunConfiguration configuration) {
    final boolean javaAppRunConfiguration = configuration instanceof ApplicationConfiguration;
    final boolean springbootAppRunConfiguration = StringUtils.equals(configuration.getClass().getName(), SPRING_BOOT_CONFIGURATION);
    final boolean azureWebAppRunConfiguration = configuration instanceof IWebAppRunConfiguration;
    if (javaAppRunConfiguration || azureWebAppRunConfiguration || springbootAppRunConfiguration) {
        final Module module = getTargetModule(configuration);
        return Objects.nonNull(module) && Objects.equals(module.getName(), this.consumer.getName());
    }
    return false;
}
Also used : IWebAppRunConfiguration(com.microsoft.azure.toolkit.intellij.common.runconfig.IWebAppRunConfiguration) Module(com.intellij.openapi.module.Module) ApplicationConfiguration(com.intellij.execution.application.ApplicationConfiguration)

Example 9 with ApplicationConfiguration

use of com.intellij.execution.application.ApplicationConfiguration in project intellij-community by JetBrains.

the class ConfigurationsTest method testCreatingApplicationConfiguration.

public void testCreatingApplicationConfiguration() throws ConfigurationException {
    if (PlatformTestUtil.COVERAGE_ENABLED_BUILD)
        return;
    ApplicationConfiguration configuration = new ApplicationConfiguration(null, myProject, ApplicationConfigurationType.getInstance());
    ApplicationConfigurable editor = new ApplicationConfigurable(myProject);
    try {
        // To get all the watchers installed.
        editor.getComponent();
        Configurable configurable = new RunConfigurationConfigurableAdapter(editor, configuration);
        configurable.reset();
        CommonJavaParametersPanel javaParameters = editor.getCommonProgramParameters();
        javaParameters.setProgramParameters("prg");
        javaParameters.setVMParameters("vm");
        javaParameters.setWorkingDirectory("dir");
        assertTrue(configurable.isModified());
        configurable.apply();
        assertEquals("prg", configuration.getProgramParameters());
        assertEquals("vm", configuration.getVMParameters());
        assertEquals("dir", configuration.getWorkingDirectory());
    } finally {
        Disposer.dispose(editor);
    }
}
Also used : JUnitConfigurable(com.intellij.execution.junit2.configuration.JUnitConfigurable) Configurable(com.intellij.openapi.options.Configurable) ApplicationConfigurable(com.intellij.execution.application.ApplicationConfigurable) ApplicationConfiguration(com.intellij.execution.application.ApplicationConfiguration) CommonJavaParametersPanel(com.intellij.execution.ui.CommonJavaParametersPanel) ApplicationConfigurable(com.intellij.execution.application.ApplicationConfigurable)

Example 10 with ApplicationConfiguration

use of com.intellij.execution.application.ApplicationConfiguration in project intellij-community by JetBrains.

the class ConfigurationsTest method testCreateConfiguration.

public void testCreateConfiguration() throws IOException, ExecutionException {
    Module module1 = getModule1();
    PsiClass psiClass = findTestA(module1);
    JUnitConfiguration configuration = createConfiguration(psiClass);
    assertEquals(Collections.singleton(module1), ContainerUtilRt.newHashSet(configuration.getModules()));
    checkClassName(psiClass.getQualifiedName(), configuration);
    assertEquals(psiClass.getName(), configuration.getName());
    checkTestObject(JUnitConfiguration.TEST_CLASS, configuration);
    Module module2 = getModule2();
    Assertion.compareUnordered(new Module[] { module1, module2 }, configuration.getValidModules());
    PsiClass innerTest = findClass(module1, INNER_TEST_NAME);
    configuration = createJUnitConfiguration(innerTest, TestInClassConfigurationProducer.class, new MapDataContext());
    checkClassName(RT_INNER_TEST_NAME, configuration);
    checkCanRun(configuration);
    PsiMethod[] testMethod = innerTest.findMethodsByName("test", false);
    assertEquals(1, testMethod.length);
    configuration = createConfiguration(testMethod[0]);
    checkClassName(RT_INNER_TEST_NAME, configuration);
    checkMethodName("test", configuration);
    checkTestObject(JUnitConfiguration.TEST_METHOD, configuration);
    checkCanRun(configuration);
    PsiMethod mainMethod = innerTest.findMethodsByName("main", false)[0];
    ApplicationConfiguration appConfiguration = createConfiguration(mainMethod);
    assertEquals(RT_INNER_TEST_NAME, appConfiguration.MAIN_CLASS_NAME);
    checkCanRun(configuration);
}
Also used : MapDataContext(com.intellij.testFramework.MapDataContext) Module(com.intellij.openapi.module.Module) ApplicationConfiguration(com.intellij.execution.application.ApplicationConfiguration)

Aggregations

ApplicationConfiguration (com.intellij.execution.application.ApplicationConfiguration)14 Module (com.intellij.openapi.module.Module)4 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)3 RuntimeConfigurationException (com.intellij.execution.configurations.RuntimeConfigurationException)2 PsiClass (com.intellij.psi.PsiClass)2 MapDataContext (com.intellij.testFramework.MapDataContext)2 Nullable (org.jetbrains.annotations.Nullable)2 DesignerEditorPanelFacade (com.intellij.designer.DesignerEditorPanelFacade)1 CantRunException (com.intellij.execution.CantRunException)1 ExecutionException (com.intellij.execution.ExecutionException)1 ApplicationConfigurable (com.intellij.execution.application.ApplicationConfigurable)1 ApplicationConfigurationType (com.intellij.execution.application.ApplicationConfigurationType)1 JavaParameters (com.intellij.execution.configurations.JavaParameters)1 JUnitConfigurable (com.intellij.execution.junit2.configuration.JUnitConfigurable)1 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)1 CommonJavaParametersPanel (com.intellij.execution.ui.CommonJavaParametersPanel)1 JreVersionDetector (com.intellij.execution.util.JreVersionDetector)1 IdeView (com.intellij.ide.IdeView)1 PaletteGroup (com.intellij.ide.palette.PaletteGroup)1 LafManagerListener (com.intellij.ide.ui.LafManagerListener)1