public void testNewProjectCreationFirstNoConnection() throws Exception {
@SuppressWarnings("unused")
List<GerritServer> servers = PluginImpl.getInstance().getServers();
//create a server for testing
GerritServer server = new GerritServer(PluginImpl.DEFAULT_SERVER_NAME);
servers.add(server);
server.start();
createGerritTriggeredJob(j, "testJob4");
GerritHandler handler = Whitebox.getInternalState(server, GerritHandler.class);
assertNotNull(handler);
GerritConnection connection = Whitebox.getInternalState(server, GerritConnection.class);
assertNull(connection);
Collection<GerritEventListener> savedEventListeners =
Whitebox.getInternalState(handler, "gerritEventListeners");
// DependencyQueueTaskDispatcher adds 1 listener
// ReplicationQueueTaskDispatcher adds 1 listener
assertEquals(3, savedEventListeners.size());
Config config = (Config)server.getConfig();
config.setGerritAuthKeyFile(keyFile.getPublicKey());
config.setGerritHostName("localhost");
config.setGerritFrontEndURL("http://localhost");
config.setGerritSshPort(29418);
config.setGerritProxy("");
server.startConnection();
handler = Whitebox.getInternalState(server, GerritHandler.class);
Collection<GerritEventListener> gerritEventListeners =
Whitebox.getInternalState(handler, "gerritEventListeners");
// DependencyQueueTaskDispatcher adds 1 listener