我正在使用这个依赖项:
<dependencies>
<!-- Testing -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<exclusions>
<exclusion>
<artifactId>hamcrest-core</artifactId>
<groupId>org.hamcrest</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.9.5</version>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>
Run Code Online (Sandbox Code Playgroud)
但是,使用如下函数:
List<String> output = ..;
List<String> data = ...;
Assert.assertThat(output, Matchers.containsInAnyOrder(data));
Run Code Online (Sandbox Code Playgroud)
结果出错。修复 hamcrest 以便该功能真正发挥作用的正确方法是什么?我尝试找出正确的依赖管理并找到了上面提到的配置。
我收到的错误是断言错误,如果我比较两个相同的列表但具有已打乱的值,它不会通过但会失败
例子:
List<String> output = Arrays.asList(
"text1\t1",
"text2\t1",
"text3\t1",
"text4\t1",
"text5\t1",
"text6\t1",
"text7\t1",
"text8\t1", …Run Code Online (Sandbox Code Playgroud) 我正在做nodechool练习,
此问题与上一个问题(HTTP COLLECT)相同,因为您需要使用http.get().但是,这次您将获得三个URL作为前三个命令行参数.
您必须收集每个URL提供给您的完整内容,并将其打印到控制台(stdout).您不需要打印长度,只需将数据打印为String; 每个网址一行.问题是您必须按照与作为命令行参数提供的URL相同的顺序打印它们.
换句话说,我要注册3个http.get请求,并按顺序打印从中收到的数据.
我试图用promises做另外一个get请求不会被调用直到第一个没有结束.
我的代码看起来像这样
var http=require("http");
var collect=[];
var dat=[];
for( var i = 2 ; i < process.argv.length;i++){
collect.push(process.argv[i]);
}
function chainIt(array,callback){
return array.reduce(function(promise,item){
return promise.then(function(){
return callback(item)
})
},Promise.resolve())
}
function getIt(item){
return http.get(item,function(response){
response.on("data",function(data){
dat.push(data);
})
})
}
chainIt(collett,function(item){
return getIt(item)
})
}).then(function(){
collect.forEach(function(x){
console.log(x);
})
})
Run Code Online (Sandbox Code Playgroud)
但我实际上没有打印数据=我没有通过练习.
我没有看到任何错误,但我只是从promises和node开始.哪里出错了?
我正在尝试实现网络套接字。我的代码:
在春季安全中,我允许带有身份验证的路径
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
httpSecurity.csrf()
.disable()
.authorizeRequests()
.antMatchers("/register","/login","/testAuth","/web","/ws").permitAll()
.anyRequest().authenticated()
.and()
.exceptionHandling()
.authenticationEntryPoint(jwtAuthenticationEntryPoint)
.and()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS);
httpSecurity.addFilterBefore(jwtRequestFilter, UsernamePasswordAuthenticationFilter.class);
}
Run Code Online (Sandbox Code Playgroud)
和 ws 的配置
@Configuration
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer {
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
registry.addHandler(new WsMessageHandler(), "/ws")
.addInterceptors(new CustomInterceptor())
.setAllowedOrigins("*")
.setHandshakeHandler(new DefaultHandshakeHandler())
.withSockJS();
}
}
Run Code Online (Sandbox Code Playgroud)
`
public class CustomInterceptor implements HandshakeInterceptor {
@Override
public boolean beforeHandshake(ServerHttpRequest serverHttpRequest, ServerHttpResponse serverHttpResponse, WebSocketHandler webSocketHandler, Map<String, Object> map) throws Exception {
return true;
}
@Override
public void …Run Code Online (Sandbox Code Playgroud) 我正在学习lisp,我正在尝试创建简单的函数来总结arr.
(defun sum( N )
( if ( null N )
nil
( + (car N ) ( sum ( cdr N )))))
(sum '(1 2 3 ))
Run Code Online (Sandbox Code Playgroud)
但它会引发错误
错误:执行:未绑定的符号:"N"[]
括号应该是正确的.为什么这会抛出错误或我的代码背后的逻辑有什么问题?
如果list为空,它将返回nil,否则,它将递归返回列表的第一个元素+其余部分.
感谢帮助
我有一个排序的数组,例如
var arr = [ "aasd","march","mazz" ,"xav" ];
Run Code Online (Sandbox Code Playgroud)
我想找到第一个以"m"开头的字母,这里它将是1.你是否有任何方式如何做到这一点没有循环整个阵列?
java ×2
javascript ×2
arrays ×1
common-lisp ×1
hamcrest ×1
lisp ×1
mockito ×1
node.js ×1
promise ×1
spring ×1
spring-boot ×1
websocket ×1