UnfinishedVerificationException当我认为我已经完成了所有事情时,Mockito似乎正在投掷.这是我的部分测试用例:
HttpServletRequest req = mock(HttpServletRequest.class);
when(req.getHeader("Authorization")).thenReturn("foo");
HttpServletResponse res = mock(HttpServletResponse.class);
classUnderTest.doMethod(req, res); // Use the mock
verify(res, never());
verify(req).setAttribute(anyString(), anyObject());
Run Code Online (Sandbox Code Playgroud)
这是部分类和方法:
class ClassUnderTest extends AnotherClass {
@Override
public String doMethod(ServletRequest req, ServletRequest res) {
// etc.
return "someString";
}
}
Run Code Online (Sandbox Code Playgroud)
忽略你不应该模仿你不拥有的接口的事实,为什么Mockito给我以下信息?
org.mockito.exceptions.misusing.UnfinishedVerificationException:
Missing method call for verify(mock) here:
-> at (redacted)
Example of correct verification:
verify(mock).doSomething()
Also, this error might show up because you verify either of: final/private/equals()/hashCode() methods.
Those methods *cannot* be stubbed/verified.
at [test method name and …Run Code Online (Sandbox Code Playgroud) 如何在grails上的groovy中读取和导入.csv文件.我有.csv文件包含数据,
需要使用用户界面导入到db.
我在OSX上安装了Cassandra.尝试从/ bin /运行cqlsh时,出现以下错误:
> Connection error: ('Unable to connect to any servers', {'127.0.0.1':
> ConnectionShutdown('Connection <AsyncoreConnection(4522252560)
> 127.0.0.1:9160 (closed)> is already closed',)})
Run Code Online (Sandbox Code Playgroud)
我在安装Cassandra时遇到了困难,并且使用了brew install cassandra,从datastax安装了DSE,并从Apache下载了二进制文件.
我们有一场战争,通过基于hibernate-4.2.7验证的验证(实现validation-api-1.0.0.GA),在场地2.6上展示休息服务.
在我们升级到java 8和tc-server 3.1.X之前,一切正常.
升级到java 8之后,看起来在验证API中出现了问题.
我们得到了
java.lang.NoSuchMethodError:javax.validation.Configuration.getBootstrapConfiguration()Ljavax/validation/BootstrapConfiguration;
当我们从客户端发送休息请求时.
最奇怪的是,这种行为并不构成
当我从依赖项添加或删除jar时,它有时会起作用,有时候不起作用.
我们得到以下例外
SEVERE [tomcat-http--1] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [jerseyServlet] in context with path [/Analyzer] threw exception [A MultiException has 1 exceptions. They are:
1. java.lang.NoSuchMethodError: javax.validation.Configuration.getBootstrapConfiguration()Ljavax/validation/BootstrapConfiguration;
] with root cause
java.lang.NoSuchMethodError: javax.validation.Configuration.getBootstrapConfiguration()Ljavax/validation/BootstrapConfiguration;
at org.glassfish.jersey.server.validation.internal.ValidationBinder$ConfiguredValidatorProvider.getTraversableResolver(ValidationBinder.java:287)
at org.glassfish.jersey.server.validation.internal.ValidationBinder$ConfiguredValidatorProvider.getDefaultValidatorContext(ValidationBinder.java:268)
at org.glassfish.jersey.server.validation.internal.ValidationBinder$ConfiguredValidatorProvider.getDefaultValidator(ValidationBinder.java:248)
at org.glassfish.jersey.server.validation.internal.ValidationBinder$ConfiguredValidatorProvider.provide(ValidationBinder.java:199)
at org.glassfish.jersey.server.validation.internal.ValidationBinder$ConfiguredValidatorProvider.provide(ValidationBinder.java:173)
at org.jvnet.hk2.internal.FactoryCreator.create(FactoryCreator.java:96)
at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456)
at org.jvnet.hk2.internal.PerLookupContext.findOrCreate(PerLookupContext.java:69)
at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2445)
at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:621)
at org.jvnet.hk2.internal.IterableProviderImpl.get(IterableProviderImpl.java:107)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:135)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$VoidOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:136)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:104)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:406)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:350)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:106)
at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:259)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) …Run Code Online (Sandbox Code Playgroud) 我正在研究一个有两种口味的项目,有多种租赁方式.
该项目公开了一个我希望异步的REST服务.所以我的基本服务看起来像
@Component
@Path("/resouce")
@Consumes(MediaType.APPLICATION_JSON)
public class ResouceEndpoint {
@POST
@ManagedAsync
public void add(final Event event, @Suspended final AsyncResponse asyncResponse) {
resouce.insert (event);
asyncResponse.resume( Response.status(Response.Status.NO_CONTENT).build());
}
}
Run Code Online (Sandbox Code Playgroud)
没有多租户就可以正常工作,我可以免费获得内部Jersey执行器服务的好处.请参阅@ManagedAsync
当我切换到多租户时,我在请求上添加了一个过滤器,用于解析租户ID并将其放在本地线程上(在我们的例子中是HTTP线程).
当处理链命中上面的"add()"方法时,当前线程是Jersey执行器服务提供的线程,因此它不包括我的租户ID.我只能考虑以下选项来解决这个问题.
将ResouceEndpoint扩展为MutliTenantResouceEndpoint并使用我自己的线程执行器删除@ManagedAsync
public class MutliTenantResouceEndpoint extends ResouceEndpoint {
@POST
public void add(final Event event, @Suspended final AsyncResponse asyncResponse) {
final String tenantId = getTeantIdFromThreadLocal();
taskExecutor.submit(new Callable<Void>() {
@Override
public Void call() throws Exception {
setTeantIdToThreadLocal(tenantId);
browserEventsAnalyzer.insertEvent(event);
Response response = Response.status(Response.Status.NO_CONTENT).build();
asyncResponse.resume(response);
return null;
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
但是这样我需要管理自己的线程执行器,感觉就像我在这里遗漏了一些东西.有关不同方法的任何建议吗?
我们需要创建大型(1G-16G)行数据报告来压缩和加密它们.我们的客户将通过sFTP使用这些报告.我们正在替换现有的实施,因此我们的客户应该透明地进行此更改.
Azure Blob服务不公开sFTP服务,因此我们需要一些方法来使用sFTP服务来覆盖它.类似于FTP到Azure Blob存储桥的基于工作者角色的东西.worker角色会将sFTP端点暴露给外部世界.我们将为每个客户设置一个容器,并限制工作者角色的访问权限,以便保护容器免受直接访问.
我的问题是:
通过 powershell 创建 SASToken 时,它会从 New-AzureStorageContainerSASToken comdlet 返回创建的 SAS 令牌 URL。
$Context = New-AzureStorageContext -StorageAccountName $StorageAccount -StorageAccountKey $StorageAccountKey
$now = Get-Date
$sasUrl = New-AzureStorageContainerSASToken -Name mycontainer -Permission rwdl -StartTime $now.AddHours(-1) -ExpiryTime $now.AddMonths(1) -Context $context -FullUri
echo $sasUrl
Run Code Online (Sandbox Code Playgroud)
但是现在万一我丢失了它,我该如何列出现有的 SASToken?您可能在同一个容器上有几个。
尝试了 Get-AzureStorageContainer,但此信息不可用。
与其他 Get-AzureStorage* 一起玩,但未能找到它。
是否通过 powershell 支持此操作?
powershell azure azure-storage azure-powershell azure-blob-storage
是否可以访问在步骤范围之外定义的 bean?例如,如果我定义一个策略“strategyA”并将其传递到作业参数中,我希望 @Value 解析为 strategyA bean。这可能吗?我目前正在通过从 applicationContext 手动获取 bean 来解决这个问题。
@Bean
@StepScope
public Tasklet myTasklet(
@Value("#{jobParameters['strategy']}") MyCustomClass myCustomStrategy)
MyTasklet myTasklet= new yTasklet();
myTasklet.setStrategy(myCustomStrategy);
return myTasklet;
}
Run Code Online (Sandbox Code Playgroud)
我希望能够在无需修改代码的情况下添加更多策略。
我想从 java 客户端使用rabbitmq-consistency-hash-exchange 的功能,或者最好使用 spring 抽象 spring-amqp。不幸的是,我未能找到一个解释 java 用法并引用要包含的 jar 依赖项的示例,请提出建议。
在我的 Spring 应用程序中,我有带有两个注释的控制器:
@Controller - Spring注解
@AdminPanelController - 我的注释
是否可以更改我的注释,以便我可以使用 if 而无需另外放置 @Controller ?
我希望 Spring 将我的注释处理为 @Controller 注释。
this is my application.properties file in src/main/resource
spring.datasource.platform=h2
spring.h2.console.enabled=true
spring.datasource.url=jdbc:h2:mem:testdb
Run Code Online (Sandbox Code Playgroud)
我在 pom.xml 中添加了 h2 依赖项
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
另一种是Jpa依赖和Web依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)
整个项目在邮递员中运行良好,但当我在网络浏览器中点击 url 时不起作用
java ×3
azure ×2
jersey ×2
spring ×2
spring-boot ×2
cassandra ×1
cqlsh ×1
csv ×1
groovy ×1
h2 ×1
hk2 ×1
import ×1
java-8 ×1
jersey-2.0 ×1
junit ×1
junit5 ×1
mockito ×1
postman ×1
powershell ×1
rabbitmq ×1
rest ×1
servlet-3.0 ×1
sftp ×1
spring-batch ×1
unit-testing ×1
validation ×1