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
JBIDE-22601 - fix regression causing error starting rse.mgmt profile … #429
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
...src/org/jboss/tools/as/test/core/subsystems/DeploymentOptionsSubsystemResolutionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2016 Red Hat, Inc. | ||
* Distributed under license by Red Hat, Inc. All rights reserved. | ||
* This program is made available under the terms of the | ||
* Eclipse Public License v1.0 which accompanies this distribution, | ||
* and is available at http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
******************************************************************************/ | ||
package org.jboss.tools.as.test.core.subsystems; | ||
|
||
import java.util.Collection; | ||
|
||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.core.runtime.NullProgressMonitor; | ||
import org.eclipse.wst.server.core.IServer; | ||
import org.eclipse.wst.server.core.IServerWorkingCopy; | ||
import org.jboss.ide.eclipse.as.core.util.JBossServerBehaviorUtils; | ||
import org.jboss.ide.eclipse.as.wtp.core.server.behavior.IControllableServerBehavior; | ||
import org.jboss.ide.eclipse.as.wtp.core.server.behavior.IPublishController; | ||
import org.jboss.ide.eclipse.as.wtp.core.server.behavior.ISubsystemController; | ||
import org.jboss.ide.eclipse.as.wtp.core.server.behavior.ServerProfileModel; | ||
import org.jboss.tools.as.core.server.controllable.systems.IDeploymentOptionsController; | ||
import org.jboss.tools.as.test.core.internal.utils.MatrixUtils; | ||
import org.jboss.tools.as.test.core.internal.utils.ServerCreationTestUtils; | ||
import org.jboss.tools.as.test.core.internal.utils.ServerParameterUtils; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
import org.junit.runners.Parameterized.Parameters; | ||
|
||
import junit.framework.TestCase; | ||
|
||
@RunWith(value = Parameterized.class) | ||
public class DeploymentOptionsSubsystemResolutionTest extends TestCase { | ||
private String serverType; | ||
private String mode; | ||
private IServer server; | ||
@Parameters | ||
public static Collection<Object[]> data() { | ||
String[] servers = ServerParameterUtils.getJBossServerTypeParameters(); | ||
String[] modes = new String[]{"local", "rse", "local.mgmt", "rse.mgmt", null}; | ||
return MatrixUtils.toMatrix(new Object[][]{servers, modes}); | ||
} | ||
|
||
public DeploymentOptionsSubsystemResolutionTest(String serverType, String mode) { | ||
this.serverType = serverType; | ||
this.mode = mode; | ||
} | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
server = ServerCreationTestUtils.createMockServerWithRuntime(serverType, getClass().getName() + serverType); | ||
IServerWorkingCopy wc = server.createWorkingCopy(); | ||
ServerProfileModel.setProfile(wc, mode); | ||
server = wc.save(false, new NullProgressMonitor()); | ||
} | ||
|
||
@After | ||
public void tearDown() throws Exception { | ||
ServerCreationTestUtils.deleteAllServersAndRuntimes(); | ||
} | ||
|
||
|
||
@Test | ||
public void testResolution() throws Exception { | ||
IControllableServerBehavior beh = JBossServerBehaviorUtils.getControllableBehavior(server); | ||
assertNotNull(beh); | ||
try { | ||
ISubsystemController controller = beh.getController(IDeploymentOptionsController.SYSTEM_ID); | ||
if( mode != null ) { | ||
assertFalse(mode.contains(".mgmt")); | ||
} | ||
assertNotNull(controller); | ||
} catch(CoreException ce) { | ||
// management should fail to find this | ||
assertTrue(mode.contains(".mgmt")); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
...test.core/src/org/jboss/tools/as/test/core/utiltests/ServerHomeValidationUtilityTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2016 Red Hat, Inc. | ||
* Distributed under license by Red Hat, Inc. All rights reserved. | ||
* This program is made available under the terms of the | ||
* Eclipse Public License v1.0 which accompanies this distribution, | ||
* and is available at http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
******************************************************************************/ | ||
package org.jboss.tools.as.test.core.utiltests; | ||
|
||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
import static org.mockito.Matchers.*; | ||
|
||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.core.runtime.IPath; | ||
import org.eclipse.core.runtime.IProgressMonitor; | ||
import org.eclipse.core.runtime.IStatus; | ||
import org.eclipse.core.runtime.NullProgressMonitor; | ||
import org.eclipse.core.runtime.Status; | ||
import org.eclipse.wst.server.core.IServer; | ||
import org.eclipse.wst.server.core.model.ServerBehaviourDelegate; | ||
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin; | ||
import org.jboss.ide.eclipse.as.core.util.RemotePath; | ||
import org.jboss.ide.eclipse.as.core.util.ServerHomeValidationUtility; | ||
import org.jboss.ide.eclipse.as.wtp.core.server.behavior.ControllableServerBehavior; | ||
import org.jboss.ide.eclipse.as.wtp.core.server.behavior.IFilesystemController; | ||
import org.jboss.ide.eclipse.as.wtp.core.server.behavior.IServerDetailsController; | ||
import org.jboss.tools.as.core.server.controllable.systems.IDeploymentOptionsController; | ||
import org.junit.Test; | ||
import org.mockito.ArgumentCaptor; | ||
|
||
import junit.framework.TestCase; | ||
|
||
/** | ||
* This test just makes sure the server hoem validation | ||
* will only request filesystem and serverdetails subsystems, | ||
* and will not request deploymentoptions as some profiles don't have it. | ||
* | ||
*/ | ||
public class ServerHomeValidationUtilityTest extends TestCase { | ||
|
||
|
||
@Test | ||
public void testMockServerHomeValidator() throws CoreException { | ||
IStatus ret = internalValidation("/home/user/test", "/", true); | ||
assertTrue(ret.isOK()); | ||
} | ||
|
||
@Test | ||
public void testMockServerNullHome() throws CoreException { | ||
IStatus ret = internalValidation(null, "/", true); | ||
assertTrue(ret.getSeverity() == IStatus.ERROR); | ||
} | ||
|
||
@Test | ||
public void testMockServerNullSep() throws CoreException { | ||
IStatus ret = internalValidation("/home/user/test", null, true); | ||
assertTrue(ret.getSeverity() == IStatus.ERROR); | ||
} | ||
|
||
@Test | ||
public void testMockServerDNE() throws CoreException { | ||
IStatus ret = internalValidation("/home/user/test", "/", false); | ||
assertTrue(ret.getSeverity() == IStatus.ERROR); | ||
} | ||
|
||
@Test | ||
public void testMockServerDeploymentOptions() throws CoreException { | ||
try { | ||
IStatus ret = internalValidation("/home/user/test", "/", true, true); | ||
fail(); // should not reach | ||
} catch(CoreException ce) { | ||
// ignore | ||
} | ||
} | ||
|
||
private IStatus internalValidation(String home, String sep, boolean exists) throws CoreException { | ||
return internalValidation(home, sep, exists, false); | ||
} | ||
|
||
private IStatus internalValidation(String home, String sep, boolean exists, boolean loadDeploymentOptions) throws CoreException { | ||
|
||
IServer s = mock(IServer.class); | ||
ControllableServerBehavior delegate = mock(ControllableServerBehavior.class); | ||
when(s.loadAdapter(ServerBehaviourDelegate.class, null)).thenReturn(delegate); | ||
when(s.getAdapter(ServerBehaviourDelegate.class)).thenReturn(delegate); | ||
|
||
IFilesystemController fs = mock(IFilesystemController.class); | ||
IServerDetailsController details = mock(IServerDetailsController.class); | ||
|
||
when(delegate.getController(IFilesystemController.SYSTEM_ID)).thenReturn(fs); | ||
when(delegate.getController(IServerDetailsController.SYSTEM_ID)).thenReturn(details); | ||
when(delegate.getController(IDeploymentOptionsController.SYSTEM_ID)).thenThrow( | ||
new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, "Fail test"))); | ||
|
||
|
||
when(details.getProperty(IServerDetailsController.PROP_SERVER_HOME)).thenReturn(home); | ||
when(details.getProperty(IServerDetailsController.SEPARATOR_CHAR)).thenReturn(sep); | ||
|
||
|
||
IPath remoteHome = null; | ||
if( sep != null && home != null ) | ||
remoteHome = new RemotePath(home, sep); | ||
|
||
when(fs.exists(any(RemotePath.class), | ||
any(IProgressMonitor.class))).thenReturn(exists); | ||
|
||
if( loadDeploymentOptions ) { | ||
delegate.getController(IDeploymentOptionsController.SYSTEM_ID); | ||
} | ||
|
||
|
||
IStatus ret = new ServerHomeValidationUtility().validateServerHome(s, false); | ||
return ret; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are breaking API of a public class/method here. Do we really have to do it? Why not deprecate the old method and add a new one. You can ignore options here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the class is only a month old and nobody else uses it yet. In fact the introduction of this class is what broke the code in the first place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. thanks