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


Java ByteString.fromString方法代码示例

本文整理汇总了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);
}
 
开发者ID:connor4312,项目名称:HubSub,代码行数:22,代码来源:PoolTest.java

示例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);
}
 
开发者ID:connor4312,项目名称:HubSub,代码行数:21,代码来源:PoolTest.java

示例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);
}
 
开发者ID:connor4312,项目名称:HubSub,代码行数:20,代码来源:PoolTest.java

示例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);
}
 
开发者ID:connor4312,项目名称:HubSub,代码行数:22,代码来源:PoolTest.java

示例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);
}
 
开发者ID:connor4312,项目名称:HubSub,代码行数:28,代码来源:PoolTest.java

示例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"));
}
 
开发者ID:connor4312,项目名称:HubSub,代码行数:10,代码来源:PoolTest.java

示例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);
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:39,代码来源:SSLHandlerTest.java

示例8: createPacket

import akka.util.ByteString; //导入方法依赖的package包/类
public static ByteString createPacket(ATCommand atcommand) {
    return ByteString.fromString(atcommand.toString());
}
 
开发者ID:ugent-cros,项目名称:cros-core,代码行数:4,代码来源:PacketCreator.java

示例9: buildPacket

import akka.util.ByteString; //导入方法依赖的package包/类
public static ByteString buildPacket(ATCommand packet) {
    return ByteString.fromString(packet.toString());
}
 
开发者ID:ugent-cros,项目名称:cros-core,代码行数:4,代码来源:PacketHelper.java


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