How to use method of org.jmock.test.unit.lib.concurrent.BlitzerTests class

Best Jmock-library code snippet using org.jmock.test.unit.lib.concurrent.BlitzerTests.

Run Jmock-library automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

copy
1package org.jmock.test.unit.lib.concurrent;
2
3import static org.hamcrest.Matchers.equalTo;
4import static org.junit.Assert.assertThat;
5
6import java.util.concurrent.TimeoutException;
7import java.util.concurrent.atomic.AtomicInteger;
8
9import junit.framework.TestCase;
10
11import org.jmock.lib.concurrent.Blitzer;
12import org.junit.After;
13
14public class BlitzerTests extends TestCase {
15    int threadCount = 3;
16    int actionCount = 12;
17    
18    Blitzer blitzer = new Blitzer(actionCount, threadCount);
19    
20    
21    @After
22    public void cleanUp() {
23        blitzer.shutdown();
24    }
25    
26    public void testRunsTheActionMultipleTimesOnMultipleThreads() throws InterruptedException {
27        final AtomicInteger actualActionCount = new AtomicInteger();
28        
29        blitzer.blitz(new Runnable() {
30            public void run() {
31                actualActionCount.incrementAndGet();
32            }
33        });
34        
35        assertThat(actualActionCount.get(), equalTo(actionCount));
36    }
37    
38    public void testActionsCanFailWithoutDeadlockingTheTestThread() throws InterruptedException, TimeoutException {
39        blitzer.blitz(100, new Runnable() {
40            public void run() {
41                throw new RuntimeException("boom!");
42            }
43        });
44        
45        // thread reaches here and does not time out
46    }
47    
48    public void testReportsTheTotalNumberOfActions() {
49        assertThat(blitzer.totalActionCount(), equalTo(actionCount));
50    }
51}
52
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Trigger code on LambdaTest Cloud Grid

Execute automation tests with on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)