Пример #1
0
 public void writeStreamToSession(InputStream stream) throws Exception {
   int bufSize = 10;
   int size = 0;
   byte[] bytes = new byte[bufSize];
   //            ProtocolDecoder decoder = new BinkDataDecoder();
   while ((size = stream.read(bytes)) != -1) {
     IoBuffer buf = IoBuffer.allocate(size);
     buf.put(bytes, 0, size);
     buf.flip();
     // decoder.decode(session, buf, session.getDecoderOutput());
     session.getFilterChain().fireMessageReceived(buf);
     Thread.sleep(100);
   }
   Thread.sleep(1000);
   sessionContext.setState(SessionState.STATE_END);
 }
Пример #2
0
 @Test
 public void testBaseFlow() throws InterruptedException {
   StationConfig config =
       new StationConfig(
           "Test Station", "Vasya Pupkin", "Odessa, Ukraine", "BINKP", "2:467/110.113");
   final FTNAddr node = new FTNAddr("2:467/110");
   LinksInfo linksInfo =
       new LinksInfo(
           new LinkedList<Link>() {
             {
               add(
                   new Link(
                       node,
                       new LinkedList<FTNAddr>() {
                         {
                           add(new FTNAddr("2:467/110.113"));
                         }
                       },
                       "pass_i_f",
                       "localhost",
                       24554));
             }
           });
   linksInfo.setCurLink(node);
   SessionContext sessionContext = new SessionContext(config, linksInfo);
   sessionContext.getStationConfig().setCryptMode(true);
   ClientMock clientMock = new ClientMock(sessionContext);
   registerEvents(clientMock);
   Thread thread = new Thread(clientMock);
   thread.start();
   thread.join();
   FileInfo fileInfo = sessionContext.getRecvFiles().peek().getInfo();
   Assert.assertEquals("0000FF8F.WE5", fileInfo.getName());
   Assert.assertEquals(766, fileInfo.getSize());
   Assert.assertEquals(true, fileInfo.isFinished());
   Assert.assertEquals(true, connected);
   Assert.assertEquals(true, disconnected);
   Assert.assertEquals(true, fileReceived);
 }