From 7cb2f6ebc7a6f76a1cdf6dc1dcd2ca2264c0787c Mon Sep 17 00:00:00 2001 From: "adrian.f.cole" Date: Fri, 25 Sep 2009 17:25:31 +0000 Subject: [PATCH] Issue 100: authentication now works git-svn-id: http://jclouds.googlecode.com/svn/trunk@1927 3d8758e0-26b5-11de-8745-db77d3ebf521 --- nirvanix/pom.xml | 68 ++++++++++++++++ nirvanix/sdn/core/pom.xml | 48 +++++++++++ .../jclouds/nirvanix/sdn/Authentication.java | 44 ++++++++++ .../java/org/jclouds/nirvanix/sdn/SDN.java | 44 ++++++++++ .../nirvanix/sdn/SDNAuthentication.java | 58 ++++++++++++++ .../nirvanix/sdn/SDNContextBuilder.java | 59 ++++++++++++++ .../config/RestSDNAuthenticationModule.java | 80 +++++++++++++++++++ .../ParseSessionTokenFromJsonResponse.java | 42 ++++++++++ .../nirvanix/sdn/reference/SDNConstants.java | 36 +++++++++ .../sdn/reference/SDNQueryParams.java | 15 ++++ .../sdn/SDNAuthenticationLiveTest.java | 65 +++++++++++++++ ...ParseSessionTokenFromJsonResponseTest.java | 36 +++++++++ .../sdn/core/src/test/resources/log4j.xml | 79 ++++++++++++++++++ .../sdn/core/src/test/resources/login.json | 1 + nirvanix/sdn/pom.xml | 61 ++++++++++++++ pom.xml | 1 + project/pom.xml | 4 + 17 files changed, 741 insertions(+) create mode 100644 nirvanix/pom.xml create mode 100644 nirvanix/sdn/core/pom.xml create mode 100644 nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/Authentication.java create mode 100644 nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/SDN.java create mode 100755 nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/SDNAuthentication.java create mode 100755 nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/SDNContextBuilder.java create mode 100755 nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/config/RestSDNAuthenticationModule.java create mode 100644 nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/functions/ParseSessionTokenFromJsonResponse.java create mode 100644 nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/reference/SDNConstants.java create mode 100644 nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/reference/SDNQueryParams.java create mode 100644 nirvanix/sdn/core/src/test/java/org/jclouds/nirvanix/sdn/SDNAuthenticationLiveTest.java create mode 100644 nirvanix/sdn/core/src/test/java/org/jclouds/nirvanix/sdn/functions/ParseSessionTokenFromJsonResponseTest.java create mode 100755 nirvanix/sdn/core/src/test/resources/log4j.xml create mode 100644 nirvanix/sdn/core/src/test/resources/login.json create mode 100644 nirvanix/sdn/pom.xml diff --git a/nirvanix/pom.xml b/nirvanix/pom.xml new file mode 100644 index 0000000000..806df4a710 --- /dev/null +++ b/nirvanix/pom.xml @@ -0,0 +1,68 @@ + + + + + jclouds-project + org.jclouds + 1.0-SNAPSHOT + ../project/pom.xml + + 4.0.0 + jclouds-nirvanix-project + pom + jclouds nirvanix project + + sdn + + + + ${project.groupId} + jclouds-core + ${project.version} + + + ${project.groupId} + jclouds-core + ${project.version} + test-jar + test + + + log4j + log4j + 1.2.14 + test + + + ${project.groupId} + jclouds-log4j + ${project.version} + test + + + diff --git a/nirvanix/sdn/core/pom.xml b/nirvanix/sdn/core/pom.xml new file mode 100644 index 0000000000..551c6fbc99 --- /dev/null +++ b/nirvanix/sdn/core/pom.xml @@ -0,0 +1,48 @@ + + + + + org.jclouds + jclouds-sdn-project + 1.0-SNAPSHOT + ../pom.xml + + 4.0.0 + org.jclouds + jclouds-sdn + jclouds nirvanix storage delivery network core + jar + jclouds Core components to access nirvanix sdn + + + scm:svn:http://jclouds.googlecode.com/svn/trunk/mezo/sdn/core + scm:svn:https://jclouds.googlecode.com/svn/trunk/mezo/sdn/core + http://jclouds.googlecode.com/svn/trunk/mezo/sdn/core + + + diff --git a/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/Authentication.java b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/Authentication.java new file mode 100644 index 0000000000..36511915ed --- /dev/null +++ b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/Authentication.java @@ -0,0 +1,44 @@ +/** + * + * Copyright (C) 2009 Global Cloud Specialists, Inc. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.nirvanix.sdn; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +/** + * Related to a SDN resource. + * + * @author Adrian Cole + * + */ +@Retention(value = RetentionPolicy.RUNTIME) +@Target(value = { ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) +@Qualifier +public @interface Authentication { + +} \ No newline at end of file diff --git a/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/SDN.java b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/SDN.java new file mode 100644 index 0000000000..2a99a4222f --- /dev/null +++ b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/SDN.java @@ -0,0 +1,44 @@ +/** + * + * Copyright (C) 2009 Global Cloud Specialists, Inc. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.nirvanix.sdn; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +/** + * Related to a SDN resource. + * + * @author Adrian Cole + * + */ +@Retention(value = RetentionPolicy.RUNTIME) +@Target(value = { ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) +@Qualifier +public @interface SDN { + +} \ No newline at end of file diff --git a/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/SDNAuthentication.java b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/SDNAuthentication.java new file mode 100755 index 0000000000..d00c264fda --- /dev/null +++ b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/SDNAuthentication.java @@ -0,0 +1,58 @@ +/** + * + * Copyright (C) 2009 Global Cloud Specialists, Inc. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.nirvanix.sdn; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +import org.jclouds.nirvanix.sdn.functions.ParseSessionTokenFromJsonResponse; +import org.jclouds.nirvanix.sdn.reference.SDNQueryParams; +import org.jclouds.rest.Endpoint; +import org.jclouds.rest.QueryParams; +import org.jclouds.rest.ResponseParser; + +/** + * Provides access to Nirvanix SDN resources via their REST API. + *

+ * + * @see + * @author Adrian Cole + */ +@Endpoint(SDN.class) +@QueryParams(keys = SDNQueryParams.OUTPUT, values = "json") +public interface SDNAuthentication { + + public interface AuthenticationResponse { + @Authentication + String getSessionToken(); + } + + @GET + @ResponseParser(ParseSessionTokenFromJsonResponse.class) + @Path("/Authentication/Login.ashx") + String authenticate(@QueryParam(SDNQueryParams.APPKEY) String appKey, + @QueryParam(SDNQueryParams.USERNAME) String user, + @QueryParam(SDNQueryParams.PASSWORD) String password); +} diff --git a/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/SDNContextBuilder.java b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/SDNContextBuilder.java new file mode 100755 index 0000000000..2e9b2582cd --- /dev/null +++ b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/SDNContextBuilder.java @@ -0,0 +1,59 @@ +/** + * + * Copyright (C) 2009 Global Cloud Specialists, Inc. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.nirvanix.sdn; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.List; +import java.util.Properties; + +import org.jclouds.cloud.CloudContext; +import org.jclouds.cloud.CloudContextBuilder; +import org.jclouds.nirvanix.sdn.config.RestSDNAuthenticationModule; +import org.jclouds.nirvanix.sdn.reference.SDNConstants; + +import com.google.inject.Module; + +/** + * + * @author Adrian Cole + */ +public abstract class SDNContextBuilder> extends CloudContextBuilder { + + public SDNContextBuilder(Properties props) { + super(props); + properties.setProperty(SDNConstants.PROPERTY_SDN_ENDPOINT, "http://services.nirvanix.com/ws"); + } + + public void authenticate(String id, String secret) { + checkNotNull(properties.getProperty(SDNConstants.PROPERTY_SDN_APPKEY)); + properties.setProperty(SDNConstants.PROPERTY_SDN_USERNAME, checkNotNull(id, "user")); + properties.setProperty(SDNConstants.PROPERTY_SDN_PASSWORD, checkNotNull(secret, "key")); + } + + protected void addApiModule(List modules) { + modules.add(new RestSDNAuthenticationModule()); + } + +} diff --git a/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/config/RestSDNAuthenticationModule.java b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/config/RestSDNAuthenticationModule.java new file mode 100755 index 0000000000..a537f9432b --- /dev/null +++ b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/config/RestSDNAuthenticationModule.java @@ -0,0 +1,80 @@ +/** + * + * Copyright (C) 2009 Global Cloud Specialists, Inc. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.nirvanix.sdn.config; + +import java.net.URI; + +import javax.inject.Named; +import javax.inject.Singleton; + +import org.jclouds.http.RequiresHttp; +import org.jclouds.nirvanix.sdn.Authentication; +import org.jclouds.nirvanix.sdn.SDNAuthentication; +import org.jclouds.nirvanix.sdn.reference.SDNConstants; +import org.jclouds.rest.RestClientFactory; +import org.jclouds.rest.config.JaxrsModule; + +import com.google.inject.AbstractModule; +import com.google.inject.Provides; + +/** + * Configures the SDN authentication service connection, including logging and http transport. + * + * @author Adrian Cole + */ +@RequiresHttp +public class RestSDNAuthenticationModule extends AbstractModule { + + @Override + protected void configure() { + install(new JaxrsModule()); + bindErrorHandlers(); + bindRetryHandlers(); + } + + @Provides + @Singleton + @Authentication + protected URI provideAuthenticationURI(@Named(SDNConstants.PROPERTY_SDN_ENDPOINT) String endpoint) { + return URI.create(endpoint); + } + + @Provides + @Authentication + protected String provideSessionToken(RestClientFactory factory, + @Named(SDNConstants.PROPERTY_SDN_APPKEY) String appKey, + @Named(SDNConstants.PROPERTY_SDN_USERNAME) String username, + @Named(SDNConstants.PROPERTY_SDN_PASSWORD) String password) { + return factory.create(SDNAuthentication.class).authenticate(appKey, username, password); + } + + protected void bindErrorHandlers() { + // TODO + } + + protected void bindRetryHandlers() { + // TODO retry on 401 by AuthenticateRequest.update() + } + +} \ No newline at end of file diff --git a/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/functions/ParseSessionTokenFromJsonResponse.java b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/functions/ParseSessionTokenFromJsonResponse.java new file mode 100644 index 0000000000..87f5864c8b --- /dev/null +++ b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/functions/ParseSessionTokenFromJsonResponse.java @@ -0,0 +1,42 @@ +package org.jclouds.nirvanix.sdn.functions; + +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.UnsupportedEncodingException; + +import javax.inject.Inject; + +import org.jclouds.http.functions.ParseJson; + +import com.google.gson.Gson; + +/** + * This parses the Nirvanix SessionToken from a gson string. + * + * @author Adrian Cole + */ +public class ParseSessionTokenFromJsonResponse extends ParseJson { + + @Inject + public ParseSessionTokenFromJsonResponse(Gson gson) { + super(gson); + } + + private static class SessionTokenResponse { + Integer ResponseCode; + String SessionToken; + } + + public String apply(InputStream stream) { + + try { + SessionTokenResponse response = gson.fromJson(new InputStreamReader(stream, "UTF-8"), + SessionTokenResponse.class); + if (response.ResponseCode == null || response.ResponseCode != 0) + throw new RuntimeException("bad response code: " + response.ResponseCode); + return response.SessionToken; + } catch (UnsupportedEncodingException e) { + throw new RuntimeException("jclouds requires UTF-8 encoding", e); + } + } +} \ No newline at end of file diff --git a/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/reference/SDNConstants.java b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/reference/SDNConstants.java new file mode 100644 index 0000000000..78b0f2b5dd --- /dev/null +++ b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/reference/SDNConstants.java @@ -0,0 +1,36 @@ +/** + * + * Copyright (C) 2009 Global Cloud Specialists, Inc. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.nirvanix.sdn.reference; + +/** + * Configuration properties and constants used in SDN connections. + * + * @author Adrian Cole + */ +public interface SDNConstants { + public static final String PROPERTY_SDN_ENDPOINT = "jclouds.nirvanix.sdn.endpoint"; + public static final String PROPERTY_SDN_USERNAME = "jclouds.nirvanix.sdn.username"; + public static final String PROPERTY_SDN_PASSWORD = "jclouds.nirvanix.sdn.password"; + public static final String PROPERTY_SDN_APPKEY = "jclouds.nirvanix.sdn.appkey"; +} diff --git a/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/reference/SDNQueryParams.java b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/reference/SDNQueryParams.java new file mode 100644 index 0000000000..06ad0e1efd --- /dev/null +++ b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/reference/SDNQueryParams.java @@ -0,0 +1,15 @@ +package org.jclouds.nirvanix.sdn.reference; + +/** + * Query parameters common to SDN apis. + * + * @see + * @author Adrian Cole + * + */ +public interface SDNQueryParams { + public static final String USERNAME = "username"; + public static final String PASSWORD = "password"; + public static final String APPKEY = "appKey"; + public static final String OUTPUT = "output"; +} \ No newline at end of file diff --git a/nirvanix/sdn/core/src/test/java/org/jclouds/nirvanix/sdn/SDNAuthenticationLiveTest.java b/nirvanix/sdn/core/src/test/java/org/jclouds/nirvanix/sdn/SDNAuthenticationLiveTest.java new file mode 100644 index 0000000000..a937b7fc06 --- /dev/null +++ b/nirvanix/sdn/core/src/test/java/org/jclouds/nirvanix/sdn/SDNAuthenticationLiveTest.java @@ -0,0 +1,65 @@ +package org.jclouds.nirvanix.sdn; + +import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.http.HttpConstants.PROPERTY_JSON_DEBUG; +import static org.testng.Assert.assertNotNull; + +import java.net.URI; + +import javax.inject.Singleton; + +import org.jclouds.concurrent.WithinThreadExecutorService; +import org.jclouds.concurrent.config.ExecutorServiceModule; +import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; +import org.jclouds.logging.log4j.config.Log4JLoggingModule; +import org.jclouds.rest.RestClientFactory; +import org.jclouds.rest.config.JaxrsModule; +import org.jclouds.util.Jsr330; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import com.google.inject.AbstractModule; +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.Provides; + +/** + * Tests behavior of {@code SDNAuthentication} + * + * @author Adrian Cole + */ +@Test(groups = "live", testName = "sdn.SDNAuthenticationLiveTest") +public class SDNAuthenticationLiveTest { + String app = checkNotNull(System.getProperty("jclouds.test.app"), "jclouds.test.app"); + String user = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user"); + String password = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key"); + + private Injector injector; + + @Test + public void testAuthentication() throws Exception { + SDNAuthentication authentication = injector.getInstance(SDNAuthentication.class); + String response = authentication.authenticate(app, user, password); + assertNotNull(response); + } + + @BeforeClass + void setupFactory() { + injector = Guice.createInjector(new AbstractModule() { + @Override + protected void configure() { + bind(URI.class).annotatedWith(SDN.class).toInstance( + URI.create("http://services.nirvanix.com/ws")); + bindConstant().annotatedWith(Jsr330.named(PROPERTY_JSON_DEBUG)).to(true); + } + + @SuppressWarnings("unused") + @Provides + @Singleton + protected SDNAuthentication provideCloud(RestClientFactory factory) { + return factory.create(SDNAuthentication.class); + } + }, new JaxrsModule(), new Log4JLoggingModule(), new ExecutorServiceModule( + new WithinThreadExecutorService()), new JavaUrlHttpCommandExecutorServiceModule()); + } +} diff --git a/nirvanix/sdn/core/src/test/java/org/jclouds/nirvanix/sdn/functions/ParseSessionTokenFromJsonResponseTest.java b/nirvanix/sdn/core/src/test/java/org/jclouds/nirvanix/sdn/functions/ParseSessionTokenFromJsonResponseTest.java new file mode 100644 index 0000000000..75584a5f60 --- /dev/null +++ b/nirvanix/sdn/core/src/test/java/org/jclouds/nirvanix/sdn/functions/ParseSessionTokenFromJsonResponseTest.java @@ -0,0 +1,36 @@ +package org.jclouds.nirvanix.sdn.functions; + +import static org.testng.Assert.assertEquals; + +import java.io.InputStream; +import java.net.UnknownHostException; + +import org.jclouds.http.functions.config.ParserModule; +import org.jclouds.util.DateService; +import org.testng.annotations.Test; + +import com.google.gson.Gson; +import com.google.inject.Guice; +import com.google.inject.Injector; + +/** + * Tests behavior of {@code ParseSessionTokenFromJsonResponse} + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "sdn.ParseSessionTokenFromJsonResponseTest") +public class ParseSessionTokenFromJsonResponseTest { + + Injector i = Guice.createInjector(new ParserModule()); + DateService dateService = new DateService(); + + public void testApplyInputStreamDetails() throws UnknownHostException { + InputStream is = getClass().getResourceAsStream("/login.json"); + + ParseSessionTokenFromJsonResponse parser = new ParseSessionTokenFromJsonResponse(i + .getInstance(Gson.class)); + String response = parser.apply(is); + assertEquals(response, "e4b08449-4501-4b7a-af6a-d4e1e1bd7919"); + } + +} diff --git a/nirvanix/sdn/core/src/test/resources/log4j.xml b/nirvanix/sdn/core/src/test/resources/log4j.xml new file mode 100755 index 0000000000..a97df723b7 --- /dev/null +++ b/nirvanix/sdn/core/src/test/resources/log4j.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nirvanix/sdn/core/src/test/resources/login.json b/nirvanix/sdn/core/src/test/resources/login.json new file mode 100644 index 0000000000..33f4833ec3 --- /dev/null +++ b/nirvanix/sdn/core/src/test/resources/login.json @@ -0,0 +1 @@ +{"ResponseCode":0,"SessionToken":"e4b08449-4501-4b7a-af6a-d4e1e1bd7919"} \ No newline at end of file diff --git a/nirvanix/sdn/pom.xml b/nirvanix/sdn/pom.xml new file mode 100644 index 0000000000..111055e58d --- /dev/null +++ b/nirvanix/sdn/pom.xml @@ -0,0 +1,61 @@ + + + + jclouds-nirvanix-project + org.jclouds + 1.0-SNAPSHOT + ../pom.xml + + 4.0.0 + jclouds-sdn-project + pom + jclouds nirvanix storage delivery network project + + core + + + org.jclouds.nirvanix.sdn.integration.SDNTestInitializer + ${jclouds.nirvanix.sdn.username} + ${jclouds.nirvanix.sdn.password} + ${jclouds.nirvanix.sdn.appkey} + + + + ${project.groupId} + jclouds-blobstore-core + ${project.version} + + + ${project.groupId} + jclouds-blobstore-core + ${project.version} + test-jar + test + + + diff --git a/pom.xml b/pom.xml index b79c62d897..810e40c901 100644 --- a/pom.xml +++ b/pom.xml @@ -46,6 +46,7 @@ azure rackspace mezeo + nirvanix diff --git a/project/pom.xml b/project/pom.xml index 33a50752f9..3c4404cabc 100644 --- a/project/pom.xml +++ b/project/pom.xml @@ -406,6 +406,10 @@ pageTracker._trackPageview(); jclouds.test.key ${jclouds.test.key} + + jclouds.test.app + ${jclouds.test.app} + jclouds.blobstore.httpstream.url ${jclouds.blobstore.httpstream.url}