Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/394.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用jclouds和Openstack Swift的单元测试的瞬态模式';行不通_Java_Unit Testing_Openstack Swift_Jclouds - Fatal编程技术网

Java 使用jclouds和Openstack Swift的单元测试的瞬态模式';行不通

Java 使用jclouds和Openstack Swift的单元测试的瞬态模式';行不通,java,unit-testing,openstack-swift,jclouds,Java,Unit Testing,Openstack Swift,Jclouds,我刚刚迁移到jclouds 2.0.0(假设它解决了一些不可重复操作的问题,它确实做到了)。这里是依赖项 <dependency> <groupId>org.apache.jclouds.driver</groupId> <artifactId>jclouds-slf4j</artifactId> <version>2.0.0</version> &

我刚刚迁移到jclouds 2.0.0(假设它解决了一些不可重复操作的问题,它确实做到了)。这里是依赖项

    <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>
我得到一个例外:

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)

这让我觉得应该支持
瞬态
。但如何让它起作用呢

您无法创建瞬态blobstore的
SwiftApi
视图;相反,您必须使用便携式
BlobStore
视图:

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();

无法创建瞬态blobstore的
SwiftApi
视图;相反,您必须使用便携式
BlobStore
视图:

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();

这就是我最后所做的,它是有效的。。。但首先有点遗憾,您无法对SwiftApi代码进行单元测试。第二:例外是列出可用的提供程序是错误的和误导性的。SwiftApi和transient有不同的API,您不能只将一个插入另一个。BlobStore代码实现了这个可移植层。如果您想要测试Swift服务器,您可以使用SwiftProxy:感谢您的澄清。使用SwiftApi比Blobstore有什么优势吗?我在J2LeV2之前使用它,它现在工作得很好,但是文档建议使用SWIFTAPI:我应该考虑它吗?一般用户调用BubSt店API来进行大多数操作,以便他们的应用程序是可移植的。当用户需要仅由SwiftApi公开的附加功能时,他们会在特定的呼叫站点中调用该功能。一个例子是以字节为单位获取容器大小,而不是由所有Blobstore公开,因此只是SwiftApi的一部分。。。但首先有点遗憾,您无法对SwiftApi代码进行单元测试。第二:例外是列出可用的提供程序是错误的和误导性的。SwiftApi和transient有不同的API,您不能只将一个插入另一个。BlobStore代码实现了这个可移植层。如果您想要测试Swift服务器,您可以使用SwiftProxy:感谢您的澄清。使用SwiftApi比Blobstore有什么优势吗?我在J2LeV2之前使用它,它现在工作得很好,但是文档建议使用SWIFTAPI:我应该考虑它吗?一般用户调用BubSt店API来进行大多数操作,以便他们的应用程序是可移植的。当用户需要仅由SwiftApi公开的附加功能时,他们会在特定的呼叫站点中调用该功能。一个例子是以字节为单位获取容器大小,而不是由所有blobstores公开,因此只是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();