Skip to content

Commit

Permalink
Merge pull request #67 from bia-technologies/feature/66-remote-launcher
Browse files Browse the repository at this point in the history
66 / Запуск тестов без перезапуска
  • Loading branch information
alkoleft authored Jan 27, 2025
2 parents cd349d8 + 8e48b75 commit 73d3eb4
Show file tree
Hide file tree
Showing 89 changed files with 2,240 additions and 2,210 deletions.
15 changes: 15 additions & 0 deletions .idea/libraries/fasterxml_jackson_dataformat_xml.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/libraries/java_websocket_Java_WebSocket.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion templates/eclipse_project/bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<current-release-directory>${releases-directory}/${qualifiedVersion}</current-release-directory>
<!-- The label for the Composite sites -->
<site.label>${env.site_label_suffix}EDT Test Runner Repository</site.label>
<lombok.version>1.18.16</lombok.version>
<lombok.version>1.18.36</lombok.version>
</properties>

<dependencies>
Expand Down
16 changes: 16 additions & 0 deletions templates/eclipse_project/repositories/repository/category.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,21 @@
<feature id="ru.biatech.edt.xtest.feature">
<category name="ru.biatech.edt.xtest.category"/>
</feature>
<bundle id="Java-WebSocket">
<category name="ru.biatech.edt.xtest.category.addons"/>
</bundle>
<bundle id="com.fasterxml.jackson.dataformat.jackson-dataformat-xml">
<category name="ru.biatech.edt.xtest.category.addons"/>
</bundle>
<bundle id="com.fasterxml.jackson.module.jackson-module-jaxb-annotations">
<category name="ru.biatech.edt.xtest.category.addons"/>
</bundle>
<bundle id="stax2-api">
<category name="ru.biatech.edt.xtest.category.addons"/>
</bundle>
<bundle id="com.fasterxml.woodstox.woodstox-core">
<category name="ru.biatech.edt.xtest.category.addons"/>
</bundle>
<category-def name="ru.biatech.edt.xtest.category" label="Тестирование 1С"/>
<category-def name="ru.biatech.edt.xtest.category.addons" label="Дополнительные модули"/>
</site>
397 changes: 211 additions & 186 deletions templates/eclipse_project/targets/default/default.target

Large diffs are not rendered by default.

397 changes: 215 additions & 182 deletions templates/eclipse_project/targets/dev/dev.target

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion viewer/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ Require-Bundle: org.apache.felix.scr,
com._1c.g5.v8.bm.integration;bundle-version="11.0.0",
com._1c.g5.v8.bm.core;bundle-version="8.0.0",
com._1c.g5.wiring,
com.google.gson
Java-WebSocket;bundle-version="1.5.0",
com.fasterxml.jackson.core.jackson-annotations;bundle-version="2.10.3",
com.fasterxml.jackson.core.jackson-databind;bundle-version="2.10.3",
com.fasterxml.jackson.core.jackson-core;bundle-version="2.10.3",
com.fasterxml.jackson.dataformat.jackson-dataformat-xml;bundle-version="2.10.3"
Bundle-RequiredExecutionEnvironment: JavaSE-11
Import-Package: com._1c.g5.ides.ui.texteditor.xtext.embedded,
lombok;resolution:=optional,
Expand Down
4 changes: 4 additions & 0 deletions viewer/src/main/java/ru/biatech/edt/junit/Logger.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ public void debug(String message) {
}
}

public void info(String message) {
log(new Status(IStatus.INFO, getPluginID(), 0, message, null));
}

public void debug(String template, Object... objects) {
if (debug) {
String message = MessageFormat.format(template, objects);
Expand Down
39 changes: 39 additions & 0 deletions viewer/src/main/java/ru/biatech/edt/junit/Serializer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*******************************************************************************
* Copyright (c) 2025 BIA-Technologies Limited Liability Company.
*
* 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 ru.biatech.edt.junit;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import lombok.Getter;
import lombok.experimental.UtilityClass;

@UtilityClass
public class Serializer {

@Getter
private final ObjectMapper jsonMapper = new ObjectMapper()
.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true)
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);

@Getter
ObjectMapper xmlMapper = new XmlMapper()
.setDefaultUseWrapper(false)
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.osgi.framework.ServiceReference;
import ru.biatech.edt.junit.launcher.lifecycle.LifecycleMonitor;
import ru.biatech.edt.junit.ui.PluginUI;
import ru.biatech.edt.junit.yaxunit.remote.RemoteLaunchManager;

import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -137,6 +138,7 @@ public void start(BundleContext bundleContext) throws Exception {
public void stop(BundleContext bundleContext) throws Exception {
LifecycleMonitor.stop();
core().getSessionsManager().stop();
RemoteLaunchManager.stop();
plugin = null;
super.stop(bundleContext);
}
Expand Down
15 changes: 2 additions & 13 deletions viewer/src/main/java/ru/biatech/edt/junit/kinds/IUnitLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,9 @@

public interface IUnitLauncher {

IUnitLauncher NULL = new IUnitLauncher() {

@Override
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
// do nothing
}

@Override
public void configure(ILaunchConfigurationWorkingCopy configuration, ILaunchConfiguration basicConfiguration) {
// do nothing
}
IUnitLauncher NULL = (configuration, mode, launch, monitor) -> {
// do nothing
};

void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException;

void configure(ILaunchConfigurationWorkingCopy configuration, ILaunchConfiguration basicConfiguration);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package ru.biatech.edt.junit.launcher.lifecycle;

import com.google.common.base.Strings;
import lombok.SneakyThrows;
import lombok.experimental.UtilityClass;
import org.eclipse.debug.core.DebugEvent;
Expand All @@ -30,6 +29,7 @@
import ru.biatech.edt.junit.launcher.v8.LaunchConfigurationAttributes;
import ru.biatech.edt.junit.launcher.v8.LaunchHelper;
import ru.biatech.edt.junit.ui.UIMessages;
import ru.biatech.edt.junit.ui.utils.StringUtilities;

import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -177,7 +177,7 @@ public void launchAdded(ILaunch launch) {
var item = new LifecycleItem(launch, configuration.getName());
monitoringItems.put(launch, item);
onItemStart(item);
} else if (LaunchHelper.isOnecConfiguration(configuration) && !Strings.isNullOrEmpty(LaunchConfigurationAttributes.getTestKind(configuration))) {
} else if (LaunchHelper.isOnecConfiguration(configuration) && !StringUtilities.isNullOrEmpty(LaunchConfigurationAttributes.getTestKind(configuration))) {
var name = configuration.getName();
for (var item : monitoringItems.values()) {
if (name.contains(item.getName()) && item.getMainLaunch() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public void createControl(Composite parent) {
control.testModuleControl.addSelectionChangedListener(this::selectionChanged);
control.projectPathControl.addModifyListener(e -> onChanged());
control.loggingControl.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> onChanged()));
control.useRemoteLaunchControl.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> onChanged()));
}

@Override
Expand All @@ -77,6 +78,26 @@ public void initializeFrom(ILaunchConfiguration configuration) {
updateParametersFromConfig(configuration);
}

private void updateParametersFromConfig(ILaunchConfiguration configuration) {
try {
var usedConfiguration = LaunchHelper.getTargetConfiguration(configuration);
var project = LaunchHelper.getTestExtension(configuration);
var moduleName = LaunchConfigurationAttributes.getTestModuleName(configuration);
var projectPath = LaunchConfigurationAttributes.getProjectPath(configuration);
var logging = LaunchConfigurationAttributes.getLoggingToConsole(configuration);
var useRemoteLaunch = LaunchConfigurationAttributes.useRemoteLaunch(configuration);

UtilsUI.setSelection(control.usedLaunchConfigurationControl, usedConfiguration);
UtilsUI.setSelection(control.testExtensionControl, project);
UtilsUI.setSelection(control.testModuleControl, moduleName);
control.projectPathControl.setText(projectPath == null ? "" : projectPath);
control.loggingControl.setSelection(logging);
control.useRemoteLaunchControl.setSelection(useRemoteLaunch);
} catch (CoreException e) {
TestViewerPlugin.log().logError(UIMessages.LaunchConfigurationTab_failedRestoreSettings, e);
}
}

@Override
public void performApply(ILaunchConfigurationWorkingCopy configuration) {
var usedConfiguration = UtilsUI.getSelection(control.usedLaunchConfigurationControl, ILaunchConfiguration.class);
Expand All @@ -88,6 +109,7 @@ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
configuration.setAttribute(LaunchConfigurationAttributes.TEST_MODULE, module);
configuration.setAttribute(LaunchConfigurationAttributes.PROJECT_PATH, control.projectPathControl.getText());
configuration.setAttribute(LaunchConfigurationAttributes.LOGGING_CONSOLE, control.loggingControl.getSelection());
configuration.setAttribute(LaunchConfigurationAttributes.USE_REMOTE_LAUNCH, control.useRemoteLaunchControl.getSelection());
}

@Override
Expand All @@ -109,24 +131,6 @@ public boolean isValid(ILaunchConfiguration launchConfig) {
return success;
}

private void updateParametersFromConfig(ILaunchConfiguration configuration) {
try {
var usedConfiguration = LaunchHelper.getTargetConfiguration(configuration);
var project = LaunchHelper.getTestExtension(configuration);
var moduleName = LaunchConfigurationAttributes.getTestModuleName(configuration);
var projectPath = LaunchConfigurationAttributes.getProjectPath(configuration);
var logging = LaunchConfigurationAttributes.getLoggingToConsole(configuration);

UtilsUI.setSelection(control.usedLaunchConfigurationControl, usedConfiguration);
UtilsUI.setSelection(control.testExtensionControl, project);
UtilsUI.setSelection(control.testModuleControl, moduleName);
control.projectPathControl.setText(projectPath == null ? "" : projectPath);
control.loggingControl.setSelection(logging);
} catch (CoreException e) {
TestViewerPlugin.log().logError(UIMessages.LaunchConfigurationTab_failedRestoreSettings, e);
}
}

private void selectionChanged(SelectionChangedEvent event) {
onChanged();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class LaunchControl extends Composite {
ComboViewer testModuleControl;
Text projectPathControl;
Button loggingControl;
Button useRemoteLaunchControl;

public LaunchControl(Composite parent, int style) {
super(parent, style);
Expand Down Expand Up @@ -74,10 +75,12 @@ public LaunchControl(Composite parent, int style) {
appendLabel(grpSettings, "Выводить лог в консоль");
loggingControl = new Button(grpSettings, SWT.CHECK);
loggingControl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
}

@Override
protected void checkSubclass() {
var toolTip = "Запуск тестов без перезапуска.1С:Предприятие на закрывается и слушает команды 1С:EDT";
appendLabel(grpSettings, "Запуск тестов без перезапуска.", toolTip);
useRemoteLaunchControl = new Button(grpSettings, SWT.CHECK);
useRemoteLaunchControl.setToolTipText(toolTip);
useRemoteLaunchControl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
}

void initializeFrom() {
Expand All @@ -87,9 +90,14 @@ void initializeFrom() {
}

private void appendLabel(Composite parent, String text) {
appendLabel(parent, text, null);
}

private void appendLabel(Composite parent, String text, String tooltip) {
Label label = new Label(parent, SWT.NONE);
label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
label.setText(text);
label.setToolTipText(tooltip);
}

private AutoCompleteComboViewer appendAutoCompleteComboViewer(Composite parent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,51 +19,34 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import ru.biatech.edt.junit.TestViewerPlugin;

import java.util.List;

public final class LaunchConfigurationAttributes {

public static final String USED_LAUNCH_CONFIGURATION = "ru.biatech.edt.junit.launcher.ATTR_USED_LAUNCH_CONFIGURATION"; //$NON-NLS-1$

public static final String TEST_EXTENSION = "ru.biatech.edt.junit.launcher.TEST_EXTENSION"; //$NON-NLS-1$

public static final String TEST_MODULE = "ru.biatech.edt.junit.launcher.TEST_MODULE"; //$NON-NLS-1$
public static final String PROJECT_PATH = "ru.biatech.edt.junit.launcher.PROJECT_PATH"; //$NON-NLS-1$
public static final String LOGGING_CONSOLE = "ru.biatech.edt.junit.launcher.LOGGING_TO_CONSOLE"; //$NON-NLS-1$
import static ru.biatech.edt.junit.Constants.PLUGIN_ID;

public static final String WORK_PATH = "ru.biatech.edt.junit.launcher.WORK_PATH"; //$NON-NLS-1$
public final class LaunchConfigurationAttributes {

public static final String PROJECT = "ru.biatech.edt.junit.launcher.PROJECT"; //$NON-NLS-1$
public static final String USED_LAUNCH_CONFIGURATION = PLUGIN_ID + ".launcher.USED_LAUNCH_CONFIGURATION"; //$NON-NLS-1$

public static final String TEST_FULL_NAME = "ru.biatech.edt.junit.launcher.TEST_FULL_NAME"; //$NON-NLS-1$
public static final String TEST_EXTENSION = PLUGIN_ID + ".launcher.TEST_EXTENSION"; //$NON-NLS-1$

public static final String ATTR_TEST_RUNNER_KIND = "ru.biatech.edt.junit.launcher.TEST_KIND"; //$NON-NLS-1$
public static final String TEST_MODULE = PLUGIN_ID + ".launcher.TEST_MODULE"; //$NON-NLS-1$

public static final String ATTR_PORT = TestViewerPlugin.getPluginId() + ".PORT"; //$NON-NLS-1$
public static final String PROJECT_PATH = PLUGIN_ID + ".launcher.PROJECT_PATH"; //$NON-NLS-1$

/**
* The test method name (followed by a comma-separated list of fully qualified parameter type
* names in parentheses, if exists), or "" iff running the whole test type.
*/
public static final String ATTR_TEST_NAME = TestViewerPlugin.getPluginId() + ".TESTNAME"; //$NON-NLS-1$
public static final String LOGGING_CONSOLE = PLUGIN_ID + ".launcher.LOGGING_TO_CONSOLE"; //$NON-NLS-1$

public static final String ATTR_KEEPRUNNING = TestViewerPlugin.getPluginId() + ".KEEPRUNNING_ATTR"; //$NON-NLS-1$
/**
* The launch container, or "" iff running a single test type.
*/
public static final String ATTR_TEST_CONTAINER = TestViewerPlugin.getPluginId() + ".CONTAINER"; //$NON-NLS-1$
public static final String WORK_PATH = PLUGIN_ID + ".launcher.WORK_PATH"; //$NON-NLS-1$

public static final String ATTR_FAILURES_NAMES = TestViewerPlugin.getPluginId() + ".FAILURENAMES"; //$NON-NLS-1$
public static final String PROJECT = PLUGIN_ID + ".launcher.PROJECT"; //$NON-NLS-1$

public static final String ATTR_TEST_HAS_INCLUDE_TAGS = TestViewerPlugin.getPluginId() + ".HAS_INCLUDE_TAGS"; //$NON-NLS-1$
public static final String TEST_FULL_NAME = PLUGIN_ID + ".launcher.TEST_FULL_NAME"; //$NON-NLS-1$

public static final String ATTR_TEST_HAS_EXCLUDE_TAGS = TestViewerPlugin.getPluginId() + ".HAS_EXCLUDE_TAGS"; //$NON-NLS-1$
public static final String TEST_RUNNER_KIND = PLUGIN_ID + ".launcher.TEST_KIND"; //$NON-NLS-1$

public static final String ATTR_TEST_INCLUDE_TAGS = TestViewerPlugin.getPluginId() + ".INCLUDE_TAGS"; //$NON-NLS-1$
public static final String USE_REMOTE_LAUNCH = PLUGIN_ID + ".launcher.USE_REMOTE_LAUNCH"; //$NON-NLS-1$

public static final String ATTR_TEST_EXCLUDE_TAGS = TestViewerPlugin.getPluginId() + ".EXCLUDE_TAGS"; //$NON-NLS-1$
public static final String RPC_KEY = PLUGIN_ID + ".launcher.RPC_KEY"; //$NON-NLS-1$

public static String getTargetConfigurationName(ILaunchConfiguration configuration) throws CoreException {
return configuration.getAttribute(USED_LAUNCH_CONFIGURATION, (String) null);
Expand Down Expand Up @@ -108,7 +91,7 @@ public static boolean getLoggingToConsole(ILaunchConfiguration configuration) {
}

public static String getTestKind(ILaunchConfiguration configuration) {
return getAttribute(configuration, ATTR_TEST_RUNNER_KIND);
return getAttribute(configuration, TEST_RUNNER_KIND);
}

public static String getAttribute(ILaunchConfiguration configuration, String attributeName) {
Expand All @@ -134,4 +117,8 @@ public static String getWorkPath(ILaunchConfiguration configuration) {
public static String getProject(ILaunchConfiguration configuration) {
return getAttribute(configuration, PROJECT);
}

public static boolean useRemoteLaunch(ILaunchConfiguration configuration) {
return getBooleanAttribute(configuration, LaunchConfigurationAttributes.USE_REMOTE_LAUNCH);
}
}
Loading

0 comments on commit 73d3eb4

Please sign in to comment.