KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opensubsystems > core > util > FileCommitUtilsTest


1 /*
2  * Copyright (c) 2003 - 2007 OpenSubsystems s.r.o. Slovak Republic. All rights reserved.
3  *
4  * Project: OpenSubsystems
5  *
6  * $Id: FileCommitUtilsTest.java,v 1.4 2007/01/07 06:14:55 bastafidli Exp $
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; version 2 of the License.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */

21
22 package org.opensubsystems.core.util;
23
24 import java.util.ArrayList JavaDoc;
25 import java.util.List JavaDoc;
26
27 import junit.framework.TestCase;
28
29 /**
30  * Tests for file transaction - prepare to commit, commit and rollback processes.
31  *
32  * @version $Id: FileCommitUtilsTest.java,v 1.4 2007/01/07 06:14:55 bastafidli Exp $
33  * @author Julo Legeny
34  * @code.reviewer Miro Halas
35  * @code.reviewed Initial revision
36  */

37 public class FileCommitUtilsTest extends TestCase
38 {
39
40    /**
41     * FileCommitUtils object for processing of the file transaction
42     */

43    protected FileCommitUtils m_fcuFileTrancastion;
44    
45    /**
46     * Constructor for DateUtilsTest.
47     * @param arg0 - name of the test
48     */

49    public FileCommitUtilsTest(
50       String JavaDoc arg0
51    )
52    {
53       super(arg0);
54
55       // --------------------------------------------------------------------------
56
// initialize files that will be colocated
57
// --------------------------------------------------------------------------
58

59       // TODO: For Miro: Review these locations? Why are these files there?
60
// new source files
61
TwoObjectStruct tosSourceNewFile = new TwoObjectStruct(
62          "TODO: Bug: Missing file - filetransaction/temp/",
63          "test_file_new.pdf");
64       TwoObjectStruct tosSourceNewFilePage1JPG = new TwoObjectStruct(
65          "TODO: Bug: Missing file - filetransaction/temp/",
66          "test_page_1_new.jpg");
67       TwoObjectStruct tosSourceNewFilePage1TIF = new TwoObjectStruct(
68          "TODO: Bug: Missing file - filetransaction/temp/",
69          "test_page_1_new.tif");
70       TwoObjectStruct tosSourceNewFilePage1THM = new TwoObjectStruct(
71          "TODO: Bug: Missing file - filetransaction/temp/",
72          "test_page_1_thm_new.jpg");
73       TwoObjectStruct tosSourceNewFilePage2JPG = new TwoObjectStruct(
74          "TODO: Bug: Missing file - filetransaction/temp/",
75          "test_page_2_new.jpg");
76       TwoObjectStruct tosSourceNewFilePage2TIF = new TwoObjectStruct(
77          "TODO: Bug: Missing file - filetransaction/temp/",
78          "test_page_2_new.tif");
79       TwoObjectStruct tosSourceNewFilePage2THM = new TwoObjectStruct(
80          "TODO: Bug: Missing file - filetransaction/temp/",
81          "test_page_2_thm_new.jpg");
82       
83       // new destination files
84
TwoObjectStruct tosDestinationNewFile = new TwoObjectStruct(
85          "TODO: Bug: Missing file - filetransaction/testfiles/",
86          "test_file_2_new_copyied.pdf");
87       TwoObjectStruct tosDestinationNewFilePage1JPG = new TwoObjectStruct(
88          "TODO: Bug: Missing file - filetransaction/testfilepages/",
89          "test_page_2_1_new_copyied.jpg");
90       TwoObjectStruct tosDestinationNewFilePage1TIF = new TwoObjectStruct(
91          "TODO: Bug: Missing file - filetransaction/testfilepages/",
92          "test_page_2_1_new_copyied.tif");
93       TwoObjectStruct tosDestinationNewFilePage1THM = new TwoObjectStruct(
94          "TODO: Bug: Missing file - filetransaction/testfilepages/",
95          "test_page_2_1_thm_new_copyied.jpg");
96       TwoObjectStruct tosDestinationNewFilePage2JPG = new TwoObjectStruct(
97          "TODO: Bug: Missing file - filetransaction/testfilepages/",
98          "test_page_2_2_new_copyied.jpg");
99       TwoObjectStruct tosDestinationNewFilePage2TIF = new TwoObjectStruct(
100          "TODO: Bug: Missing file - filetransaction/testfilepages/",
101          "test_page_2_2_new_copyied.tif");
102       TwoObjectStruct tosDestinationNewFilePage2THM = new TwoObjectStruct(
103          "TODO: Bug: Missing file - filetransaction/testfilepages/",
104          "test_page_2_2_thm_new_copyied.jpg");
105
106       // files that will be moved to another location (sources)
107
TwoObjectStruct tosSourceMoveFile = new TwoObjectStruct(
108          "TODO: Bug: Missing file - filetransaction/temp/",
109          "test_file_move.pdf");
110       TwoObjectStruct tosSourceMovePage1JPG = new TwoObjectStruct(
111          "TODO: Bug: Missing file - filetransaction/temp/",
112          "test_page_8_move.jpg");
113       TwoObjectStruct tosSourceMovePage1TIF = new TwoObjectStruct(
114          "TODO: Bug: Missing file - filetransaction/temp/",
115          "test_page_8_move.tif");
116       TwoObjectStruct tosSourceMovePage1THM = new TwoObjectStruct(
117          "TODO: Bug: Missing file - filetransaction/temp/",
118          "test_page_8_thm_move.jpg");
119
120       // files that will be moved to this location (destinations)
121
TwoObjectStruct tosDestinationMoveFile = new TwoObjectStruct(
122          "TODO: Bug: Missing file - filetransaction/testfiles/",
123          "test_file_1_moved.pdf");
124       TwoObjectStruct tosDestinationMovePage1JPG = new TwoObjectStruct(
125          "TODO: Bug: Missing file - filetransaction/testfilepages/",
126          "test_page_8_moved.jpg");
127       TwoObjectStruct tosDestinationMovePage1TIF = new TwoObjectStruct(
128          "TODO: Bug: Missing file - filetransaction/testfilepages/",
129          "test_page_8_moved.tif");
130       TwoObjectStruct tosDestinationMovePage1THM = new TwoObjectStruct(
131          "TODO: Bug: Missing file - filetransaction/testfilepages/",
132          "test_page_8_thm_moved.jpg");
133
134       // files that will replace another (sources)
135
TwoObjectStruct tosSourceReplaceFile = new TwoObjectStruct(
136          "TODO: Bug: Missing file - filetransaction/temp/",
137          "test_file_replace.pdf");
138       TwoObjectStruct tosSourceReplacePage1JPG = new TwoObjectStruct(
139          "TODO: Bug: Missing file - filetransaction/temp/",
140          "test_page_6_replace.jpg");
141       TwoObjectStruct tosSourceReplacePage1TIF = new TwoObjectStruct(
142          "TODO: Bug: Missing file - filetransaction/temp/",
143          "test_page_6_replace.tif");
144       TwoObjectStruct tosSourceReplacePage1THM = new TwoObjectStruct(
145          "TODO: Bug: Missing file - filetransaction/temp/",
146          "test_page_6_thm_replace.jpg");
147
148       // files that will be replaced by another (destinations)
149
TwoObjectStruct tosDestinationReplaceFile = new TwoObjectStruct(
150          "TODO: Bug: Missing file - filetransaction/testfiles/",
151          "test_file_1_to_be_replaced.pdf");
152       TwoObjectStruct tosDestinationReplacePage1JPG = new TwoObjectStruct(
153          "TODO: Bug: Missing file - filetransaction/testfilepages/",
154          "test_page_6_to_be_replaced.jpg");
155       TwoObjectStruct tosDestinationReplacePage1TIF = new TwoObjectStruct(
156          "TODO: Bug: Missing file - filetransaction/testfilepages/",
157          "test_page_6_to_be_replaced.tif");
158       TwoObjectStruct tosDestinationReplacePage1THM = new TwoObjectStruct(
159          "TODO: Bug: Missing file - filetransaction/testfilepages/",
160          "test_page_6_thm_to_be_replaced.jpg");
161
162       // files that will be deleted (sources)
163
TwoObjectStruct tosSourceDeletePage1JPG = new TwoObjectStruct(
164          "TODO: Bug: Missing file - filetransaction/testfilepages/",
165          "test_page_7_delete.jpg");
166       TwoObjectStruct tosSourceDeletePage1TIF = new TwoObjectStruct(
167          "TODO: Bug: Missing file - filetransaction/testfilepages/",
168          "test_page_7_delete.tif");
169       TwoObjectStruct tosSourceDeletePage1THM = new TwoObjectStruct(
170          "TODO: Bug: Missing file - filetransaction/testfilepages/",
171          "test_page_7_thm_delete.jpg");
172
173       // --------------------------------------------------------------------------
174
// initialize lists of colocated files
175
// --------------------------------------------------------------------------
176
List JavaDoc lstCopyFilesFrom = new ArrayList JavaDoc(7);
177       List JavaDoc lstCopyFilesTo = new ArrayList JavaDoc(7);
178
179       List JavaDoc lstMoveFilesFrom = new ArrayList JavaDoc(4);
180       List JavaDoc lstMoveFilesTo = new ArrayList JavaDoc(4);
181
182       List JavaDoc lstReplaceFilesFrom = new ArrayList JavaDoc(4);
183       List JavaDoc lstReplaceFilesTo = new ArrayList JavaDoc(4);
184       List JavaDoc lstDeleteFilesFrom = new ArrayList JavaDoc(3);
185       
186       lstCopyFilesFrom.add(tosSourceNewFile);
187       lstCopyFilesFrom.add(tosSourceNewFilePage1JPG);
188       lstCopyFilesFrom.add(tosSourceNewFilePage1TIF);
189       lstCopyFilesFrom.add(tosSourceNewFilePage1THM);
190       lstCopyFilesFrom.add(tosSourceNewFilePage2JPG);
191       lstCopyFilesFrom.add(tosSourceNewFilePage2TIF);
192       lstCopyFilesFrom.add(tosSourceNewFilePage2THM);
193
194       lstCopyFilesTo.add(tosDestinationNewFile);
195       lstCopyFilesTo.add(tosDestinationNewFilePage1JPG);
196       lstCopyFilesTo.add(tosDestinationNewFilePage1TIF);
197       lstCopyFilesTo.add(tosDestinationNewFilePage1THM);
198       lstCopyFilesTo.add(tosDestinationNewFilePage2JPG);
199       lstCopyFilesTo.add(tosDestinationNewFilePage2TIF);
200       lstCopyFilesTo.add(tosDestinationNewFilePage2THM);
201
202       lstMoveFilesFrom.add(tosSourceMoveFile);
203       lstMoveFilesFrom.add(tosSourceMovePage1JPG);
204       lstMoveFilesFrom.add(tosSourceMovePage1TIF);
205       lstMoveFilesFrom.add(tosSourceMovePage1THM);
206
207       lstMoveFilesTo.add(tosDestinationMoveFile);
208       lstMoveFilesTo.add(tosDestinationMovePage1JPG);
209       lstMoveFilesTo.add(tosDestinationMovePage1TIF);
210       lstMoveFilesTo.add(tosDestinationMovePage1THM);
211
212       lstReplaceFilesFrom.add(tosSourceReplaceFile);
213       lstReplaceFilesFrom.add(tosSourceReplacePage1JPG);
214       lstReplaceFilesFrom.add(tosSourceReplacePage1TIF);
215       lstReplaceFilesFrom.add(tosSourceReplacePage1THM);
216
217       lstReplaceFilesTo.add(tosDestinationReplaceFile);
218       lstReplaceFilesTo.add(tosDestinationReplacePage1JPG);
219       lstReplaceFilesTo.add(tosDestinationReplacePage1TIF);
220       lstReplaceFilesTo.add(tosDestinationReplacePage1THM);
221
222       lstDeleteFilesFrom.add(tosSourceDeletePage1JPG);
223       lstDeleteFilesFrom.add(tosSourceDeletePage1TIF);
224       lstDeleteFilesFrom.add(tosSourceDeletePage1THM);
225       
226       // --------------------------------------------------------------------------
227
// initialize FileCommitUtils object
228
// --------------------------------------------------------------------------
229
this.m_fcuFileTrancastion = new FileCommitUtils(FileCommitUtils.RC_OK_OBJ,
230                                                      lstCopyFilesFrom,
231                                                      lstCopyFilesTo,
232                                                      lstMoveFilesFrom,
233                                                      lstMoveFilesTo,
234                                                      lstReplaceFilesFrom,
235                                                      lstReplaceFilesTo,
236                                                      lstDeleteFilesFrom,
237                                                      true);
238    }
239
240    /**
241     * Set up environment for the test case.
242     *
243     * @throws Exception - an error has occured during setting up test
244     */

245    protected void setUp(
246    ) throws Exception JavaDoc
247    {
248       super.setUp();
249    }
250
251    /**
252     * Restore original environment after the test case.
253     *
254     * @throws Exception - an error has occured during tearing down up test
255     */

256    protected void tearDown(
257    ) throws Exception JavaDoc
258    {
259       super.tearDown();
260    }
261    
262    /**
263     * This is here defined just so JUnit passes
264     *
265     * @throws Exception - error during test
266     */

267    public void testDummy(
268    ) throws Exception JavaDoc
269    {
270       // TODO: Test: Missing all tests
271
}
272 }
273
Popular Tags