### Question:
TcpTcDataLink extends AbstractThreadedTcDataLink { public void init(String yamcsInstance, String name, YConfiguration config) throws ConfigurationException { super.init(yamcsInstance, name, config); configure(yamcsInstance, config); timeService = YamcsServer.getTimeService(yamcsInstance); }  void init(String yamcsInstance, String name, YConfiguration config); @Override String getDetailedStatus(); @Override void shutDown(); @Override void uplinkCommand(PreparedCommand pc);  }### Answer:
@Test public void testTcpTcMaxRate() throws ConfigurationException, InterruptedException, IOException { int ncommands = 20; int tcMaxRate = 2; Map<String, Object> config = new HashMap<>(); config.put("tcMaxRate", tcMaxRate); config.put("tcQueueSize", ncommands); config.put("tcHost", "localhost"); config.put("tcPort", mtc.port); config.put("commandPostprocessorClassName", GenericCommandPostprocessor.class.getName()); TcpTcDataLink dataLink = new TcpTcDataLink(); dataLink.init("testinst", "test1", YConfiguration.wrap(config)); Semaphore semaphore = new Semaphore(0); MyPublisher mypub = new MyPublisher(semaphore); dataLink.setCommandHistoryPublisher(mypub); dataLink.startAsync(); dataLink.awaitRunning(); for (int i = 1; i <= ncommands; i++) { dataLink.sendTc(getCommand(i)); } assertTrue(semaphore.tryAcquire(ncommands, 10, TimeUnit.SECONDS)); assertTrue("Number of commands sent is smaller than queue size: ", mypub.successful.size() >= ncommands); for (int i = 5; i < mypub.successful.size() - tcMaxRate; i++) { int seq1 = mypub.successful.get(i); int seq2 = mypub.successful.get(i + tcMaxRate); long gap = mypub.sentTime.get(seq2) - mypub.sentTime.get(seq1); assertTrue("gap is not right: " + gap, gap >= 850 && gap < 1150); } dataLink.stopAsync(); }
@Test public void testTcpTcDefault() throws ConfigurationException, InterruptedException, IOException { Map<String, Object> config = new HashMap<>(); config.put("tcHost", "localhost"); config.put("tcPort", mtc.port); config.put("commandPostprocessorClassName", GenericCommandPostprocessor.class.getName()); TcpTcDataLink dataLink = new TcpTcDataLink(); dataLink.init("testinst", "test1", YConfiguration.wrap(config)); Semaphore semaphore = new Semaphore(0); MyPublisher mypub = new MyPublisher(semaphore); dataLink.setCommandHistoryPublisher(mypub); dataLink.startAsync(); dataLink.awaitRunning(); for (int i = 1; i <= 1000; i++) { dataLink.sendTc(getCommand(i)); } assertTrue(semaphore.tryAcquire(1000, 300, TimeUnit.SECONDS)); assertEquals(1000, mypub.successful.size()); dataLink.stopAsync(); }