当前位置: 首页>>代码示例>>Java>>正文


Java Publisher类代码示例

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


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

示例1: testRemovingAnUnknownClient

import org.wisdom.api.http.websockets.Publisher; //导入依赖的package包/类
@Test
public void testRemovingAnUnknownClient() {
    message = null;
    Json json = new JsonService();
    Publisher publisher = mock(Publisher.class);
    final Answer<Object> answer = new Answer<Object>() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            message = (String) invocation.getArguments()[2];
            return null;
        }
    };
    doAnswer(answer).when(publisher).send(anyString(), anyString(), anyString());

    WampController controller = new WampController(json, publisher, TestConstants.PREFIX);

    controller.close("unknown");
}
 
开发者ID:wisdom-framework,项目名称:wisdom-wamp,代码行数:19,代码来源:WampControllerTest.java

示例2: testMissingPrefix

import org.wisdom.api.http.websockets.Publisher; //导入依赖的package包/类
@Test
public void testMissingPrefix() {
    message = null;
    Json json = new JsonService();
    Publisher publisher = mock(Publisher.class);
    final Answer<Object> answer = new Answer<Object>() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            message = (String) invocation.getArguments()[2];
            return null;
        }
    };
    doAnswer(answer).when(publisher).send(anyString(), anyString(), anyString());

    WampController controller = new WampController(json, publisher, TestConstants.PREFIX);
    controller.open("id");
    assertThat(message).isNotNull();
    Map.Entry<String, WampClient> entry = controller.getClientById("id");
    assertThat(entry).isNotNull();
    assertThat(entry.getValue().getUri("calc:square")).isEqualTo("calc:square");
    assertThat(entry.getValue().getUri("http://perdu.com")).isEqualTo("http://perdu.com");
}
 
开发者ID:wisdom-framework,项目名称:wisdom-wamp,代码行数:23,代码来源:WampControllerPrefixTest.java

示例3: testThatWelcomeIsSent

import org.wisdom.api.http.websockets.Publisher; //导入依赖的package包/类
@Test
public void testThatWelcomeIsSent() {
    message = null;
    Json json = new JsonService();
    Publisher publisher = mock(Publisher.class);
    final Answer<Object> answer = new Answer<Object>() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            message = (String) invocation.getArguments()[2];
            return null;
        }
    };
    doAnswer(answer).when(publisher).send(anyString(), anyString(), anyString());

    WampController controller = new WampController(json, publisher, TestConstants.PREFIX);
    controller.open("id");
    assertThat(message).isNotNull();
    JsonNode node = json.parse(message);
    assertThat(node.isArray());
    assertThat(node.get(0).asInt()).isEqualTo(MessageType.WELCOME.code());
    assertThat(node.get(1).asText()).isNotNull();
    assertThat(node.get(2).asInt()).isEqualTo(Constants.WAMP_PROTOCOL_VERSION);
    assertThat(node.get(3).asText()).isEqualTo(Constants.WAMP_SERVER_VERSION);
}
 
开发者ID:wisdom-framework,项目名称:wisdom-wamp,代码行数:25,代码来源:WampControllerWelcomeTest.java

示例4: testThatWelcomeIsNotResent

import org.wisdom.api.http.websockets.Publisher; //导入依赖的package包/类
@Test
public void testThatWelcomeIsNotResent() {
    message = null;
    Json json = new JsonService();
    Publisher publisher = mock(Publisher.class);
    final Answer<Object> answer = new Answer<Object>() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            message = (String) invocation.getArguments()[2];
            return null;
        }
    };
    doAnswer(answer).when(publisher).send(anyString(), anyString(), anyString());

    WampController controller = new WampController(json, publisher, TestConstants.PREFIX);
    controller.open("id");
    assertThat(message).isNotNull();

    message = null;

    controller.open("id");
    assertThat(message).isNull();
}
 
开发者ID:wisdom-framework,项目名称:wisdom-wamp,代码行数:24,代码来源:WampControllerWelcomeTest.java

示例5: createWampControllerAndConnectClient

import org.wisdom.api.http.websockets.Publisher; //导入依赖的package包/类
private WampController createWampControllerAndConnectClient(Json json) {
    Publisher publisher = mock(Publisher.class);
    final Answer<Object> answer = new Answer<Object>() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            message = (String) invocation.getArguments()[2];
            return null;
        }
    };
    doAnswer(answer).when(publisher).send(anyString(), anyString(), anyString());

    WampController controller = new WampController(json, publisher, TestConstants.PREFIX);
    controller.open("id");
    assertThat(message).isNotNull();
    return controller;
}
 
开发者ID:wisdom-framework,项目名称:wisdom-wamp,代码行数:17,代码来源:WampControllerRPCTest.java

示例6: createWampControllerAndConnectClient

import org.wisdom.api.http.websockets.Publisher; //导入依赖的package包/类
private WampController createWampControllerAndConnectClient(Json json) {
    Publisher publisher = mock(Publisher.class);
    final Answer<Object> answer = new Answer<Object>() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            message.add(0, (String) invocation.getArguments()[2]);
            return null;
        }
    };
    doAnswer(answer).when(publisher).send(anyString(), anyString(), anyString());

    WampController controller = new WampController(json, publisher, TestConstants.PREFIX);
    controller.ea = mock(EventAdmin.class);
    controller.open(CLIENT_ID);
    assertThat(message).isNotNull();
    return controller;
}
 
开发者ID:wisdom-framework,项目名称:wisdom-wamp,代码行数:18,代码来源:WampControllerPubSubTest.java

示例7: testClientManagement

import org.wisdom.api.http.websockets.Publisher; //导入依赖的package包/类
@Test
public void testClientManagement() {
    message = null;
    Json json = new JsonService();
    Publisher publisher = mock(Publisher.class);
    final Answer<Object> answer = new Answer<Object>() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            message = (String) invocation.getArguments()[2];
            return null;
        }
    };
    doAnswer(answer).when(publisher).send(anyString(), anyString(), anyString());

    WampController controller = new WampController(json, publisher, TestConstants.PREFIX);
    controller.open("id");
    assertThat(message).isNotNull();
    JsonNode node = json.parse(message);
    assertThat(node.isArray());
    assertThat(node.get(0).asInt()).isEqualTo(MessageType.WELCOME.code());
    assertThat(node.get(1).asText()).isNotNull();
    assertThat(node.get(2).asInt()).isEqualTo(Constants.WAMP_PROTOCOL_VERSION);
    assertThat(node.get(3).asText()).isEqualTo(Constants.WAMP_SERVER_VERSION);

    assertThat(controller.getClientById("id")).isNotNull();

    controller.close("id");

    assertThat(controller.getClientById("id")).isNull();
    assertThat(controller.getClientById("id2")).isNull();

}
 
开发者ID:wisdom-framework,项目名称:wisdom-wamp,代码行数:33,代码来源:WampControllerTest.java

示例8: testPrefix

import org.wisdom.api.http.websockets.Publisher; //导入依赖的package包/类
@Test
public void testPrefix() {
    message = null;
    Json json = new JsonService();
    Publisher publisher = mock(Publisher.class);
    final Answer<Object> answer = new Answer<Object>() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            message = (String) invocation.getArguments()[2];
            return null;
        }
    };
    doAnswer(answer).when(publisher).send(anyString(), anyString(), anyString());

    WampController controller = new WampController(json, publisher, TestConstants.PREFIX);
    controller.open("id");
    assertThat(message).isNotNull();

    ArrayNode prefix = json.newArray();
    prefix.add(MessageType.PREFIX.code());
    prefix.add("calc");
    prefix.add("http://example.com/simple/calc#");
    controller.onMessage("id", prefix);

    Map.Entry<String, WampClient> entry = controller.getClientById("id");
    assertThat(entry).isNotNull();
    assertThat(entry.getValue().getUri("calc:square")).isEqualTo("http://example.com/simple/calc#square");
    assertThat(entry.getValue().getUri("http://perdu.com")).isEqualTo("http://perdu.com");
}
 
开发者ID:wisdom-framework,项目名称:wisdom-wamp,代码行数:30,代码来源:WampControllerPrefixTest.java

示例9: testPrefixFromUnknownClient

import org.wisdom.api.http.websockets.Publisher; //导入依赖的package包/类
@Test
public void testPrefixFromUnknownClient() {
    message = null;
    Json json = new JsonService();
    Publisher publisher = mock(Publisher.class);
    final Answer<Object> answer = new Answer<Object>() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            message = (String) invocation.getArguments()[2];
            return null;
        }
    };
    doAnswer(answer).when(publisher).send(anyString(), anyString(), anyString());

    WampController controller = new WampController(json, publisher, TestConstants.PREFIX);
    controller.open("id");
    assertThat(message).isNotNull();

    ArrayNode prefix = json.newArray();
    prefix.add(MessageType.PREFIX.code());
    prefix.add("calc");
    prefix.add("http://example.com/simple/calc#");
    controller.onMessage("unknown", prefix);

    Map.Entry<String, WampClient> entry = controller.getClientById("id");
    assertThat(entry).isNotNull();
    assertThat(entry.getValue().getUri("calc:square")).isNotEqualTo("http://example.com/simple/calc#square");
    assertThat(entry.getValue().getUri("http://perdu.com")).isEqualTo("http://perdu.com");
}
 
开发者ID:wisdom-framework,项目名称:wisdom-wamp,代码行数:30,代码来源:WampControllerPrefixTest.java

示例10: WisitOutputStream

import org.wisdom.api.http.websockets.Publisher; //导入依赖的package包/类
public WisitOutputStream(final Publisher publisher, final String topic,OutputType outputType) {
    if(publisher == null || topic == null || outputType == null){
        throw new IllegalArgumentException("publisher, topic and outputType cannot be null");
    }

    this.publisher = publisher;
    this.topic = topic;
    this.myType = outputType;
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:10,代码来源:WisitOutputStream.java

示例11: WisitSession

import org.wisdom.api.http.websockets.Publisher; //导入依赖的package包/类
/**
 * Create a new WisitSession.
 * @param processor The CommandProcessor used in order to create the commandSession.
 * @param publisher The websocket publisher on which the asynchronous commandResult will be broadcast.
 * @param topic The websocket topic.
 */
public WisitSession(final CommandProcessor processor,final Publisher publisher,final String topic) {
    WisitOutputStream resultStream = new WisitOutputStream(publisher,topic);
    WisitOutputStream errorStream = new WisitOutputStream(publisher,topic, ERR);

    shellSession = processor.createSession(null, new PrintStream(resultStream,true),
                                                 new PrintStream(errorStream,true));
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:14,代码来源:WisitSession.java

示例12: WampController

import org.wisdom.api.http.websockets.Publisher; //导入依赖的package包/类
/**
 * Constructor used for testing purpose only.
 * Do not use directly outside the test scope.
 *
 * @param json      the json service
 * @param publisher the publisher
 * @param prefix    the  url prefix
 */
public WampController(Json json, Publisher publisher, String prefix) {
    this.json = json;
    this.publisher = publisher;
    this.prefix = prefix;
    this.errorPrefix = prefix + Constants.WAMP_ERROR;
}
 
开发者ID:wisdom-framework,项目名称:wisdom-wamp,代码行数:15,代码来源:WampController.java


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