Search in sources :

Example 1 with CfmlRunConfiguration

use of com.intellij.coldFusion.UI.runner.CfmlRunConfiguration in project intellij-plugins by JetBrains.

the class CfmlRunConfigurationTest method getDefaultCfmlRunConfiguration.

public CfmlRunConfiguration getDefaultCfmlRunConfiguration() throws IOException {
    final Project project = myFixture.getProject();
    final Editor editor = openCfmFileInEditor(indexCfm);
    final Presentation presentation = getPresentationForRunAction(editor);
    assert editor != null;
    final DataContext dataContext = DataManager.getInstance().getDataContext(editor.getComponent());
    TestCase.assertEquals("Run 'index.cfm'", presentation.getText());
    final ConfigurationContext configurationContext = ConfigurationContext.getFromContext(dataContext);
    final List<RunConfigurationProducer<?>> producers = RunConfigurationProducer.getProducers(project);
    List<ConfigurationFromContext> configs = new ArrayList<>();
    for (RunConfigurationProducer<?> producer : producers) {
        final ConfigurationFromContext configurationFromContext = producer.createConfigurationFromContext(configurationContext);
        if (configurationFromContext != null)
            configs.add(configurationFromContext);
    }
    TestCase.assertEquals(true, configs.size() == 1);
    final ConfigurationFromContext defaultConfigurationFromContext = configs.get(0);
    final RunConfiguration configuration = defaultConfigurationFromContext.getConfiguration();
    TestCase.assertNotNull(configuration);
    UsefulTestCase.assertInstanceOf(configuration, CfmlRunConfiguration.class);
    return (CfmlRunConfiguration) configuration;
}
Also used : ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) ArrayList(java.util.ArrayList) CfmlRunConfiguration(com.intellij.coldFusion.UI.runner.CfmlRunConfiguration) Project(com.intellij.openapi.project.Project) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) CfmlRunConfiguration(com.intellij.coldFusion.UI.runner.CfmlRunConfiguration) RunConfigurationProducer(com.intellij.execution.actions.RunConfigurationProducer) ConfigurationFromContext(com.intellij.execution.actions.ConfigurationFromContext) Editor(com.intellij.openapi.editor.Editor)

Example 2 with CfmlRunConfiguration

use of com.intellij.coldFusion.UI.runner.CfmlRunConfiguration in project intellij-plugins by JetBrains.

the class CfmlRunConfigurationTest method testNonDefaultRunConfiguration.

public void testNonDefaultRunConfiguration() throws IOException, ConfigurationException {
    generateNonDefaultRunConfiguration();
    final Editor editor = myFixture.getEditor();
    final CfmlRunConfiguration cfmlConfig = getContextRunConfiguration(editor);
    assert cfmlConfig != null;
    cfmlConfig.getRunnerParameters().getUrl();
    assertEquals("http://4.4.4.4/src/index.cfm", cfmlConfig.getRunnerParameters().getUrl());
}
Also used : CfmlRunConfiguration(com.intellij.coldFusion.UI.runner.CfmlRunConfiguration) Editor(com.intellij.openapi.editor.Editor)

Example 3 with CfmlRunConfiguration

use of com.intellij.coldFusion.UI.runner.CfmlRunConfiguration in project intellij-plugins by JetBrains.

the class CfmlRunConfigurationTest method testCreateContextRunConfiguration.

public void testCreateContextRunConfiguration() throws IOException, ConfigurationException {
    generateNonDefaultRunConfiguration();
    final Editor editor = openCfmFileInEditor(index2Cfm);
    final CfmlRunConfiguration configuration = getContextRunConfiguration(editor);
    assert configuration != null;
    TestCase.assertEquals("http://localhost:8500/src/index2.cfm", configuration.getRunnerParameters().getUrl());
    TestCase.assertEquals("index2.cfm", configuration.getName());
}
Also used : CfmlRunConfiguration(com.intellij.coldFusion.UI.runner.CfmlRunConfiguration) Editor(com.intellij.openapi.editor.Editor)

Example 4 with CfmlRunConfiguration

use of com.intellij.coldFusion.UI.runner.CfmlRunConfiguration in project intellij-plugins by JetBrains.

the class CfmlRunConfigurationTest method testDefaultRunConfiguration.

public void testDefaultRunConfiguration() throws IOException {
    final CfmlRunConfiguration configuration = getDefaultCfmlRunConfiguration();
    final String url = configuration.getRunnerParameters().getUrl();
    TestCase.assertEquals(true, StringUtil.startsWith(url, "http://localhost:8500/"));
    TestCase.assertEquals(false, StringUtil.startsWith(url, "http://localhost:8500//"));
}
Also used : CfmlRunConfiguration(com.intellij.coldFusion.UI.runner.CfmlRunConfiguration)

Example 5 with CfmlRunConfiguration

use of com.intellij.coldFusion.UI.runner.CfmlRunConfiguration in project intellij-plugins by JetBrains.

the class CfmlRunConfigurationTest method getContextRunConfiguration.

private static CfmlRunConfiguration getContextRunConfiguration(Editor editor) {
    final DataContext dataContext = DataManager.getInstance().getDataContext(editor.getComponent());
    final ConfigurationContext configurationContext = ConfigurationContext.getFromContext(dataContext);
    //this block emulates RunContextAction.perform()
    RunnerAndConfigurationSettings configuration = configurationContext.findExisting();
    if (configuration == null) {
        configuration = configurationContext.getConfiguration();
        if (configuration == null) {
            return null;
        }
        ((RunManagerEx) configurationContext.getRunManager()).setTemporaryConfiguration(configuration);
    }
    //end of the emulated block
    return (CfmlRunConfiguration) configuration.getConfiguration();
}
Also used : ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) RunManagerEx(com.intellij.execution.RunManagerEx) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) CfmlRunConfiguration(com.intellij.coldFusion.UI.runner.CfmlRunConfiguration)

Aggregations

CfmlRunConfiguration (com.intellij.coldFusion.UI.runner.CfmlRunConfiguration)6 Editor (com.intellij.openapi.editor.Editor)3 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)2 ConfigurationContext (com.intellij.execution.actions.ConfigurationContext)2 RunManagerEx (com.intellij.execution.RunManagerEx)1 ConfigurationFromContext (com.intellij.execution.actions.ConfigurationFromContext)1 RunConfigurationProducer (com.intellij.execution.actions.RunConfigurationProducer)1 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)1 Project (com.intellij.openapi.project.Project)1 ArrayList (java.util.ArrayList)1