View Javadoc
1   /**
2    * Copyright 2005-2014 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.rice.core.test;
17  
18  import java.lang.annotation.Documented;
19  import java.lang.annotation.ElementType;
20  import java.lang.annotation.Inherited;
21  import java.lang.annotation.Retention;
22  import java.lang.annotation.RetentionPolicy;
23  import java.lang.annotation.Target;
24  
25  import org.junit.After;
26  import org.junit.Before;
27  import org.junit.BeforeClass;
28  import org.junit.Test;
29  import org.kuali.rice.core.api.lifecycle.BaseLifecycle;
30  import org.kuali.rice.test.BaselineTestCase;
31  import org.kuali.rice.test.ClearDatabaseLifecycle;
32  import org.kuali.rice.test.data.PerSuiteUnitTestData;
33  import org.kuali.rice.test.data.PerTestUnitTestData;
34  import org.kuali.rice.test.data.UnitTestData;
35  
36  import static org.junit.Assert.assertNotNull;
37  import static org.junit.Assert.fail;
38  
39  /**
40   * DataLoaderAnnotationOverrideTest is used to test the annotation data entry provided by {@link UnitTestData}, {@link PerTestUnitTestData}, and {@link PerSuiteUnitTestData}
41   * 
42   * @author Kuali Rice Team (rice.collab@kuali.org)
43   *
44   */
45  @PerSuiteUnitTestData(
46          overrideSuperClasses = true,
47          value = {@UnitTestData("insert into " + AnnotationTestParent.TEST_TABLE_NAME + " (COL) values ('3')"),
48          @UnitTestData(filename = "classpath:org/kuali/rice/test/DataLoaderAnnotationTestData.sql")
49  })
50  //@BaselineTestCase.BaselineMode(BaselineTestCase.Mode.NONE)
51  @DataLoaderAnnotationOverrideTest.Nothing
52  public class DataLoaderAnnotationOverrideTest extends AnnotationTestParent {
53      // a dummy annotation to test that data loading annotations work in presence of
54      // other annotations
55      @Documented
56      @Target({ElementType.TYPE, ElementType.METHOD})
57      @Retention(RetentionPolicy.RUNTIME)
58      @Inherited
59      public static @interface Nothing {
60      }
61  
62      @Override
63      protected void setUpInternal() throws Exception {
64          try{
65              resetDb();
66          } catch (Exception e) {
67             // Will error of db not previously loaded, ignore reset error
68          }
69          super.setUpInternal();
70      }
71  
72      @Test public void testParentAndSubClassImplementation() throws Exception {
73          // verify that the sql only ran once...
74  
75          // check sql statement from this class
76          verifyCount("3", 1, "https://jira.kuali.org/browse/KULRICE-9283");
77  
78          // check sql file from this class
79          verifyCount("4", 1);
80  
81          // check sql statement from parent class
82          verifyNonExistent("1");
83  
84          // check sql file from parent class
85          verifyNonExistent("2");
86  
87      }
88  
89  }