View Javadoc
1   /**
2    * Copyright 2005-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.ole;
17  
18  import org.junit.Test;
19  import org.junit.Before;
20  import org.junit.After;
21  
22  import static org.junit.Assert.*;
23  
24  /**
25   * Kuali Rice ArcheType Help
26   *
27   * This is an abstract unit test for several service implementations.  Unit tests should run quick and not
28   * depend on external or unstable resources.  This test logic will run at every maven project build.
29   *
30   *
31   * An abstract test class to test different {@link ProductService} implementations.
32   * Extend this class and override the {@link #createService()} method for each implementation.
33   */
34  public abstract class AbstractProductServiceImplTest {
35  
36      private ProductService service;
37  
38      /**
39       * Abstract method to override by test implementations.
40       * @return an instance of {@link ProductService}
41       */
42      public abstract ProductService createService();
43  
44      @Before
45      public final void initService() {
46          service = createService();
47      }
48  
49      @After
50      public final void destroyService() {
51          service = null;
52      }
53  
54      @Test
55      public final void testPositiveNumbers() {
56          assertEquals(4, service.product(2, 2).intValue());
57      }
58  
59      @Test
60      public final void testNegativeNumbers() {
61          assertEquals(4, service.product(-2, -2).intValue());
62      }
63  
64      @Test
65      public final void testZero() {
66          assertEquals(0, service.product(2, 0).intValue());
67      }
68  
69      @Test(expected=IllegalArgumentException.class)
70      public final void testNulls() {
71          assertEquals(0, service.product(null, null).intValue());
72      }
73  }