Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 352898

Summary: Server created with a user defined name incorrectly uses the default name when runtime type or hostname is changed after
Product: [WebTools] WTP ServerTools Reporter: Steven Hung <sghung>
Component: wst.serverAssignee: Elson Yuen <eyuen7>
Status: RESOLVED FIXED QA Contact: Angel Vera <arvera>
Severity: normal    
Priority: P3 CC: eyuen7
Version: 3.2   
Target Milestone: 3.2.5   
Hardware: PC   
OS: Windows XP   
See Also: https://git.eclipse.org/r/109054
Whiteboard:
Attachments:
Description Flags
Patch v1.0
eyuen7: iplog+
Patch v1.2 none

Description Steven Hung CLA 2011-07-22 14:27:53 EDT
Build Identifier: 

A server created with a user defined name incorrectly uses the default name when runtime type or hostname is changed after.

Reproducible: Always

Steps to Reproduce:
1. Enter a server name (e.g. "ServerA")
2. Click on another sever type or change the hostname
3. Create the server, the server name will be the default generated server name instead of "ServerA"
Comment 1 Steven Hung CLA 2011-07-22 14:30:14 EDT
Created attachment 200219 [details]
Patch v1.0
Comment 2 Steven Hung CLA 2011-07-22 14:33:13 EDT
In both handleHostnameChange(IServerType) and handleTypeSelection(IServerType)

The Server working copy is set to the defualt value of the server in two places in those methods:
1. loadServerImpl(IServerType)
2. updateRuntimeCombo(IServerType), which eventually calls setRuntime(IRuntime)

updateRuntimeCombo is called after loadServerImpl, therefore only the server working modifications in updateRuntimeCombo would need to be modified. 

Within updateRuntimeCombo(IServerType) org.eclipse.wst.server.ui.internal.wizard.page.NewManualServerComposite.setRuntime(IRuntime), if serverNameModified, then the server name should be set to the value of the serverName's text field. 

serverName.getText() is used, without any trims or processing, because that is how the name is set in org.eclipse.wst.server.ui.internal.wizard.page.NewManualServerComposite.createControl().new ModifyListener() {...}.modifyText(ModifyEvent) within the NewManualServerComposite.

=============================================
Tests run before patch
=============================================
I will use server A to be one server type I had selected and server B to be another server type I had selected.

Expected:
1. Choose server A, then create server. The default generated name is used for the created server
2. Choose server A, change the server name to "ServerA". The created server says "ServerA"
3. Choose server A, then choose server B and create the server. The default generated name for server B is used
4. Choose server A, change the hostname to "localhost123". The default generated name for server A with the new hostname is used.

Failing cases:
1. Choose server A, change the name to "ServerA", then choose server B and create the server. The created server will use the default name for server B instead of "ServerA"
2. Choose server A, change the name to "ServerA", then change the hostname to "localhost123". The default generated name for "localhost123" is used instead of "ServerA"

=============================================
Tests run after patch
=============================================
I will use server A to be one server type I had selected and server B to be another server type I had selected.

1. Choose server A, then create server. The default generated name is used for the created server
2. Choose server A, change the server name to "ServerA". The created server says "ServerA"
3. Choose server A, then choose server B and create the server. The default generated name for server B is used
4. Choose server A, change the hostname to "localhost123". The default generated name for server A with the new hostname is used.
5. Choose server A, change the name to "ServerA", then choose server B and create the server. The created server will be named "ServerA"
6. Choose server A, change the name to "ServerA", then change the hostname to "localhost123". The created server will be named "ServerA"
7. Choose server A, change the name to "ServerA", then choose server B, then choose server A again. The created server will be named "ServerA"
8. Choose server A, change the name to "ServerA", then choose server B, then change the hostname to "localhost123". The created server will be named "ServerA"
Comment 3 Elson Yuen CLA 2011-07-22 16:39:28 EDT
The changes looks good and the test coverage is good as well. One minor comment on the code change is that there is no need to cast to ServerWorkingCopy since the method setName is exposed on IServerWorkingCopy.
Comment 4 Steven Hung CLA 2011-07-22 16:50:47 EDT
Created attachment 200223 [details]
Patch v1.2
Comment 5 Elson Yuen CLA 2011-07-22 17:12:55 EDT
The new patch looks good.
Comment 6 Elson Yuen CLA 2011-07-22 17:13:22 EDT
Changes released to 32M, 33M and HEAD
Comment 7 Eclipse Genie CLA 2017-10-11 16:36:48 EDT
New Gerrit change created: https://git.eclipse.org/r/109054