Skip to content
This repository was archived by the owner on Nov 15, 2022. It is now read-only.

Commit 44e297b

Browse files
sumauppayaminikb
authored andcommitted
Fixes #20763 : Confirmation message display issue is resolved when enable/disable action is successfully performed. (#21929)
* Added test for application ->targets page
1 parent 313d03a commit 44e297b

File tree

10 files changed

+93
-17
lines changed

10 files changed

+93
-17
lines changed

appserver/admingui/common/src/main/resources/appServer/serverInstResources.jsf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
<sun:form id="propertyForm">
6262

6363
#include "/common/appServer/serverInstTabs.inc"
64+
#include "/common/shared/alertMsg_1.inc"
6465
<!-- Page Title -->
6566

6667
<sun:title id="propertyContentPage" title="$resource{i18nc.resourcesTarget.pageTitle}"

appserver/admingui/common/src/main/resources/applications/targetListing.jsf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,13 @@
109109
setAttribute(key="actionValue" value="#{click.selected}")
110110
if( ${actionValue}=enable){
111111
gf.changeTargetStatus(selectedRows="${selectedRows}" Enabled="#{true}" forLB="$boolean{false}")
112+
prepareAlertMsg(summary="$resource{i18n.msg.enableOnTargetsSuccessful}", type="success");
113+
gf.redirect(page="#{request.contextPath}/common/applications/targetListing.jsf?appName=#{pageSession.encodedAppName}&listPageLink=#{pageSession.listPageLink}&alertType=${alertType}&alertSummary=${alertSummary}&alertDetail=${alertDetail}");
112114
}
113115
if( ${actionValue}=disable){
114116
gf.changeTargetStatus(selectedRows="${selectedRows}" Enabled="#{false}" forLB="$boolean{false}")
117+
prepareAlertMsg(summary="$resource{i18n.msg.disableOnTargetsSuccessful}", type="success");
118+
gf.redirect(page="#{request.contextPath}/common/applications/targetListing.jsf?appName=#{pageSession.encodedAppName}&listPageLink=#{pageSession.listPageLink}&alertType=${alertType}&alertSummary=${alertSummary}&alertDetail=${alertDetail}");
115119
}
116120
if( ${actionValue}=lb-enable){
117121
gf.changeTargetStatus(selectedRows="${selectedRows}" Enabled="#{true}" forLB="$boolean{true}")

appserver/admingui/common/src/main/resources/resourceNode/resourceEditTargets.jsf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@
103103
method="post");
104104
}
105105
setAttribute(key="selectedRows" value="${selectedRows}");
106-
gf.redirect(page="#{pageSession.targetPage}&generalPage=#{pageSession.generalPage}");
106+
prepareAlertMsg(summary="$resource{i18n.msg.enableResourceOnTargetsSuccessful}", type="success");
107+
gf.redirect(page="#{pageSession.targetPage}&generalPage=#{pageSession.generalPage}&alertType=${alertType}&alertSummary=${alertSummary}&alertDetail=${alertDetail}");
107108
/>
108109
</sun:button>
109110
<sun:button id="button3" text="$resource{i18n.button.Disable}" disabled="#{true}" primary="#{false}" >
@@ -117,7 +118,8 @@
117118
method="post");
118119
}
119120
setAttribute(key="selectedRows" value="${selectedRows}");
120-
gf.redirect(page="#{pageSession.targetPage}&generalPage=#{pageSession.generalPage}");
121+
prepareAlertMsg(summary="$resource{i18n.msg.disableResourceOnTargetsSuccessful}", type="success");
122+
gf.redirect(page="#{pageSession.targetPage}&generalPage=#{pageSession.generalPage}&alertType=${alertType}&alertSummary=${alertSummary}&alertDetail=${alertDetail}");
121123
/>
122124
</sun:button>
123125
</sun:panelGroup>

appserver/admingui/common/src/main/resources/resourceNode/targetResourceTableButtons.inc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@
6868
}
6969
}
7070
setAttribute(key="selectedRows" value="${selectedRows}");
71-
gf.redirect(page="#{pageSession.listLink}&filterValue=#{pageSession.filterValue}");
71+
prepareAlertMsg(summary="$resource{i18n.msg.enableResourceSuccessful}", type="success");
72+
gf.redirect(page="#{pageSession.listLink}&filterValue=#{pageSession.filterValue}&alertType=${alertType}&alertSummary=${alertSummary}&alertDetail=${alertDetail}");
7273
/>
7374
</sun:button>
7475
<sun:button id="button2" text="$resource{i18n.button.Disable}" disabled="#{true}" primary="#{false}" >
@@ -92,7 +93,8 @@
9293
}
9394
}
9495
setAttribute(key="selectedRows" value="${selectedRows}");
95-
gf.redirect(page="#{pageSession.listLink}&filterValue=#{pageSession.filterValue}");
96+
prepareAlertMsg(summary="$resource{i18n.msg.disableResourceSuccessful}", type="success");
97+
gf.redirect(page="#{pageSession.listLink}&filterValue=#{pageSession.filterValue}&alertType=${alertType}&alertSummary=${alertSummary}&alertDetail=${alertDetail}");
9698
/>
9799
</sun:button>
98100

appserver/admingui/core/src/main/resources/org/glassfish/admingui/core/Strings.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,12 @@ msg.updateAndNewModulesAvailable=<b>1 new update and {0} new software are availa
268268
msg.runUpdateCenter=<br/>Please run the Update Center Client ({0}) for download and installation.</b>
269269
msg.enableSuccessful=Selected application(s) has been enabled on all targets.
270270
msg.disableSuccessful=Selected application(s) has been disabled on all targets.
271+
msg.enableOnTargetsSuccessful=Application has been enabled on selected target(s).
272+
msg.disableOnTargetsSuccessful=Application has been disabled on selected target(s).
271273
msg.enableResourceSuccessful=Selected resource(s) has been enabled.
272274
msg.disableResourceSuccessful=Selected resource(s) has been disabled.
275+
msg.enableResourceOnTargetsSuccessful=Resource has been enabled on selected target(s).
276+
msg.disableResourceOnTargetsSuccessful=Resource has been disabled on selected target(s).
273277
msg.enableSuccessfulPE=Selected application(s) has been enabled.
274278
msg.disableSuccessfulPE=Selected application(s) has been disabled.
275279
msg.enableSuccessfulLifecycle=Selected Lifecycle Module(s) has been enabled.

appserver/admingui/devtests/src/test/java/org/glassfish/admingui/devtests/AppScopedResourcesTest.java

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public class AppScopedResourcesTest extends BaseSeleniumTestClass {
5656
private static final String TRIGGER_APPLICATIONS = "Applications can be enterprise or web applications, or various kinds of modules.";
5757
private static final String TRIGGER_EDIT_APPLICATION = "Modify an existing application or module.";
5858
private static final String TRIGGER_RESOURCES_APPLICATION = "View application scoped resources for the application.";
59+
private static final String TRIGGER_TARGETS_APPLICATION = "List application targets.";
5960

6061
private static final String ELEMENT_APP_NAME = "form:war:psection:nameProp:appName";
6162
private static final String ELEMENT_UNDEPLOY_BUTTON = "propertyForm:deployTable:topActionsGroup1:button1";
@@ -65,6 +66,7 @@ public class AppScopedResourcesTest extends BaseSeleniumTestClass {
6566
private static final String ELEMENT_DEPLOY_BUTTON = "propertyForm:deployTable:topActionsGroup1:deployButton";
6667
private static final String ELEMENT_APPLICATIONS = "treeForm:tree:applications:applications_link";
6768
private static final String ELEMENT_APPLICATION_RESOURCES_TAB = "propertyForm:appGeneralTabs:resourcesTab";
69+
private static final String ELEMENT_APPLICATION_TARGETS_TAB = "propertyForm:appGeneralTabs:targetTab";
6870
private static final String ELEMENT_APP_RESOURCES_TABLE = "propertyForm:appScopedResources";
6971

7072
@Test
@@ -179,12 +181,51 @@ public void testMonitoringAppScopedresources() {
179181
}
180182
}
181183

182-
public void deployApp(String applicationName) {
184+
@Test
185+
public void deployAppWithTargets() {
186+
final String applicationName = "app" + generateRandomString();
187+
final String TRIGGER_MANAGE_TARGETS = "Manage Targets";
188+
final String enableMessage = "i18n.msg.enableOnTargetsSuccessful";
189+
final String disableMessage = "i18n.msg.disableOnTargetsSuccessful";
190+
final String tableSelectMutlipleId = "propertyForm:targetTable:_tableActionsTop:_selectMultipleButton:_selectMultipleButton_image";
191+
final String dropdownId = "propertyForm:targetTable:topActionsGroup1:dropdown1";
192+
193+
String instanceName = "in" + generateRandomString() ;
194+
clearTargets();
195+
StandaloneTest instance = new StandaloneTest();
196+
instance.createStandAloneInstance(instanceName);
197+
198+
deploy(applicationName);
199+
200+
goToApplicationTargetsTab(applicationName);
201+
clickAndWait("propertyForm:targetTable:topActionsGroup1:manageTargetButton", TRIGGER_MANAGE_TARGETS);
202+
pressButton("form:targetSection:targetSectionId:addRemoveProp:commonAddRemove:commonAddRemove_addAllButton");
203+
clickAndWait("form:propertyContentPage:topButtons:saveButton", TRIGGER_NEW_VALUES_SAVED);
204+
205+
pressButton(tableSelectMutlipleId);
206+
selectDropdownOption(dropdownId, "Enable");
207+
waitForPageLoad(enableMessage, TIMEOUT);
208+
pressButton(tableSelectMutlipleId);
209+
selectDropdownOption(dropdownId, "Disable");
210+
waitForPageLoad(disableMessage, TIMEOUT);
183211

212+
undeployApp(applicationName);
213+
clearTargets();
214+
}
215+
216+
private void clearTargets() {
184217
StandaloneTest standaloneTest = new StandaloneTest();
185218
ClusterTest clusterTest = new ClusterTest();
186219
standaloneTest.deleteAllStandaloneInstances();
187220
clusterTest.deleteAllClusters();
221+
}
222+
223+
public void deployApp(String applicationName) {
224+
clearTargets();
225+
deploy(applicationName);
226+
}
227+
228+
private void deploy(String applicationName) {
188229

189230
clickAndWait("treeForm:tree:applications:applications_link", TRIGGER_APPLICATIONS);
190231
int preCount = this.getTableRowCount(ELEMENT_DEPLOY_TABLE);
@@ -236,6 +277,13 @@ private void goToApplicationResourcesTab(String appName) {
236277
clickAndWait(ELEMENT_APPLICATION_RESOURCES_TAB, TRIGGER_RESOURCES_APPLICATION);
237278
}
238279

280+
private void goToApplicationTargetsTab(String appName) {
281+
clickAndWait(ELEMENT_APPLICATIONS, TRIGGER_APPLICATIONS);
282+
waitForPageLoad(appName, 60000);
283+
clickAndWait(getLinkIdByLinkText(ELEMENT_DEPLOY_TABLE, appName), TRIGGER_EDIT_APPLICATION);
284+
clickAndWait(ELEMENT_APPLICATION_TARGETS_TAB, TRIGGER_TARGETS_APPLICATION);
285+
}
286+
239287
public String getResName(String resName, String appScope) {
240288
if(appScope.equals("app")) {
241289
resName = "java:app/" + resName;

appserver/admingui/devtests/src/test/java/org/glassfish/admingui/devtests/BaseSeleniumTestClass.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -561,16 +561,25 @@ protected void handleLogin(String userName, String password, String triggerText)
561561
}
562562

563563
protected void waitForButtonEnabled(String buttonId) {
564-
// waitForCondition("document.getElementById('" + buttonId + "').disabled == false", BUTTON_TIMEOUT);
565564
waitForLoad(BUTTON_TIMEOUT, new ButtonDisabledStateCallBack(buttonId, false));
566565
}
567566

567+
protected void waitForButtonEnabledMessage(String buttonId) {
568+
String enabledMessage = "i18n.msg.enableResourceSuccessful";
569+
waitForLoad(BUTTON_TIMEOUT, new ButtonDisabledStateCallBack(buttonId, false));
570+
waitForPageLoad(enabledMessage, TIMEOUT);
571+
}
572+
568573
protected void waitForButtonDisabled(String buttonId) {
569-
String value = selenium.getEval(CURRENT_WINDOW + ".document.getElementById('" + buttonId + "').disabled");
570-
// waitForCondition("document.getElementById('" + buttonId + "').disabled == true", BUTTON_TIMEOUT);
571574
waitForLoad(BUTTON_TIMEOUT, new ButtonDisabledStateCallBack(buttonId, true));
572575
}
573576

577+
protected void waitForButtonDisabledMessage(String buttonId) {
578+
String disabledMessage = "i18n.msg.disableResourceSuccessful";
579+
waitForLoad(BUTTON_TIMEOUT, new ButtonDisabledStateCallBack(buttonId, true));
580+
waitForPageLoad(disabledMessage, TIMEOUT);
581+
}
582+
574583
protected void waitForCondition(String js, int timeOutInMillis) {
575584
selenium.waitForCondition(CURRENT_WINDOW + "." + js, Integer.toString(timeOutInMillis));
576585
}
@@ -876,11 +885,13 @@ protected void testEnableOrDisableTarget(String tableSelectMutlipleId,
876885
String statusId,
877886
String generalTriggerText,
878887
String targetTriggerText,
879-
String state) {
888+
String state,
889+
String enableResourceOnTargetsStatus) {
880890
pressButton(tableSelectMutlipleId);
881891
waitForButtonEnabled(enableButtonId);
882892
pressButton(enableButtonId);
883893
waitForButtonDisabled(enableButtonId);
894+
waitForPageLoad(enableResourceOnTargetsStatus, TIMEOUT);
884895

885896
clickAndWait(generalTabId, generalTriggerText);
886897
Assert.assertEquals(state, getText(statusId));
@@ -903,6 +914,8 @@ protected void testManageTargets(String resourcesLinkId,
903914
final String enableStatus = "Enabled on 2 of 2 Target(s)";
904915
final String disableStatus = "Enabled on 0 of 2 Target(s)";
905916
final String TRIGGER_MANAGE_TARGETS = "Manage Resource Targets";
917+
final String enableResourceOnTargetsStatus = "i18n.msg.enableResourceOnTargetsSuccessful";
918+
final String disableResourceOnTargetsStatus = "i18n.msg.disableResourceOnTargetsSuccessful";
906919
final String DEFAULT_SERVER = "server";
907920

908921
reset();
@@ -921,7 +934,8 @@ protected void testManageTargets(String resourcesLinkId,
921934
enableOrDisableTextFieldId,
922935
resEditTriggerText,
923936
TRIGGER_EDIT_RESOURCE_TARGETS,
924-
disableStatus);
937+
disableStatus,
938+
disableResourceOnTargetsStatus);
925939

926940
//Enable all targets
927941
testEnableOrDisableTarget("propertyForm:targetTable:_tableActionsTop:_selectMultipleButton:_selectMultipleButton_image",
@@ -931,7 +945,8 @@ protected void testManageTargets(String resourcesLinkId,
931945
enableOrDisableTextFieldId,
932946
resEditTriggerText,
933947
TRIGGER_EDIT_RESOURCE_TARGETS,
934-
enableStatus);
948+
enableStatus,
949+
enableResourceOnTargetsStatus);
935950

936951
//Test the manage targets : Remove the server from targets.
937952
clickAndWait("propertyForm:targetTable:topActionsGroup1:manageTargetButton", TRIGGER_MANAGE_TARGETS);

appserver/admingui/devtests/src/test/java/org/glassfish/admingui/devtests/ClusterTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,9 @@ public void testClusterResourcesPage() {
352352
waitForTableRowCount(tableID, jdbcCount);
353353

354354
selectTableRowByValue("propertyForm:resourcesTable", jndiName);
355-
waitForButtonEnabled("propertyForm:resourcesTable:topActionsGroup1:button1");
355+
waitForButtonEnabledMessage("propertyForm:resourcesTable:topActionsGroup1:button1");
356356
pressButton("propertyForm:resourcesTable:topActionsGroup1:button1");
357-
waitForButtonDisabled("propertyForm:resourcesTable:topActionsGroup1:button1");
357+
waitForButtonDisabledMessage("propertyForm:resourcesTable:topActionsGroup1:button1");
358358
jdbcTest.deleteJDBCResource(jndiName, target, MonitoringTest.TARGET_CLUSTER_TYPE);
359359
}
360360

appserver/admingui/devtests/src/test/java/org/glassfish/admingui/devtests/EnterpriseServerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ public void testServerResourcesPage() {
140140
waitForTableRowCount(tableID, jdbcCount);
141141

142142
selectTableRowByValue("propertyForm:resourcesTable", jndiName);
143-
waitForButtonEnabled("propertyForm:resourcesTable:topActionsGroup1:button1");
143+
waitForButtonEnabledMessage("propertyForm:resourcesTable:topActionsGroup1:button1");
144144
pressButton("propertyForm:resourcesTable:topActionsGroup1:button1");
145-
waitForButtonDisabled("propertyForm:resourcesTable:topActionsGroup1:button1");
145+
waitForButtonDisabledMessage("propertyForm:resourcesTable:topActionsGroup1:button1");
146146

147147
/*selenium.select("propertyForm:resourcesTable:topActionsGroup1:actions", "JDBC Resources");
148148
waitForPageLoad(JdbcTest.TRIGGER_NEW_JDBC_RESOURCE, true);

appserver/admingui/devtests/src/test/java/org/glassfish/admingui/devtests/StandaloneTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ public void testStandaloneInstanceResourcesPage() {
164164
waitForTableRowCount(tableID, jdbcCount);
165165

166166
selectTableRowByValue("propertyForm:resourcesTable", jndiName);
167-
waitForButtonEnabled("propertyForm:resourcesTable:topActionsGroup1:button1");
167+
waitForButtonEnabledMessage("propertyForm:resourcesTable:topActionsGroup1:button1");
168168
pressButton("propertyForm:resourcesTable:topActionsGroup1:button1");
169-
waitForButtonDisabled("propertyForm:resourcesTable:topActionsGroup1:button1");
169+
waitForButtonDisabledMessage("propertyForm:resourcesTable:topActionsGroup1:button1");
170170

171171
/*selectDropdownOption("propertyForm:resourcesTable:topActionsGroup1:actions", "JDBC Resources");
172172
waitForPageLoad(JdbcTest.TRIGGER_NEW_JDBC_RESOURCE, true);

0 commit comments

Comments
 (0)