本文整理汇总了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");
}
示例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");
}
示例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);
}
示例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();
}
示例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;
}
示例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;
}
示例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();
}
示例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");
}
示例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");
}
示例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;
}
示例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));
}
示例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;
}