Search in sources :

Example 1 with StatCommand

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);
}
Also used : ArrayList(java.util.ArrayList) ZKDatabase(org.apache.zookeeper.server.ZKDatabase) ServerCnxn(org.apache.zookeeper.server.ServerCnxn) StringWriter(java.io.StringWriter) ServerStats(org.apache.zookeeper.server.ServerStats) StatCommand(org.apache.zookeeper.server.command.StatCommand) ServerCnxnFactory(org.apache.zookeeper.server.ServerCnxnFactory) PrintWriter(java.io.PrintWriter) Before(org.junit.Before)

Aggregations

PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 ArrayList (java.util.ArrayList)1 ServerCnxn (org.apache.zookeeper.server.ServerCnxn)1 ServerCnxnFactory (org.apache.zookeeper.server.ServerCnxnFactory)1 ServerStats (org.apache.zookeeper.server.ServerStats)1 ZKDatabase (org.apache.zookeeper.server.ZKDatabase)1 StatCommand (org.apache.zookeeper.server.command.StatCommand)1 Before (org.junit.Before)1