Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue436 - Automated test case versionless feature server.xml #449

Open
wants to merge 56 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
08aefcd
code to open server.xml and entry for logging
SuparnaSuresh Nov 12, 2024
c1a82a4
code added for hover and quicfix
SuparnaSuresh Nov 14, 2024
121f17b
Code added to open server.xml
SuparnaSuresh Nov 18, 2024
2771093
Code Added for write text in server.xml
SuparnaSuresh Nov 18, 2024
80d8e87
Code for hover data
SuparnaSuresh Nov 18, 2024
01d668f
Code for quick fix
SuparnaSuresh Nov 18, 2024
3f5e62f
Code formatted
SuparnaSuresh Nov 18, 2024
dbba2a0
removed unwanted code
SuparnaSuresh Nov 18, 2024
3e4affe
Copyright and docuementation
SuparnaSuresh Nov 18, 2024
883f757
Merge branch 'OpenLiberty:main' into issue124-AutomatedTestcaseLCLS
SuparnaSuresh Nov 18, 2024
150019c
Renamed file
SuparnaSuresh Nov 20, 2024
7fdc278
Renamed file to GradleSingleModLCLSTest
SuparnaSuresh Nov 20, 2024
108bfd5
added code to update the old content
SuparnaSuresh Nov 20, 2024
f238c52
updated quick fix element name
SuparnaSuresh Nov 21, 2024
41114d8
Timeout value updated
SuparnaSuresh Nov 21, 2024
fab341b
Timeout value updated
SuparnaSuresh Nov 21, 2024
26b5cdb
GHA build fix - timeout value updated
SuparnaSuresh Nov 21, 2024
8986c67
Merge branch 'OpenLiberty:main' into issue124-AutomatedTestcaseLCLS
SuparnaSuresh Nov 21, 2024
7c60cd8
Added mpHealth
SuparnaSuresh Nov 25, 2024
e7490fa
Merge branch 'OpenLiberty:main' into issue124-AutomatedTestcaseLCLS
SuparnaSuresh Nov 25, 2024
13498f5
await added for find element
SuparnaSuresh Nov 25, 2024
7ee5da3
Merge branch 'OpenLiberty:main' into issue124-AutomatedTestcaseLCLS
SuparnaSuresh Dec 4, 2024
499247d
updated server.xml file
SuparnaSuresh Dec 4, 2024
9c3b83a
updated - added code for new config folder
SuparnaSuresh Dec 4, 2024
4d2fa91
updated the function removeConfigDir
SuparnaSuresh Dec 4, 2024
3515049
server.env file added
SuparnaSuresh Dec 5, 2024
e320f4d
Merge branch 'OpenLiberty:main' into issue124-AutomatedTestcaseLCLS
SuparnaSuresh Dec 6, 2024
a582ac6
GHA build failure - Increased timeout value
SuparnaSuresh Dec 6, 2024
b193cc5
Added test case to coppy server.xml content
SuparnaSuresh Dec 6, 2024
288d1e0
Diagnostic server.xml test case added
SuparnaSuresh Dec 9, 2024
4492afc
updated test case
SuparnaSuresh Dec 9, 2024
45f2c84
changed server.xml path
SuparnaSuresh Dec 9, 2024
bf7369b
Diagnostic support for server platform
SuparnaSuresh Dec 16, 2024
614c4f6
Merge branch 'OpenLiberty:main' into AutomatedTestCaseVersionlessFeature
SuparnaSuresh Dec 16, 2024
1b8f9b2
Quickfix support test case added for server platform
SuparnaSuresh Dec 16, 2024
1c9cbec
Merge branch 'AutomatedTestCaseVersionlessFeature' of https://github.…
SuparnaSuresh Dec 16, 2024
4ad1575
hover support server platform
SuparnaSuresh Dec 16, 2024
bc06620
Daiganostic support server feature
SuparnaSuresh Dec 16, 2024
145afdd
quickfix server feature
SuparnaSuresh Dec 16, 2024
bf6f968
type ahead suppoer server platform
SuparnaSuresh Dec 16, 2024
62a005e
Test case for valid server feature entry with platform entry
SuparnaSuresh Dec 16, 2024
3ea5a26
removed unwanted variable
SuparnaSuresh Dec 16, 2024
bd658a3
updated text for the false case
SuparnaSuresh Dec 16, 2024
448672b
removed unwanted variable
SuparnaSuresh Dec 16, 2024
67d39c5
updated wordings
SuparnaSuresh Dec 16, 2024
07faf04
removed unwanted code
SuparnaSuresh Dec 16, 2024
4a91dee
GHA build fix - timeout value updated
SuparnaSuresh Dec 16, 2024
3452b27
updated typo error and year info
SuparnaSuresh Jan 17, 2025
e7d4d23
updated testUtils
SuparnaSuresh Jan 27, 2025
8a3e87a
Merge branch 'OpenLiberty:main' into AutomatedTestCaseVersionlessFeature
SuparnaSuresh Jan 27, 2025
9294733
resolved conflic for testUtils
SuparnaSuresh Jan 27, 2025
2c17e18
Merge branch 'AutomatedTestCaseVersionlessFeature' of https://github.…
SuparnaSuresh Jan 27, 2025
f91628f
updated constants
SuparnaSuresh Jan 27, 2025
525ce4e
updated - variable names and time delay
SuparnaSuresh Jan 27, 2025
3ebd4af
description added for new methods
SuparnaSuresh Jan 27, 2025
f48a5ba
time delay updated
SuparnaSuresh Jan 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
370 changes: 370 additions & 0 deletions src/test/GradleSingleModLCLSTest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,370 @@
/**
* Copyright (c) 2025 IBM Corporation.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*/
import { By, EditorView, TextEditor, VSBrowser } from "vscode-extension-tester";
import * as utils from './utils/testUtils';
import * as constants from './definitions/constants';

const path = require('path');
const assert = require('assert');

describe('LCLS tests for Gradle Project', function () {
let editor: TextEditor;
let actualServerXMLContent: string;

before(() => {
utils.copyDirectoryByPath(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config'), path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2'));
});

it('Should copy content of server.xml', async () => {
await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML)
editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor;

actualServerXMLContent = await editor.getText();
assert(actualServerXMLContent.length !== 0, 'Content of server.xml is not in copied.');
console.log('Sever.xml content is:', actualServerXMLContent);

}).timeout(25000);

it('Should show diagnostic for server.xml invalid value', async () => {
await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML);

const expectedOutcomeValue = `'wrong' is not a valid value of union type 'booleanType'.`;
const hoverTargetValue = '<logging appsWriteJson = \"wrong\" />';

await editor.typeTextAt(17, 5, hoverTargetValue);
const focusTargetedElement = editor.findElement(By.xpath("//*[contains(text(), 'wrong')]"));
await utils.delay(3000);
focusTargetedElement.click();
await editor.click();

const driverActionList = VSBrowser.instance.driver.actions();
await driverActionList.move({ origin: focusTargetedElement }).perform();
await utils.delay(5000);

const hoverContents = editor.findElement(By.className('hover-contents'));
const hoverFoundOutcome = await hoverContents.getText();
console.log("Hover text is:" + hoverFoundOutcome);

assert(hoverFoundOutcome.includes(expectedOutcomeValue), 'Did not get expected diagnostic in server.xml');

editor.clearText();
editor.setText(actualServerXMLContent);
console.log("server.xml content is restored");

}).timeout(38000);

it('Should apply quick fix for invalid value in server.xml', async () => {
await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML)
editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor;

const stanzaSnippet = "<logging appsWriteJson = \"wrong\" />";
const hoverExpectedSnippet = "<logging appsWriteJson = \"true\" />";
await editor.typeTextAt(17, 5, stanzaSnippet);
await utils.delay(2000);
const hoverTargetValue = await editor.findElement(By.xpath("//*[contains(text(), '\"wrong\"')]"));
await utils.delay(7000);

const driverActionList = VSBrowser.instance.driver.actions();
await driverActionList.move({ origin: hoverTargetValue }).perform();
await utils.delay(3000);

const driver = VSBrowser.instance.driver;
const hoverRowStatusBar = await editor.findElement(By.className('hover-row status-bar'));
await utils.delay(2000);

const quickFixPopupLink = await hoverRowStatusBar.findElement(By.xpath("//*[contains(text(), 'Quick Fix')]"));
await quickFixPopupLink.click();

const hoverWindowTaskBar = await editor.findElement(By.className('context-view monaco-component bottom left fixed'));
await hoverWindowTaskBar.findElement(By.className('actionList'));
await utils.delay(2000);

const pointerBlockedElement = await driver.findElement(By.css('.context-view-pointerBlock'));
// Setting pointer block element display value as none to choose option from Quickfix menu
if (pointerBlockedElement) {
await driver.executeScript("arguments[0].style.display = 'none';", pointerBlockedElement);
} else {
console.log('pointerBlockElement is not found!');
}
const quickfixOptionValues = await editor.findElement(By.xpath("//*[contains(text(), \"Replace with 'true'\")]"));
await quickfixOptionValues.click();

const updatedSeverXMLContent = await editor.getText();
await utils.delay(3000);
console.log("Content after Quick fix is: ", updatedSeverXMLContent);
assert(updatedSeverXMLContent.includes(hoverExpectedSnippet), 'Quick fix not applied correctly for the invalid value in server.xml.');

editor.clearText();
editor.setText(actualServerXMLContent);
console.log("server.xml content is restored");

}).timeout(38000);

it('Should show hover text in server.xml for server platform', async () => {
await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML)
editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor;

const stanzaSnippet = "<platform>jakartaee-11.0</platform>";
const expectedDiagnosticData = `Description: This platform resolves the Liberty features that support the Jakarta EE 11.0 platform.`;
await editor.typeTextAt(15, 35, '\n');
await editor.typeTextAt(16, 9, stanzaSnippet);
await utils.delay(2000);
const focusTargetedElement = await editor.findElement(By.xpath("//*[contains(text(), '\jakarta\')]"));
await utils.delay(3000);
focusTargetedElement.click();
await editor.click();

const driverActionList = VSBrowser.instance.driver.actions();
await driverActionList.move({ origin: focusTargetedElement }).perform();
await utils.delay(5000);

const hoverContents = editor.findElement(By.className('hover-contents'));
const hoverValue = await hoverContents.getText();
console.log("Hover text is:" + hoverValue);

assert(hoverValue.includes(expectedDiagnosticData), 'Did not get expected hover text in server.xml server platform');

editor.clearText();
editor.setText(actualServerXMLContent);
console.log("Content is restored");

}).timeout(38000);

it('Should show diagnostic for invalid value in server.xml for server platform', async () => {
await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML)
editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor;

const stanzaSnippet = "<platform>jakarta</platform>";
const expectedDiagnosticData = `ERROR: The platform "jakarta" does not exist.`;
await editor.typeTextAt(15, 35, '\n');
await editor.typeTextAt(16, 9, stanzaSnippet);
await utils.delay(2000);
const focusTargetedElement = await editor.findElement(By.xpath("//*[contains(text(), '\jakarta\')]"));
await utils.delay(3000);
focusTargetedElement.click();
await editor.click();

const driverActionList = VSBrowser.instance.driver.actions();
await driverActionList.move({ origin: focusTargetedElement }).perform();
await utils.delay(5000);

const hoverContents = editor.findElement(By.className('hover-contents'));
const hoverValue = await hoverContents.getText();
console.log("Hover text:" + hoverValue);

assert(hoverValue.includes(expectedDiagnosticData), 'Did not get expected diagnostic in server.xml server platform');

editor.clearText();
editor.setText(actualServerXMLContent);
console.log("Content is restored");

}).timeout(38000);

it('Should apply quick fix for invalid value in server.xml for server platform', async () => {
await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML)
editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor;

const stanzaSnipet = "<platform>jakarta</platform>";
const expectedHoverData = "<platform>jakartaee-11.0</platform>";
await editor.typeTextAt(15, 35, '\n');
await editor.typeTextAt(16, 9, stanzaSnipet);
await utils.delay(2000);
const flaggedString = await editor.findElement(By.xpath("//*[contains(text(), '\jakarta\')]"));
await utils.delay(7000);

const driverActionList = VSBrowser.instance.driver.actions();
await driverActionList.move({ origin: flaggedString }).perform();
await utils.delay(3000);

const driver = VSBrowser.instance.driver;
const hoverRowStatusBar = await editor.findElement(By.className('hover-row status-bar'));
await utils.delay(2000);

const quickFixPopupLink = await hoverRowStatusBar.findElement(By.xpath("//*[contains(text(), 'Quick Fix')]"));
await quickFixPopupLink.click();

const hoverTaskBar = await editor.findElement(By.className('context-view monaco-component bottom left fixed'));
await hoverTaskBar.findElement(By.className('actionList'));
await utils.delay(2000);

const pointerBlockedElement = await driver.findElement(By.css('.context-view-pointerBlock'));
// Setting pointer block element display value as none to choose option from Quickfix menu
if (pointerBlockedElement) {
await driver.executeScript("arguments[0].style.display = 'none';", pointerBlockedElement);
} else {
console.log('PointerBlockedElement is not found!');
}
const quickfixOption = await editor.findElement(By.xpath("//*[contains(text(), \"Replace platform with jakartaee-11.0\")]"));
await quickfixOption.click();

const updatedSeverXMLContent = await editor.getText();
await utils.delay(3000);
console.log("Content after Quick fix : ", updatedSeverXMLContent);
assert(updatedSeverXMLContent.includes(expectedHoverData), 'Quick fix not applied correctly for the invalid value in server.xml server platform.');

editor.clearText();
editor.setText(actualServerXMLContent);
console.log("Content is restored");

}).timeout(38000);

it('Should show diagnostic for invalid value in server.xml for server feature', async () => {
await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML)
editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor;

const stanzaSnippet = "<feature>servlet</feature>";
const expectedDiagnosticData = `ERROR: The "servlet" versionless feature cannot be resolved since there are more than one common platform. Specify a platform or a feature with a version to enable resolution`;
await editor.typeTextAt(15, 35, '\n');
await editor.typeTextAt(16, 9, stanzaSnippet);
await utils.delay(2000);
const focusTargetedElement = await editor.findElement(By.xpath("//*[contains(text(), '\servlet\')]"));
await utils.delay(3000);
focusTargetedElement.click();
await editor.click();

const driverActionList = VSBrowser.instance.driver.actions();
await driverActionList.move({ origin: focusTargetedElement }).perform();
await utils.delay(5000);

const hoverContents = editor.findElement(By.className('hover-contents'));
const hoverValue = await hoverContents.getText();
console.log("Hover text:" + hoverValue);

assert(hoverValue.includes(expectedDiagnosticData), 'Did not get expected diagnostic in server.xml server feature');

editor.clearText();
editor.setText(actualServerXMLContent);
console.log("Content is restored");

}).timeout(38000);

it('Should apply quick fix for invalid value in server.xml for server feature', async () => {
await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML)
editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor;

const stanzaSnippet = "<feature>servlet</feature>";
const expectedHoverData = "<feature>servlet-3.1</feature>";
await editor.typeTextAt(15, 35, '\n');
await editor.typeTextAt(16, 9, stanzaSnippet);
await utils.delay(2000);
const flaggedString = await editor.findElement(By.xpath("//*[contains(text(), '\servlet\')]"));
await utils.delay(7000);

const driverActionList = VSBrowser.instance.driver.actions();
await driverActionList.move({ origin: flaggedString }).perform();
await utils.delay(3000);

const driver = VSBrowser.instance.driver;
const hoverRowStatusBar = await editor.findElement(By.className('hover-row status-bar'));
await utils.delay(2000);

const quickFixPopupLink = await hoverRowStatusBar.findElement(By.xpath("//*[contains(text(), 'Quick Fix')]"));
await quickFixPopupLink.click();

const hoverTaskBar = await editor.findElement(By.className('context-view monaco-component bottom left fixed'));
await hoverTaskBar.findElement(By.className('actionList'));
await utils.delay(2000);

const pointerBlockedElement = await driver.findElement(By.css('.context-view-pointerBlock'));
// Setting pointer block element display value as none to choose option from Quickfix menu
if (pointerBlockedElement) {
await driver.executeScript("arguments[0].style.display = 'none';", pointerBlockedElement);
} else {
console.log('pointerBlockElementt not found!');
}
const quickfixOption = await editor.findElement(By.xpath("//*[contains(text(), \"Replace feature with servlet-3.1\")]"));
await quickfixOption.click();

const updatedSeverXMLContent = await editor.getText();
await utils.delay(3000);
console.log("Content after Quick fix is: ", updatedSeverXMLContent);
assert(updatedSeverXMLContent.includes(expectedHoverData), 'Quick fix is not applied correctly for the invalid value in server.xml server feature.');

editor.clearText();
editor.setText(actualServerXMLContent);
console.log("Content is restored");

}).timeout(38000);

it('Should show type ahead support in server.xml Liberty Server platform', async () => {
await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML)
editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor;

const featureTag = "<p";
const addFeature = "<platform>jakartaee-11.0</platform>";
await editor.typeTextAt(15, 35, '\n');
await editor.typeTextAt(16, 9, featureTag);
await utils.delay(5000);
await utils.callAssitantAction(editor, 'platform');

await editor.toggleContentAssist(false);
const stanzaSnippet = "jakar";

await editor.typeTextAt(16, 19, stanzaSnippet);
await utils.delay(5000);

await utils.callAssitantAction(editor, 'jakartaee-11.0')
await editor.toggleContentAssist(false);

const updatedServerxmlContent = await editor.getText();
await utils.delay(3000);
console.log("Content after type ahead support is: ", updatedServerxmlContent);
assert(updatedServerxmlContent.includes(addFeature), 'Type ahead support is not worked as expected in server.xml Liberty Server platform');

editor.clearText();
editor.setText(actualServerXMLContent);
console.log("Content is restored");

}).timeout(38000);

it('Valid server feature entry with platform entry in server.xml', async () => {
await utils.openConfigFile(constants.CONFIG_TWO, constants.SERVER_XML)
editor = await new EditorView().openEditor(constants.SERVER_XML) as TextEditor;

const stanzaSnippetFeature = "<feature>servlet</feature>";
const stanzaSnippetPlatform = "<platform>jakartaee-9.1</platform>";
const expectedDiagnosticData = `ERROR: The "servlet" versionless feature cannot be resolved since there are more than one common platform. Specify a platform or a feature with a version to enable resolution`;
await editor.typeTextAt(15, 35, '\n');
await editor.typeTextAt(16, 9, stanzaSnippetFeature);
await utils.delay(2000);
const focusTargetedElement = await editor.findElement(By.xpath("//*[contains(text(), '\servlet\')]"));
await utils.delay(3000);
focusTargetedElement.click();
await editor.click();

const driverActionList = VSBrowser.instance.driver.actions();
await driverActionList.move({ origin: focusTargetedElement }).perform();
await utils.delay(5000);

const holverContents = editor.findElement(By.className('hover-contents'));
const hoverValue = await holverContents.getText();
console.log("Hover text is:" + hoverValue);
if (hoverValue.includes(expectedDiagnosticData)) {
await editor.typeTextAt(16, 35, '\n');
await editor.typeTextAt(17, 9, stanzaSnippetPlatform);
await utils.delay(2000);
}
const updatedServerxmlContent = await editor.getText();
console.log("Updated server.xml content is:" + updatedServerxmlContent);

assert(updatedServerxmlContent.includes(stanzaSnippetFeature) && updatedServerxmlContent.includes(stanzaSnippetPlatform), 'Did not get expected entries in server.xml for versionless combination for server feature and platform');

editor.clearText();
editor.setText(actualServerXMLContent);
console.log("Content is restored");

}).timeout(38000);

after(() => {
utils.removeDirectoryByPath(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2'));
console.log("Removed new config folder:");
});

});
6 changes: 6 additions & 0 deletions src/test/definitions/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

/**
* Copyright (c) 2020, 2022 IBM Corporation.
*
Expand Down Expand Up @@ -40,3 +41,8 @@ export const ATTACH_DEBUGGER_DASHBOARD_MAC_ACTION = "Liberty: Attach debugger";
export const MAVEN_DEVMODE_DEBUG_PORT_PARM = "-DdebugPort";
/** Gradle: Dev mode debug port argument key. */
export const GRADLE_DEVMODE_DEBUG_PORT_PARM = "--libertyDebugPort";
export const CONFIG = "config";
export const CONFIG_TWO = "config2";
export const BOOTSTRAP_PROPERTIES = "bootstrap.properties";
export const SERVER_XML = "server.xml";
export const SERVER_ENV = "server.env";
Loading
Loading