小编Hec*_*tor的帖子

使用Apache Camel解压缩文件?

如何使用Apache Camel从zip文件中提取文件(一个或多个)?可能吗?

我正在尝试这个

from("file:/home/myinputzip?noop=true&delay=5000&moveFailed=error")
  .split(new ZipSplitter())
    .streaming().convertBodyTo(String.class)      
  .to("file:/home/myinputzip")
.end();
Run Code Online (Sandbox Code Playgroud)

当我启动应用程序时,文件是从zip中提取的,但是camel会抛出异常并将文件移动到错误文件夹:

错误:org.apache.camel.processor.DefaultErrorHandler - (ExchangeId上的MessageId:ID-ubuntu-35217-1377806407437-0-5:ID-ubuntu-35217-1377806407437-0-7)的传递失败.交付尝试后用尽:1捕获:org.apache.camel.component.file.GenericFileOperationFailedException:无法将null body写入文件:/home/myinputzip/aVIII_crrpfp201304.cap org.apache.camel.component.file.GenericFileOperationFailedException:无法写入null body to file:/home/myinputzip/aVIII_crrpfp201304.cap org.apache.camel.component.file.FileOperations.storeFile(FileOperations.java:194)at org.apache.camel.component.file.GenericFileProducer.writeFile(GenericFileProducer. java:257)org.apache中的org.apache.camel.component.file.GenericFileProducer.processExchange(GenericFileProducer.java:159)atg.apache.camel.component.file.GenericFileProducer.process(GenericFileProducer.java:80)位于org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)的.camel.util.AsyncProcessorConverterHelper $ ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)org.apache.camel.processor.SendProcessor $ 2.doInAsyncProducer( SendProcessor.java:122)org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:298)at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:117)

谁能帮我?

file unzip apache-camel

6
推荐指数
1
解决办法
6524
查看次数

Mockito问题 - InvalidUseOfMatchersException

我正在使用mockito进行测试,但我遇到了这个问题:

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: 
Invalid use of argument matchers!
2 matchers expected, 1 recorded:
-> at cl.gps.tms.planifications.planification.test.PlanificationCreateTest.setUp(PlanificationCreateTest.java:68)

This exception may occur if matchers are combined with raw values:
    //incorrect:
    someMethod(anyObject(), "raw String");
When using matchers, all arguments have to be provided by matchers.
For example:
    //correct:
    someMethod(anyObject(), eq("String by matcher"));

...
Run Code Online (Sandbox Code Playgroud)

PlanificationCreateTest使用SimpleQueryBus创建一个通用查询,其中de first参数指示返回的对象类型,第二个参数是查询的过滤器.

我想要存根SimpleQueryBus类(外部库)返回null(仅限现在)

SimpleQueryBus代码

public class SimpleQueryBus implements QueryBus {

    public <T, R> R handle(Class<R> clazz, T query) throws Exception {
    ...
    }
}
Run Code Online (Sandbox Code Playgroud)

我的测试代码

public class PlanificationCreateTest {

    private QueryBus …
Run Code Online (Sandbox Code Playgroud)

java testing mockito

5
推荐指数
1
解决办法
2万
查看次数

NestJS:依赖注入和提供者注册

谁能帮助我理解 DI Nest 基础知识,我的问题:

“是否可以有一个没有 @Injectable 注解的服务类,并且该类不属于任何模块?” 我在互联网上看到一个例子,如下所示:

此类存在于公共文件夹中:

export class NotificationService {
  constructor(
    @Inject(Logger) private readonly logger: LoggerService,
    private readonly appConfigService: AppConfigService,
    @Inject(HttpService) private readonly httpService: HttpService
  ) {}
 
  async sendNotification(msg: string) {
   ....
  } 
}
Run Code Online (Sandbox Code Playgroud)

然后它被注册到providers数组中的另一个模块中:

import { Module, Logger, forwardRef, HttpModule } from '@nestjs/common';
import { MongooseModule } from '@nestjs/mongoose';
import { NotificationService } from '../../commons/notification/notification.service';
 
@Module({
    imports: [
        ...
    ],
    controllers: [InvoiceController],
    providers: [
        InvoiceService,
        NotificationService,
        Logger],
    exports: [InvoiceService]
})
export class …
Run Code Online (Sandbox Code Playgroud)

service dependency-injection node.js nestjs

3
推荐指数
1
解决办法
3484
查看次数