Search in sources :

Example 1 with DefaultBadWord

use of org.qiunet.function.badword.DefaultBadWord in project DuoDuo by qiunet.

the class TestWebsocketBootstrap method testProtobufWebSocket.

@Test
public void testProtobufWebSocket() throws InterruptedException {
    LoadBadWordEventData.valueOf(new DefaultBadWord(Lists.newArrayList("毛泽东"))).fireEventHandler();
    text = "test [testProtobufWebSocket]";
    IChannelMessageSender client = NettyWebSocketClient.create(WebSocketClientParams.custom().setAddress("localhost", port).build(), new ResponseTrigger());
    WsPbLoginRequest request = WsPbLoginRequest.valueOf(text, text, 11);
    latch = new CountDownLatch(1);
    client.sendMessage(request);
    latch.await();
}
Also used : DefaultBadWord(org.qiunet.function.badword.DefaultBadWord) IPersistConnResponseTrigger(org.qiunet.flash.handler.netty.client.trigger.IPersistConnResponseTrigger) WsPbLoginRequest(org.qiunet.test.handler.proto.WsPbLoginRequest) CountDownLatch(java.util.concurrent.CountDownLatch) IChannelMessageSender(org.qiunet.flash.handler.context.sender.IChannelMessageSender) Test(org.junit.jupiter.api.Test)

Example 2 with DefaultBadWord

use of org.qiunet.function.badword.DefaultBadWord in project DuoDuo by qiunet.

the class TestBadWord method testBadWord.

@Test
public void testBadWord() {
    DefaultBadWord defaultBadWord = new DefaultBadWord(new String[] { "柟", "王岐山", "王玉刚", "毛泽东", "fuck", "www.qq.com" });
    LoadBadWordEventData.valueOf(defaultBadWord).fireEventHandler();
    Assertions.assertEquals("毛泽东", BadWordFilter.instance.powerFind("sss毛2泽3东7--"));
    Assertions.assertEquals("fuck", BadWordFilter.instance.powerFind("sss毛fuck东7--"));
    Assertions.assertEquals(null, BadWordFilter.instance.powerFind("王小川"));
    Assertions.assertEquals("柟", BadWordFilter.instance.find("sss王柟山7--"));
    Assertions.assertEquals("王岐山", BadWordFilter.instance.find("s王ss王岐山7--"));
    Assertions.assertEquals("ss王s****7我****--", BadWordFilter.instance.powerFilter("ss王s王s#岐&&山7我毛~泽~东--"));
    Assertions.assertEquals("ss王s***7我***--", BadWordFilter.instance.doFilter("ss王s王岐山7我毛泽东--"));
    Assertions.assertEquals("访问**********就行", BadWordFilter.instance.doFilter("访问www.qq.com就行"));
}
Also used : DefaultBadWord(org.qiunet.function.badword.DefaultBadWord) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)2 DefaultBadWord (org.qiunet.function.badword.DefaultBadWord)2 CountDownLatch (java.util.concurrent.CountDownLatch)1 IChannelMessageSender (org.qiunet.flash.handler.context.sender.IChannelMessageSender)1 IPersistConnResponseTrigger (org.qiunet.flash.handler.netty.client.trigger.IPersistConnResponseTrigger)1 WsPbLoginRequest (org.qiunet.test.handler.proto.WsPbLoginRequest)1