本文整理汇总了Java中akka.util.ByteString.fromString方法的典型用法代码示例。如果您正苦于以下问题:Java ByteString.fromString方法的具体用法?Java ByteString.fromString怎么用?Java ByteString.fromString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类akka.util.ByteString
的用法示例。
在下文中一共展示了ByteString.fromString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBasic
import akka.util.ByteString; //导入方法依赖的package包/类
@Test
public void testBasic() throws Exception {
Pool p = new Pool();
Publishable pub1 = mock(Publishable.class);
Publishable pub2 = mock(Publishable.class);
p.subscribe("asdf", pub1);
Event ev1 = new Event("asdf", ByteString.fromString("hello"));
Event ev2 = new Event("wasd", ByteString.fromString("hello"));
Event ev3 = new Event("asdf", ByteString.fromString("bye"));
p.publish(ev1);
p.publish(ev2);
p.subscribe("asdf", pub2);
p.publish(ev3);
verify(pub1).publish(ev1);
verify(pub1, never()).publish(ev2);
verify(pub1).publish(ev3);
verify(pub2).publish(ev3);
}
示例2: testPatterns
import akka.util.ByteString; //导入方法依赖的package包/类
@Test
public void testPatterns() throws Exception {
Pool p = new Pool();
Publishable pub1 = mock(Publishable.class);
Publishable pub2 = mock(Publishable.class);
p.psubscribe("h?llo", pub1);
p.psubscribe("h*llo", pub2);
Event ev1 = new Event("hello", ByteString.fromString("hello"));
p.publish(ev1);
verify(pub1).publish(ev1);
verify(pub2).publish(ev1);
Event ev2 = new Event("heeello", ByteString.fromString("hello"));
p.publish(ev2);
verify(pub1, never()).publish(ev2);
verify(pub2).publish(ev2);
}
示例3: testMixes
import akka.util.ByteString; //导入方法依赖的package包/类
@Test
public void testMixes() throws Exception {
Pool p = new Pool();
Publishable pub1 = mock(Publishable.class);
p.psubscribe("h[e]llo", pub1);
Publishable pub2 = mock(Publishable.class);
p.subscribe("h[e]llo", pub2);
Event ev1 = new Event("h[e]llo", ByteString.fromString("hello"));
p.publish(ev1);
verify(pub1, never()).publish(ev1);
verify(pub2).publish(ev1);
Event ev2 = new Event("hello", ByteString.fromString("hello"));
p.publish(ev2);
verify(pub1).publish(ev2);
verify(pub2, never()).publish(ev2);
}
示例4: testAddsToExisting
import akka.util.ByteString; //导入方法依赖的package包/类
@Test
public void testAddsToExisting() throws Exception {
Pool p = new Pool();
Publishable pub1 = mock(Publishable.class);
Publishable pub2 = mock(Publishable.class);
p.subscribe("a", pub1);
p.subscribe("a", pub2);
Event ev1 = new Event("a", ByteString.fromString("hello"));
p.publish(ev1);
verify(pub1).publish(ev1);
verify(pub2).publish(ev1);
p.unsubscribe(pub1);
Event ev2 = new Event("a", ByteString.fromString("hello"));
p.publish(ev2);
verify(pub1, never()).publish(ev2);
verify(pub2).publish(ev2);
}
示例5: testUnsubscribes
import akka.util.ByteString; //导入方法依赖的package包/类
@Test
public void testUnsubscribes() throws Exception {
Pool p = new Pool();
Publishable pub1 = mock(Publishable.class);
p.subscribe("a", pub1);
p.subscribe("b", pub1);
Event ev1 = new Event("a", ByteString.fromString("hello"));
p.publish(ev1);
verify(pub1).publish(ev1);
p.unsubscribe("a", pub1);
Event ev2 = new Event("a", ByteString.fromString("hello"));
p.publish(ev2);
verify(pub1, never()).publish(ev2);
Event ev3 = new Event("b", ByteString.fromString("hello"));
p.publish(ev3);
verify(pub1).publish(ev3);
p.unsubscribe(pub1);
Event ev4 = new Event("b", ByteString.fromString("hello"));
p.publish(ev4);
verify(pub1, never()).publish(ev4);
}
示例6: testEventEncodes
import akka.util.ByteString; //导入方法依赖的package包/类
@Test
public void testEventEncodes() {
Event ev1 = new Event("a", ByteString.fromString("hello"));
assertThat(ev1.packet().encode().utf8String(), is("*3\r\n" +
"$7\r\nmessage\r\n" +
"$1\r\na\r\n" +
"$5\r\nhello\r\n"));
}
示例7: testTranceiving
import akka.util.ByteString; //导入方法依赖的package包/类
@Test
public void testTranceiving() throws Exception {
ActorRef clientConnection = actorSystem.actorOf(ConnectionMock.props(), "client-connection");
ActorRef clientListener = actorSystem.actorOf(Receiver.props(), "client-listener");
ActorRef clientHandler = actorSystem.actorOf(
SSLHandler.props(clientConfig, false, clientConnection, clientListener),
"client-handler");
ActorRef serverConnection = actorSystem.actorOf(ConnectionMock.props(), "server-connection");
ActorRef serverListener = actorSystem.actorOf(Receiver.props(), "server-listener");
ActorRef serverHandler = actorSystem.actorOf(
SSLHandler.props(serverConfig, true, serverConnection, serverListener),
"server-handler");
clientConnection.tell(TcpMessage.register(clientHandler), clientHandler);
serverConnection.tell(TcpMessage.register(serverHandler), serverHandler);
serverConnection.tell(new Sync(), clientConnection);
final int repeatCount = 1000;
ByteString message = ByteString.empty();
ByteString messagePart = ByteString.fromString("Hello world!");
for(int i = 0; i < repeatCount; i++) {
clientHandler.tell(TcpMessage.write(messagePart), clientListener);
message = message.concat(messagePart);
}
ByteString received = f.ask(serverListener, new GetReceived(message.size()), ByteString.class).get();
assertEquals(received, message);
for(int i = 0; i < repeatCount; i++) {
serverHandler.tell(TcpMessage.write(messagePart), serverListener);
}
received = f.ask(clientListener, new GetReceived(message.size()), ByteString.class).get();
assertEquals(received, message);
}
示例8: createPacket
import akka.util.ByteString; //导入方法依赖的package包/类
public static ByteString createPacket(ATCommand atcommand) {
return ByteString.fromString(atcommand.toString());
}
示例9: buildPacket
import akka.util.ByteString; //导入方法依赖的package包/类
public static ByteString buildPacket(ATCommand packet) {
return ByteString.fromString(packet.toString());
}