01: /*
02: * $Id: ControllerLoadTest.java 577 2005-11-07 07:45:10Z hengels $
03: * (c) Copyright 2004 con:cern development team.
04: *
05: * This file is part of con:cern (http://concern.org).
06: *
07: * con:cern is free software; you can redistribute it and/or modify
08: * it under the terms of the GNU Lesser General Public License
09: * as published by the Free Software Foundation; either version 2.1
10: * of the License, or (at your option) any later version.
11: *
12: * Please see COPYING for the complete licence.
13: */
14: package org.concern.controller;
15:
16: import junit.framework.TestCase;
17: import org.hibernate.cfg.Configuration;
18: import org.concern.Log;
19: import org.concern.SubjectNotFoundException;
20: import org.concern.UnknownSubjectException;
21: import org.hibernate.*;
22: import org.hibernate.Transaction;
23:
24: import java.util.*;
25:
26: /** @noinspection ALL*/
27: // NOTE: @noinspection ALL is to prevent IntelliJ IDEA from displaying
28: // (many!) warnings if you happen to be in a project with 1.5 syntax
29: // enabled.
30: public class ControllerLoadTest extends TestCase {
31: public ControllerLoadTest(String name) {
32: super (name);
33: }
34:
35: public void testSequential() throws Exception {
36: ControllerTest controllerTest;
37: controllerTest = new ControllerTest(getName());
38: controllerTest.setUp();
39: controllerTest.testCreateAndRemoveSubject();
40: controllerTest.testGetSubjects();
41: controllerTest.testScheduleAnnouncement();
42: controllerTest.testEnlistments();
43: controllerTest.testLogAndArchive();
44: controllerTest.testExecuteSynchronous();
45: controllerTest.testExecuteAsynchronous();
46: controllerTest.testExecuteEvent();
47: controllerTest.testExecuteListener();
48: controllerTest.testTemporalConditions();
49: controllerTest.testTimerTask();
50: controllerTest.testSubjectNotFound();
51: //controllerTest.testDirtySubjectAfterRollback();
52: controllerTest.tearDown();
53: }
54:
55: public void testParallelTransactions() throws Exception {
56: Thread[] threads = new Thread[10];
57:
58: for (int i = 0; i < threads.length; i++)
59: threads[i] = new Thread(new Runnable() {
60: public void run() {
61: try {
62: testSequential();
63: testSequential();
64: } catch (Exception e) {
65: e.printStackTrace();
66: fail(e.getMessage());
67: }
68: }
69: });
70:
71: for (int i = 0; i < threads.length; i++) {
72: Thread thread = threads[i];
73: thread.start();
74: }
75:
76: for (int i = 0; i < threads.length; i++) {
77: Thread thread = threads[i];
78: thread.join();
79: }
80: }
81: }
|