Skip to content

Commit

Permalink
FUSETOOLS2-2313: Add UI tests for Display variable values with Exchan…
Browse files Browse the repository at this point in the history
…ge scope during debugging
  • Loading branch information
pospisilf authored and djelinek committed Apr 18, 2024
1 parent 7df63c6 commit 00acf98
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/ui-test/resources/VariablesTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import org.apache.camel.builder.RouteBuilder;

public class VariablesTest extends RouteBuilder {
@Override
public void configure() throws Exception {
from("timer:foo")
.setVariable("item", constant("world"))
.setVariable("name", constant("Camel"))
.log("Hello ${variable.item} and ${variable.name}");
}
}
92 changes: 92 additions & 0 deletions src/ui-test/tests/variables.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License", destination); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* https://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.
*/
import { expect } from 'chai';
import {
ActivityBar,
EditorView,
SideBarView,
TextEditor,
VSBrowser,
WebDriver
} from "vscode-uitests-tooling";
import {
CAMEL_RUN_DEBUG_ACTION_QUICKPICKS_LABEL,
disconnectDebugger,
executeCommand,
killTerminal,
waitUntilTerminalHasText,
getDebuggerSectionItem,
isCamelVersionProductized,
isVersionNewer,
} from '../utils';
import { RESOURCES_DIR, VARIABLESTEST_JAVA } from '../variables';

describe('Display exchange variables values test', function () {
this.timeout(300000);

let driver: WebDriver;
let textEditor: TextEditor;

before(async function () {

if (isCamelVersionProductized(process.env.CAMEL_VERSION) || (process.env.CAMEL_VERSION !== undefined && !isVersionNewer("4.4.0", process.env.CAMEL_VERSION))){ // available since Camel 4.4
this.skip();
}

driver = VSBrowser.instance.driver;

await VSBrowser.instance.openResources(RESOURCES_DIR);
await (await new ActivityBar().getViewControl('Explorer')).openView();
const section = await new SideBarView().getContent().getSection('resources');

await section.openItem(VARIABLESTEST_JAVA);
const editorView = new EditorView();
await driver.wait(async function () {
return (await editorView.getOpenEditorTitles()).find(title => title === VARIABLESTEST_JAVA);
}, 5000);

await executeCommand(CAMEL_RUN_DEBUG_ACTION_QUICKPICKS_LABEL);
await (await new ActivityBar().getViewControl('Run')).openView();
await waitUntilTerminalHasText(driver, ['A debugger has been attached'], 4000, 120000);

textEditor = new TextEditor();
});

after(async function () {
if (isCamelVersionProductized(process.env.CAMEL_VERSION) || (process.env.CAMEL_VERSION !== undefined && !isVersionNewer("4.4.0", process.env.CAMEL_VERSION))){
// do nothing - after is executed even if skip is called in before
}
else {
await disconnectDebugger(driver);
await (await new ActivityBar().getViewControl('Run and Debug')).closeView();
await killTerminal();
await new EditorView().closeAllEditors();
}
});

it('Variable is displayed', async function () {
await driver.wait(async function () {
return await textEditor.toggleBreakpoint(9);
}, 5000);

const sectionItem = await getDebuggerSectionItem(driver, 'item:', 'Message', 'Variables');
expect(await sectionItem?.getVariableValue()).to.be.equal("world");

const sectionItem2 = await getDebuggerSectionItem(driver, 'name:', 'Message', 'Variables');
expect(await sectionItem2?.getVariableValue()).to.be.equal("Camel");
});
});
4 changes: 3 additions & 1 deletion src/ui-test/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,13 @@ export const MVN_COMPILE = 'mvn compile';
export const MVN_CLEAN = 'mvn clean';
export const MVN_BUILD_SUCCESS = 'BUILD SUCCESS';


// tasks.json
export const RUN_WITH_JBANG_WITH_CAMEL_DEBUG = 'Run Camel application with JBang with camel-debug';
export const START_WITH_CAMEL_DEBUG_MVN_GOAL = 'Start Camel application with camel:debug Maven goal';
export const ATTACH_DEBUGGER_USING_PRELAUNCH_TASK = 'Attach Camel Debugger after starting the Camel Application using the preLaunchTask specified';

// launch.json
export const LAUNCH_START_AND_ATTACH_DEBUGGER = 'Camel: Start Camel application and attach Camel debugger';

// variablesTest.java
export const VARIABLESTEST_JAVA = 'VariablesTest.java';

0 comments on commit 00acf98

Please sign in to comment.