Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 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
23d1ce7
hover support for server.xml Liberty Server Attribute
SuparnaSuresh Nov 20, 2024
6eba89d
updated code for quick fix element
SuparnaSuresh Nov 21, 2024
c35d6bf
Merge branch 'OpenLiberty:main' into issue378-HoversupportServerAttri…
SuparnaSuresh Dec 5, 2024
13bb977
Added code for new config folder
SuparnaSuresh Dec 5, 2024
008cb5c
updated variable and code format
SuparnaSuresh Dec 5, 2024
c452b38
Added test case for hover support for server.xml Liberty Server Feature
SuparnaSuresh Dec 5, 2024
368ac77
test case added - type ahead support in server.xml Liberty Server Fea…
SuparnaSuresh Dec 5, 2024
767952a
updated test case
SuparnaSuresh Dec 5, 2024
358f41d
Updated test case
SuparnaSuresh Dec 6, 2024
a5e0e5f
Test case added for type ahead support config stanza
SuparnaSuresh Dec 6, 2024
2e03f59
Test case added for server.env
SuparnaSuresh Dec 6, 2024
b1d39e1
Test cases added for server.env
SuparnaSuresh Dec 9, 2024
ebcad9d
Test case added for server.env LCLS
SuparnaSuresh Dec 9, 2024
0843603
chanaged server.xml path
SuparnaSuresh Dec 9, 2024
33c6213
typo error and copyright hear year updated
SuparnaSuresh Jan 17, 2025
dad152d
Updated testUtils
SuparnaSuresh Jan 27, 2025
53a7165
Merge branch 'OpenLiberty:main' into issue124-TestcasesForServerEnvLCLS
SuparnaSuresh Jan 27, 2025
fa5caeb
Updated test cases
SuparnaSuresh Jan 27, 2025
a0f1d58
description added for methods
SuparnaSuresh Jan 27, 2025
4e8f0f9
addressed review comments
SuparnaSuresh Jan 28, 2025
e2ba375
Server.env test cases updated to diffrent file
SuparnaSuresh Jan 29, 2025
fefa988
removed server.xml test cases
SuparnaSuresh Jan 29, 2025
a243593
test case time - delay updated
SuparnaSuresh Jan 29, 2025
cbb74bc
constant - file updated
SuparnaSuresh Jan 29, 2025
9f92154
formated - constants
SuparnaSuresh Jan 29, 2025
aa9a0cb
constant file updated
SuparnaSuresh Jan 29, 2025
d1d8d5c
GHA build failure fix
SuparnaSuresh Jan 29, 2025
41ced49
GHA build failure fix
SuparnaSuresh Jan 29, 2025
f775424
Merge branch 'OpenLiberty:main' into issue124-TestcasesForServerEnvLCLS
SuparnaSuresh Feb 7, 2025
6244e3e
Merge branch 'OpenLiberty:main' into issue124-TestcasesForServerEnvLCLS
SuparnaSuresh Feb 17, 2025
d6baa4e
GHA build failure - fix
SuparnaSuresh Feb 18, 2025
c08854e
GHA build failure fix
SuparnaSuresh Feb 18, 2025
cfa3ce6
GHA build failure - fix delay added
SuparnaSuresh Feb 18, 2025
b47dd2b
Changed config path
SuparnaSuresh Feb 18, 2025
dbd33fb
increased time delay
SuparnaSuresh Feb 18, 2025
883c9ae
review comments addressed
SuparnaSuresh Feb 18, 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
141 changes: 141 additions & 0 deletions src/test/GradleSingleModLclsServerEnvTest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/**
* 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, SideBarView, TextEditor, ViewSection, VSBrowser } from "vscode-extension-tester";
import * as utils from './utils/testUtils';
import * as constants from './definitions/constants';
import { expect } from "chai";

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

describe('LCLS tests for Gradle Project - Server.env', function () {
let editor: TextEditor;
let sidebar: SideBarView;
let section: ViewSection;

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

it('getViewControl works with the correct label', async () => {
const contentPart = sidebar.getContent();
section = await contentPart.getSection('Liberty Dashboard');
console.log("Found Liberty Dashboard....");
expect(section).not.undefined;

}).timeout(30000);

it('Should show hover support for server.env Liberty Server config setting', async () => {
await utils.delay(15000);
await utils.openFileByPath(constants.CONFIG, constants.SERVER_ENV);
editor = await new EditorView().openEditor(constants.SERVER_ENV) as TextEditor;

const expectedHoverOutcome = 'This setting controls the granularity of messages that go to the console. The valid values are INFO, AUDIT, WARNING, ERROR, and OFF. The default is AUDIT. If using with the Eclipse developer tools this must be set to the default.';
await editor.clearText();
const testHoverTarget = 'WLP_LOGGING_CONSOLE_LOGLEVEL=OFF';
await editor.typeTextAt(1, 1, testHoverTarget);
await utils.delay(5000);

const focusTargetLement = editor.findElement(By.xpath("//*[contains(text(), 'CONSOLE_LOGLEVEL')]"));
await utils.delay(3000);
focusTargetLement.click();
await editor.click();

const actions = VSBrowser.instance.driver.actions();
await actions.move({ origin: focusTargetLement }).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(expectedHoverOutcome), 'Did not get expected hover data for server.env');

await editor.clearText();
await utils.closeFileTab(constants.SERVER_ENV);
await utils.delay(8000);

}).timeout(85000);

it('Should show completion support in server.env for a Liberty Server Configuration Stanza', async () => {
await utils.openFileByPath(constants.CONFIG, constants.SERVER_ENV);
editor = await new EditorView().openEditor('server.env') as TextEditor;

const configNameSnippet = 'WLP_LOGGING_CON';
const insertConfig = "=TBA";
const envCfgNameChooserSnippet = 'WLP_LOGGING_CONSOLE_FORMAT';
const expectedServerEnvString = 'WLP_LOGGING_CONSOLE_FORMAT=TBASIC';

await editor.typeTextAt(1, 1, configNameSnippet);
await utils.delay(5000);
//open the assistant
await utils.callAssitantAction(editor, envCfgNameChooserSnippet);

await editor.typeTextAt(1, 27, insertConfig);
await utils.delay(2500);
await utils.callAssitantAction(editor, 'TBASIC');

await editor.toggleContentAssist(false);

const updatedSeverEnvContent = await editor.getText();
await utils.delay(3000);
assert(updatedSeverEnvContent.includes(expectedServerEnvString), 'Completion support is not working as expected in server.env');

await editor.clearText();
await utils.closeFileTab(constants.SERVER_ENV);
await utils.delay(8000);

}).timeout(85000);

it('Should show diagnostic support in server.env ', async () => {
await utils.openFileByPath(constants.CONFIG, constants.SERVER_ENV);
editor = await new EditorView().openEditor(constants.SERVER_ENV) as TextEditor;

const configNameSnippet = 'WLP_LOGGING_CON';
const insertConfig = '=sample_value_is_updating_as_nodata';
const envCfgNameChooserSnippet = 'WLP_LOGGING_CONSOLE_FORMAT';
const expectedHoverData = 'The value `sample_value_is_updating_as_nodata` is not valid for the variable `WLP_LOGGING_CONSOLE_FORMAT`.';

await editor.typeTextAt(1, 1, configNameSnippet);
await utils.delay(5000);
//open the assistant
await utils.callAssitantAction(editor, envCfgNameChooserSnippet);
// close the assistant
await editor.toggleContentAssist(false);

await editor.typeTextAt(1, 27, insertConfig);
const focusTargetElement = editor.findElement(By.xpath("//*[contains(text(), 'nodata')]"));
await utils.delay(3000);
focusTargetElement.click();
await editor.click();

const actions = VSBrowser.instance.driver.actions();
await actions.move({ origin: focusTargetElement }).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(expectedHoverData), 'Did not get expected diagnostic as expected in server.env file');

await editor.clearText();
await utils.closeFileTab(constants.SERVER_ENV);
await utils.delay(8000);

}).timeout(85000);

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

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

/**
* Copyright (c) 2020, 2022 IBM Corporation.
* Copyright (c) 2020, 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
Expand All @@ -9,7 +10,7 @@
*/

export const MAVEN_PROJECT = "liberty.maven.test.wrapper.app";
export const GRADLE_PROJECT= "liberty.gradle.test.wrapper.app";
export const GRADLE_PROJECT = "liberty.gradle.test.wrapper.app";
export const START_DASHBOARD_ACTION = "Start";
export const STOP_DASHBOARD_ACTION = "Stop";
export const START_DASHBOARD_MAC_ACTION = "Liberty: Start";
Expand Down Expand Up @@ -37,6 +38,68 @@ export const GRADLE_TEST_REPORT_TITLE = "liberty.gradle.test.wrapper.app test re
export const ATTACH_DEBUGGER_DASHBOARD_ACTION = "Attach debugger";
export const ATTACH_DEBUGGER_DASHBOARD_MAC_ACTION = "Liberty: Attach debugger";
/** Maven: Dev mode debug port argument key. */
export const MAVEN_DEVMODE_DEBUG_PORT_PARM = "-DdebugPort";
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";
export const CLOSE_EDITOR = "View: Close Editor";
export const CONFIRM_MESSAGES = {
[SERVER_XML]: 'Do you want to save the changes you made to server.xml?',
[SERVER_ENV]: 'Do you want to save the changes you made to server.env?',
[BOOTSTRAP_PROPERTIES]: 'Do you want to save the changes you made to bootstrap.properties?'
};
export const EXPECTED_OUTCOME_WRONG = "'wrong' is not a valid value of union type 'booleanType'.";
export const TARGETED_VALUE_LOGGING = '<logging appsWriteJson = \"wrong\" />';
export const FOCUS_WRONG = "//*[contains(text(), 'wrong')]";
export const SNIPPET_LOGGING = "<logging appsWriteJson = \"true\" />";
export const FOCUS_QUICKFIX = "//*[contains(text(), 'Quick Fix')]";
export const LOGGING_TRUE = "//*[contains(text(), \"Replace with 'true'\")]";
export const FOCUS_HTTPENDPOINT = "//*[contains(text(), 'httpEndpoint')]";
export const FOCUS_MPHEALTH = "//*[contains(text(), 'mpHealth')]";
export const FEATURE_MPHEALTH = '<feature>mpHealth-4.0</feature>';
export const NEWLINE = '\n';
export const DESCRIPTION_MPHEALTH = "Description: This feature provides support for the MicroProfile Health specification.";
export const DESCRIPTION_HTTPENDPOINT = `Configuration properties for an HTTP endpoint.`;
export const FEATURE_EL = "<feature>el-3.0</feature>";
export const LOGGING_TAG = "<logging></logging>";
export const LOGGING = 'logging';
export const FEATURE_TAG = 'feature';
export const EL_VALUE = 'el-3.0';
export const PLATFORM_JAKARTA_VALUE = "<platform>jakartaee-11.0</platform>";
export const DESCRIPTION_PLATFORM = `Description: This platform resolves the Liberty features that support the Jakarta EE 11.0 platform.`;
export const FOCUS_JAKARTA = "//*[contains(text(), '\jakarta\')]";
export const PLATFORM_JAKARTA = "<platform>jakarta</platform>";
export const PLATFORM_JAKARTA_ERROR = `ERROR: The platform "jakarta" does not exist.`;
export const FOCUS_JAKARTA_ELEVEN = "//*[contains(text(), \"Replace platform with jakartaee-11.0\")]";
export const FEATURE_SERVLET = "<feature>servlet</feature>";
export const SERVLET_ERROR = `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`;
export const FOCUS_SERVLET = "//*[contains(text(), '\servlet\')]";
export const SERVLET_VALUE = "<feature>servlet-3.1</feature>";
export const FOCUS_SERVLET_VALUE = "//*[contains(text(), \"Replace feature with servlet-3.1\")]";
export const PLATFORM = "platform";
export const JAKARTA_ELEVEN = 'jakartaee-11.0';
export const PLATFORM_JAKARTA_NINE = "<platform>jakartaee-9.1</platform>";
export const WLP_LOGGING_CONSOLE_FORMAT = 'WLP_LOGGING_CONSOLE_FORMAT';
export const CONSOLE_FORMAT_TBASIC = 'WLP_LOGGING_CONSOLE_FORMAT=TBASIC';
export const TBASIC = 'TBASIC';
export const TBA = "=TBA";
export const WLP_LOGGING_CON = 'WLP_LOGGING_CON';
export const LOG_LEVEL_INFO_MSG = 'This setting controls the granularity of messages that go to the console. The valid values are INFO, AUDIT, WARNING, ERROR, and OFF. The default is AUDIT. If using with the Eclipse developer tools this must be set to the default.';
export const FOCUS_LOGLEVEL = "//*[contains(text(), 'CONSOLE_LOGLEVEL')]";
export const LOGLEVEL_WITH_VALUE = 'WLP_LOGGING_CONSOLE_LOGLEVEL=OFF';
export const CONSOLE_FORMAT_DIAGNOSTIC = 'The value `sample_value_is_updating_as_nodata` is not valid for the variable `WLP_LOGGING_CONSOLE_FORMAT`.';
export const FOCUS_NODATA = "//*[contains(text(), 'nodata')]";
export const VALUE_NODATA = '=sample_value_is_updating_as_nodata';
export const WS_LOGGING_CON = "com.ibm.ws.logging.con";
export const VALUE_WRONG = "=wrong";
export const WS_LOGGING_CONSOLE_FORMAT = "com.ibm.ws.logging.console.format";
export const WS_LOGGING_CONSOLE_DIAGNOSTIC = "The value `wrong` is not valid for the property `com.ibm.ws.logging.console.format`.";
export const WS_LOGGING_CONSOLE_VALUE = "com.ibm.ws.logging.console.log.level=OFF";
export const FOCUS_WS_LOGLEVEL = "//*[contains(text(), 'ws.logging.console.log.level')]";
export const WS_LOGLEVEL_TBASIC = 'com.ibm.ws.logging.trace.format=TBASIC';
export const WS_LOG_TRACE_FORMAT = 'com.ibm.ws.logging.trace.format';
export const WS_LOGGING_T = "com.ibm.ws.logging.t";
92 changes: 88 additions & 4 deletions src/test/utils/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
* SPDX-License-Identifier: EPL-2.0
*/
import path = require('path');
import { Workbench, InputBox, DefaultTreeItem, ModalDialog } from 'vscode-extension-tester';
import { Workbench, InputBox, DefaultTreeItem, ModalDialog, SideBarView, VSBrowser, TextEditor } from 'vscode-extension-tester';
import * as fs from 'fs';
import { STOP_DASHBOARD_MAC_ACTION } from '../definitions/constants';
import * as constants from '../definitions/constants';
import { MapContextMenuforMac } from './macUtils';
import clipboard = require('clipboardy');
import { expect } from 'chai';
import * as fse from 'fs-extra';

export function delay(millisec: number) {
return new Promise( resolve => setTimeout(resolve, millisec) );
Expand Down Expand Up @@ -180,7 +181,7 @@ export function getMvnProjectPath(): string {
export async function stopLibertyserver(projectName: string) {
console.log("Stop Server action for Project : " + projectName);
const workbench = new Workbench();
await workbench.executeCommand(STOP_DASHBOARD_MAC_ACTION);
await workbench.executeCommand(constants.STOP_DASHBOARD_MAC_ACTION);
const input = InputBox.create();
(await input).clear();
(await input).setText(projectName);
Expand All @@ -202,4 +203,87 @@ export async function clearCommandPalette() {
await dialog.pushButton('Clear');
}


/**
*
* @param projectPath
* Remove specific directory with contents
*/
export async function removeDirectoryByPath(dirPath: string): Promise<void> {
try {
fs.accessSync(dirPath);
const dirContent = fs.readdirSync(dirPath);
await Promise.all(
dirContent.map(async (dirFiles) => {
const projectContentPath = path.join(dirPath, dirFiles);
const stats = fs.lstatSync(projectContentPath);
if (stats.isDirectory()) {
await removeDirectoryByPath(projectContentPath);
} else {
fs.unlinkSync(projectContentPath);
}
})
);
fs.rmdirSync(dirPath);
} catch (error) {
console.error(`Error removing directory: ${error}`);
}
}

/**
*
* @param existingConfigPath
* @param copyConfigPath
* Copy a specific directory
*/
export async function copyDirectoryByPath(existingDirPath: string, copyDirPath: string): Promise<void> {
fse.copy(existingDirPath, copyDirPath)
.then(() => console.log("Folder content copied :" + copyDirPath))
.catch(err => console.log("Error occuried while copying content"));
}

/**
*
* @param parentDir
* @param configFileName
* Open specific file from parent directory
*/
export async function openFileByPath(parentDir: string, fileName: string) {
const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT);
section.expand();
await VSBrowser.instance.openResources(path.join(getGradleProjectPath(), 'src', 'main', 'liberty', parentDir, fileName));
}

/**
* Function to close currently opened file tab
*/
export async function closeFileTab(fileType: string) {
const workbench = new Workbench();
await workbench.openCommandPrompt();
await delay(3000);
await workbench.executeCommand(constants.CLOSE_EDITOR);
await delay(3000);
const dialog = new ModalDialog();
const message = await dialog.getMessage();

if (fileType in constants.CONFIRM_MESSAGES) {
expect(message).contains(constants.CONFIRM_MESSAGES[fileType as keyof typeof constants.CONFIRM_MESSAGES]);
}
const buttons = await dialog.getButtons();
expect(buttons.length).equals(3);
await dialog.pushButton('Don\'t Save');
}

/**
*
* @param editor
* @param selectValue
* Function to call toggle assistant to select value from suggestion list
*/
export async function callAssitantAction(editor: TextEditor, selectValue: string) {
let assist = await editor.toggleContentAssist(true);
// toggle can return void, so we need to make sure the object is present
if (assist) {
// to select an item use
await assist.select(selectValue);
}
}