use of org.apache.zookeeper.server.command.StatCommand in project zookeeper by apache.
the class StatCommandTest method setUp.
@Before
public void setUp() throws IOException {
outputWriter = new StringWriter();
ServerCnxn serverCnxnMock = mock(ServerCnxn.class);
LeaderZooKeeperServer zks = mock(LeaderZooKeeperServer.class);
when(zks.isRunning()).thenReturn(true);
providerMock = mock(ServerStats.Provider.class);
when(zks.serverStats()).thenReturn(new ServerStats(providerMock));
ZKDatabase zkDatabaseMock = mock(ZKDatabase.class);
when(zks.getZKDatabase()).thenReturn(zkDatabaseMock);
Leader leaderMock = mock(Leader.class);
when(leaderMock.getProposalStats()).thenReturn(new ProposalStats());
when(zks.getLeader()).thenReturn(leaderMock);
ServerCnxnFactory serverCnxnFactory = mock(ServerCnxnFactory.class);
ServerCnxn serverCnxn = mock(ServerCnxn.class);
List<ServerCnxn> connections = new ArrayList<>();
connections.add(serverCnxn);
when(serverCnxnFactory.getConnections()).thenReturn(connections);
statCommand = new StatCommand(new PrintWriter(outputWriter), serverCnxnMock, FourLetterCommands.statCmd);
statCommand.setZkServer(zks);
statCommand.setFactory(serverCnxnFactory);
}
Aggregations