1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.kuali.kfs.sys.context;
20
21 import org.kuali.kfs.coa.businessobject.Account;
22 import org.kuali.kfs.gl.batch.service.impl.BalancingServiceBaseImpl;
23 import org.kuali.kfs.gl.businessobject.Balance;
24 import org.kuali.kfs.gl.businessobject.Entry;
25 import org.kuali.kfs.sys.ConfigureContext;
26 import org.kuali.rice.coreservice.framework.parameter.ParameterService;
27
28
29
30
31
32 @ConfigureContext
33 public class TestUtilsTest extends KualiTestBase {
34
35 public static final String TEST_PARAM_NAME = "FUND_GROUP_DENOTES_CG_IND";
36 public static final Class TEST_PARAM_COMPONENT = Account.class;
37
38 public void testSetSystemParameter1() throws Exception {
39 String dbValue = SpringContext.getBean(ParameterService.class).getParameterValueAsString(TEST_PARAM_COMPONENT, TEST_PARAM_NAME);
40 assertEquals( "indicator must be true", "Y", dbValue );
41 TestUtils.setSystemParameter(TEST_PARAM_COMPONENT, TEST_PARAM_NAME, "N");
42 String cachedValue = SpringContext.getBean(ParameterService.class).getParameterValueAsString(TEST_PARAM_COMPONENT, TEST_PARAM_NAME);
43 assertEquals( "indicator must be false when pulled after the set", "N", cachedValue );
44 }
45
46 public void testSetSystemParameter2() throws Exception {
47 String dbValue = SpringContext.getBean(ParameterService.class).getParameterValueAsString(TEST_PARAM_COMPONENT, TEST_PARAM_NAME);
48 assertEquals( "indicator must be true", "Y", dbValue );
49 }
50
51 @ConfigureContext(shouldCommitTransactions=true)
52 public void testSetSystemParameterFailsWhenNonRollback() throws Exception {
53 try {
54 TestUtils.setSystemParameter(TEST_PARAM_COMPONENT, TEST_PARAM_NAME, "N");
55 fail( "TestUtils.setSystemParameter() did not fail when called from a committing test.");
56 } catch ( Exception ex ) {
57 System.err.println( ex.getMessage() );
58
59 }
60 }
61
62 @ConfigureContext(shouldCommitTransactions=false)
63 public void testSetSystemParameterSucceedsWhenRollback() throws Exception {
64 try {
65 TestUtils.setSystemParameter(TEST_PARAM_COMPONENT, TEST_PARAM_NAME, "N");
66 } catch ( Exception ex ) {
67 fail( "TestUtils.setSystemParameter() failed when called from a non-committing test: " + ex.getMessage() );
68 }
69 }
70
71 public void testGetUnproxiedService() {
72 try {
73 BalancingServiceBaseImpl<Entry, Balance> balancingService = (BalancingServiceBaseImpl<Entry, Balance>) TestUtils.getUnproxiedService("laborBalancingService");
74 assertNotNull(balancingService);
75 }
76 catch (Exception e) {
77 assertTrue("testGetUnproxiedService failed due to stacktrace: " + e.getMessage(), false);
78 }
79 }
80 }