gerrithudsontrigger/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/spec/SpecGerritTriggerHudsonTest.java
/**
     * Tests that a build for a patch set of the gets canceled when a new patch set of the same change arrives.
     *
     * @throws Exception if so.
     */
Tests that a build for a patch set of the gets canceled when a new patch set of the same change arrives.
@throws Exception if so.
Tests that a build for a patch set of the gets canceled when a new patch set of the same change arrives . @throws Exception if so .
@LocalData
    public void testBuildLatestPatchsetOnly() throws Exception {
        ((Config)PluginImpl.getInstance().getConfig()).setGerritBuildCurrentPatchesOnly(true);
        FreeStyleProject project = DuplicatesUtil.createGerritTriggeredJob(this, "projectX");
        project.getBuildersList().add(new SleepBuilder(2000));
        server.waitForCommand(GERRIT_STREAM_EVENTS, 2000);
        PatchsetCreated firstEvent = Setup.createPatchsetCreated();
        PluginImpl.getInstance().triggerEvent(firstEvent);
        AbstractBuild firstBuild = DuplicatesUtil.waitForBuildToStart(firstEvent, 5000);
        PatchsetCreated secondEvent = Setup.createPatchsetCreated();
        if (null != secondEvent.getPatchSet()) {
            secondEvent.getPatchSet().setNumber("2");
        }
        PluginImpl.getInstance().triggerEvent(secondEvent);
        RunList<FreeStyleBuild> builds = DuplicatesUtil.waitForBuilds(project, 2, 10000);
        assertEquals(2, builds.size());
        assertSame(Result.ABORTED, firstBuild.getResult());
        assertSame(Result.ABORTED, builds.getFirstBuild().getResult());
        assertSame(Result.SUCCESS, builds.getLastBuild().getResult());
    }
@ LocalData public void testBuildLatestPatchsetOnly ( ) throws Exception { ( ( Config ) PluginImpl . getInstance ( ) . getConfig ( ) ) . setGerritBuildCurrentPatchesOnly ( true ) ; FreeStyleProject project = DuplicatesUtil . createGerritTriggeredJob ( this , "projectX" ) ; project . getBuildersList ( ) . add ( new SleepBuilder ( 2000 ) ) ; server . waitForCommand ( GERRIT_STREAM_EVENTS , 2000 ) ; PatchsetCreated firstEvent = Setup . createPatchsetCreated ( ) ; PluginImpl . getInstance ( ) . triggerEvent ( firstEvent ) ; AbstractBuild firstBuild = DuplicatesUtil . waitForBuildToStart ( firstEvent , 5000 ) ; PatchsetCreated secondEvent = Setup . createPatchsetCreated ( ) ; if ( null != secondEvent . getPatchSet ( ) ) { secondEvent . getPatchSet ( ) . setNumber ( "2" ) ; } PluginImpl . getInstance ( ) . triggerEvent ( secondEvent ) ; RunList < FreeStyleBuild > builds = DuplicatesUtil . waitForBuilds ( project , 2 , 10000 ) ; assertEquals ( 2 , builds . size ( ) ) ; assertSame ( Result . ABORTED , firstBuild . getResult ( ) ) ; assertSame ( Result . ABORTED , builds . getFirstBuild ( ) . getResult ( ) ) ; assertSame ( Result . SUCCESS , builds . getLastBuild ( ) . getResult ( ) ) ; }
Tests that a build for a patch set of the gets canceled when a new patch set of the same change arrives.
Tests that a build for a patch set of the gets canceled when a new patch set of the same change arrives .