Mercurial > hg4j
comparison hg4j/src/test/java/org/tmatesoft/hg/test/TestStorePath.java @ 213:6ec4af642ba8 gradle
Project uses Gradle for build - actual changes
author | Alexander Kitaev <kitaev@gmail.com> |
---|---|
date | Tue, 10 May 2011 10:52:53 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
212:edb2e2829352 | 213:6ec4af642ba8 |
---|---|
1 /* | |
2 * Copyright (c) 2011 TMate Software Ltd | |
3 * | |
4 * This program is free software; you can redistribute it and/or modify | |
5 * it under the terms of the GNU General Public License as published by | |
6 * the Free Software Foundation; version 2 of the License. | |
7 * | |
8 * This program is distributed in the hope that it will be useful, | |
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 * GNU General Public License for more details. | |
12 * | |
13 * For information on how to redistribute this software under | |
14 * the terms of a license other than GNU General Public License | |
15 * contact TMate Software at support@hg4j.com | |
16 */ | |
17 package org.tmatesoft.hg.test; | |
18 | |
19 import static org.hamcrest.CoreMatchers.equalTo; | |
20 import junit.framework.Assert; | |
21 | |
22 import org.junit.Rule; | |
23 import org.junit.Test; | |
24 import org.tmatesoft.hg.internal.Internals; | |
25 import org.tmatesoft.hg.util.PathRewrite; | |
26 | |
27 /** | |
28 * | |
29 * @author Artem Tikhomirov | |
30 * @author TMate Software Ltd. | |
31 */ | |
32 public class TestStorePath { | |
33 | |
34 @Rule | |
35 public ErrorCollectorExt errorCollector = new ErrorCollectorExt(); | |
36 | |
37 private PathRewrite storePathHelper; | |
38 | |
39 public static void main(String[] args) throws Throwable { | |
40 final TestStorePath test = new TestStorePath(); | |
41 test.testWindowsFilenames(); | |
42 test.testHashLongPath(); | |
43 test.errorCollector.verify(); | |
44 } | |
45 | |
46 public TestStorePath() { | |
47 final Internals i = new Internals(); | |
48 i.setStorageConfig(1, 0x7); | |
49 storePathHelper = i.buildDataFilesHelper(); | |
50 } | |
51 | |
52 @Test | |
53 public void testWindowsFilenames() { | |
54 // see http://mercurial.selenic.com/wiki/fncacheRepoFormat#Encoding_of_Windows_reserved_names | |
55 String n1 = "aux.bla/bla.aux/prn/PRN/lpt/com3/nul/coma/foo.NUL/normal.c"; | |
56 String r1 = "store/data/au~78.bla/bla.aux/pr~6e/_p_r_n/lpt/co~6d3/nu~6c/coma/foo._n_u_l/normal.c.i"; | |
57 Assert.assertEquals("Windows filenames are ", r1, storePathHelper.rewrite(n1)); | |
58 } | |
59 | |
60 @Test | |
61 public void testHashLongPath() { | |
62 String n1 = "AUX/SECOND/X.PRN/FOURTH/FI:FTH/SIXTH/SEVENTH/EIGHTH/NINETH/TENTH/ELEVENTH/LOREMIPSUM.TXT"; | |
63 String r1 = "store/dh/au~78/second/x.prn/fourth/fi~3afth/sixth/seventh/eighth/nineth/tenth/loremia20419e358ddff1bf8751e38288aff1d7c32ec05.i"; | |
64 String n2 = "enterprise/openesbaddons/contrib-imola/corba-bc/netbeansplugin/wsdlExtension/src/main/java/META-INF/services/org.netbeans.modules.xml.wsdl.bindingsupport.spi.ExtensibilityElementTemplateProvider"; | |
65 String r2 = "store/dh/enterpri/openesba/contrib-/corba-bc/netbeans/wsdlexte/src/main/java/org.net7018f27961fdf338a598a40c4683429e7ffb9743.i"; | |
66 String n3 = "AUX.THE-QUICK-BROWN-FOX-JU:MPS-OVER-THE-LAZY-DOG-THE-QUICK-BROWN-FOX-JUMPS-OVER-THE-LAZY-DOG.TXT"; | |
67 String r3 = "store/dh/au~78.the-quick-brown-fox-ju~3amps-over-the-lazy-dog-the-quick-brown-fox-jud4dcadd033000ab2b26eb66bae1906bcb15d4a70.i"; | |
68 // TODO segment[8] == [. ], segment[8] in the middle of windows reserved name or character (to see if ~xx is broken) | |
69 errorCollector.checkThat(storePathHelper.rewrite(n1), equalTo(r1)); | |
70 errorCollector.checkThat(storePathHelper.rewrite(n2), equalTo(r2)); | |
71 errorCollector.checkThat(storePathHelper.rewrite(n3), equalTo(r3)); | |
72 } | |
73 } |