PageRenderTime 4218ms CodeModel.GetById 29ms RepoModel.GetById 3ms app.codeStats 0ms

/nirvanix/sdn/core/src/test/java/org/jclouds/nirvanix/sdn/functions/ParseUploadInfoFromJsonResponseTest.java

https://github.com/jraghu/jclouds
Java | 56 lines | 24 code | 9 blank | 23 comment | 0 complexity | e4fa99ffb5537a29e843d96dcbfa62f3 MD5 | raw file
  1. /**
  2. *
  3. * Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
  4. *
  5. * ====================================================================
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. * ====================================================================
  18. */
  19. package org.jclouds.nirvanix.sdn.functions;
  20. import static org.testng.Assert.assertEquals;
  21. import java.io.InputStream;
  22. import java.net.URI;
  23. import java.net.UnknownHostException;
  24. import org.jclouds.http.functions.config.ParserModule;
  25. import org.jclouds.nirvanix.sdn.domain.UploadInfo;
  26. import org.testng.annotations.Test;
  27. import com.google.gson.Gson;
  28. import com.google.inject.Guice;
  29. import com.google.inject.Injector;
  30. /**
  31. * Tests behavior of {@code ParseUploadInfoFromJsonResponse}
  32. *
  33. * @author Adrian Cole
  34. */
  35. @Test(groups = "unit", testName = "sdn.ParseUploadInfoFromJsonResponse")
  36. public class ParseUploadInfoFromJsonResponseTest {
  37. Injector i = Guice.createInjector(new ParserModule());
  38. public void testApplyInputStreamDetails() throws UnknownHostException {
  39. InputStream is = getClass().getResourceAsStream("/authtoken.json");
  40. ParseUploadInfoFromJsonResponse parser = new ParseUploadInfoFromJsonResponse(i
  41. .getInstance(Gson.class));
  42. UploadInfo response = parser.apply(is);
  43. assertEquals(response.getHost(), URI.create("https://node1.nirvanix.com"));
  44. assertEquals(response.getToken(),
  45. "siR-ALYd~BEcJ8GR2tE~oX3SEHO8~2WXKT5xjFk~YLS5OvJyHI21TN34rQ");
  46. }
  47. }