2016-12-02 4 views
1

방금 ​​jclouds 2.0.0으로 마이그레이션했습니다 (반복 가능한 작업이 아닌 몇 가지 문제를 생각해 냈습니다.). 종속성은 다음과 같습니다.jclouds 및 Openstack Swift로 단위 테스트를위한 과도 모드가 작동하지 않습니다.

<dependency> 
     <groupId>org.apache.jclouds.driver</groupId> 
     <artifactId>jclouds-slf4j</artifactId> 
     <version>2.0.0</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.jclouds.api</groupId> 
     <artifactId>openstack-keystone</artifactId> 
     <version>2.0.0</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.jclouds.api</groupId> 
     <artifactId>openstack-swift</artifactId> 
     <version>2.0.0</version> 
    </dependency> 

내 코드에 대한 단위 테스트가 필요합니다. 나는 제공자로 transient를 사용할 때 :

com.google.inject.ConfigurationException: Guice configuration errors: 

1) No implementation for org.jclouds.openstack.swift.v1.SwiftApi was bound. 
    while locating org.jclouds.openstack.swift.v1.SwiftApi 

1 error 

    at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:1004) 
    at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1009) 
    at org.jclouds.ContextBuilder.buildApi(ContextBuilder.java:651) 
    at org.jclouds.ContextBuilder.buildApi(ContextBuilder.java:643) 
    at eu.europeana.cloud.service.mcs.persistent.swift.SimpleSwiftConnectionProvider.openConnections(SimpleSwiftConnectionProvider.java:91) 
    at eu.europeana.cloud.service.mcs.persistent.swift.SimpleSwiftConnectionProvider.<init>(SimpleSwiftConnectionProvider.java:67) 
    at eu.europeana.cloud.service.mcs.persistent.swift.SimpleSwiftConnectionProviderTest.getContainer(SimpleSwiftConnectionProviderTest.java:24) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:606) 
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) 
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) 
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) 
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) 
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) 
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) 
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) 
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) 
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) 
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) 
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) 
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) 
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363) 
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137) 
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) 
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51) 
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237) 
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:606) 
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) 

제공 (그리고 올바른 자격 증명 및 엔드 포인트) 등의 openstack-swift와 동일한 코드 실행이 잘 작동 :

SwiftApi swiftApi = ContextBuilder.newBuilder("transient") 
       .endpoint(endpoint) 
       .credentials(user, password) 
       .modules(modules) 
       .overrides(overrides) 
       .buildApi(SwiftApi.class); 

나는이 예외를 얻을. 는 newBuilder 함수 매개 변수의 원인으로 다른 문자열을 전달 :

java.util.NoSuchElementException: key [wrongstring] not in the list of providers or apis: {apis=[openstack-keystone, openstack-swift, transient]} 
    at org.jclouds.ContextBuilder.newBuilder(ContextBuilder.java:175) 

것은 나를 transient 지원해야한다고 생각하게한다. 하지만 어떻게 작동하게 할까?

답변

0

일시적인 Blobstore보기를 SwiftApi 만들 수 없습니다. 대신 당신이 휴대용 BlobStore보기를 사용합니다

나는 결국 무슨 짓을했는지와 작동 ...하지만 먼저 그것은 당신이 할 수없는 단위 테스트 SwiftApi 코드, 약간 슬픈
String provider = ...; // openstack-swift or transient 
BlobStoreContext context = ContextBuilder.newBuilder(provider) 
      .endpoint(endpoint) 
      .credentials(user, password) 
      .buildApi(BlobStoreContext.class); 
BlobStore blobStore = context.getBlobStore(); 
// interact with blobStore, e.g., get, put 
... 
context.close(); 
+0

. 두 번째 : 예외는 사용 가능한 제공 업체를 나열하는 것이 잘못되어 오도하는 것입니다. – lotk

+0

SwiftApi와 transient는 서로 다른 API를 가지고있어서 다른 API에 플러그인 할 수 없습니다. BlobStore 코드는이 휴대용 레이어를 구현합니다. 테스트 용 Swift 서버를 원한다면 SwiftProxy를 사용할 수 있습니다 : https://github.com/bouncestorage/swiftproxy –

+0

설명해 주셔서 감사합니다. Blobstore보다 SwiftApi를 사용하면 어떤 이점이 있습니까? 나는 jclouds v2 이전에 그것을 사용하고 있었지만 지금 당장은 완벽하게 작동하지만 문서는 SwiftApi를 사용하여 제안합니다 : https://jclouds.apache.org/guides/openstack/#swift 나는 그것을 고려해야합니까? – lotk

관련 문제