KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > transaction > manager > HOWLLogRecoveryTest


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.geronimo.transaction.manager;
19
20 import java.io.File JavaDoc;
21
22 import org.apache.geronimo.transaction.log.HOWLLog;
23 import junit.framework.Test;
24 import junit.framework.TestSuite;
25 import junit.extensions.TestSetup;
26
27 /**
28  *
29  *
30  * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
31  *
32  * */

33 public class HOWLLogRecoveryTest extends AbstractRecoveryTest {
34     private static final File JavaDoc basedir = new File JavaDoc(System.getProperty("basedir", System.getProperty("user.dir")));
35     private static final String JavaDoc LOG_FILE_NAME = "howl_test_";
36     private static final String JavaDoc logFileDir = "txlog";
37     private static final String JavaDoc targetDir = new File JavaDoc(basedir, "target").getAbsolutePath();
38     private static final File JavaDoc txlogDir = new File JavaDoc(basedir, "target/" + logFileDir);
39
40     public void test2Again() throws Exception JavaDoc {
41         test2ResOnlineAfterRecoveryStart();
42     }
43
44     public void test3Again() throws Exception JavaDoc {
45         test3ResOnlineAfterRecoveryStart();
46     }
47
48     protected void setUp() throws Exception JavaDoc {
49         // Deletes the previous transaction log files.
50
File JavaDoc[] files = txlogDir.listFiles();
51         if ( null != files ) {
52             for (int i = 0; i < files.length; i++) {
53                 files[i].delete();
54             }
55         }
56         setUpHowlLog();
57     }
58
59     private void setUpHowlLog() throws Exception JavaDoc {
60         HOWLLog howlLog = new HOWLLog(
61                 "org.objectweb.howl.log.BlockLogBuffer", // "bufferClassName",
62
4, // "bufferSizeKBytes",
63
true, // "checksumEnabled",
64
true, // "adler32Checksum",
65
20, // "flushSleepTime",
66
logFileDir, // "logFileDir",
67
"log", // "logFileExt",
68
LOG_FILE_NAME, // "logFileName",
69
200, // "maxBlocksPerFile",
70
10, // "maxBuffers", log
71
2, // "maxLogFiles",
72
2, // "minBuffers",
73
10,// "threadsWaitingForceThreshold"});
74
xidFactory,
75                 new File JavaDoc(targetDir)
76         );
77         howlLog.doStart();
78         txLog = howlLog;
79     }
80
81     protected void tearDown() throws Exception JavaDoc {
82         ((HOWLLog)txLog).doStop();
83         txLog = null;
84     }
85
86     protected void prepareForReplay() throws Exception JavaDoc {
87         tearDown();
88         setUpHowlLog();
89     }
90
91     public static Test suite() {
92         return new TestSetup(new TestSuite(HOWLLogRecoveryTest.class)) {
93             protected void setUp() throws Exception JavaDoc {
94                 File JavaDoc logFile = new File JavaDoc(txlogDir, LOG_FILE_NAME + "_1.log");
95                 if (logFile.exists()) {
96                     logFile.delete();
97                 }
98                 logFile = new File JavaDoc(txlogDir, LOG_FILE_NAME + "_2.log");
99                 if (logFile.exists()) {
100                     logFile.delete();
101                 }
102             }
103         };
104     }
105 }
106
Popular Tags