View Javadoc

1   /**
2    * Copyright 2004-2012 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.common.threads;
17  
18  import junit.framework.Assert;
19  
20  import org.junit.Test;
21  
22  public class ThreadHandlerFactoryTest {
23  
24      ThreadHandlerFactory factory = new ThreadHandlerFactory();
25  
26      @Test
27      public void testGetDivideEvenly() {
28          int[] split = factory.getDivideEvenly(100, 7);
29  
30          Assert.assertEquals(15, split[0]);
31          Assert.assertEquals(15, split[1]);
32          Assert.assertEquals(14, split[2]);
33          Assert.assertEquals(14, split[3]);
34          Assert.assertEquals(14, split[4]);
35          Assert.assertEquals(14, split[5]);
36          Assert.assertEquals(14, split[6]);
37      }
38  
39      @Test
40      public void testGetThreadCount() {
41          int threads1 = factory.getThreadCount(1, 0, 0, 0);
42          int threads2 = factory.getThreadCount(50, 10, 21826, 0);
43          System.out.println(threads1);
44          System.out.println(threads2);
45      }
46  
47  }