Search in sources :

Example 1 with Times

use of org.mockito.internal.verification.Times in project gocd by gocd.

the class TestArtifactPlanTest method shouldSupportGlobPatternsInSourcePath.

@Test
public void shouldSupportGlobPatternsInSourcePath() {
    ArtifactPlan artifactPlan = new ArtifactPlan("**/*/a.log", "logs");
    TestArtifactPlan testArtifactPlan = new TestArtifactPlan(artifactPlan);
    File first = new File("target/test/report/a.log");
    File second = new File("target/test/test/a/b/a.log");
    first.mkdirs();
    second.mkdirs();
    testArtifactPlan.publish(mockArtifactPublisher, rootPath);
    verify(mockArtifactPublisher).upload(first, "logs/report");
    verify(mockArtifactPublisher).upload(second, "logs/test/a/b");
    verify(mockArtifactPublisher, new Times(2)).upload(any(File.class), eq("testoutput"));
}
Also used : ArtifactPlan(com.thoughtworks.go.config.ArtifactPlan) TestArtifactPlan(com.thoughtworks.go.config.TestArtifactPlan) Times(org.mockito.internal.verification.Times) TestArtifactPlan(com.thoughtworks.go.config.TestArtifactPlan) File(java.io.File) Test(org.junit.Test)

Example 2 with Times

use of org.mockito.internal.verification.Times in project geode by apache.

the class GMSJoinLeaveJUnitTest method testNetworkPartionMessage.

// With the removal of the JoinResponse message from GMSJoinLeave.processJoinRequest (GEODE-870)
// This test now seems to be invalid
// @Test
// public void testJoinResponseMsgWithBecomeCoordinator() throws Exception {
// initMocks(false);
// gmsJoinLeaveMemberId.getNetMember().setPreferredForCoordinator(false);
// JoinRequestMessage reqMsg = new JoinRequestMessage(gmsJoinLeaveMemberId, mockMembers[0], null,
// 56734);
// InternalDistributedMember ids = new InternalDistributedMember("localhost", 97898);
// ids.getNetMember().setPreferredForCoordinator(true);
// gmsJoinLeave.processMessage(reqMsg);
// ArgumentCaptor<JoinResponseMessage> ac = ArgumentCaptor.forClass(JoinResponseMessage.class);
// verify(messenger).send(ac.capture());
//
// assertTrue("Should have asked for becoming a coordinator",
// ac.getValue().getBecomeCoordinator());
// }
@Test
public void testNetworkPartionMessage() throws Exception {
    try {
        initMocks(true);
        System.setProperty(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY, "true");
        gmsJoinLeave.join();
        installView(1, gmsJoinLeaveMemberId, createMemberList(mockMembers[0], mockMembers[1], mockMembers[2], gmsJoinLeaveMemberId, mockMembers[3]));
        for (int i = 1; i < 4; i++) {
            RemoveMemberMessage msg = new RemoveMemberMessage(gmsJoinLeaveMemberId, mockMembers[i], "crashed");
            msg.setSender(gmsJoinLeaveMemberId);
            gmsJoinLeave.processMessage(msg);
        }
        Timeout to = new Timeout(3 * ServiceConfig.MEMBER_REQUEST_COLLECTION_INTERVAL, new Times(1));
        verify(messenger, to).send(isA(NetworkPartitionMessage.class));
    } finally {
        System.getProperties().remove(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY);
    }
}
Also used : NetworkPartitionMessage(org.apache.geode.distributed.internal.membership.gms.messages.NetworkPartitionMessage) RemoveMemberMessage(org.apache.geode.distributed.internal.membership.gms.messages.RemoveMemberMessage) Timeout(org.mockito.verification.Timeout) Times(org.mockito.internal.verification.Times) Test(org.junit.Test) MembershipTest(org.apache.geode.test.junit.categories.MembershipTest) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

Test (org.junit.Test)2 Times (org.mockito.internal.verification.Times)2 ArtifactPlan (com.thoughtworks.go.config.ArtifactPlan)1 TestArtifactPlan (com.thoughtworks.go.config.TestArtifactPlan)1 File (java.io.File)1 NetworkPartitionMessage (org.apache.geode.distributed.internal.membership.gms.messages.NetworkPartitionMessage)1 RemoveMemberMessage (org.apache.geode.distributed.internal.membership.gms.messages.RemoveMemberMessage)1 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)1 MembershipTest (org.apache.geode.test.junit.categories.MembershipTest)1 Timeout (org.mockito.verification.Timeout)1