Package com.sonyericsson.hudson.plugins.gerrit.trigger

Examples of com.sonyericsson.hudson.plugins.gerrit.trigger.GerritServer


     *
     * @throws Exception if so.
     */
    @LocalData
    public void testNotBuildLatestPatchsetOnly() throws Exception {
        GerritServer gerritServer = PluginImpl.getInstance().getServer(PluginImpl.DEFAULT_SERVER_NAME);
        ((Config)gerritServer.getConfig()).setGerritBuildCurrentPatchesOnly(false);
        FreeStyleProject project = DuplicatesUtil.createGerritTriggeredJob(j, "projectX");
        project.getBuildersList().add(new SleepBuilder(2000));
        server.waitForCommand(GERRIT_STREAM_EVENTS, 2000);
        ManualPatchsetCreated firstEvent = Setup.createManualPatchsetCreated();
        AtomicReference<AbstractBuild> firstBuildRef = TestUtils.getFutureBuildToStart(firstEvent);
        gerritServer.triggerEvent(firstEvent);
        AbstractBuild firstBuild = TestUtils.waitForBuildToStart(firstBuildRef);
        PatchsetCreated secondEvent = Setup.createPatchsetCreated();
        if (null != secondEvent.getPatchSet()) {
            secondEvent.getPatchSet().setNumber("2");
        }
        gerritServer.triggerEvent(secondEvent);
        TestUtils.waitForBuilds(project, 2);
        assertEquals(2, project.getLastCompletedBuild().getNumber());
        assertSame(Result.SUCCESS, firstBuild.getResult());
        assertSame(Result.SUCCESS, project.getFirstBuild().getResult());
        assertSame(Result.SUCCESS, project.getLastBuild().getResult());
View Full Code Here


     *
     * @throws Exception if so.
     */
    @LocalData
    public void testTriggerOnCommentAdded() throws Exception {
        GerritServer gerritServer = PluginImpl.getInstance().getServer(PluginImpl.DEFAULT_SERVER_NAME);
        gerritServer.getConfig().setCategories(Setup.createCodeReviewVerdictCategoryList());
        FreeStyleProject project = DuplicatesUtil.createGerritTriggeredJobForCommentAdded(j, "projectX");
        project.getBuildersList().add(new SleepBuilder(2000));
        server.waitForCommand(GERRIT_STREAM_EVENTS, 2000);
        CommentAdded firstEvent = Setup.createCommentAdded();
        gerritServer.triggerEvent(firstEvent);
        TestUtils.waitForBuilds(project, 1);
        assertEquals(1, project.getLastCompletedBuild().getNumber());
        assertSame(Result.SUCCESS, project.getLastCompletedBuild().getResult());
    }
View Full Code Here

     *
     * @throws Exception if so.
     */
    @LocalData
    public void testDoubleTriggeredOnCommentAdded() throws Exception {
        GerritServer gerritServer = PluginImpl.getInstance().getServer(PluginImpl.DEFAULT_SERVER_NAME);
        gerritServer.getConfig().setCategories(Setup.createCodeReviewVerdictCategoryList());
        FreeStyleProject project = DuplicatesUtil.createGerritTriggeredJobForCommentAdded(j, "projectX");
        project.getBuildersList().add(new SleepBuilder(2000));
        server.waitForCommand(GERRIT_STREAM_EVENTS, 2000);

        gerritServer.triggerEvent(Setup.createCommentAdded());
        gerritServer.triggerEvent(Setup.createCommentAdded());
        TestUtils.waitForBuilds(project, 1);
        assertEquals(1, project.getLastCompletedBuild().getNumber());
        assertSame(Result.SUCCESS, project.getLastCompletedBuild().getResult());
    }
View Full Code Here

    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
View Full Code Here

     * Tests that a triggered build in silent start mode does not emit any build started messages.
     * @throws Exception if so.
     */
    @LocalData
    public void testTriggeredSilentStartModeBuild() throws Exception {
        GerritServer gerritServer = PluginImpl.getInstance().getServer(PluginImpl.DEFAULT_SERVER_NAME);
        ((Config)gerritServer.getConfig()).setDynamicConfigRefreshInterval(1);
        FreeStyleProject project = DuplicatesUtil.createGerritDynamicTriggeredJob(j, "projectX");

        GerritTrigger trigger = project.getTrigger(GerritTrigger.class);
        trigger.setSilentStartMode(true);

        server.waitForCommand(GERRIT_STREAM_EVENTS, 2000);
        waitForDynamicTimer(project, 5000);
        gerritServer.triggerEvent(Setup.createPatchsetCreated());
        TestUtils.waitForBuilds(project, 1, 5000);

        List<SshdServerMock.CommandMock> commands = server.getCommandHistory();
        for (int i = 0; i < commands.size(); i++) {
            String command = commands.get(i).getCommand();
View Full Code Here

        mockStatic(PluginImpl.class);
        PluginImpl plugin = mock(PluginImpl.class);
        when(PluginImpl.getInstance()).thenReturn(plugin);

        config = Setup.createConfig();
        GerritServer server = new GerritServer(PluginImpl.DEFAULT_SERVER_NAME);
        server.setConfig(config);
        when(plugin.getServer(eq(PluginImpl.DEFAULT_SERVER_NAME))).thenReturn(server);
        when(plugin.getFirstServer()).thenReturn(server);
    }
View Full Code Here

    @Before
    public void setup() {
        PluginImpl plugin = mock(PluginImpl.class);
        mockStatic(PluginImpl.class);
        when(PluginImpl.getInstance()).thenReturn(plugin);
        gerritServer = spy(new GerritServer(gerritServerName));
        doNothing().when(gerritServer).startConnection();
        when(plugin.getServers()).thenReturn(Arrays.asList(gerritServer));
    }
View Full Code Here

        AbstractProject project = PowerMockito.mock(AbstractProject.class);
        when(project.getFullDisplayName()).thenReturn("MockedProject");
        when(project.getFullName()).thenReturn("MockedProject");
        PowerMockito.mockStatic(PluginImpl.class);
        PluginImpl plugin = PowerMockito.mock(PluginImpl.class);
        GerritServer server = mock(GerritServer.class);
        IGerritHudsonTriggerConfig config = Setup.createConfig();
        config = spy(config);
        doReturn("http://mock.url").when(config).getGerritFrontEndUrlFor(any(String.class), any(String.class));
        when(plugin.getServer(any(String.class))).thenReturn(server);
        GerritHandler handler = mock(GerritHandler.class);
        when(plugin.getHandler()).thenReturn(handler);
        when(server.getConfig()).thenReturn(config);
        PowerMockito.when(PluginImpl.getInstance()).thenReturn(plugin);
        when(config.getBuildScheduleDelay()).thenReturn(20);

        GerritTrigger trigger = Setup.createDefaultTrigger(project);
        when(project.getTrigger(GerritTrigger.class)).thenReturn(trigger);
View Full Code Here

        AbstractProject project = PowerMockito.mock(AbstractProject.class);
        when(project.getFullDisplayName()).thenReturn("MockedProject");
        when(project.getFullName()).thenReturn("MockedProject");
        PowerMockito.mockStatic(PluginImpl.class);
        PluginImpl plugin = PowerMockito.mock(PluginImpl.class);
        GerritServer server = mock(GerritServer.class);
        when(plugin.getServer(any(String.class))).thenReturn(server);
        IGerritHudsonTriggerConfig config = Setup.createConfig();
        config = spy(config);
        doReturn("http://mock.url").when(config).getGerritFrontEndUrlFor(any(String.class), any(String.class));
        when(server.getConfig()).thenReturn(config);
        GerritHandler handler = mock(GerritHandler.class);
        when(plugin.getHandler()).thenReturn(handler);
        PowerMockito.when(PluginImpl.getInstance()).thenReturn(plugin);
        when(config.getBuildScheduleDelay()).thenReturn(-20);
View Full Code Here

        AbstractProject project = PowerMockito.mock(AbstractProject.class);
        when(project.getFullDisplayName()).thenReturn("MockedProject");
        when(project.getFullName()).thenReturn("MockedProject");
        PowerMockito.mockStatic(PluginImpl.class);
        PluginImpl plugin = PowerMockito.mock(PluginImpl.class);
        GerritServer server = mock(GerritServer.class);
        when(plugin.getServer(any(String.class))).thenReturn(server);
        IGerritHudsonTriggerConfig config = Setup.createConfig();
        config = spy(config);
        doReturn("http://mock.url").when(config).getGerritFrontEndUrlFor(any(String.class), any(String.class));
        when(server.getConfig()).thenReturn(config);
        GerritHandler handler = mock(GerritHandler.class);
        when(plugin.getHandler()).thenReturn(handler);
        PowerMockito.when(PluginImpl.getInstance()).thenReturn(plugin);
        when(config.getBuildScheduleDelay()).thenReturn(0);
View Full Code Here

TOP

Related Classes of com.sonyericsson.hudson.plugins.gerrit.trigger.GerritServer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.