~svn/ubuntu/raring/subversion/ppa

« back to all changes in this revision

Viewing changes to subversion/bindings/java/javahl/src/org/tigris/subversion/javahl/tests/BasicTests.java

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-12-05 01:26:14 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051205012614-qom4xfypgtsqc2xq
Tags: 1.2.3dfsg1-3ubuntu1
Merge with the final Debian release of 1.2.3dfsg1-3, bringing in
fixes to the clean target, better documentation of the libdb4.3
upgrade and build fixes to work with swig1.3_1.3.27.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * @copyright
 
3
 * ====================================================================
 
4
 * Copyright (c) 2003-2004 CollabNet.  All rights reserved.
 
5
 *
 
6
 * This software is licensed as described in the file COPYING, which
 
7
 * you should have received as part of this distribution.  The terms
 
8
 * are also available at http://subversion.tigris.org/license-1.html.
 
9
 * If newer versions of this license are posted there, you may use a
 
10
 * newer version instead, at your option.
 
11
 *
 
12
 * This software consists of voluntary contributions made by many
 
13
 * individuals.  For exact contribution history, see the revision
 
14
 * history and logs, available at http://subversion.tigris.org/.
 
15
 * ====================================================================
 
16
 * @endcopyright
 
17
 */
 
18
package org.tigris.subversion.javahl.tests;
 
19
 
 
20
import junit.framework.TestSuite;
 
21
import junit.framework.TestResult;
 
22
import org.tigris.subversion.javahl.*;
 
23
 
 
24
import java.io.File;
 
25
import java.io.FileOutputStream;
 
26
import java.io.PrintWriter;
 
27
import java.util.Arrays;
 
28
/**
 
29
 * this class tests the basic functionality of javahl binding. It was inspired
 
30
 * by the tests in subversion/tests/clients/cmdline/basic_tests.py
 
31
 */
 
32
public class BasicTests extends SVNTests
 
33
{
 
34
    /**
 
35
     * base name of all our tests
 
36
     */
 
37
    public final static String testName = "basic_test";
 
38
 
 
39
    /**
 
40
     * Initialize the testBaseName and the testCounter, if this is the first
 
41
     * test of this class
 
42
     */
 
43
    public BasicTests()
 
44
    {
 
45
        if(!testName.equals(testBaseName))
 
46
        {
 
47
            testCounter = 0;
 
48
            testBaseName = testName;
 
49
        }
 
50
    }
 
51
 
 
52
    /**
 
53
     * Build a test suite of all tests of this class
 
54
     * @return the new test suite
 
55
     */
 
56
    public static TestSuite suite() {
 
57
        return new TestSuite(BasicTests.class);
 
58
    }
 
59
 
 
60
    /**
 
61
     * Main method to run tests standalone
 
62
     * @param args command line arguments to specify root directory and root
 
63
     * url
 
64
     */
 
65
    public static void main(String[] args) {
 
66
        processArgs(args);
 
67
        TestResult tr = junit.textui.TestRunner.run(suite());
 
68
        if (tr.errorCount() != 0 || tr.failureCount() != 0) {
 
69
            System.exit(1);
 
70
        }
 
71
        System.exit(0);
 
72
    }
 
73
 
 
74
    /**
 
75
     * test the basic SVNCLient.checkout functionality
 
76
     * @throws Throwable
 
77
     */
 
78
    public void testBasicCheckout() throws Throwable
 
79
    {
 
80
        // build the test setup
 
81
        OneTest thisTest = new OneTest();
 
82
        try
 
83
        {
 
84
            // obstructed checkout must fail
 
85
            client.checkout(thisTest.getUrl() + "/A", thisTest.getWCPath(),
 
86
                    null, true);
 
87
            fail("missing exception");
 
88
        }
 
89
        catch (ClientException e)
 
90
        {
 
91
        }
 
92
        // modify file A/mu
 
93
        File mu = new File(thisTest.getWorkingCopy(), "A/mu");
 
94
        PrintWriter muPW = new PrintWriter(new FileOutputStream(mu, true));
 
95
        muPW.print("appended mu text");
 
96
        muPW.close();
 
97
        thisTest.getWc().setItemTextStatus("A/mu", Status.Kind.modified);
 
98
 
 
99
        // delete A/B/lambda without svn
 
100
        File lambda = new File(thisTest.getWorkingCopy(), "A/B/lambda");
 
101
        lambda.delete();
 
102
        thisTest.getWc().setItemTextStatus("A/B/lambda", Status.Kind.missing);
 
103
 
 
104
        // remove A/D/G
 
105
        client.remove(new String[]{thisTest.getWCPath() + "/A/D/G"}, null,
 
106
                false);
 
107
        thisTest.getWc().setItemTextStatus("A/D/G", Status.Kind.deleted);
 
108
        thisTest.getWc().setItemTextStatus("A/D/G/pi", Status.Kind.deleted);
 
109
        thisTest.getWc().setItemTextStatus("A/D/G/rho", Status.Kind.deleted);
 
110
        thisTest.getWc().setItemTextStatus("A/D/G/tau", Status.Kind.deleted);
 
111
 
 
112
        // check the status of the working copy
 
113
        thisTest.checkStatus();
 
114
 
 
115
        // recheckout the working copy
 
116
        client.checkout(thisTest.getUrl(), thisTest.getWCPath(), null, true);
 
117
 
 
118
        // deleted file should reapear
 
119
        thisTest.getWc().setItemTextStatus("A/B/lambda", Status.Kind.normal);
 
120
 
 
121
        // check the status of the working copy
 
122
        thisTest.checkStatus();
 
123
    }
 
124
 
 
125
    /**
 
126
     * test the basic SVNClient.status functionality
 
127
     * @throws Throwable
 
128
     */
 
129
    public void testBasicStatus() throws Throwable
 
130
    {
 
131
        // build the test setup
 
132
        OneTest thisTest = new OneTest();
 
133
 
 
134
        // check the status of the working copy
 
135
        thisTest.checkStatus();
 
136
    }
 
137
 
 
138
    /**
 
139
     * test the basic SVNClient.commit functionality
 
140
     * @throws Throwable
 
141
     */
 
142
    public void testBasicCommit() throws Throwable
 
143
    {
 
144
        // build the test setup
 
145
        OneTest thisTest = new OneTest();
 
146
 
 
147
        // modify file A/mu
 
148
        File mu = new File(thisTest.getWorkingCopy(), "A/mu");
 
149
        PrintWriter muPW = new PrintWriter(new FileOutputStream(mu, true));
 
150
        muPW.print("appended mu text");
 
151
        muPW.close();
 
152
        thisTest.getWc().setItemWorkingCopyRevision("A/mu", 2);
 
153
        thisTest.getWc().setItemContent("A/mu",
 
154
                thisTest.getWc().getItemContent("A/mu") + "appended mu text");
 
155
        addExpectedCommitItem(thisTest.getWCPath(),
 
156
                thisTest.getUrl(), "A/mu",NodeKind.file,
 
157
                CommitItemStateFlags.TextMods);
 
158
 
 
159
        // modify file A/D/G/rho
 
160
        File rho = new File(thisTest.getWorkingCopy(), "A/D/G/rho");
 
161
        PrintWriter rhoPW = new PrintWriter(new FileOutputStream(rho, true));
 
162
        rhoPW.print("new appended text for rho");
 
163
        rhoPW.close();
 
164
        thisTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 2);
 
165
        thisTest.getWc().setItemContent("A/D/G/rho",
 
166
                thisTest.getWc().getItemContent("A/D/G/rho")
 
167
                + "new appended text for rho");
 
168
        addExpectedCommitItem(thisTest.getWCPath(),
 
169
                thisTest.getUrl(), "A/D/G/rho",NodeKind.file,
 
170
                CommitItemStateFlags.TextMods);
 
171
 
 
172
        // commit the changes
 
173
        assertEquals("wrong revision number from commit",
 
174
                client.commit(new String[]{thisTest.getWCPath()}, "log msg",
 
175
                        true), 2);
 
176
 
 
177
        // check the status of the working copy
 
178
        thisTest.checkStatus();
 
179
    }
 
180
 
 
181
    /**
 
182
     * test the basic SVNClient.update functionality
 
183
     * @throws Throwable
 
184
     */
 
185
    public void testBasicUpdate() throws Throwable
 
186
    {
 
187
        // build the test setup. Used for the changes
 
188
        OneTest thisTest = new OneTest();
 
189
 
 
190
        // build the backup test setup. That is the one that will be updated
 
191
        OneTest backupTest = thisTest.copy(".backup");
 
192
 
 
193
        // modify A/mu
 
194
        File mu = new File(thisTest.getWorkingCopy(), "A/mu");
 
195
        PrintWriter muPW = new PrintWriter(new FileOutputStream(mu, true));
 
196
        muPW.print("appended mu text");
 
197
        muPW.close();
 
198
        thisTest.getWc().setItemWorkingCopyRevision("A/mu", 2);
 
199
        thisTest.getWc().setItemContent("A/mu",
 
200
                thisTest.getWc().getItemContent("A/mu") + "appended mu text");
 
201
        addExpectedCommitItem(thisTest.getWCPath(),
 
202
                thisTest.getUrl(), "A/mu",NodeKind.file,
 
203
                CommitItemStateFlags.TextMods);
 
204
 
 
205
        // modify A/D/G/rho
 
206
        File rho = new File(thisTest.getWorkingCopy(), "A/D/G/rho");
 
207
        PrintWriter rhoPW = new PrintWriter(new FileOutputStream(rho, true));
 
208
        rhoPW.print("new appended text for rho");
 
209
        rhoPW.close();
 
210
        thisTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 2);
 
211
        thisTest.getWc().setItemContent("A/D/G/rho",
 
212
                thisTest.getWc().getItemContent("A/D/G/rho")
 
213
                + "new appended text for rho");
 
214
        addExpectedCommitItem(thisTest.getWCPath(),
 
215
                thisTest.getUrl(), "A/D/G/rho",NodeKind.file,
 
216
                CommitItemStateFlags.TextMods);
 
217
 
 
218
        // commit the changes
 
219
        assertEquals("wrong revision number from commit",
 
220
                client.commit(new String[]{thisTest.getWCPath()}, "log msg",
 
221
                        true), 2);
 
222
 
 
223
        // check the status of the working copy
 
224
        thisTest.checkStatus();
 
225
 
 
226
        // update the backup test
 
227
        assertEquals("wrong revision number from update",
 
228
                client.update(backupTest.getWCPath(), null, true), 2);
 
229
 
 
230
        // set the expected working copy layout for the backup test
 
231
        backupTest.getWc().setItemWorkingCopyRevision("A/mu", 2);
 
232
        backupTest.getWc().setItemContent("A/mu",
 
233
                backupTest.getWc().getItemContent("A/mu") + "appended mu text");
 
234
        backupTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 2);
 
235
        backupTest.getWc().setItemContent("A/D/G/rho",
 
236
                backupTest.getWc().getItemContent("A/D/G/rho")
 
237
                + "new appended text for rho");
 
238
 
 
239
        // check the status of the working copy of the backup test
 
240
        backupTest.checkStatus();
 
241
    }
 
242
 
 
243
    /**
 
244
     * test basic SVNClient.mkdir with url parameter functionality
 
245
     * @throws Throwable
 
246
     */
 
247
    public void testBasicMkdirUrl() throws Throwable
 
248
    {
 
249
        // build the test setup.
 
250
        OneTest thisTest = new OneTest();
 
251
 
 
252
        // create Y and Y/Z directories in the repository
 
253
        addExpectedCommitItem(null, thisTest.getUrl(), "Y", NodeKind.none,
 
254
                CommitItemStateFlags.Add);
 
255
        addExpectedCommitItem(null, thisTest.getUrl(), "Y/Z", NodeKind.none,
 
256
                CommitItemStateFlags.Add);
 
257
        client.mkdir(new String[]{thisTest.getUrl() + "/Y",
 
258
                                  thisTest.getUrl() + "/Y/Z"}, "log_msg");
 
259
 
 
260
        // add the new directories the expected working copy layout
 
261
        thisTest.getWc().addItem("Y", null);
 
262
        thisTest.getWc().setItemWorkingCopyRevision("Y", 2);
 
263
        thisTest.getWc().addItem("Y/Z", null);
 
264
        thisTest.getWc().setItemWorkingCopyRevision("Y/Z", 2);
 
265
 
 
266
        // update the working copy
 
267
        assertEquals("wrong revision from update",
 
268
                client.update(thisTest.getWCPath(), null, true), 2);
 
269
 
 
270
        // check the status of the working copy
 
271
        thisTest.checkStatus();
 
272
    }
 
273
 
 
274
    /**
 
275
     * test the basic SVNClient.update functionality with concurrent changes
 
276
     * in the repository and the working copy
 
277
     * @throws Throwable
 
278
     */
 
279
    public void testBasicMergingUpdate() throws Throwable
 
280
    {
 
281
        // build the first working copy
 
282
        OneTest thisTest = new OneTest();
 
283
 
 
284
        // append 10 lines to A/mu
 
285
        File mu = new File(thisTest.getWorkingCopy(), "A/mu");
 
286
        PrintWriter muPW = new PrintWriter(new FileOutputStream(mu, true));
 
287
        String muContent = thisTest.getWc().getItemContent("A/mu");
 
288
        for (int i = 2; i < 11; i++)
 
289
        {
 
290
            muPW.print("\nThis is line " + i + " in mu");
 
291
            muContent = muContent + "\nThis is line " + i + " in mu";
 
292
        }
 
293
        muPW.close();
 
294
        thisTest.getWc().setItemWorkingCopyRevision("A/mu", 2);
 
295
        thisTest.getWc().setItemContent("A/mu", muContent);
 
296
        addExpectedCommitItem(thisTest.getWorkingCopy().getAbsolutePath(),
 
297
                thisTest.getUrl(), "A/mu", NodeKind.file,
 
298
                CommitItemStateFlags.TextMods);
 
299
 
 
300
        // append 10 line to A/D/G/rho
 
301
        File rho = new File(thisTest.getWorkingCopy(), "A/D/G/rho");
 
302
        PrintWriter rhoPW = new PrintWriter(new FileOutputStream(rho, true));
 
303
        String rhoContent = thisTest.getWc().getItemContent("A/D/G/rho");
 
304
        for (int i = 2; i < 11; i++)
 
305
        {
 
306
            rhoPW.print("\nThis is line " + i + " in rho");
 
307
            rhoContent = rhoContent + "\nThis is line " + i + " in rho";
 
308
        }
 
309
        rhoPW.close();
 
310
        thisTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 2);
 
311
        thisTest.getWc().setItemContent("A/D/G/rho", rhoContent);
 
312
        addExpectedCommitItem(thisTest.getWCPath(),
 
313
                thisTest.getUrl(), "A/D/G/rho", NodeKind.file,
 
314
                CommitItemStateFlags.TextMods);
 
315
 
 
316
        // commit the changes
 
317
        assertEquals("wrong revision number from commit",
 
318
                client.commit(new String[]{thisTest.getWCPath()}, "log msg",
 
319
                        true), 2);
 
320
 
 
321
        // check the status of the first working copy
 
322
        thisTest.checkStatus();
 
323
 
 
324
        // create a backup copy of the working copy
 
325
        OneTest backupTest = thisTest.copy(".backup");
 
326
 
 
327
        // change the last line of A/mu in the first working copy
 
328
        muPW = new PrintWriter(new FileOutputStream(mu, true));
 
329
        muContent = thisTest.getWc().getItemContent("A/mu");
 
330
        muPW.print(" Appended to line 10 of mu");
 
331
        muContent = muContent + " Appended to line 10 of mu";
 
332
        muPW.close();
 
333
        thisTest.getWc().setItemWorkingCopyRevision("A/mu", 3);
 
334
        thisTest.getWc().setItemContent("A/mu", muContent);
 
335
        addExpectedCommitItem(thisTest.getWCPath(),
 
336
                thisTest.getUrl(), "A/mu", NodeKind.file,
 
337
                CommitItemStateFlags.TextMods);
 
338
 
 
339
        // change the last line of A/mu in the first working copy
 
340
        rhoPW = new PrintWriter(new FileOutputStream(rho, true));
 
341
        rhoContent = thisTest.getWc().getItemContent("A/D/G/rho");
 
342
        rhoPW.print(" Appended to line 10 of rho");
 
343
        rhoContent = rhoContent + " Appended to line 10 of rho";
 
344
        rhoPW.close();
 
345
        thisTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 3);
 
346
        thisTest.getWc().setItemContent("A/D/G/rho", rhoContent);
 
347
        addExpectedCommitItem(thisTest.getWCPath(),
 
348
                thisTest.getUrl(), "A/D/G/rho", NodeKind.file,
 
349
                CommitItemStateFlags.TextMods);
 
350
 
 
351
        // commit these changes to the repository
 
352
        assertEquals("wrong revision number from commit",
 
353
                client.commit(new String[]{thisTest.getWCPath()}, "log msg",
 
354
                        true), 3);
 
355
 
 
356
        // check the status of the first working copy
 
357
        thisTest.checkStatus();
 
358
 
 
359
        // modify the first line of A/mu in the backup working copy
 
360
        mu = new File(backupTest.getWorkingCopy(), "A/mu");
 
361
        muPW = new PrintWriter(new FileOutputStream(mu));
 
362
        muPW.print("This is the new line 1 in the backup copy of mu");
 
363
        muContent = "This is the new line 1 in the backup copy of mu";
 
364
        for (int i = 2; i < 11; i++)
 
365
        {
 
366
            muPW.print("\nThis is line " + i + " in mu");
 
367
            muContent = muContent + "\nThis is line " + i + " in mu";
 
368
        }
 
369
        muPW.close();
 
370
        backupTest.getWc().setItemWorkingCopyRevision("A/mu", 3);
 
371
        muContent = muContent + " Appended to line 10 of mu";
 
372
        backupTest.getWc().setItemContent("A/mu", muContent);
 
373
        backupTest.getWc().setItemTextStatus("A/mu", Status.Kind.modified);
 
374
 
 
375
        // modify the first line of A/D/G/rho in the backup working copy
 
376
        rho = new File(backupTest.getWorkingCopy(), "A/D/G/rho");
 
377
        rhoPW = new PrintWriter(new FileOutputStream(rho));
 
378
        rhoPW.print("This is the new line 1 in the backup copy of rho");
 
379
        rhoContent = "This is the new line 1 in the backup copy of rho";
 
380
        for (int i = 2; i < 11; i++)
 
381
        {
 
382
            rhoPW.print("\nThis is line " + i + " in rho");
 
383
            rhoContent = rhoContent + "\nThis is line " + i + " in rho";
 
384
        }
 
385
        rhoPW.close();
 
386
        backupTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 3);
 
387
        rhoContent = rhoContent + " Appended to line 10 of rho";
 
388
        backupTest.getWc().setItemContent("A/D/G/rho", rhoContent);
 
389
        backupTest.getWc().setItemTextStatus("A/D/G/rho", Status.Kind.modified);
 
390
 
 
391
        // update the backup working copy
 
392
        assertEquals("wrong revision number from update",
 
393
                client.update(backupTest.getWCPath(), null, true), 3);
 
394
 
 
395
        // check the status of the backup working copy
 
396
        backupTest.checkStatus();
 
397
    }
 
398
 
 
399
    /**
 
400
     * test the basic SVNClient.update functionality with concurrent changes
 
401
     * in the repository and the working copy that generate conflicts
 
402
     * @throws Throwable
 
403
     */
 
404
    public void testBasicConflict() throws Throwable
 
405
    {
 
406
        // build the first working copy
 
407
        OneTest thisTest = new OneTest();
 
408
 
 
409
        // copy the first working copy to the backup working copy
 
410
        OneTest backupTest = thisTest.copy(".backup");
 
411
 
 
412
        // append a line to A/mu in the first working copy
 
413
        File mu = new File(thisTest.getWorkingCopy(), "A/mu");
 
414
        PrintWriter muPW = new PrintWriter(new FileOutputStream(mu, true));
 
415
        String muContent = thisTest.getWc().getItemContent("A/mu");
 
416
        muPW.print("\nOriginal appended text for mu");
 
417
        muContent = muContent + "\nOriginal appended text for mu";
 
418
        muPW.close();
 
419
        thisTest.getWc().setItemWorkingCopyRevision("A/mu", 2);
 
420
        thisTest.getWc().setItemContent("A/mu", muContent);
 
421
        addExpectedCommitItem(thisTest.getWCPath(),
 
422
                thisTest.getUrl(), "A/mu", NodeKind.file,
 
423
                CommitItemStateFlags.TextMods);
 
424
 
 
425
        // append a line to A/D/G/rho in the first working copy
 
426
        File rho = new File(thisTest.getWorkingCopy(), "A/D/G/rho");
 
427
        PrintWriter rhoPW = new PrintWriter(new FileOutputStream(rho, true));
 
428
        String rhoContent = thisTest.getWc().getItemContent("A/D/G/rho");
 
429
        rhoPW.print("\nOriginal appended text for rho");
 
430
        rhoContent = rhoContent + "\nOriginal appended text for rho";
 
431
        rhoPW.close();
 
432
        thisTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 2);
 
433
        thisTest.getWc().setItemContent("A/D/G/rho", rhoContent);
 
434
        addExpectedCommitItem(thisTest.getWCPath(),
 
435
                thisTest.getUrl(), "A/D/G/rho", NodeKind.file,
 
436
                CommitItemStateFlags.TextMods);
 
437
 
 
438
        // commit the changes in the first working copy
 
439
        assertEquals("wrong revision number from commit",
 
440
                client.commit(new String[]{thisTest.getWCPath()}, "log msg",
 
441
                        true), 2);
 
442
 
 
443
        // test the status of the working copy after the commit
 
444
        thisTest.checkStatus();
 
445
 
 
446
        // append a different line to A/mu in the backup working copy
 
447
        mu = new File(backupTest.getWorkingCopy(), "A/mu");
 
448
        muPW = new PrintWriter(new FileOutputStream(mu, true));
 
449
        muPW.print("\nConflicting appended text for mu");
 
450
        muContent = "<<<<<<< .mine\nThis is the file 'mu'.\n"+
 
451
                "Conflicting appended text for mu=======\n"+
 
452
                "This is the file 'mu'.\n"+
 
453
                "Original appended text for mu>>>>>>> .r2";
 
454
        muPW.close();
 
455
        backupTest.getWc().setItemWorkingCopyRevision("A/mu", 2);
 
456
        backupTest.getWc().setItemContent("A/mu", muContent);
 
457
        backupTest.getWc().setItemTextStatus("A/mu", Status.Kind.conflicted);
 
458
        backupTest.getWc().addItem("A/mu.r1", "");
 
459
        backupTest.getWc().setItemNodeKind("A/mu.r1", NodeKind.unknown);
 
460
        backupTest.getWc().setItemTextStatus("A/mu.r1",
 
461
                Status.Kind.unversioned);
 
462
        backupTest.getWc().addItem("A/mu.r2", "");
 
463
        backupTest.getWc().setItemNodeKind("A/mu.r2", NodeKind.unknown);
 
464
        backupTest.getWc().setItemTextStatus("A/mu.r2",
 
465
                Status.Kind.unversioned);
 
466
        backupTest.getWc().addItem("A/mu.mine", "");
 
467
        backupTest.getWc().setItemNodeKind("A/mu.mine", NodeKind.unknown);
 
468
        backupTest.getWc().setItemTextStatus("A/mu.mine",
 
469
                Status.Kind.unversioned);
 
470
 
 
471
        // append a different line to A/D/G/rho in the backup working copy
 
472
        rho = new File(backupTest.getWorkingCopy(), "A/D/G/rho");
 
473
        rhoPW = new PrintWriter(new FileOutputStream(rho, true));
 
474
        rhoPW.print("\nConflicting appended text for rho");
 
475
        rhoContent = "<<<<<<< .mine\nThis is the file 'rho'.\n"+
 
476
                "Conflicting appended text for rho=======\n"+
 
477
                "his is the file 'rho'.\n"+
 
478
                "Original appended text for rho>>>>>>> .r2";
 
479
        rhoPW.close();
 
480
        backupTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 2);
 
481
        backupTest.getWc().setItemContent("A/D/G/rho", rhoContent);
 
482
        backupTest.getWc().setItemTextStatus("A/D/G/rho",
 
483
                Status.Kind.conflicted);
 
484
        backupTest.getWc().addItem("A/D/G/rho.r1", "");
 
485
        backupTest.getWc().setItemNodeKind("A/D/G/rho.r1", NodeKind.unknown);
 
486
        backupTest.getWc().setItemTextStatus("A/D/G/rho.r1",
 
487
                Status.Kind.unversioned);
 
488
        backupTest.getWc().addItem("A/D/G/rho.r2", "");
 
489
        backupTest.getWc().setItemNodeKind("A/D/G/rho.r2", NodeKind.unknown);
 
490
        backupTest.getWc().setItemTextStatus("A/D/G/rho.r2",
 
491
                Status.Kind.unversioned);
 
492
        backupTest.getWc().addItem("A/D/G/rho.mine", "");
 
493
        backupTest.getWc().setItemNodeKind("A/D/G/rho.mine", NodeKind.unknown);
 
494
        backupTest.getWc().setItemTextStatus("A/D/G/rho.mine",
 
495
                Status.Kind.unversioned);
 
496
 
 
497
        // update the backup working copy from the repository
 
498
        assertEquals("wrong revision number from update",
 
499
                client.update(backupTest.getWCPath(), null, true), 2);
 
500
 
 
501
        // check the status of the backup working copy
 
502
        backupTest.checkStatus();
 
503
 
 
504
        // flag A/mu as resolved
 
505
        client.resolved(backupTest.getWCPath()+"/A/mu",false);
 
506
        backupTest.getWc().setItemTextStatus("A/mu", Status.Kind.modified);
 
507
        backupTest.getWc().removeItem("A/mu.r1");
 
508
        backupTest.getWc().removeItem("A/mu.r2");
 
509
        backupTest.getWc().removeItem("A/mu.mine");
 
510
 
 
511
        // flag A/D/G/rho as resolved
 
512
        client.resolved(backupTest.getWCPath()+"/A/D/G/rho",false);
 
513
        backupTest.getWc().setItemTextStatus("A/D/G/rho", Status.Kind.modified);
 
514
        backupTest.getWc().removeItem("A/D/G/rho.r1");
 
515
        backupTest.getWc().removeItem("A/D/G/rho.r2");
 
516
        backupTest.getWc().removeItem("A/D/G/rho.mine");
 
517
 
 
518
        // check the status after the conflicts are flaged as resolved
 
519
        backupTest.checkStatus();
 
520
    }
 
521
 
 
522
    /**
 
523
     * test the basic SVNClient.cleanup functionality
 
524
     * @throws Throwable
 
525
     */
 
526
    public void testBasicCleanup() throws Throwable
 
527
    {
 
528
        // create a test working copy
 
529
        OneTest thisTest = new OneTest();
 
530
 
 
531
        // create a lock file in A/B
 
532
        File adminLock = new File(thisTest.getWorkingCopy(),"A/B/.svn/lock");
 
533
        PrintWriter pw = new PrintWriter(new FileOutputStream(adminLock));
 
534
        pw.print("stop looking!");
 
535
        pw.close();
 
536
        thisTest.getWc().setItemIsLocked("A/B", true);
 
537
 
 
538
        // create a lock file in A/D/G
 
539
        adminLock = new File(thisTest.getWorkingCopy(),"A/D/G/.svn/lock");
 
540
        pw = new PrintWriter(new FileOutputStream(adminLock));
 
541
        pw.print("stop looking!");
 
542
        pw.close();
 
543
        thisTest.getWc().setItemIsLocked("A/D/G", true);
 
544
 
 
545
        // create a lock file in A/C
 
546
        adminLock = new File(thisTest.getWorkingCopy(),"A/C/.svn/lock");
 
547
        pw = new PrintWriter(new FileOutputStream(adminLock));
 
548
        pw.print("stop looking!");
 
549
        pw.close();
 
550
        thisTest.getWc().setItemIsLocked("A/C", true);
 
551
 
 
552
        // test the status of the working copy
 
553
        thisTest.checkStatus();
 
554
 
 
555
        // run cleanup
 
556
        client.cleanup(thisTest.getWCPath());
 
557
        thisTest.getWc().setItemIsLocked("A/B", false);
 
558
        thisTest.getWc().setItemIsLocked("A/D/G", false);
 
559
        thisTest.getWc().setItemIsLocked("A/C", false);
 
560
 
 
561
        // test the status of the working copy
 
562
        thisTest.checkStatus();
 
563
    }
 
564
 
 
565
    /**
 
566
     * Test the basic SVNClient.revert functionality
 
567
      * @throws Throwable
 
568
     */
 
569
    public void testBasicRevert() throws Throwable
 
570
    {
 
571
        // create a test working copy
 
572
        OneTest thisTest = new OneTest();
 
573
 
 
574
        // modify A/B/E/beta
 
575
        File file = new File(thisTest.getWorkingCopy(), "A/B/E/beta");
 
576
        PrintWriter pw = new PrintWriter(new FileOutputStream(file, true));
 
577
        pw.print("Added some text to 'beta'.");
 
578
        pw.close();
 
579
        thisTest.getWc().setItemTextStatus("A/B/E/beta", Status.Kind.modified);
 
580
 
 
581
        // modify iota
 
582
        file = new File(thisTest.getWorkingCopy(), "iota");
 
583
        pw = new PrintWriter(new FileOutputStream(file, true));
 
584
        pw.print("Added some text to 'iota'.");
 
585
        pw.close();
 
586
        thisTest.getWc().setItemTextStatus("iota", Status.Kind.modified);
 
587
 
 
588
        // modify A/D/G/rho
 
589
        file = new File(thisTest.getWorkingCopy(), "A/D/G/rho");
 
590
        pw = new PrintWriter(new FileOutputStream(file, true));
 
591
        pw.print("Added some text to 'rho'.");
 
592
        pw.close();
 
593
        thisTest.getWc().setItemTextStatus("A/D/G/rho", Status.Kind.modified);
 
594
 
 
595
        // create new file A/D/H/zeta and add it to subversion
 
596
        file = new File(thisTest.getWorkingCopy(), "A/D/H/zeta");
 
597
        pw = new PrintWriter(new FileOutputStream(file, true));
 
598
        pw.print("Added some text to 'zeta'.");
 
599
        pw.close();
 
600
        thisTest.getWc().addItem("A/D/H/zeta", "Added some text to 'zeta'.");
 
601
        thisTest.getWc().setItemTextStatus("A/D/H/zeta", Status.Kind.added);
 
602
        client.add(file.getAbsolutePath(), false);
 
603
 
 
604
        // test the status of the working copy
 
605
        thisTest.checkStatus();
 
606
 
 
607
        // revert the changes
 
608
        client.revert(thisTest.getWCPath()+"/A/B/E/beta", false);
 
609
        thisTest.getWc().setItemTextStatus("A/B/E/beta", Status.Kind.normal);
 
610
        client.revert(thisTest.getWCPath()+"/iota", false);
 
611
        thisTest.getWc().setItemTextStatus("iota", Status.Kind.normal);
 
612
        client.revert(thisTest.getWCPath()+"/A/D/G/rho", false);
 
613
        thisTest.getWc().setItemTextStatus("A/D/G/rho", Status.Kind.normal);
 
614
        client.revert(thisTest.getWCPath()+"/A/D/H/zeta", false);
 
615
        thisTest.getWc().setItemTextStatus("A/D/H/zeta",
 
616
                Status.Kind.unversioned);
 
617
        thisTest.getWc().setItemNodeKind("A/D/H/zeta", NodeKind.unknown);
 
618
 
 
619
        // test the status of the working copy
 
620
        thisTest.checkStatus();
 
621
 
 
622
        // delete A/B/E/beta and revert the change
 
623
        file = new File(thisTest.getWorkingCopy(), "A/B/E/beta");
 
624
        file.delete();
 
625
        client.revert(file.getAbsolutePath(), false);
 
626
 
 
627
        // resurected file should not be readonly
 
628
        assertTrue("reverted file is not readonly",
 
629
                file.canWrite()&& file.canRead());
 
630
 
 
631
        // test the status of the working copy
 
632
        thisTest.checkStatus();
 
633
 
 
634
        // create & add the directory X
 
635
        client.mkdir(new String[] {thisTest.getWCPath()+"/X"}, null);
 
636
        thisTest.getWc().addItem("X", null);
 
637
        thisTest.getWc().setItemTextStatus("X", Status.Kind.added);
 
638
 
 
639
        // test the status of the working copy
 
640
        thisTest.checkStatus();
 
641
 
 
642
        // remove & revert X
 
643
        removeDirectoryWithContent(new File(thisTest.getWorkingCopy(), "X"));
 
644
        client.revert(thisTest.getWCPath()+"/X", false);
 
645
        thisTest.getWc().removeItem("X");
 
646
 
 
647
        // test the status of the working copy
 
648
        thisTest.checkStatus();
 
649
 
 
650
        // delete the directory A/B/E
 
651
        client.remove(new String[] {thisTest.getWCPath()+"/A/B/E"}, null, true);
 
652
        removeDirectoryWithContent(new File(thisTest.getWorkingCopy(), "A/B/E"));
 
653
        thisTest.getWc().setItemTextStatus("A/B/E", Status.Kind.deleted);
 
654
        thisTest.getWc().removeItem("A/B/E/alpha");
 
655
        thisTest.getWc().removeItem("A/B/E/beta");
 
656
 
 
657
        // test the status of the working copy
 
658
        thisTest.checkStatus();
 
659
 
 
660
        // revert A/B/E -> this will not resurect it
 
661
        client.revert(thisTest.getWCPath()+"/A/B/E", true);
 
662
 
 
663
        // test the status of the working copy
 
664
        thisTest.checkStatus();
 
665
    }
 
666
 
 
667
    /**
 
668
     * thest the basic SVNClient.switch functionality
 
669
     * @throws Throwable
 
670
     */
 
671
    public void testBasicSwitch() throws Throwable
 
672
    {
 
673
        // create the test working copy
 
674
        OneTest thisTest = new OneTest();
 
675
 
 
676
        // switch iota to A/D/gamma
 
677
        String iotaPath = thisTest.getWCPath() + "/iota";
 
678
        String gammaUrl = thisTest.getUrl() + "/A/D/gamma";
 
679
        thisTest.getWc().setItemContent("iota",
 
680
                greekWC.getItemContent("A/D/gamma"));
 
681
        thisTest.getWc().setItemIsSwitched("iota", true);
 
682
        client.doSwitch(iotaPath, gammaUrl, null, true);
 
683
 
 
684
        // check the status of the working copy
 
685
        thisTest.checkStatus();
 
686
 
 
687
        // switch A/D/H to /A/D/G
 
688
        String adhPath = thisTest.getWCPath() + "/A/D/H";
 
689
        String adgURL = thisTest.getUrl() + "/A/D/G";
 
690
        thisTest.getWc().setItemIsSwitched("A/D/H",true);
 
691
        thisTest.getWc().removeItem("A/D/H/chi");
 
692
        thisTest.getWc().removeItem("A/D/H/omega");
 
693
        thisTest.getWc().removeItem("A/D/H/psi");
 
694
        thisTest.getWc().addItem("A/D/H/pi",
 
695
                thisTest.getWc().getItemContent("A/D/G/pi"));
 
696
        thisTest.getWc().addItem("A/D/H/rho",
 
697
                thisTest.getWc().getItemContent("A/D/G/rho"));
 
698
        thisTest.getWc().addItem("A/D/H/tau",
 
699
                thisTest.getWc().getItemContent("A/D/G/tau"));
 
700
        client.doSwitch(adhPath, adgURL, null, true);
 
701
 
 
702
        // check the status of the working copy
 
703
        thisTest.checkStatus();
 
704
    }
 
705
 
 
706
    /**
 
707
     * test the basic SVNClient.remove functionality
 
708
     * @throws Throwable
 
709
     */
 
710
    public void testBasicDelete() throws Throwable
 
711
    {
 
712
        // create the test working copy
 
713
        OneTest thisTest = new OneTest();
 
714
 
 
715
        // modify A/D/H/chi
 
716
        File file = new File(thisTest.getWorkingCopy(), "A/D/H/chi");
 
717
        PrintWriter pw = new PrintWriter(new FileOutputStream(file, true));
 
718
        pw.print("added to chi");
 
719
        pw.close();
 
720
        thisTest.getWc().setItemTextStatus("A/D/H/chi", Status.Kind.modified);
 
721
 
 
722
        // set a property on A/D/G/rho file
 
723
        client.propertySet(thisTest.getWCPath()+"/A/D/G/rho", "abc", "def",
 
724
                true);
 
725
        thisTest.getWc().setItemPropStatus("A/D/G/rho", Status.Kind.modified);
 
726
 
 
727
        // set a property on A/B/F directory
 
728
        client.propertySet(thisTest.getWCPath()+"/A/B/F", "abc", "def", false);
 
729
        thisTest.getWc().setItemPropStatus("A/B/F", Status.Kind.modified);
 
730
 
 
731
        // create a unversioned A/C/sigma file
 
732
        file = new File(thisTest.getWCPath(),"A/C/sigma");
 
733
        pw = new PrintWriter(new FileOutputStream(file));
 
734
        pw.print("unversioned sigma");
 
735
        pw.close();
 
736
        thisTest.getWc().addItem("A/C/sigma", "unversioned sigma");
 
737
        thisTest.getWc().setItemTextStatus("A/C/sigma", Status.Kind.unversioned);
 
738
        thisTest.getWc().setItemNodeKind("A/C/sigma", NodeKind.unknown);
 
739
 
 
740
        // create unversioned directory A/C/Q
 
741
        file = new File(thisTest.getWCPath(), "A/C/Q");
 
742
        file.mkdir();
 
743
        thisTest.getWc().addItem("A/C/Q", null);
 
744
        thisTest.getWc().setItemNodeKind("A/C/Q", NodeKind.unknown);
 
745
        thisTest.getWc().setItemTextStatus("A/C/Q", Status.Kind.unversioned);
 
746
 
 
747
        // create & add the directory A/B/X
 
748
        file = new File(thisTest.getWCPath(), "A/B/X");
 
749
        client.mkdir(new String[] {file.getAbsolutePath()}, null);
 
750
        thisTest.getWc().addItem("A/B/X", null);
 
751
        thisTest.getWc().setItemTextStatus("A/B/X", Status.Kind.added);
 
752
 
 
753
        // create & add the file A/B/X/xi
 
754
        file = new File(file, "xi");
 
755
        pw = new PrintWriter(new FileOutputStream(file));
 
756
        pw.print("added xi");
 
757
        pw.close();
 
758
        client.add(file.getAbsolutePath(),false);
 
759
        thisTest.getWc().addItem("A/B/X/xi", "added xi");
 
760
        thisTest.getWc().setItemTextStatus("A/B/X/xi", Status.Kind.added);
 
761
 
 
762
        // create & add the directory A/B/Y
 
763
        file = new File(thisTest.getWCPath(), "A/B/Y");
 
764
        client.mkdir(new String[] {file.getAbsolutePath()}, null);
 
765
        thisTest.getWc().addItem("A/B/Y", null);
 
766
        thisTest.getWc().setItemTextStatus("A/B/Y", Status.Kind.added);
 
767
 
 
768
        // test the status of the working copy
 
769
        thisTest.checkStatus();
 
770
 
 
771
        // the following removes should all fail without force
 
772
 
 
773
        try
 
774
        {
 
775
            // remove of A/D/H/chi without force should fail, because it is
 
776
            // modified
 
777
            client.remove(new String[] {thisTest.getWCPath()+"/A/D/H/chi"},
 
778
                    null, false);
 
779
            fail("missing exception");
 
780
        }
 
781
        catch(ClientException e)
 
782
        {
 
783
        }
 
784
 
 
785
        try
 
786
        {
 
787
            // remove of A/D/H without force should fail, because A/D/H/chi is
 
788
            // modified
 
789
            client.remove(new String[] {thisTest.getWCPath()+"/A/D/H"}, null,
 
790
                    false);
 
791
            fail("missing exception");
 
792
        }
 
793
        catch(ClientException e)
 
794
        {
 
795
        }
 
796
 
 
797
        try
 
798
        {
 
799
            // remove of A/D/G/rho without force should fail, because it has
 
800
            // a new property
 
801
            client.remove(new String[] {thisTest.getWCPath()+"/A/D/G/rho"},
 
802
                    null, false);
 
803
            fail("missing exception");
 
804
        }
 
805
        catch(ClientException e)
 
806
        {
 
807
        }
 
808
 
 
809
        try
 
810
        {
 
811
            // remove of A/D/G without force should fail, because A/D/G/rho has
 
812
            // a new property
 
813
            client.remove(new String[] {thisTest.getWCPath()+"/A/D/G"}, null,
 
814
                    false);
 
815
            fail("missing exception");
 
816
        }
 
817
        catch(ClientException e)
 
818
        {
 
819
        }
 
820
 
 
821
        try
 
822
        {
 
823
            // remove of A/B/F without force should fail, because it has
 
824
            // a new property
 
825
            client.remove(new String[] {thisTest.getWCPath()+"/A/B/F"}, null,
 
826
                    false);
 
827
            fail("missing exception");
 
828
        }
 
829
        catch(ClientException e)
 
830
        {
 
831
        }
 
832
 
 
833
        try
 
834
        {
 
835
            // remove of A/B without force should fail, because A/B/F has
 
836
            // a new property
 
837
            client.remove(new String[] {thisTest.getWCPath()+"/A/B"}, null,
 
838
                    false);
 
839
            fail("missing exception");
 
840
        }
 
841
        catch(ClientException e)
 
842
        {
 
843
        }
 
844
 
 
845
        try
 
846
        {
 
847
            // remove of A/C/sigma without force should fail, because it is
 
848
            // unversioned
 
849
            client.remove(new String[] {thisTest.getWCPath()+"/A/C/sigma"},
 
850
                    null, false);
 
851
            fail("missing exception");
 
852
        }
 
853
        catch(ClientException e)
 
854
        {
 
855
        }
 
856
 
 
857
        try
 
858
        {
 
859
            // remove of A/C without force should fail, because A/C/sigma is
 
860
            // unversioned
 
861
            client.remove(new String[] {thisTest.getWCPath()+"/A/C"}, null,
 
862
                    false);
 
863
            fail("missing exception");
 
864
        }
 
865
        catch(ClientException e)
 
866
        {
 
867
        }
 
868
 
 
869
        try
 
870
        {
 
871
            // remove of A/B/X without force should fail, because it is new
 
872
            client.remove(new String[] {thisTest.getWCPath()+"/A/B/X"}, null,
 
873
                    false);
 
874
            fail("missing exception");
 
875
        }
 
876
        catch(ClientException e)
 
877
        {
 
878
        }
 
879
 
 
880
        // check the status of the working copy
 
881
        thisTest.checkStatus();
 
882
 
 
883
        // the following removes should all work
 
884
        client.remove(new String[] {thisTest.getWCPath()+"/A/B/E"}, null,
 
885
                false);
 
886
        thisTest.getWc().setItemTextStatus("A/B/E",Status.Kind.deleted);
 
887
        thisTest.getWc().setItemTextStatus("A/B/E/alpha",Status.Kind.deleted);
 
888
        thisTest.getWc().setItemTextStatus("A/B/E/beta",Status.Kind.deleted);
 
889
        client.remove(new String[] {thisTest.getWCPath()+"/A/D/H"}, null, true);
 
890
        thisTest.getWc().setItemTextStatus("A/D/H",Status.Kind.deleted);
 
891
        thisTest.getWc().setItemTextStatus("A/D/H/chi",Status.Kind.deleted);
 
892
        thisTest.getWc().setItemTextStatus("A/D/H/omega",Status.Kind.deleted);
 
893
        thisTest.getWc().setItemTextStatus("A/D/H/psi",Status.Kind.deleted);
 
894
        client.remove(new String[] {thisTest.getWCPath()+"/A/D/G"}, null, true);
 
895
        thisTest.getWc().setItemTextStatus("A/D/G",Status.Kind.deleted);
 
896
        thisTest.getWc().setItemTextStatus("A/D/G/rho",Status.Kind.deleted);
 
897
        thisTest.getWc().setItemPropStatus("A/D/G/rho", Status.Kind.none);
 
898
        thisTest.getWc().setItemTextStatus("A/D/G/pi",Status.Kind.deleted);
 
899
        thisTest.getWc().setItemTextStatus("A/D/G/tau",Status.Kind.deleted);
 
900
        client.remove(new String[] {thisTest.getWCPath()+"/A/B/F"}, null, true);
 
901
        thisTest.getWc().setItemTextStatus("A/B/F",Status.Kind.deleted);
 
902
        thisTest.getWc().setItemPropStatus("A/B/F", Status.Kind.none);
 
903
        client.remove(new String[] {thisTest.getWCPath()+"/A/C"}, null, true);
 
904
        thisTest.getWc().setItemTextStatus("A/C",Status.Kind.deleted);
 
905
        client.remove(new String[] {thisTest.getWCPath()+"/A/B/X"}, null, true);
 
906
        file = new File(thisTest.getWorkingCopy(), "iota");
 
907
        file.delete();
 
908
        client.remove(new String[] {file.getAbsolutePath()}, null, true);
 
909
        thisTest.getWc().setItemTextStatus("iota",Status.Kind.deleted);
 
910
        file = new File(thisTest.getWorkingCopy(), "A/D/gamma");
 
911
        file.delete();
 
912
        client.remove(new String[] {file.getAbsolutePath()}, null, false);
 
913
        thisTest.getWc().setItemTextStatus("A/D/gamma",Status.Kind.deleted);
 
914
        client.remove(new String[] {file.getAbsolutePath()}, null, true);
 
915
        client.remove(new String[] {thisTest.getWCPath()+"/A/B/E"}, null,
 
916
                false);
 
917
        thisTest.getWc().removeItem("A/B/X");
 
918
        thisTest.getWc().removeItem("A/B/X/xi");
 
919
        thisTest.getWc().removeItem("A/C/sigma");
 
920
        thisTest.getWc().removeItem("A/C/Q");
 
921
        thisTest.checkStatus();
 
922
        client.remove(new String[] {thisTest.getWCPath()+"/A/D"},null, true);
 
923
        thisTest.getWc().setItemTextStatus("A/D", Status.Kind.deleted);
 
924
        thisTest.getWc().removeItem("A/D/Y");
 
925
 
 
926
        // check the status of the working copy
 
927
        thisTest.checkStatus();
 
928
 
 
929
        // confirm that the file are realy deleted
 
930
        assertFalse("failed to remove text modified file",
 
931
                new File(thisTest.getWorkingCopy(), "A/D/G/rho").exists());
 
932
        assertFalse("failed to remove prop modified file",
 
933
                new File(thisTest.getWorkingCopy(), "A/D/H/chi").exists());
 
934
        assertFalse("failed to remove unversioned file",
 
935
                new File(thisTest.getWorkingCopy(), "A/C/sigma").exists());
 
936
        assertFalse("failed to remove unmodified file",
 
937
                new File(thisTest.getWorkingCopy(), "A/B/E/alpha").exists());
 
938
        file = new File(thisTest.getWorkingCopy(),"A/B/F");
 
939
        assertTrue("removed versioned dir", file.exists()
 
940
                && file.isDirectory());
 
941
        assertFalse("failed to remove unversioned dir",
 
942
                new File(thisTest.getWorkingCopy(), "A/C/Q").exists());
 
943
        assertFalse("failed to remove added dir",
 
944
                new File(thisTest.getWorkingCopy(), "A/B/X").exists());
 
945
 
 
946
        // delete unversioned file foo
 
947
        file = new File(thisTest.getWCPath(),"foo");
 
948
        pw = new PrintWriter(new FileOutputStream(file));
 
949
        pw.print("unversioned foo");
 
950
        pw.close();
 
951
        client.remove(new String[] {file.getAbsolutePath()}, null, true);
 
952
        assertFalse("failed to remove unversioned file foo", file.exists());
 
953
        client.remove(new String[] {file.getAbsolutePath()}, null, true);
 
954
 
 
955
        // delete file iota in the repository
 
956
        addExpectedCommitItem(null, thisTest.getUrl(), "iota", NodeKind.none,
 
957
                CommitItemStateFlags.Delete);
 
958
        client.remove(new String[] {thisTest.getUrl()+"/iota"},
 
959
                "delete iota URL", false);
 
960
    }
 
961
 
 
962
    public void testBasicCheckoutDeleted() throws Throwable
 
963
    {
 
964
        // create working copy
 
965
        OneTest thisTest = new OneTest();
 
966
 
 
967
        // delete A/D and its content
 
968
        client.remove(new String[] {thisTest.getWCPath()+"/A/D"}, null, true);
 
969
        thisTest.getWc().setItemTextStatus("A/D", Status.Kind.deleted);
 
970
        thisTest.getWc().setItemTextStatus("A/D/G", Status.Kind.deleted);
 
971
        thisTest.getWc().setItemTextStatus("A/D/G/rho", Status.Kind.deleted);
 
972
        thisTest.getWc().setItemTextStatus("A/D/G/pi", Status.Kind.deleted);
 
973
        thisTest.getWc().setItemTextStatus("A/D/G/tau", Status.Kind.deleted);
 
974
        thisTest.getWc().setItemTextStatus("A/D/H", Status.Kind.deleted);
 
975
        thisTest.getWc().setItemTextStatus("A/D/H/chi", Status.Kind.deleted);
 
976
        thisTest.getWc().setItemTextStatus("A/D/H/psi", Status.Kind.deleted);
 
977
        thisTest.getWc().setItemTextStatus("A/D/H/omega", Status.Kind.deleted);
 
978
        thisTest.getWc().setItemTextStatus("A/D/gamma", Status.Kind.deleted);
 
979
 
 
980
        // check the working copy status
 
981
        thisTest.checkStatus();
 
982
 
 
983
        // commit the change
 
984
        addExpectedCommitItem(thisTest.getWCPath(),
 
985
                thisTest.getUrl(), "A/D", NodeKind.dir,
 
986
                CommitItemStateFlags.Delete);
 
987
        assertEquals("wrong revision from commit",
 
988
                client.commit(new String[]{thisTest.getWCPath()}, "log message",
 
989
                        true),2);
 
990
        thisTest.getWc().removeItem("A/D");
 
991
        thisTest.getWc().removeItem("A/D/G");
 
992
        thisTest.getWc().removeItem("A/D/G/rho");
 
993
        thisTest.getWc().removeItem("A/D/G/pi");
 
994
        thisTest.getWc().removeItem("A/D/G/tau");
 
995
        thisTest.getWc().removeItem("A/D/H");
 
996
        thisTest.getWc().removeItem("A/D/H/chi");
 
997
        thisTest.getWc().removeItem("A/D/H/psi");
 
998
        thisTest.getWc().removeItem("A/D/H/omega");
 
999
        thisTest.getWc().removeItem("A/D/gamma");
 
1000
 
 
1001
        // check the working copy status
 
1002
        thisTest.checkStatus();
 
1003
 
 
1004
        // check out the previous revision
 
1005
        client.checkout(thisTest.getUrl()+"/A/D", thisTest.getWCPath()+"/new_D",
 
1006
                new Revision.Number(1), true);
 
1007
    }
 
1008
 
 
1009
    /**
 
1010
     * Test if Subversion will detect the change of a file to a direcory
 
1011
     * @throws Throwable
 
1012
     */
 
1013
    public void testBasicNodeKindChange() throws Throwable
 
1014
    {
 
1015
        // create working copy
 
1016
        OneTest thisTest = new OneTest();
 
1017
 
 
1018
        //  remove A/D/gamma
 
1019
        client.remove(new String[] {thisTest.getWCPath()+"/A/D/gamma"}, null,
 
1020
                false);
 
1021
        thisTest.getWc().setItemTextStatus("A/D/gamma", Status.Kind.deleted);
 
1022
 
 
1023
        // check the working copy status
 
1024
        thisTest.checkStatus();
 
1025
 
 
1026
        try
 
1027
        {
 
1028
            // creating a directory in the place of the deleted file should
 
1029
            // fail
 
1030
            client.mkdir(new String[] {thisTest.getWCPath()+"/A/D/gamma"},
 
1031
                    null);
 
1032
            fail("can change node kind");
 
1033
        }
 
1034
        catch(ClientException e)
 
1035
        {
 
1036
 
 
1037
        }
 
1038
 
 
1039
        // check the working copy status
 
1040
        thisTest.checkStatus();
 
1041
 
 
1042
        // commit the deletion
 
1043
        addExpectedCommitItem(thisTest.getWCPath(),
 
1044
                thisTest.getUrl(), "A/D/gamma", NodeKind.file,
 
1045
                CommitItemStateFlags.Delete);
 
1046
        assertEquals("wrong revision number from commit",
 
1047
                client.commit(new String[]{thisTest.getWCPath()},"log message",
 
1048
                        true), 2);
 
1049
        thisTest.getWc().removeItem("A/D/gamma");
 
1050
 
 
1051
        // check the working copy status
 
1052
        thisTest.checkStatus();
 
1053
 
 
1054
        try
 
1055
        {
 
1056
            // creating a directory in the place of the deleted file should
 
1057
            // still fail
 
1058
            client.mkdir(
 
1059
                    new String[] {thisTest.getWCPath()+"/A/D/gamma"}, null);
 
1060
            fail("can change node kind");
 
1061
        }
 
1062
        catch(ClientException e)
 
1063
        {
 
1064
 
 
1065
        }
 
1066
 
 
1067
        // check the working copy status
 
1068
        thisTest.checkStatus();
 
1069
 
 
1070
        // update the working copy
 
1071
        client.update(thisTest.getWCPath(), null, true);
 
1072
 
 
1073
        // check the working copy status
 
1074
        thisTest.checkStatus();
 
1075
 
 
1076
        // now creating the directory should succeed
 
1077
        client.mkdir(new String[] {thisTest.getWCPath()+"/A/D/gamma"}, null);
 
1078
        thisTest.getWc().addItem("A/D/gamma", null);
 
1079
        thisTest.getWc().setItemTextStatus("A/D/gamma", Status.Kind.added);
 
1080
 
 
1081
        // check the working copy status
 
1082
        thisTest.checkStatus();
 
1083
    }
 
1084
 
 
1085
    /**
 
1086
     * Test the basic SVNClient.import functionality
 
1087
     * @throws Throwable
 
1088
     */
 
1089
    public void testBasicImport() throws Throwable
 
1090
    {
 
1091
        // create the working copy
 
1092
        OneTest thisTest = new OneTest();
 
1093
 
 
1094
        // create new_file
 
1095
        File file = new File(thisTest.getWCPath(),"new_file");
 
1096
        PrintWriter pw = new PrintWriter(new FileOutputStream(file));
 
1097
        pw.print("some text");
 
1098
        pw.close();
 
1099
 
 
1100
        // import new_file info dirA/dirB/newFile
 
1101
        addExpectedCommitItem(thisTest.getWCPath(),
 
1102
                null, "new_file", NodeKind.none, CommitItemStateFlags.Add);
 
1103
        client.doImport(file.getAbsolutePath(),
 
1104
                thisTest.getUrl()+"/dirA/dirB/new_file",
 
1105
                "log message for new import", true);
 
1106
 
 
1107
        // delete new_file
 
1108
        file.delete();
 
1109
 
 
1110
        // update the working
 
1111
        assertEquals("wrong revision from update",
 
1112
                client.update(thisTest.getWCPath(), null, true),2);
 
1113
        thisTest.getWc().addItem("dirA", null);
 
1114
        thisTest.getWc().setItemWorkingCopyRevision("dirA",2);
 
1115
        thisTest.getWc().addItem("dirA/dirB", null);
 
1116
        thisTest.getWc().setItemWorkingCopyRevision("dirA/dirB",2);
 
1117
        thisTest.getWc().addItem("dirA/dirB/new_file", "some text");
 
1118
        thisTest.getWc().setItemWorkingCopyRevision("dirA/dirB/new_file",2);
 
1119
 
 
1120
        // test the working copy status
 
1121
        thisTest.checkStatus();
 
1122
    }
 
1123
 
 
1124
    /**
 
1125
     * test the basic SVNClient.fileContent functionality
 
1126
     * @throws Throwable
 
1127
     */
 
1128
    public void testBasicCat() throws Throwable
 
1129
    {
 
1130
        // create the working copy
 
1131
        OneTest thisTest = new OneTest();
 
1132
 
 
1133
        // modify A/mu
 
1134
        File mu = new File(thisTest.getWorkingCopy(), "A/mu");
 
1135
        PrintWriter pw = new PrintWriter(new FileOutputStream(mu, true));
 
1136
        pw.print("some text");
 
1137
        pw.close();
 
1138
        // get the content from the repository
 
1139
        byte[] content = client.fileContent(thisTest.getWCPath()+"/A/mu", null);
 
1140
        byte[] testContent = thisTest.getWc().getItemContent("A/mu").getBytes();
 
1141
 
 
1142
        // the content should be the same
 
1143
        assertTrue("content changed", Arrays.equals(content, testContent));
 
1144
    }
 
1145
 
 
1146
    /**
 
1147
     * test the basic SVNClient.list functionality
 
1148
     * @throws Throwable
 
1149
     */
 
1150
    public void testBasicLs() throws Throwable
 
1151
    {
 
1152
        // create the working copy
 
1153
        OneTest thisTest = new OneTest();
 
1154
 
 
1155
        // list the repository root dir
 
1156
        DirEntry[] entries = client.list(thisTest.getWCPath(), null, false);
 
1157
        thisTest.getWc().check(entries,"", false);
 
1158
 
 
1159
        // list directory A
 
1160
        entries = client.list(thisTest.getWCPath()+"/A", null, false);
 
1161
        thisTest.getWc().check(entries,"A", false);
 
1162
 
 
1163
        // list directory A in BASE revision
 
1164
        entries = client.list(thisTest.getWCPath()+"/A", Revision.BASE, false);
 
1165
        thisTest.getWc().check(entries,"A", false);
 
1166
 
 
1167
        // list file A/mu
 
1168
        entries = client.list(thisTest.getWCPath()+"/A/mu", null, false);
 
1169
        thisTest.getWc().check(entries,"A/mu");
 
1170
    }
 
1171
 
 
1172
    /**
 
1173
     * test the basis SVNClient.add functionality with files that should be
 
1174
     * ignored
 
1175
     * @throws Throwable
 
1176
     */
 
1177
    public void testBasicAddIgnores() throws Throwable
 
1178
    {
 
1179
        // create working copy
 
1180
        OneTest thisTest = new OneTest();
 
1181
 
 
1182
        // create dir
 
1183
        File dir = new File(thisTest.getWorkingCopy(), "dir");
 
1184
        dir.mkdir();
 
1185
 
 
1186
        // create dir/foo.c
 
1187
        File fileC = new File(dir, "foo.c");
 
1188
        new FileOutputStream(fileC).close();
 
1189
 
 
1190
        // create dir/foo.o (should be ignored)
 
1191
        File fileO = new File(dir, "foo.o");
 
1192
        new FileOutputStream(fileO).close();
 
1193
 
 
1194
        // add dir
 
1195
        client.add(dir.getAbsolutePath(), true);
 
1196
        thisTest.getWc().addItem("dir", null);
 
1197
        thisTest.getWc().setItemTextStatus("dir",Status.Kind.added);
 
1198
        thisTest.getWc().addItem("dir/foo.c", "");
 
1199
        thisTest.getWc().setItemTextStatus("dir/foo.c",Status.Kind.added);
 
1200
        thisTest.getWc().addItem("dir/foo.o", "");
 
1201
        thisTest.getWc().setItemTextStatus("dir/foo.o",Status.Kind.ignored);
 
1202
        thisTest.getWc().setItemNodeKind("dir/foo.o", NodeKind.unknown);
 
1203
 
 
1204
        // test the working copy status
 
1205
        thisTest.checkStatus();
 
1206
    }
 
1207
 
 
1208
    /**
 
1209
     * test the basis SVNClient.import functionality with files that should be
 
1210
     * ignored
 
1211
     * @throws Throwable
 
1212
     */
 
1213
    public void testBasicImportIgnores() throws Throwable
 
1214
    {
 
1215
        // create working copy
 
1216
        OneTest thisTest = new OneTest();
 
1217
 
 
1218
        // create dir
 
1219
        File dir = new File(thisTest.getWorkingCopy(), "dir");
 
1220
        dir.mkdir();
 
1221
 
 
1222
        // create dir/foo.c
 
1223
        File fileC = new File(dir, "foo.c");
 
1224
        new FileOutputStream(fileC).close();
 
1225
 
 
1226
        // create dir/foo.o (should be ignored)
 
1227
        File fileO = new File(dir, "foo.o");
 
1228
        new FileOutputStream(fileO).close();
 
1229
 
 
1230
        // import dir
 
1231
        addExpectedCommitItem(thisTest.getWCPath(),
 
1232
                null, "dir", NodeKind.none, CommitItemStateFlags.Add);
 
1233
        client.doImport(dir.getAbsolutePath(), thisTest.getUrl()+"/dir",
 
1234
                "log message for import", true);
 
1235
 
 
1236
        // remove dir
 
1237
        removeDirectoryWithContent(dir);
 
1238
 
 
1239
        // udpate the working copy
 
1240
        assertEquals("wrong revision from update", 2,
 
1241
                client.update(thisTest.getWCPath(), null, true));
 
1242
        thisTest.getWc().addItem("dir", null);
 
1243
        thisTest.getWc().addItem("dir/foo.c", "");
 
1244
 
 
1245
        // test the working copy status
 
1246
        thisTest.checkStatus();
 
1247
    }
 
1248
 
 
1249
    /**
 
1250
     * test the basic SVNClient.info functionality
 
1251
     * @throws Throwable
 
1252
     */
 
1253
    public void testBasicInfo() throws Throwable
 
1254
    {
 
1255
        // create the working copy
 
1256
        OneTest thisTest = new OneTest();
 
1257
 
 
1258
        // get the item information and test it
 
1259
        Info info = client.info(thisTest.getWCPath()+"/A/mu");
 
1260
        assertEquals("wrong revision from info", 1,
 
1261
                info.getLastChangedRevision());
 
1262
        assertEquals("wrong schedule kind from info", ScheduleKind.normal,
 
1263
                info.getSchedule());
 
1264
        assertEquals("wrong node kind from info", NodeKind.file,
 
1265
                info.getNodeKind());
 
1266
    }
 
1267
 
 
1268
    /**
 
1269
     * test the basic SVNClient.logMessage functionality
 
1270
     * @throws Throwable
 
1271
     */
 
1272
    public void testBasicLogMessage() throws Throwable
 
1273
    {
 
1274
        // create the working copy
 
1275
        OneTest thisTest = new OneTest();
 
1276
 
 
1277
        // get the commit message of the initial import and test it
 
1278
        LogMessage lm[] = client.logMessages(thisTest.getWCPath(), null,
 
1279
                null, false, true);
 
1280
        assertEquals("wrong number of objects", 1, lm.length);
 
1281
        assertEquals("wrong message", "Log Message", lm[0].getMessage());
 
1282
        assertEquals("wrong revision", 1, lm[0].getRevisionNumber());
 
1283
        assertEquals("wrong user", "jrandom", lm[0].getAuthor());
 
1284
        assertNotNull("changed paths set", lm[0].getChangedPaths());
 
1285
        ChangePath cp[] = lm[0].getChangedPaths();
 
1286
        assertEquals("wrong number of chang pathes", 20, cp.length);
 
1287
        assertEquals("wrong path", "/A", cp[0].getPath());
 
1288
        assertEquals("wrong copy source rev", -1, cp[0].getCopySrcRevision());
 
1289
        assertNull("wrong copy source path", cp[0].getCopySrcPath());
 
1290
        assertEquals("wrong action", 'A', cp[0].getAction());
 
1291
    }
 
1292
 
 
1293
    /**
 
1294
     * test the basic SVNClient.getVersionInfo functionality
 
1295
     * @throws Throwable
 
1296
     * @since 1.2
 
1297
     */
 
1298
    public void testBasicVersionInfo() throws Throwable
 
1299
    {
 
1300
        // create the working copy
 
1301
        OneTest thisTest = new OneTest();
 
1302
        assertEquals("wrong version info","1",
 
1303
                client.getVersionInfo(thisTest.getWCPath(), null, false));        
 
1304
    }
 
1305
 
 
1306
    /**
 
1307
     * test the baisc SVNClient locking functionality
 
1308
     * @throws Throwable
 
1309
     * @since 1.2
 
1310
     */
 
1311
    public void testBasicLocking() throws Throwable
 
1312
    {
 
1313
        // build the first working copy
 
1314
        OneTest thisTest = new OneTest();
 
1315
 
 
1316
        client.propertySet(thisTest.getWCPath()+"/A/mu",
 
1317
                           PropertyData.NEEDS_LOCK, "*", false);
 
1318
 
 
1319
        addExpectedCommitItem(thisTest.getWCPath(),
 
1320
                thisTest.getUrl(), "A/mu",NodeKind.file,
 
1321
                CommitItemStateFlags.PropMods);
 
1322
        assertEquals("bad revision number on commit", 2,
 
1323
                     client.commit(new String[] {thisTest.getWCPath()},
 
1324
                                   "message", true));
 
1325
        File f = new File(thisTest.getWCPath()+"/A/mu");
 
1326
        assertEquals("file should be read only now", false, f.canWrite());
 
1327
        client.lock(new String[] {thisTest.getWCPath()+"/A/mu"},
 
1328
                                "comment", false);
 
1329
        assertEquals("file should be read write now", true, f.canWrite());
 
1330
        client.unlock(new String[]{thisTest.getWCPath()+"/A/mu"},
 
1331
                false);
 
1332
        assertEquals("file should be read only now", false, f.canWrite());
 
1333
        client.lock(new String[]{thisTest.getWCPath()+"/A/mu"},
 
1334
                           "comment", false);
 
1335
        assertEquals("file should be read write now", true, f.canWrite());
 
1336
        addExpectedCommitItem(thisTest.getWCPath(),
 
1337
                thisTest.getUrl(), "A/mu",NodeKind.file,
 
1338
                    0);
 
1339
        assertEquals("rev number from commit",-1, client.commit(
 
1340
                new String[]{thisTest.getWCPath()},"message", true));
 
1341
        assertEquals("file should be read write now", true, f.canWrite());
 
1342
    }
 
1343
 
 
1344
    /**
 
1345
     * test the baisc SVNClient.info2 functionality 
 
1346
     * @throws Throwable
 
1347
     * @since 1.2
 
1348
     */
 
1349
    public void testBasicInfo2() throws Throwable
 
1350
    {
 
1351
        // build the first working copy
 
1352
        OneTest thisTest = new OneTest();
 
1353
 
 
1354
        Info2[] infos = client.info2(thisTest.getWCPath(), null, null, false);
 
1355
        assertEquals("this should return 1 info object", 1, infos.length);
 
1356
        infos = client.info2(thisTest.getWCPath(), null, null, true);
 
1357
        assertEquals("this should return 21 info objects", 21, infos.length);
 
1358
        infos = client.info2(thisTest.getWCPath(), new Revision.Number(1),
 
1359
                             new Revision.Number(1), true);
 
1360
        assertEquals("this should return 21 info objects", 21, infos.length);
 
1361
    }
 
1362
}