我有简单的集成测试
@Test
public void shouldReturnErrorMessageToAdminWhenCreatingUserWithUsedUserName() throws Exception {
mockMvc.perform(post("/api/users").header("Authorization", base64ForTestUser).contentType(MediaType.APPLICATION_JSON)
.content("{\"userName\":\"testUserDetails\",\"firstName\":\"xxx\",\"lastName\":\"xxx\",\"password\":\"xxx\"}"))
.andDo(print())
.andExpect(status().isBadRequest())
.andExpect(?);
}
Run Code Online (Sandbox Code Playgroud)
在最后一行中,我想将响应体中收到的字符串与期望的字符串进行比较
作为回应,我得到:
MockHttpServletResponse:
Status = 400
Error message = null
Headers = {Content-Type=[application/json]}
Content type = application/json
Body = "Username already taken"
Forwarded URL = null
Redirected URL = null
Run Code Online (Sandbox Code Playgroud)
尝试使用content(),body()但没有任何效果.
我正在寻找更优雅的方式来在测试期间刷新网页(我使用Selenium2).我只是发送F5键,但我想知道驱动程序是否有刷新整个网页的方法这是我的代码
while(driver.findElements(By.xpath("//*[text() = 'READY']")).size() == 0 )
driver.findElement(By.xpath("//body")).sendKeys(Keys.F5);
//element appear after text READY is presented
driver.findElement(By.cssSelector("div.column a")).click();
Run Code Online (Sandbox Code Playgroud)
也许是在手动刷新页面上查找元素的更好解决方案
我正在努力使用Postman Chrome扩展程序创建POST多部分/混合请求
这是我的卷曲请求什么效果很好
curl -H "Content-Type: multipart/mixed"
-F "metadata=@simple_json.json; type=application/json "
-F "content=@1.jpg; type=image/jpg" -X POST http://my/api/item -i -v
Run Code Online (Sandbox Code Playgroud)
有趣的回应部分
内容长度:41557
期待:100-继续
内容类型:multipart/mixed; 边界= ---------------------------- 8aaca457e117
- 额外的东西不精细transfer.c:1037:0 0
- 具有持久连接的HTTP 1.1或更高版本,支持流水线操作
当我使用Postman时

我得到了这样的回应
{"message":"Could not parse multipart servlet request;
nested exception is org.apache.commons.fileupload.FileUploadException:
the request was rejected because no multipart boundary was
found","type":"error","status":500,"requestId":"1861eloo6fpio"}
Run Code Online (Sandbox Code Playgroud)
就是这样 - 我希望摆脱那个错误.如果需要更多信息请问:)
要提取常量,我可以使用ctrl+ alt+ c,即"提取"创建公共常量:
public static final String CONST = "123";
Run Code Online (Sandbox Code Playgroud)
所以我需要手动键入private.有没有办法默认使用私有范围提取常量?
为什么在Python中以这种方式进行评估:
>>> False is False is False
True
Run Code Online (Sandbox Code Playgroud)
但是当试用括号时,表现如预期的那样:
>>> (False is False) is False
False
Run Code Online (Sandbox Code Playgroud) 在Bamboo我有MSBuild建立和运行测试的工作.
它工作正常 - 但我想使用test quarantine选项,所以当我将一些测试移到隔离区(这个移动的测试只是失败的)时,作业将被标记为成功
我将一个失败的测试移到隔离区,但作业被标记为失败
组态:
在Job- > Tasks我已Command命名Test runner:
Executable = VSTest.Console
Argument ="WebServiceTestClient.dll"/ Logger:trx
在运行失败的测试隔离后,我得到了日志
01-Apr-2014 10:59:44 Total tests: 62. Passed: 61. Failed: 1. Skipped: 0.
01-Apr-2014 10:59:44 Test Run Failed.
01-Apr-2014 10:59:44 Test execution time: 10.1296 Minutes
01-Apr-2014 10:59:44 Failing task since return code of [C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\VSTest.Console.exe "WebServiceTestClient.dll" /Logger:trx] was 1 while expected 0
01-Apr-2014 10:59:44 Finished task 'Test …Run Code Online (Sandbox Code Playgroud) 我正在使用PyCharm IDE,当我运行任何时,file.py我收到此错误:
..raise ImportError("无法导入设置,因为环境变量%s未定义."%ENVIRONMENT_VARIABLE)ImportError:无法导入设置,因为未定义环境变量DJANGO_SETTINGS_MODULE.
如何DJANGO_SETTINGS_MODULE在PyCharm中配置环境变量?
所以我有自定义验证器,当我设置return值false然后它工作 -
import com.vhealth.api.service.UserService;
import com.vhealth.api.utils.exceptions.InvalidPayloadException;
import org.springframework.beans.factory.annotation.Autowired;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
public class UserNameUniqueValidator implements ConstraintValidator<UserNameUnique, String> {
@Autowired
UserService userService;
@Override
public void initialize(UserNameUnique constraintAnnotation) {
}
@Override
public boolean isValid(String userName, ConstraintValidatorContext context) {
if (userService.findByUserName(userName) != null) {
throw new InvalidPayloadException("Creating user requires unique userName new");
//return false;
}
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试在该部分中抛出异常时,我得到错误,该问题是由我的自定义异常引起的:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is javax.validation.ValidationException: Unexpected exception during isValid call
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:932)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:827)
at …Run Code Online (Sandbox Code Playgroud) 如何轻松打印所有可用的docker swarm节点及其标签?
添加标签到节点
$ docker node update --label-add type=one my_node_name
和默认列表节点docker node ls没有显示过滤器.
另外我可以列出标签检查每个节点,如:
$ docker inspect my_node_name | grep type
"type": "one"
Run Code Online (Sandbox Code Playgroud)
- -编辑 -
类似的问题如何按标签过滤docker swarm节点?是关于过滤我的是关于列表
我想使用一些默认的iOS图标,即

在导航栏中.
基本上我不知道如何调用该项目的图像(直接从本机库 - 我知道如何下载它并放置为自定义图像:)):
var myButton:UIButton = UIButton.buttonWithType(UIButtonType.Custom) as! UIButton
myButton.addTarget(self, action: "reload", forControlEvents: UIControlEvents.TouchUpInside)
myButton.setImage(???, forState: <#UIControlState#>)
Run Code Online (Sandbox Code Playgroud)