Skip to content

Commit

Permalink
Added test case to copy server.xm content
Browse files Browse the repository at this point in the history
  • Loading branch information
SuparnaSuresh committed Dec 6, 2024
1 parent 938ea5d commit 88a9b0b
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions src/test/GradleSingleModLCLSTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,31 @@ const assert = require('assert');

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

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

it('Should coppy content of server.xml', async () => {
const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT);
section.expand();
await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml'));

editor = await new EditorView().openEditor('server.xml') as TextEditor;
actualSeverXMLContent = await editor.getText();

assert(actualSeverXMLContent.length!==0, 'Content of server.xml is not in coppied.');
console.log('Sever.xml content:',actualSeverXMLContent);

}).timeout(10000);

it('Should apply quick fix for invalid value in server.xml', async () => {
const section = await new SideBarView().getContent().getSection(constants.GRADLE_PROJECT);
section.expand();
await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml'));

editor = await new EditorView().openEditor('server.xml') as TextEditor;
const actualSeverXMLContent = await editor.getText();
const stanzaSnipet = "<logging appsWriteJson = \"wrong\" />";
const expectedHoverData = "<logging appsWriteJson = \"true\" />";
await editor.typeTextAt(17, 5, stanzaSnipet);
Expand Down Expand Up @@ -64,9 +77,9 @@ describe('LCLS tests for Gradle Project', function () {
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.');
await editor.clearText();
await editor.setText(actualSeverXMLContent);
await utils.delay(3000);

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

}).timeout(38000);
Expand All @@ -76,7 +89,6 @@ describe('LCLS tests for Gradle Project', function () {
await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), 'src', 'main', 'liberty', 'config2', 'server.xml'));
editor = await new EditorView().openEditor('server.xml') as TextEditor;

const actualSeverXMLContent = await editor.getText();
const hovrExpctdOutcome = `Configuration properties for an HTTP endpoint.`;

console.log(hovrExpctdOutcome);
Expand All @@ -94,9 +106,9 @@ describe('LCLS tests for Gradle Project', function () {
console.log("Hover text:" + hoveredText);

assert(hoveredText.includes(hovrExpctdOutcome), 'Did not get expected hover data Liberty Server Attribute.');
await editor.clearText();
await editor.setText(actualSeverXMLContent);
await utils.delay(3000);

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

}).timeout(35000);
Expand Down Expand Up @@ -127,6 +139,10 @@ describe('LCLS tests for Gradle Project', function () {

assert(hverValue.includes(hverExpectdOutcome), 'Did not get expected hover data Liberty Server Feature.');

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

}).timeout(33000);

after(() => {
Expand Down

0 comments on commit 88a9b0b

Please sign in to comment.