From 95c35487f09eb5f4801cae3749bd087111fab4b8 Mon Sep 17 00:00:00 2001 From: Aled Sage Date: Thu, 5 Jul 2012 16:00:29 +0100 Subject: [PATCH 1/2] Issue 1004: changes default SocketOpen impl Sets it to InetSocketAddressConnect, instead of SocketOpenUnsupported. Removes overriding the impl from Jsch and Sshj's client modules. --- core/src/main/java/org/jclouds/predicates/SocketOpen.java | 2 +- .../java/org/jclouds/ssh/jsch/config/JschSshClientModule.java | 3 --- .../main/java/org/jclouds/sshj/config/SshjSshClientModule.java | 3 --- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/core/src/main/java/org/jclouds/predicates/SocketOpen.java b/core/src/main/java/org/jclouds/predicates/SocketOpen.java index b3b380fdb4..3c6a30e21a 100644 --- a/core/src/main/java/org/jclouds/predicates/SocketOpen.java +++ b/core/src/main/java/org/jclouds/predicates/SocketOpen.java @@ -28,7 +28,7 @@ import com.google.inject.ImplementedBy; * * @author Adrian Cole */ -@ImplementedBy(SocketOpenUnsupported.class) +@ImplementedBy(InetSocketAddressConnect.class) public interface SocketOpen extends Predicate { } diff --git a/drivers/jsch/src/main/java/org/jclouds/ssh/jsch/config/JschSshClientModule.java b/drivers/jsch/src/main/java/org/jclouds/ssh/jsch/config/JschSshClientModule.java index a8f4cd7a9f..7c1650f924 100644 --- a/drivers/jsch/src/main/java/org/jclouds/ssh/jsch/config/JschSshClientModule.java +++ b/drivers/jsch/src/main/java/org/jclouds/ssh/jsch/config/JschSshClientModule.java @@ -24,8 +24,6 @@ import org.jclouds.Constants; import org.jclouds.domain.Credentials; import org.jclouds.domain.LoginCredentials; import org.jclouds.http.handlers.BackoffLimitedRetryHandler; -import org.jclouds.predicates.InetSocketAddressConnect; -import org.jclouds.predicates.SocketOpen; import org.jclouds.ssh.ConfiguresSshClient; import org.jclouds.ssh.SshClient; import org.jclouds.ssh.jsch.JschSshClient; @@ -45,7 +43,6 @@ public class JschSshClientModule extends AbstractModule { protected void configure() { bind(SshClient.Factory.class).to(Factory.class).in(Scopes.SINGLETON); - bind(SocketOpen.class).to(InetSocketAddressConnect.class).in(Scopes.SINGLETON); } private static class Factory implements SshClient.Factory { diff --git a/drivers/sshj/src/main/java/org/jclouds/sshj/config/SshjSshClientModule.java b/drivers/sshj/src/main/java/org/jclouds/sshj/config/SshjSshClientModule.java index b49b6b43a5..4083ec754a 100644 --- a/drivers/sshj/src/main/java/org/jclouds/sshj/config/SshjSshClientModule.java +++ b/drivers/sshj/src/main/java/org/jclouds/sshj/config/SshjSshClientModule.java @@ -24,8 +24,6 @@ import org.jclouds.Constants; import org.jclouds.domain.Credentials; import org.jclouds.domain.LoginCredentials; import org.jclouds.http.handlers.BackoffLimitedRetryHandler; -import org.jclouds.predicates.InetSocketAddressConnect; -import org.jclouds.predicates.SocketOpen; import org.jclouds.ssh.ConfiguresSshClient; import org.jclouds.ssh.SshClient; import org.jclouds.sshj.SshjSshClient; @@ -45,7 +43,6 @@ public class SshjSshClientModule extends AbstractModule { protected void configure() { bind(SshClient.Factory.class).to(Factory.class).in(Scopes.SINGLETON); - bind(SocketOpen.class).to(InetSocketAddressConnect.class).in(Scopes.SINGLETON); } private static class Factory implements SshClient.Factory { From 9e0f22207c39e09d90afea02331407e64b15b62c Mon Sep 17 00:00:00 2001 From: Aled Sage Date: Fri, 6 Jul 2012 10:30:32 +0100 Subject: [PATCH 2/2] Issue 1004: GAE uses SocketOpenUnsupported --- .../GoogleAppEngineConfigurationModule.java | 4 +++ .../org/jclouds/gae/GaeSocketOpenTest.java | 28 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 drivers/gae/src/test/java/org/jclouds/gae/GaeSocketOpenTest.java diff --git a/drivers/gae/src/main/java/org/jclouds/gae/config/GoogleAppEngineConfigurationModule.java b/drivers/gae/src/main/java/org/jclouds/gae/config/GoogleAppEngineConfigurationModule.java index 9374a87e2e..1f531de7d1 100644 --- a/drivers/gae/src/main/java/org/jclouds/gae/config/GoogleAppEngineConfigurationModule.java +++ b/drivers/gae/src/main/java/org/jclouds/gae/config/GoogleAppEngineConfigurationModule.java @@ -27,6 +27,8 @@ import org.jclouds.http.HttpCommandExecutorService; import org.jclouds.http.TransformingHttpCommandExecutorService; import org.jclouds.http.TransformingHttpCommandExecutorServiceImpl; import org.jclouds.http.config.ConfiguresHttpCommandExecutorService; +import org.jclouds.predicates.SocketOpen; +import org.jclouds.predicates.SocketOpenUnsupported; import com.google.appengine.api.urlfetch.URLFetchService; import com.google.appengine.api.urlfetch.URLFetchServiceFactory; @@ -35,6 +37,7 @@ import com.google.common.util.concurrent.ListeningExecutorService; import com.google.inject.AbstractModule; import com.google.inject.Module; import com.google.inject.Provides; +import com.google.inject.Scopes; /** * Configures {@link GaeHttpCommandExecutorService}. @@ -75,6 +78,7 @@ public class GoogleAppEngineConfigurationModule extends AbstractModule { protected void configure() { install(executorServiceModule); bind(TransformingHttpCommandExecutorService.class).to(TransformingHttpCommandExecutorServiceImpl.class); + bind(SocketOpen.class).to(SocketOpenUnsupported.class).in(Scopes.SINGLETON); bindHttpCommandExecutorService(); } diff --git a/drivers/gae/src/test/java/org/jclouds/gae/GaeSocketOpenTest.java b/drivers/gae/src/test/java/org/jclouds/gae/GaeSocketOpenTest.java new file mode 100644 index 0000000000..64ff091161 --- /dev/null +++ b/drivers/gae/src/test/java/org/jclouds/gae/GaeSocketOpenTest.java @@ -0,0 +1,28 @@ +package org.jclouds.gae; + +import org.jclouds.Context; +import org.jclouds.ContextBuilder; +import org.jclouds.gae.config.GoogleAppEngineConfigurationModule; +import org.jclouds.http.IntegrationTestAsyncClient; +import org.jclouds.http.IntegrationTestClient; +import org.jclouds.predicates.SocketOpen; +import org.jclouds.providers.AnonymousProviderMetadata; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableSet; +import com.google.common.net.HostAndPort; + +public class GaeSocketOpenTest { + + @Test(expectedExceptions=UnsupportedOperationException.class) + public void testSocketOpenThrowsUnsupported() { + Context context = ContextBuilder.newBuilder( + AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(IntegrationTestClient.class, IntegrationTestAsyncClient.class, + "dummyurl")) + .modules(ImmutableSet.of(new GoogleAppEngineConfigurationModule())) + .build(); + + SocketOpen socketOpen = context.getUtils().getInjector().getInstance(SocketOpen.class); + socketOpen.apply(HostAndPort.fromParts("localhost", 22)); + } +}