1 /* 2 * Copyright (c) 2007 Mockito contributors 3 * This program is made available under the terms of the MIT License. 4 */ 5 package org.mockitousage.performance; 6 7 import static org.junit.Assert.assertEquals; 8 import static org.mockito.Mockito.*; 9 10 import java.util.LinkedList; 11 import java.util.List; 12 13 import org.junit.Ignore; 14 import org.junit.Test; 15 import org.mockitousage.IMethods; 16 import org.mockitoutil.TestBase; 17 18 public class LoadsOfMocksTest extends TestBase { 19 20 @Ignore("Use it for performance checks") 21 @Test testSomething()22 public void testSomething() { 23 List<IMethods> mocks = new LinkedList<IMethods>(); 24 for (int i = 0; i < 50000; i++) { 25 System.out.println("Mock no: " + i); 26 IMethods mock = mock(IMethods.class); 27 mocks.add(mock); 28 29 when(mock.simpleMethod(1)).thenReturn("one"); 30 when(mock.simpleMethod(2)).thenReturn("two"); 31 32 assertEquals("one", mock.simpleMethod(1)); 33 assertEquals("two", mock.simpleMethod(2)); 34 35 verify(mock).simpleMethod(1); 36 verify(mock).simpleMethod(2); 37 } 38 } 39 } 40