Author: adietish
Date: 2010-12-16 13:18:39 -0500 (Thu, 16 Dec 2010)
New Revision: 27558
Added:
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/fakes/DeltaCloudFake.java
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/DeltaCloudMockIntegrationTest.launch
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/core/DeltaCloudMockIntegrationTest.java
Log:
[JBIDE-7911] corrected: throws exceptions on error (internal server error, connection
error etc)
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-12-16 17:51:15
UTC (rev 27557)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-12-16 18:18:39
UTC (rev 27558)
@@ -1,3 +1,8 @@
+2010-12-16 André Dietisheim <adietish(a)redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (testCredentials):
+ [JBIDE-7911] corrected: throws exceptions on error (internal server error, connection
error etc)
+
2010-12-15 André Dietisheim <adietish(a)redhat.com>
* src/org/jboss/tools/deltacloud/core/DeltaCloud.java
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2010-12-16
17:51:15 UTC (rev 27557)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2010-12-16
18:18:39 UTC (rev 27558)
@@ -513,7 +513,18 @@
}
- public boolean testConnection() throws DeltaCloudException {
+ /**
+ * Tests the credentials defined in this DeltaCloud instance by connecting
+ * to the server defined by the url in this instance. Returns
+ * <code>true</code> if the credentials are valid,
<code>false</code>
+ * otherwise.
+ *
+ * @return <code>true</code>, if successful
+ * @throws DeltaCloudClientException
+ * if any other error occurs while trying to connect to the
+ * server
+ */
+ public boolean testCredentials() throws DeltaCloudClientException {
String instanceId = "nonexistingInstance"; //$NON-NLS-1$
try {
client.listInstances(instanceId);
@@ -522,8 +533,6 @@
return true;
} catch (DeltaCloudAuthException e) {
return false;
- } catch (DeltaCloudClientException e) {
- return false;
}
}
Modified:
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/DeltaCloudMockIntegrationTest.launch
===================================================================
---
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/DeltaCloudMockIntegrationTest.launch 2010-12-16
17:51:15 UTC (rev 27557)
+++
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/DeltaCloudMockIntegrationTest.launch 2010-12-16
18:18:39 UTC (rev 27558)
@@ -12,7 +12,7 @@
<booleanAttribute key="clearwslog" value="false"/>
<stringAttribute key="configLocation"
value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
<booleanAttribute key="default" value="false"/>
-<stringAttribute key="deselected_workspace_plugins"
value="org.eclipse.epp.usagedata.recording,org.eclipse.epp.usagedata.gathering,org.mozilla.xulrunner.cocoa.macosx,org.jboss.tools.common,org.jboss.tools.deltacloud.docs,org.mozilla.xulrunner.gtk.linux.x86_64,org.jboss.tools.usage,org.mozilla.xulrunner.win32.win32.x86,com.jboss.jbds.usage.branding,org.jboss.tools.usage.test,org.mozilla.xulrunner.gtk.linux.x86,org.eclipse.epp.usagedata.ui,org.mozilla.xulrunner.carbon.macosx,org.mozilla.xpcom,org.jboss.tools.tests,org.jboss.tools.deltacloud.ui,org.jruby.jruby"/>
+<stringAttribute key="deselected_workspace_plugins"
value="org.jboss.tools.gwt.ui,org.eclipse.epp.usagedata.recording,org.jboss.tools.deltacloud.integration,org.eclipse.epp.usagedata.gathering,org.jboss.tools.deltacloud.docs,org.jboss.tools.usage,org.jboss.tools.usage.test,com.jboss.jbds.usage.branding,org.jboss.tools.gwt.core,org.eclipse.epp.usagedata.ui,org.jboss.tools.deltacloud.ui,org.jboss.tools.tests"/>
<booleanAttribute key="includeOptional" value="true"/>
<stringAttribute key="location"
value="${workspace_loc}/../junit-workspace"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
@@ -29,7 +29,7 @@
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR"
value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME"
value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND"
value="org.eclipse.jdt.junit.loader.junit4"/>
-<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE"
value="org.jboss.tools.internal.deltacloud.core.observable.test.core.DeltaCloudMockIntegrationTest"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE"
value="org.jboss.tools.internal.deltacloud.test.core.DeltaCloudMockIntegrationTest"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS"
value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}
-consoleLog"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR"
value="org.jboss.tools.deltacloud.test"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER"
value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
@@ -37,8 +37,8 @@
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="org.eclipse.sdk.ide"/>
<booleanAttribute key="run_in_ui_thread" value="true"/>
-<stringAttribute key="selected_target_plugins"
value="org.eclipse.help@default:default,org.eclipse.core.commands@default:default,org.eclipse.core.runtime.compatibility.auth@default:default,org.eclipse.debug.core@default:default,org.eclipse.equinox.p2.metadata@default:default,org.eclipse.emf.common@default:default,org.eclipse.jface@default:default,org.eclipse.ui@default:default,org.eclipse.ltk.ui.refactoring@default:default,org.eclipse.swt.gtk.linux.x86_64@default:false,org.eclipse.ant.core@default:default,org.eclipse.equinox.p2.metadata.repository@default:default,org.eclipse.ui.workbench@default:default,org.eclipse.wst.xml.core@default:default,org.eclipse.emf.ecore.xmi@default:default,org.eclipse.text@default:default,org.eclipse.wst.validation@default:default,org.jboss.tools.xulrunner.initializer@default:false,org.eclipse.jdt.debug@default:default,org.eclipse.core.databinding.property@default:default,org.eclipse.equinox.security@default:default,org.eclipse.equinox.app@defau!
lt:default,org.eclipse.core.runtime@default:true,org.eclipse.core.expressions@default:default,org.eclipse.ui.workbench.texteditor@default:default,org.eclipse.wst.common.frameworks@default:default,org.eclipse.ecf.provider.filetransfer.ssl@default:false,org.eclipse.ui.forms@default:default,org.eclipse.core.jobs@default:default,org.eclipse.ui.navigator@default:default,org.eclipse.ecf.ssl@default:false,org.apache.xml.resolver@default:default,org.eclipse.equinox.p2.core@default:default,org.eclipse.ltk.core.refactoring@default:default,org.eclipse.osgi.util@default:default,org.eclipse.equinox.common@2:true,org.eclipse.jem.util@default:default,org.eclipse.ecf.identity@default:default,org.hamcrest.core@default:default,com.ibm.icu@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.p2.engine@default:default,org.eclipse.core.databinding@default:default,org.eclipse.swt@default:default,org.apache.xerces@default:default,org.eclipse.equinox.concurrent@defau!
lt:default,org.eclipse.core.filebuffers@default:default,org.ec!
lipse.em
f.ecore@default:default,org.eclipse.osgi.services@default:default,org.eclipse.ecf.provider.filetransfer@default:default,org.eclipse.ui.editors@default:default,org.apache.xml.serializer@default:default,org.eclipse.search@default:default,org.apache.commons.logging*1.0.4.v201005080501@default:default,org.eclipse.core.filesystem@default:default,org.eclipse.wst.sse.core@default:default,org.eclipse.wst.common.core@default:default,org.eclipse.wst.common.project.facet.core@default:default,org.eclipse.core.resources@default:default,org.eclipse.ecf@default:default,org.eclipse.jdt.compiler.apt@default:false,org.apache.commons.httpclient*3.1.0.v201005080502@default:default,org.eclipse.team.core@default:default,org.eclipse.jdt.core.manipulation@default:default,com.instantiations.designer.jdt.fragment@default:false,org.eclipse.core.net@default:default,org.eclipse.jface.text@default:default,org.eclipse.core.net.linux.x86_64@default:false,org.eclipse.wst.common.emf@default:default,org.eclip!
se.ui.views.properties.tabbed@default:default,javax.servlet@default:default,org.eclipse.compare@default:default,org.eclipse.core.databinding.observable@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.wst.common.uriresolver@default:default,org.eclipse.ecf.filetransfer@default:default,org.eclipse.ui.console@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.ui.views@default:default,org.eclipse.jface.databinding@default:default,org.eclipse.wst.common.environment@default:default,org.eclipse.debug.ui@default:default,org.eclipse.osgi@-1:true,org.eclipse.emf.ecore.change@default:default,org.eclipse.emf.edit@default:default,org.eclipse.ui.ide@default:default,org.eclipse.team.ui@default:default,org.eclipse.core.filesystem.linux.x86_64@default:false,org.eclipse.wst.common.emfworkbench.integration@default:default,org.eclipse.jdt.compiler.tool@default:false,org.apache.commons.codec*1.3.0.v20100518-1140@default:default,org.eclipse.core.runt!
ime.compatibility.registry@default:false,org.eclipse.equinox.p!
2.reposi
tory@default:default,javax.xml@default:default,org.eclipse.jdt.ui@default:default,org.eclipse.compare.core@default:default,org.junit*4.8.1.v4_8_1_v20100427-1100@default:default,org.eclipse.ui.navigator.resources@default:default,org.eclipse.core.variables@default:default,org.eclipse.jdt.launching@default:default,org.eclipse.jdt.core@default:default"/>
-<stringAttribute key="selected_workspace_plugins"
value="org.jboss.tools.deltacloud.test@default:default,org.jboss.tools.deltacloud.core@default:default"/>
+<stringAttribute key="selected_target_plugins"
value="org.eclipse.swt.gtk.linux.x86_64@default:false,org.eclipse.ant.core@default:default,org.eclipse.core.filesystem@default:default,org.eclipse.core.runtime.compatibility.auth@default:default,org.eclipse.compare@default:default,org.eclipse.core.commands@default:default,org.eclipse.wst.common.environment@default:default,org.eclipse.ui.editors@default:default,org.eclipse.jem.util@default:default,org.eclipse.ui.console@default:default,org.apache.commons.codec*1.3.0.v20100518-1140@default:default,org.eclipse.wst.common.project.facet.core@default:default,org.eclipse.debug.ui@default:default,org.eclipse.equinox.security@default:default,org.eclipse.ui.ide@default:default,org.eclipse.ui.workbench@default:default,org.eclipse.core.variables@default:default,org.eclipse.equinox.concurrent@default:default,org.apache.xml.serializer@default:default,org.eclipse.core.databinding.property@default:default,org.eclipse.jdt.debug@default:default,!
org.eclipse.wst.common.uriresolver@default:default,org.eclipse.core.filebuffers@default:default,org.eclipse.wst.sse.core@default:default,org.eclipse.jdt.core.manipulation@default:default,org.eclipse.core.jobs@default:default,org.eclipse.wst.validation@default:default,org.eclipse.team.core@default:default,org.eclipse.wst.common.frameworks@default:default,org.eclipse.ecf@default:default,org.eclipse.core.resources@default:default,org.eclipse.ui.navigator@default:default,org.eclipse.jdt.compiler.apt@default:false,org.eclipse.jdt.ui@default:default,org.eclipse.equinox.common@default:default,org.eclipse.core.net@default:default,org.apache.xerces@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.search@default:default,javax.servlet@default:default,org.eclipse.osgi.util@default:default,org.eclipse.ecf.provider.filetransfer.ssl@default:false,org.eclipse.debug.core@default:default,org.eclipse.core.databinding@default:default,org.eclipse.osgi,org.eclipse.core.fi!
lesystem.linux.x86_64@default:false,org.eclipse.ui.navigator.r!
esources
@default:default,org.eclipse.equinox.p2.repository@default:default,org.eclipse.equinox.p2.core@default:default,org.apache.commons.httpclient*3.1.0.v201005080502@default:default,org.eclipse.ui.views@default:default,org.eclipse.wst.common.core@default:default,org.eclipse.ui.views.properties.tabbed@default:default,org.eclipse.equinox.p2.metadata@default:default,org.eclipse.jdt.compiler.tool@default:false,org.junit*4.8.1.v4_8_1_v20100427-1100@default:default,org.eclipse.jdt.core@default:default,org.eclipse.osgi.services@default:default,org.eclipse.wst.xml.core@default:default,org.eclipse.core.databinding.observable@default:default,org.jboss.tools.xulrunner.initializer@default:false,org.eclipse.jface@default:default,org.eclipse.emf.edit@default:default,org.eclipse.wst.common.emf@default:default,org.eclipse.ltk.ui.refactoring@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.core.runtime@default:true,org.eclipse.emf.ecore.change@default:default,javax.xml@!
default:default,org.eclipse.ui@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.ecf.identity@default:default,org.eclipse.swt@default:default,org.eclipse.help@default:default,org.eclipse.equinox.p2.metadata.repository@default:default,org.eclipse.jdt.launching@default:default,org.apache.commons.logging*1.0.4.v201005080501@default:default,org.apache.xml.resolver@default:default,org.eclipse.emf.ecore.xmi@default:default,com.ibm.icu@default:default,org.eclipse.equinox.app@default:default,org.eclipse.jface.text@default:default,org.eclipse.team.ui@default:default,org.eclipse.equinox.p2.engine@default:default,org.eclipse.ecf.provider.filetransfer@default:default,org.eclipse.ltk.core.refactoring@default:default,org.hamcrest.core@default:default,org.eclipse.ecf.filetransfer@default:default,org.eclipse.ui.forms@default:default,org.eclipse.wst.common.emfworkbench.integration@default:default,org.eclipse.ecf.ssl@default:false,com.instantiations.designer.jdt.fragme!
nt@default:false,org.eclipse.core.net.linux.x86_64@default:fal!
se,org.e
clipse.compare.core@default:default,org.eclipse.core.runtime.compatibility.registry@default:false,org.eclipse.text@default:default,org.eclipse.core.expressions@default:default,org.eclipse.emf.common@default:default,org.eclipse.emf.ecore@default:default,org.eclipse.jface.databinding@default:default,org.eclipse.ui.workbench.texteditor@default:default"/>
+<stringAttribute key="selected_workspace_plugins"
value="org.jboss.tools.deltacloud.test@default:default,org.jboss.tools.common@default:default,org.jboss.tools.deltacloud.core@default:default"/>
<booleanAttribute key="show_selected_only" value="false"/>
<booleanAttribute key="tracing" value="false"/>
<booleanAttribute key="useCustomFeatures" value="false"/>
Modified:
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/core/DeltaCloudMockIntegrationTest.java
===================================================================
---
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/core/DeltaCloudMockIntegrationTest.java 2010-12-16
17:51:15 UTC (rev 27557)
+++
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/core/DeltaCloudMockIntegrationTest.java 2010-12-16
18:18:39 UTC (rev 27558)
@@ -19,6 +19,7 @@
import org.jboss.tools.deltacloud.core.DeltaCloudException;
import org.jboss.tools.deltacloud.core.client.DeltaCloudClientException;
import org.jboss.tools.internal.deltacloud.test.context.MockIntegrationTestContext;
+import org.jboss.tools.internal.deltacloud.test.fakes.DeltaCloudFake;
import org.jboss.tools.internal.deltacloud.test.fakes.ServerFake;
import org.junit.After;
import org.junit.Before;
@@ -29,7 +30,7 @@
*
* @author Andre Dietisheim
*
- * @see DeltaCloud#testConnection()
+ * @see DeltaCloud#testCredentials()
*
*/
public class DeltaCloudMockIntegrationTest {
@@ -48,15 +49,15 @@
}
@Test
- public void testConnectionReportsFalseOnAuthFailure() throws MalformedURLException,
DeltaCloudClientException, DeltaCloudException {
+ public void testConnectionReportsFalseOnAuthFailure() throws MalformedURLException,
DeltaCloudClientException,
+ DeltaCloudException {
ServerFake serverFake = setupServerFake("HTTP/1.1 403 Forbidden\n\n\n");
try {
- DeltaCloud deltaCloud = new DeltaCloud(
- "aName",
- "http://localhost:" + ServerFake.DEFAULT_PORT,
- "badUser",
+ DeltaCloud deltaCloud = new DeltaCloudFake(
+ "http://localhost:" + ServerFake.DEFAULT_PORT,
+ "badUser",
"badPassword");
- assertFalse(deltaCloud.testConnection());
+ assertFalse(deltaCloud.testCredentials());
} finally {
serverFake.stop();
}
@@ -66,9 +67,9 @@
public void testConnectionThrowsOnGeneralFailure() throws MalformedURLException,
DeltaCloudClientException, DeltaCloudException {
ServerFake serverFake = setupServerFake("HTTP/1.1 501 Some Error\ndummy dummy
dummy\n\n");
try {
- DeltaCloud deltaCloud = new DeltaCloud("aName",
"http://localhost:" + ServerFake.DEFAULT_PORT, "badUser",
- "badPassword");
- deltaCloud.testConnection();
+ DeltaCloud deltaCloud =
+ new DeltaCloudFake("http://localhost:" + ServerFake.DEFAULT_PORT,
"badUser", "badPassword");
+ deltaCloud.testCredentials();
} finally {
serverFake.stop();
}
Added:
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/fakes/DeltaCloudFake.java
===================================================================
---
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/fakes/DeltaCloudFake.java
(rev 0)
+++
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/fakes/DeltaCloudFake.java 2010-12-16
18:18:39 UTC (rev 27558)
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.internal.deltacloud.test.fakes;
+
+import org.jboss.tools.deltacloud.core.DeltaCloud;
+import org.jboss.tools.deltacloud.core.DeltaCloudException;
+import org.jboss.tools.deltacloud.core.SecurePasswordStore;
+
+/**
+ * @author André Dietisheim
+ */
+public class DeltaCloudFake extends DeltaCloud {
+
+ public DeltaCloudFake() throws DeltaCloudException {
+ this("http://dummy.org", "aUser", "aPassword");
+ }
+
+ public DeltaCloudFake(String url, String username, String password) throws
DeltaCloudException {
+ super("fake", url, username, password);
+ }
+
+ @Override
+ protected SecurePasswordStore createSecurePasswordStore(String name, String username,
String password) {
+ return new SecurePasswordStoreFake("dummyPassword");
+ }
+
+ private static class SecurePasswordStoreFake extends SecurePasswordStore {
+
+ private String password;
+
+ public SecurePasswordStoreFake(String password) {
+ super(null, password);
+ this.password = password;
+ }
+
+ @Override
+ public String getPassword() throws DeltaCloudException {
+ return password;
+ }
+
+ @Override
+ public void setPassword(String password) throws DeltaCloudException {
+ this.password = password;
+ }
+
+ @Override
+ public void update(IStorageKey key, String password) throws DeltaCloudException {
+ setPassword(password);
+ }
+
+ @Override
+ public void remove() throws DeltaCloudException {
+ }
+ }
+}
\ No newline at end of file
Property changes on:
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/fakes/DeltaCloudFake.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain