我试图验证具有以下签名的方法被调用:
public void process(Map<String, Set<String>> data) {
...
}
Run Code Online (Sandbox Code Playgroud)
嵌套的参数化Set给我带来了困难.我可以使用any()匹配器来正确验证它,如下所示:
verify(dataProcessor).process(Matchers.<Map<String, Set<String>>> any());
Run Code Online (Sandbox Code Playgroud)
如Mockito中所述:使用泛型参数进行验证虽然令人讨厌,但如果我直接静态导入Matchers.any并将其称为以下内容则无效:
verify(dataProcessor).process(<Map<String, Set<String>>> any())
Run Code Online (Sandbox Code Playgroud)
但是在这种情况下,anyMapOf(clazz,clazz)似乎更合适.既然你不能做Set.class我不知道你会怎么做.以下不起作用,因为缺乏通用:
verify(dataProcessor).process(anyMapOf(String.class, Set.class));
Run Code Online (Sandbox Code Playgroud)
是否可以使用anyMapOf验证这种情况,还是应该坚持使用Matchers.<> any()?
我正在Windows机器上运行一个django webapp在vagrant(运行ubuntu).该应用程序设置了RotatingFileHandler,大部分都是正确记录.但最终日志文件填满了,此时它无法翻转
Logged from file util.py, line 79
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/handlers.py", line 78, in emit
self.doRollover()
File "/usr/lib/python2.7/logging/handlers.py", line 141, in doRollover
os.rename(self.baseFilename, dfn)
OSError: [Errno 26] Text file busy
Run Code Online (Sandbox Code Playgroud)
(很多次)
以下是RotatingFileHandler的配置代码段:
'default': {
'level':'DEBUG',
'class':'logging.handlers.RotatingFileHandler',
'filename': 'logs/application.log',
'maxBytes': 1024 * 1024 * 5, # 5 MB
'backupCount': 5,
'formatter':'standard',
},
Run Code Online (Sandbox Code Playgroud)
问题似乎是它正在登录共享的vagrant目录,因此它遇到了Windows文件锁定问题.如果我将其更改为登录共享目录之外的目录,它就会滚动好.
我的问题是,有什么我可以做的,以防止上述错误,而不必将注册表移出vagrant目录?
我想将它保存在那里,以便更容易移植到其他服务器,因此我可以在Windows中查看日志.
在我当前的项目中,我有一个子模块,它使用 maven exec 插件运行测试服务,该服务从资源/testResources 文件夹之外的位置提取配置文件。
我需要使用过滤将环境变量注入到一些配置文件中。这适用于其中一个文件 .properties 文件,但不适用于另一个 .json 文件。在后一种情况下,它只是将变量留在 json 文件中。这两个文件在过滤目录中彼此相邻。
这是来自子模块的过滤片段:
<build>
<finalName>${artifactId}</finalName>
<testResources>
<testResource>
<filtering>true</filtering>
<directory>../etc</directory>
</testResource>
</testResources>
Run Code Online (Sandbox Code Playgroud)
json文件:
{ "customMappings" :
{ "tag:example.com:/vagrant/" : "file:${VAGRANT_CWD}" }
}
Run Code Online (Sandbox Code Playgroud)
简化的项目结构:
子模块肯定会加载这两个文件,但只过滤 .properties 文件。
它是一个 json 文件有什么特别之处可以防止过滤发生在它身上吗?有什么可以做的吗?