小编eth*_*esx的帖子

JMeter:如何为循环计数的第二次迭代更改用户定义的变量值

我正在运行具有以下属性值的线程组:

线程数:200加速时间(秒):20循环计数:2

我还为HTTP请求设置了用户定义的变量.但是,当达到第二次迭代时,我还需要更改用户定义变量的值.

jmeter

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

将mock注入Spring MockMvc WebApplicationContext

我正在使用Spring-boot测试(通过JUnit4和Spring MockMvc)一个REST服务适配器.适配器只是将对其发出的请求传递给另一个REST服务(使用自定义RestTemplate),并将其他数据附加到响应中.

我想运行MockMvc测试来执行控制器集成测试,但是想要RestTemplate使用模拟覆盖控制器中的控件,以允许我预定义第三方REST响应并防止它在每次测试期间被命中.我已经能够通过实例化一个做到这一点MockMvcBuilders.standAloneSetup(),并把它传递给与在此列出注入模拟测试控制器(及以下我的设置),但我无法做到使用相同的MockMvcBuilders.webAppContextSetup().

我已经阅读了其他几篇文章,其中没有一篇文章回答了如何实现这一目标的问题.我想将实际的Spring应用程序上下文用于测试,而不是单独使用,以防止应用程序可能增长时出现任何差距.

编辑:我使用Mockito作为我的模拟框架,并试图将其中一个模拟注入上下文.如果没有必要,那就更好了.

控制器:

@RestController
@RequestMapping(Constants.REQUEST_MAPPING_PATH)
public class Controller{

    @Autowired
    private DataProvider dp;    

    @Autowired
    private RestTemplate template;

    @RequestMapping(value = Constants.REQUEST_MAPPING_RESOURCE, method = RequestMethod.GET)
    public Response getResponse(
            @RequestParam(required = true) String data,
            @RequestParam(required = false, defaultValue = "80") String minScore
            ) throws Exception {

        Response resp = new Response();

        // Set the request params from the client request
        Map<String, String> parameters = new HashMap<String, String>();
        parameters.put(Constants.PARAM_DATA, data); …
Run Code Online (Sandbox Code Playgroud)

java integration-testing junit4 mockito spring-boot

11
推荐指数
2
解决办法
3万
查看次数

运行Gradle JUnit测试时"正在使用的地址:绑定"异常

我正在使用Spring Boot 1.2.1.RELEASE,JUnit4和Gradle 2.1来获取RESTful服务,并且我正在尝试定义一个属性文件,该文件包含和/或覆盖将仅在JUnit测试中使用的值.当作为JUnit测试调用时,所有测试都会执行而不会出现问题.但是,当在gradle"build"或"test"任务期间运行这些相同的测试时,它们会失败,并出现"引发:java.lang.IllegalStateException:处于失败状态的Tomcat连接器",其根本原因为"java.net" .BindException:地址已在使用中:bind".

有多个测试类需要应用程序上下文才能运行.

为了通过属性文件来促进替代值,我已经包含了TestPropertySource()

是否需要额外的Gradle配置才能使其工作?

ControllerTest类

@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@SpringApplicationConfiguration(classes = RESTAdapter.class)
@TestPropertySource(locations="classpath:application-junit.properties")
public class ControllerTest {

    @Value("${test.token}")
    private String token;

    @Autowired
    private WebApplicationContext wac;

    private MockMvc mockMvc;

    @Before
    public void setup() {
          this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
    }

    public void TestMockMvc(String[] strings) throws Exception{

        mockMvc.perform(URL_all_paramters, strings)
            .param(Constants.PARAM_TOKEN, token)
            .accept(Constants.APPLICATION_JSON_UTF8))
            .andDo(print())
            .andExpect(status().isOk())
            .andExpect(content().contentType(Constants.APPLICATION_JSON_UTF8))
            .andExpect(content().json(strings[strings.length-1]));
    }
  } 
Run Code Online (Sandbox Code Playgroud)

application.properties(/ src/main/resources)

logging.level.org.springframework.web=TRACE
server.port=4040
shape.file=./shape/tl_2014_34_tabblock10_county_muni.shp
Run Code Online (Sandbox Code Playgroud)

application-junit.properties(/ src/test/resources)

test.token=..dDKidjwel
Run Code Online (Sandbox Code Playgroud)

的build.gradle

buildscript {
    ext {
        springBootVersion = '1.2.1.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") …
Run Code Online (Sandbox Code Playgroud)

junit4 gradle properties-file spring-boot springjunit4classrunner

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

重命名TFS 2013分支

我们正在使用TFS分支的版本号.我刚刚创建了一个新的TFS分支,其中包含即将发布的版本号.但是,客户端已经更改了我们希望保留并行TFS分支名称的版本号.

该分支是新的,尚未对其进行任何更改.

如果我重命名分支,我可以期待什么问题?使用新版本号从main创建新分支是否更好?

tfs branch rename tfs2013

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