• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JsonPathExpectationsHelper类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.test.util.JsonPathExpectationsHelper的典型用法代码示例。如果您正苦于以下问题:Java JsonPathExpectationsHelper类的具体用法?Java JsonPathExpectationsHelper怎么用?Java JsonPathExpectationsHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JsonPathExpectationsHelper类属于org.springframework.test.util包,在下文中一共展示了JsonPathExpectationsHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: test02Sync

import org.springframework.test.util.JsonPathExpectationsHelper; //导入依赖的package包/类
@Test
public void test02Sync() throws Exception {
    //Build the message (with a payload and headers)
    Message<byte[]> message = this.createMessage("sync", "/app/sync");

    this.brokerChannelInterceptor.setIncludedDestinations("/user/**");
    this.brokerChannelInterceptor.startRecording();

    this.clientInboundChannel.send(message);

    Message<?> reply = this.brokerChannelInterceptor.awaitMessage(5);
    assertNotNull(reply);
    //Wrap the response in a header accessor
    StompHeaderAccessor replyHeaders = StompHeaderAccessor.wrap(reply);
    //Make sure its the same session
    //assertEquals("0", replyHeaders.getSessionId());
    //Make sure the message was sent to the correct user (uuid from above)
    assertEquals(String.format("/user/%s/queue/device", this.uuid), replyHeaders.getDestination());
    //Unescape/unquote the string
    String json = new String((byte[]) reply.getPayload(), "UTF-8");
    //json = json.substring(1, json.length()-1);
    //Make sure the server time is in the payload
    new JsonPathExpectationsHelper("serverTime").exists(json);
    new JsonPathExpectationsHelper("type").assertValue(json, "sync");
}
 
开发者ID:wieden-kennedy,项目名称:composite-framework,代码行数:26,代码来源:ContextCompositeTests.java


示例2: test05Start

import org.springframework.test.util.JsonPathExpectationsHelper; //导入依赖的package包/类
@Test
public void test05Start() throws Exception {
    Session session = this.sessionRepository.findByDeviceUuid(this.uuid);

    //Build the message
    Message<byte[]> message = this.createMessage("start", String.format("/app/%s", session.getUuid()), session.getDevices().get(0).getUuid());

    this.brokerChannelInterceptor.setIncludedDestinations("/topic/**");
    this.brokerChannelInterceptor.startRecording();

    this.clientInboundChannel.send(message);

    Message<?> reply = this.brokerChannelInterceptor.awaitMessage(5);
    assertNotNull(reply);
    //Wrap the response in a header accessor
    StompHeaderAccessor replyHeaders = StompHeaderAccessor.wrap(reply);
    //Make sure the message was sent to the correct topic (sessionUuid from above)
    assertEquals(String.format("/topic/%s", session.getUuid()), replyHeaders.getDestination());
    //Unescape/unquote the string
    String json = new String((byte[]) reply.getPayload(), "UTF-8");
    //json = json.substring(1, json.length()-1);
    //Verify the data
    new JsonPathExpectationsHelper("type").assertValue(json, "start");
}
 
开发者ID:wieden-kennedy,项目名称:composite-framework,代码行数:25,代码来源:ContextCompositeTests.java


示例3: test06Update

import org.springframework.test.util.JsonPathExpectationsHelper; //导入依赖的package包/类
@Test
public void test06Update() throws Exception {
    //Build the message
    Message<byte[]> message = this.createMessage("update", String.format("/app/%s", this.sessionUuid), "THIS IS AN UPDATE");

    this.brokerChannelInterceptor.setIncludedDestinations("/topic/**");
    this.brokerChannelInterceptor.startRecording();

    this.clientInboundChannel.send(message);

    Message<?> reply = this.brokerChannelInterceptor.awaitMessage(5);
    assertNotNull(reply);
    //Wrap the response in a header accessor
    StompHeaderAccessor replyHeaders = StompHeaderAccessor.wrap(reply);
    //Make sure the message was sent to the correct topic (sessionUuid from above)
    assertEquals(String.format("/topic/%s",this.sessionUuid), replyHeaders.getDestination());
    //Unescape/unquote the string
    String json = new String((byte[]) reply.getPayload(), "UTF-8");
    //json = json.substring(1, json.length()-1);
    //Verify the data
    new JsonPathExpectationsHelper("type").assertValue(json, "update");
    new JsonPathExpectationsHelper("data").assertValue(json, "THIS IS AN UPDATE");
}
 
开发者ID:wieden-kennedy,项目名称:composite-framework,代码行数:24,代码来源:ContextCompositeTests.java


示例4: test07Data

import org.springframework.test.util.JsonPathExpectationsHelper; //导入依赖的package包/类
@Test
public void test07Data() throws Exception {

    //Build the message
    Message<byte[]> message = this.createMessage("data", String.format("/app/%s",this.sessionUuid), "THIS IS SOME DATA");

    this.brokerChannelInterceptor.setIncludedDestinations("/topic/**");
    this.brokerChannelInterceptor.startRecording();

    this.clientInboundChannel.send(message);

    Message<?> reply = this.brokerChannelInterceptor.awaitMessage(5);
    assertNotNull(reply);
    //Wrap the response in a header accessor
    StompHeaderAccessor replyHeaders = StompHeaderAccessor.wrap(reply);
    //Make sure the message was sent to the correct topic (sessionUuid from above)
    assertEquals(String.format("/topic/%s",this.sessionUuid), replyHeaders.getDestination());
    //Unescape/unquote the string
    String json = new String((byte[]) reply.getPayload(), "UTF-8");
    //json = json.substring(1, json.length()-1);
    //Verify the data
    new JsonPathExpectationsHelper("type").assertValue(json, "data");
    new JsonPathExpectationsHelper("data").assertValue(json, "THIS IS SOME DATA");
}
 
开发者ID:wieden-kennedy,项目名称:composite-framework,代码行数:25,代码来源:ContextCompositeTests.java


示例5: test09Stop

import org.springframework.test.util.JsonPathExpectationsHelper; //导入依赖的package包/类
@Test
public void test09Stop() throws Exception {
    Session session = this.sessionRepository.findByDeviceUuid(this.uuid);

    //Build the message
    Message<byte[]> message = this.createMessage("stop", String.format("/app/%s", session.getUuid()), session.getDevices().get(0).getUuid());

    this.brokerChannelInterceptor.setIncludedDestinations("/topic/**");
    this.brokerChannelInterceptor.startRecording();

    this.clientInboundChannel.send(message);

    Message<?> reply = this.brokerChannelInterceptor.awaitMessage(5);
    assertNotNull(reply);
    //Wrap the response in a header accessor
    StompHeaderAccessor replyHeaders = StompHeaderAccessor.wrap(reply);
    //Make sure the message was sent to the correct topic (sessionUuid from above)
    assertEquals(String.format("/topic/%s", session.getUuid()), replyHeaders.getDestination());
    //Unescape/unquote the string
    String json = new String((byte[]) reply.getPayload(), "UTF-8");
    //json = json.substring(1, json.length()-1);
    //Verify the data
    new JsonPathExpectationsHelper("type").assertValue(json, "stop");
}
 
开发者ID:wieden-kennedy,项目名称:composite-framework,代码行数:25,代码来源:ContextCompositeTests.java


示例6: getPositions

import org.springframework.test.util.JsonPathExpectationsHelper; //导入依赖的package包/类
@Test
public void getPositions() throws Exception {

 StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.SUBSCRIBE);
 headers.setSubscriptionId("0");
 headers.setDestination("/app/positions");
 headers.setSessionId("0");
 headers.setUser(new TestPrincipal("fabrice"));
 headers.setSessionAttributes(new HashMap<String, Object>());
 Message<byte[]> message = MessageBuilder.createMessage(new byte[0], headers.getMessageHeaders());

 this.clientOutboundChannelInterceptor.setIncludedDestinations("/app/positions");
 this.clientInboundChannel.send(message);

 Message<?> reply = this.clientOutboundChannelInterceptor.awaitMessage(5);
 assertNotNull(reply);

 StompHeaderAccessor replyHeaders = StompHeaderAccessor.wrap(reply);
 assertEquals("0", replyHeaders.getSessionId());
 assertEquals("0", replyHeaders.getSubscriptionId());
 assertEquals("/app/positions", replyHeaders.getDestination());

 String json = new String((byte[]) reply.getPayload(), Charset.forName("UTF-8"));
 new JsonPathExpectationsHelper("$[0].company").assertValue(json, "Citrix Systems, Inc.");
 new JsonPathExpectationsHelper("$[1].company").assertValue(json, "Dell Inc.");
 new JsonPathExpectationsHelper("$[2].company").assertValue(json, "Microsoft");
 new JsonPathExpectationsHelper("$[3].company").assertValue(json, "Oracle");
}
 
开发者ID:Appverse,项目名称:appverse-server,代码行数:29,代码来源:WebsocketTest.java


示例7: executeTrade

import org.springframework.test.util.JsonPathExpectationsHelper; //导入依赖的package包/类
@Test
public void executeTrade() throws Exception {

 Trade trade = new Trade();
 trade.setAction(Trade.TradeAction.Buy);
 trade.setTicker("DELL");
 trade.setShares(25);

 byte[] payload = new ObjectMapper().writeValueAsBytes(trade);

 StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.SEND);
 headers.setDestination("/app/trade");
 headers.setSessionId("0");
 headers.setUser(new TestPrincipal("fabrice"));
 headers.setSessionAttributes(new HashMap<String, Object>());
 Message<byte[]> message = MessageBuilder.createMessage(payload, headers.getMessageHeaders());

 this.brokerChannelInterceptor.setIncludedDestinations("/user/**");
 this.clientInboundChannel.send(message);

 Message<?> positionUpdate = this.brokerChannelInterceptor.awaitMessage(5);
 assertNotNull(positionUpdate);

 StompHeaderAccessor positionUpdateHeaders = StompHeaderAccessor.wrap(positionUpdate);
 assertEquals("/user/fabrice/queue/position-updates", positionUpdateHeaders.getDestination());

 String json = new String((byte[]) positionUpdate.getPayload(), Charset.forName("UTF-8"));
 new JsonPathExpectationsHelper("$.ticker").assertValue(json, "DELL");
 new JsonPathExpectationsHelper("$.shares").assertValue(json, 75);
}
 
开发者ID:Appverse,项目名称:appverse-server,代码行数:31,代码来源:WebsocketTest.java


示例8: test01Init

import org.springframework.test.util.JsonPathExpectationsHelper; //导入依赖的package包/类
@Test
public void test01Init() throws Exception {

    //Build the message (with a payload and headers)
    Message<byte[]> message = this.createMessage("init", "/app/init");

    this.brokerChannelInterceptor.setIncludedDestinations("/user/**");
    this.brokerChannelInterceptor.startRecording();

    this.clientInboundChannel.send(message);



    Message<?> reply = this.brokerChannelInterceptor.awaitMessage(5);
    assertNotNull(reply);

    //Wrap the response in a header accessor
    StompHeaderAccessor replyHeaders = StompHeaderAccessor.wrap(reply);
    //Make sure its the same session
    //assertEquals("0", replyHeaders.getSessionId());
    //Make sure the message was sent to the correct user (uuid from above)
    assertEquals(String.format("/user/%s/queue/device", this.uuid), replyHeaders.getDestination());
    //get the payload as string
    String json = new String((byte[]) reply.getPayload(), "UTF-8");
    new JsonPathExpectationsHelper("uuid").assertValue(json, this.uuid);
    new JsonPathExpectationsHelper("type").assertValue(json, "init");

}
 
开发者ID:wieden-kennedy,项目名称:composite-framework,代码行数:29,代码来源:ContextCompositeTests.java


示例9: test03Join

import org.springframework.test.util.JsonPathExpectationsHelper; //导入依赖的package包/类
@Test
public void test03Join() throws Exception {
    //Build the message (with a payload and headers)
    Message<byte[]> message = createMatchMessage("join", "/app/join", "0", UUID.fromString(this.uuid));

    this.brokerChannelInterceptor.setIncludedDestinations("/user/**");
    this.brokerChannelInterceptor.startRecording();

    this.clientInboundChannel.send(message);

    Message<?> joinReply = this.brokerChannelInterceptor.awaitMessage(5);
    // Getting back null for joinReply
    assertNotNull(joinReply);
    //Wrap the response in a header accessor
    StompHeaderAccessor replyHeaders = StompHeaderAccessor.wrap(joinReply);
    //Make sure its the same session
    //assertEquals("0", replyHeaders.getSessionId());
    //Make sure the message was sent to the correct user (uuid from above)
    assertEquals(String.format("/user/%s/queue/device", this.uuid), replyHeaders.getDestination());
    //Unescape/unquote the string
    String json = new String((byte[]) joinReply.getPayload(), "UTF-8");
    //json = json.substring(1, json.length()-1);
    //Make sure the devices are in the payload
    new JsonPathExpectationsHelper("id").exists(json);
    new JsonPathExpectationsHelper("devices").exists(json);
    new JsonPathExpectationsHelper("devices").assertValueIsArray(json);
    new JsonPathExpectationsHelper("type").assertValue(json, "join");
    new JsonPathExpectationsHelper("$devices.[-1:].uuid").assertValue(json, this.uuid);
}
 
开发者ID:wieden-kennedy,项目名称:composite-framework,代码行数:30,代码来源:ContextCompositeTests.java


示例10: JsonpPathResultMatchers

import org.springframework.test.util.JsonPathExpectationsHelper; //导入依赖的package包/类
/**
 * Protected constructor. Use {@link MockMvcResultMatchers#jsonPath(String, Object...)} or
 * {@link MockMvcResultMatchers#jsonPath(String, Matcher)}.
 */
public JsonpPathResultMatchers(String expression, Object... args) {

	this.jsonPathHelper = new JsonPathExpectationsHelper(expression, args);
}
 
开发者ID:bullhorn,项目名称:starter-kit-spring-maven,代码行数:9,代码来源:JsonpPathResultMatchers.java


示例11: test11Pair

import org.springframework.test.util.JsonPathExpectationsHelper; //导入依赖的package包/类
@Test
public void test11Pair() throws Exception {
    UUID user = UUID.randomUUID();

    //Build the message (with a payload and headers)
    Message<byte[]> message = createMatchMessage("pair", "/app/pair", "1", user);

    this.brokerChannelInterceptor.setIncludedDestinations("/user/**");
    this.brokerChannelInterceptor.startRecording();

    this.clientInboundChannel.send(message);

    Message<?> pairReply = this.brokerChannelInterceptor.awaitMessage(5);
    assertNotNull(pairReply);
    //Wrap the response in a header accessor
    StompHeaderAccessor replyHeaders = StompHeaderAccessor.wrap(pairReply);
    //Make sure its the same session
    //assertEquals("0", replyHeaders.getSessionId());
    //Make sure the message was sent to the correct user (uuid from above)
    assertEquals(String.format("/user/%s/queue/device", user.toString()), replyHeaders.getDestination());
    //Unescape/unquote the string
    String json = StringEscapeUtils.unescapeJava(new String((byte[]) pairReply.getPayload(), "UTF-8"));
    //json = json.substring(1, json.length()-1);
    //Make sure the devices are in the payload
    new JsonPathExpectationsHelper("id").exists(json);
    new JsonPathExpectationsHelper("devices").exists(json);
    new JsonPathExpectationsHelper("devices").assertValueIsArray(json);
    new JsonPathExpectationsHelper("type").assertValue(json, "pair");
    new JsonPathExpectationsHelper("$devices.[0].uuid").assertValue(json, user.toString());

    Thread.sleep(120);

    UUID user2 = UUID.randomUUID();

    //Build the message (with a payload and headers)
    Message<byte[]> message2 = createMatchMessage("pair", "/app/pair", "1", user2);

    this.brokerChannelInterceptor.setIncludedDestinations("/user/**");
    this.brokerChannelInterceptor.startRecording();

    this.clientInboundChannel.send(message2);

    Message<?> pairReply2 = this.brokerChannelInterceptor.awaitMessage(5);
    assertNotNull(pairReply2);
    //Wrap the response in a header accessor
    StompHeaderAccessor replyHeaders2 = StompHeaderAccessor.wrap(pairReply2);
    //Make sure its the same session
    //assertEquals("0", replyHeaders2.getSessionId());
    //Make sure the message was sent to the correct user (uuid from above)
    assertEquals(String.format("/user/%s/queue/device", user2.toString()), replyHeaders2.getDestination());
    //Unescape/unquote the string
    String json2 = new String((byte[]) pairReply2.getPayload(), "UTF-8");
    //json2 = json2.substring(1, json2.length()-1);
    //Make sure the devices are in the payload
    new JsonPathExpectationsHelper("id").exists(json2);
    new JsonPathExpectationsHelper("devices").exists(json2);
    new JsonPathExpectationsHelper("devices").assertValueIsArray(json2);
    new JsonPathExpectationsHelper("type").assertValue(json2, "pair");
    new JsonPathExpectationsHelper("$devices.[0].uuid").assertValue(json2, user.toString());
    new JsonPathExpectationsHelper("$devices.[1].uuid").assertValue(json2, user2.toString());

    this.clientInboundChannel.send(this.createMessage("disconnect", "/app/disconnect"));
    this.clientInboundChannel.send(this.createMessage("disconnect", "/app/disconnect", user2));
}
 
开发者ID:wieden-kennedy,项目名称:composite-framework,代码行数:65,代码来源:ContextCompositeTests.java


示例12: JsonPathResultMatchers

import org.springframework.test.util.JsonPathExpectationsHelper; //导入依赖的package包/类
/**
 * Protected constructor.
 * <p>Use {@link MockMvcResultMatchers#jsonPath(String, Object...)} or
 * {@link MockMvcResultMatchers#jsonPath(String, Matcher)}.
 * @param expression the {@link JsonPath} expression; never {@code null} or empty
 * @param args arguments to parameterize the {@code JsonPath} expression with,
 * using formatting specifiers defined in {@link String#format(String, Object...)}
 */
protected JsonPathResultMatchers(String expression, Object ... args) {
	this.jsonPathHelper = new JsonPathExpectationsHelper(expression, args);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:12,代码来源:JsonPathResultMatchers.java


示例13: JsonPathRequestMatchers

import org.springframework.test.util.JsonPathExpectationsHelper; //导入依赖的package包/类
/**
 * Protected constructor.
 * <p>Use {@link MockRestRequestMatchers#jsonPath(String, Matcher)} or
 * {@link MockRestRequestMatchers#jsonPath(String, Object...)}.
 * @param expression the {@link JsonPath} expression; never {@code null} or empty
 * @param args arguments to parameterize the {@code JsonPath} expression with,
 * using formatting specifiers defined in {@link String#format(String, Object...)}
 */
protected JsonPathRequestMatchers(String expression, Object ... args) {
	this.jsonPathHelper = new JsonPathExpectationsHelper(expression, args);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:12,代码来源:JsonPathRequestMatchers.java


示例14: JsonPathResultMatchers

import org.springframework.test.util.JsonPathExpectationsHelper; //导入依赖的package包/类
/**
 * Protected constructor. Use
 * {@link MockMvcResultMatchers#jsonPath(String, Object...)} or
 * {@link MockMvcResultMatchers#jsonPath(String, Matcher)}.
 */
protected JsonPathResultMatchers(String expression, Object ... args) {
	this.jsonPathHelper = new JsonPathExpectationsHelper(expression, args);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:9,代码来源:JsonPathResultMatchers.java


示例15: JsonPathRequestMatchers

import org.springframework.test.util.JsonPathExpectationsHelper; //导入依赖的package包/类
/**
 * Class constructor, not for direct instantiation. Use
 * {@link MockRestRequestMatchers#jsonPath(String, Matcher)} or
 * {@link MockRestRequestMatchers#jsonPath(String, Object...)}.
 *
 * @param expression the JSONPath expression
 * @param args arguments to parameterize the JSONPath expression with using
 * the formatting specifiers defined in
 * {@link String#format(String, Object...)}
 */
protected JsonPathRequestMatchers(String expression, Object ... args) {
	this.jsonPathHelper = new JsonPathExpectationsHelper(expression, args);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:14,代码来源:JsonPathRequestMatchers.java



注:本文中的org.springframework.test.util.JsonPathExpectationsHelper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ActionManager类代码示例发布时间:2022-05-23
下一篇:
Java CPacketTabComplete类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap