01: /*
02: * Copyright 2005-2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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.module.chart;
17:
18: import java.util.Calendar;
19:
20: import org.kuali.kfs.context.KualiTestBase;
21: import org.kuali.kfs.context.SpringContext;
22: import org.kuali.module.chart.bo.Account;
23: import org.kuali.module.chart.dao.AccountDao;
24: import org.kuali.test.ConfigureContext;
25:
26: /**
27: * This class tests the DAO implementations directly on Account. The goal is to exercise and produce comparative timings of proxied
28: * vs. non-proxied OJB configurations.
29: */
30: @ConfigureContext
31: public class ProxyPerformanceTest extends KualiTestBase {
32: private long timeBefore = 0;
33: private long timeAfter = 0;
34: private AccountDao accountDao;
35: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
36: .getLogger(ProxyPerformanceTest.class);
37:
38: // note that the reason we're using the getAppContext() here, and not the
39: // SpringContext is that we're exercising the DAO implementations directly.
40: //
41: // Most other tests use the Services, not the DAO's directly. This was done
42: // to provide the lowest-level test, and not lose any performance to the web app
43: // or services overhead, which is not relevant to these tests.
44: //
45: @Override
46: protected void setUp() throws Exception {
47: super .setUp();
48: accountDao = SpringContext.getBean(AccountDao.class);
49:
50: timeBefore = Calendar.getInstance().getTimeInMillis();
51:
52: }
53:
54: @Override
55: protected void tearDown() throws Exception {
56: timeAfter = Calendar.getInstance().getTimeInMillis();
57:
58: long millisecs = timeAfter - timeBefore;
59: long secs = millisecs / 1000;
60: long remainder = millisecs % 1000;
61:
62: LOG.info("ending test, time took: " + secs + " sec "
63: + remainder + " ms");
64: super .tearDown();
65: }
66:
67: public void testOneAccountLookupProxy() {
68: Account account = null;
69: account = accountDao.getByPrimaryId("BL", "1031400");
70: assertNotNull(account);
71: }
72:
73: }
|