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