134
* Test SVNClient.getVersionExtended().
137
public void testVersionExtendedQuiet() throws Throwable
141
VersionExtended vx = client.getVersionExtended(false);
142
String result = vx.getBuildDate();
143
if (result == null || result.trim().length() == 0)
144
throw new Exception("Build date empty");
145
result = vx.getBuildTime();
146
if (result == null || result.trim().length() == 0)
147
throw new Exception("Build time empty");
148
result = vx.getBuildHost();
149
if (result == null || result.trim().length() == 0)
150
throw new Exception("Build host empty");
151
result = vx.getCopyright();
152
if (result == null || result.trim().length() == 0)
153
throw new Exception("Copyright empty");
157
fail("VersionExtended should always be available unless the " +
158
"native libraries failed to initialize: " + e);
163
* Test SVNClient.getVersionExtended().
166
public void testVersionExtendedVerbose() throws Throwable
170
VersionExtended vx = client.getVersionExtended(true);
171
String result = vx.getRuntimeHost();
172
if (result == null || result.trim().length() == 0)
173
throw new Exception("Runtime host empty");
175
// OS name is allowed to be null, but not empty
176
result = vx.getRuntimeOSName();
177
if (result != null && result.trim().length() == 0)
178
throw new Exception("Runtime OS name empty");
180
java.util.Iterator<VersionExtended.LinkedLib> ikl;
181
ikl = vx.getLinkedLibs();
184
VersionExtended.LinkedLib lib = ikl.next();
185
result = lib.getName();
186
if (result == null || result.trim().length() == 0)
187
throw new Exception("Linked lib name empty");
188
result = lib.getCompiledVersion();
189
if (result == null || result.trim().length() == 0)
190
throw new Exception("Linked lib compiled version empty");
191
// Runtime version is allowed to be null, but not empty
192
result = lib.getRuntimeVersion();
193
if (result != null && result.trim().length() == 0)
194
throw new Exception("Linked lib runtime version empty");
197
java.util.Iterator<VersionExtended.LoadedLib> ill;
198
ill = vx.getLoadedLibs();
201
VersionExtended.LoadedLib lib = ill.next();
202
result = lib.getName();
203
if (result == null || result.trim().length() == 0)
204
throw new Exception("Loaded lib name empty");
205
// Version is allowed to be null, but not empty
206
result = lib.getVersion();
207
if (result != null && result.trim().length() == 0)
208
throw new Exception("Loaded lib version empty");
213
fail("VersionExtended should always be available unless the " +
214
"native libraries failed to initialize: " + e);
133
219
* Test the JNIError class functionality
134
220
* @throws Throwable
799
* Test property inheritance.
802
public void testInheritedProperties() throws Throwable
804
OneTest thisTest = new OneTest();
805
WC wc = thisTest.getWc();
807
String adirPath = fileToSVNPath(new File(thisTest.getWCPath(),
810
String alphaPath = fileToSVNPath(new File(thisTest.getWCPath(),
814
String propval = "ybg";
815
setprop(adirPath, "ahqrtz", propval.getBytes());
817
final Map<String, Collection<InheritedProplistCallback.InheritedItem>> ipropMaps =
818
new HashMap<String, Collection<InheritedProplistCallback.InheritedItem>>();
820
client.properties(alphaPath, null, null, Depth.empty, null,
821
new InheritedProplistCallback () {
822
public void singlePath(
823
String path, Map<String, byte[]> props,
824
Collection<InheritedProplistCallback.InheritedItem> iprops)
825
{ ipropMaps.put(path, iprops); }
827
Collection<InheritedProplistCallback.InheritedItem> iprops = ipropMaps.get(alphaPath);
828
for (InheritedProplistCallback.InheritedItem item : iprops)
830
for (String key : item.properties.keySet())
832
assertEquals("ahqrtz", key);
833
assertEquals(propval, new String(item.properties.get(key)));
837
wc.setItemPropStatus("A", Status.Kind.modified);
838
thisTest.checkStatus();
713
842
* Test the basic SVNClient.update functionality.
714
843
* @throws Throwable
899
1028
client.move(srcPaths,
900
1029
new File(thisTest.getWorkingCopy(), "A/B/F").getPath(),
901
false, true, false, null, null, null);
1030
false, true, false, false, false, null, null, null);
1032
MyStatusCallback statusCallback = new MyStatusCallback();
1033
String statusPath = fileToSVNPath(new File(thisTest.getWCPath() + "/A/B"), true);
1034
client.status(statusPath, Depth.infinity, false, false, false, true,
1035
null, statusCallback);
1036
Status[] statusList = statusCallback.getStatusArray();
1037
assertEquals(statusPath + "/F/alpha",
1038
statusList[0].getMovedToAbspath());
1039
assertEquals(statusPath + "/F/beta",
1040
statusList[1].getMovedToAbspath());
1041
assertEquals(statusPath + "/E/alpha",
1042
statusList[2].getMovedFromAbspath());
1043
assertEquals(statusPath + "/E/beta",
1044
statusList[3].getMovedFromAbspath());
903
1046
// Commit the changes, and check the state of the WC.
904
1047
checkCommitRevision(thisTest,
2539
* Test merge with automatic source and revision determination
2540
* (e.g. 'svn merge -g) with implied revision range.
2544
public void testMergeUsingHistoryImpliedRange() throws Throwable
2546
OneTest thisTest = setupAndPerformMerge();
2548
// Test that getMergeinfo() returns null.
2549
assertNull(client.getMergeinfo(new File(thisTest.getWCPath(), "A")
2550
.toString(), Revision.HEAD));
2552
// Merge and commit some changes (r4).
2553
appendText(thisTest, "A/mu", "xxx", 4);
2554
checkCommitRevision(thisTest, "wrong revision number from commit", 4,
2555
thisTest.getWCPathSet(), "log msg", Depth.infinity,
2556
false, false, null, null);
2558
String branchPath = thisTest.getWCPath() + "/branches/A";
2559
String modUrl = thisTest.getUrl() + "/A";
2560
client.merge(modUrl, Revision.HEAD, null,
2561
branchPath, true, Depth.infinity, false, false, false);
2563
// commit the changes so that we can verify merge
2564
addExpectedCommitItem(thisTest.getWCPath(), thisTest.getUrl().toString(),
2565
"branches/A", NodeKind.dir,
2566
CommitItemStateFlags.PropMods);
2567
addExpectedCommitItem(thisTest.getWCPath(), thisTest.getUrl().toString(),
2568
"branches/A/mu", NodeKind.file,
2569
CommitItemStateFlags.TextMods);
2570
checkCommitRevision(thisTest, "wrong revision number from commit", 5,
2571
thisTest.getWCPathSet(), "log msg", Depth.infinity,
2572
false, false, null, null);
2396
2576
* Test reintegrating a branch with trunk
2397
2577
* (e.g. 'svn merge --reintegrate').
2398
2578
* @throws Throwable
3067
* Test the {@link ISVNClient.diff()} with {@link DiffOptions}.
3070
public void testDiffOptions()
3071
throws SubversionException, IOException
3073
OneTest thisTest = new OneTest(true);
3074
File diffOutput = new File(super.localTmp, thisTest.testName);
3075
final String NL = System.getProperty("line.separator");
3076
final String sepLine =
3077
"===================================================================" + NL;
3078
final String underSepLine =
3079
"___________________________________________________________________" + NL;
3080
final String iotaPath = thisTest.getWCPath().replace('\\', '/') + "/iota";
3081
final String wcPath = fileToSVNPath(new File(thisTest.getWCPath()),
3083
final String expectedDiffHeader =
3084
"Index: iota" + NL + sepLine +
3085
"--- iota\t(revision 1)" + NL +
3086
"+++ iota\t(working copy)" + NL;
3088
// make edits to iota
3089
PrintWriter writer = new PrintWriter(new FileOutputStream(iotaPath));
3090
writer.print("This is the file 'iota'.");
3096
final String expectedDiffOutput = expectedDiffHeader +
3097
"@@ -1 +1 @@" + NL +
3098
"-This is the file 'iota'." + NL +
3099
"\\ No newline at end of file" + NL +
3100
"+This is the file 'iota'." + NL +
3101
"\\ No newline at end of file" + NL;
3103
client.diff(iotaPath, Revision.BASE, iotaPath, Revision.WORKING,
3104
wcPath, new FileOutputStream(diffOutput.getPath()),
3105
Depth.infinity, null,
3106
false, false, false, false, false, false, null);
3107
assertFileContentsEquals(
3108
"Unexpected diff output with no options in file '" +
3109
diffOutput.getPath() + '\'',
3110
expectedDiffOutput, diffOutput);
3111
diffOutput.delete();
3113
catch (ClientException e)
3115
fail(e.getMessage());
3120
final String expectedDiffOutput = "";
3122
client.diff(iotaPath, Revision.BASE, iotaPath, Revision.WORKING,
3123
wcPath, new FileOutputStream(diffOutput.getPath()),
3124
Depth.infinity, null,
3125
false, false, false, false, false, false,
3126
new DiffOptions(DiffOptions.Flag.IgnoreWhitespace));
3127
assertFileContentsEquals(
3128
"Unexpected diff output with Flag.IgnoreWhitespace in file '" +
3129
diffOutput.getPath() + '\'',
3130
expectedDiffOutput, diffOutput);
3131
diffOutput.delete();
3133
catch (ClientException e)
3135
fail("Using Flag.IgnoreWhitespace: "
3141
final String expectedDiffOutput = "";
3143
client.diff(iotaPath, Revision.BASE, iotaPath, Revision.WORKING,
3144
wcPath, diffOutput.getPath(), Depth.infinity, null,
3145
false, false, false, false, false, false,
3146
new DiffOptions(DiffOptions.Flag.IgnoreSpaceChange));
3147
assertFileContentsEquals(
3148
"Unexpected diff output with Flag.IgnoreSpaceChange in file '" +
3149
diffOutput.getPath() + '\'',
3150
expectedDiffOutput, diffOutput);
3151
diffOutput.delete();
3153
catch (ClientException e)
3155
fail("Using Flag.IgnoreSpaceChange: "
3159
// make edits to iota
3160
writer = new PrintWriter(new FileOutputStream(iotaPath));
3161
writer.print("This is the file 'io ta'.");
3167
final String expectedDiffOutput = expectedDiffHeader +
3168
"@@ -1 +1 @@" + NL +
3169
"-This is the file 'iota'." + NL +
3170
"\\ No newline at end of file" + NL +
3171
"+This is the file 'io ta'." + NL +
3172
"\\ No newline at end of file" + NL;
3174
client.diff(iotaPath, Revision.BASE, iotaPath, Revision.WORKING,
3175
wcPath, diffOutput.getPath(), Depth.infinity, null,
3176
false, false, false, false, false, false,
3177
new DiffOptions(DiffOptions.Flag.IgnoreSpaceChange));
3178
assertFileContentsEquals(
3179
"Unexpected diff output with Flag.IgnoreSpaceChange in file '" +
3180
diffOutput.getPath() + '\'',
3181
expectedDiffOutput, diffOutput);
3182
diffOutput.delete();
3184
catch (ClientException e)
3186
fail("Using Flag.IgnoreSpaceChange: "
2886
3192
private void assertFileContentsEquals(String msg, String expected,
2888
3194
throws IOException
3102
3408
ConflictDescriptor conflict = conflicts.iterator().next();
3104
3410
assertNotNull("Conflict should not be null", conflict);
3411
assertNotNull("Repository UUID must be set", conflict.getSrcLeftVersion().getReposUUID());
3106
3413
assertEquals(conflict.getSrcLeftVersion().getNodeKind(), NodeKind.file);
3107
3414
assertEquals(conflict.getSrcLeftVersion().getReposURL() + "/" +
3108
3415
conflict.getSrcLeftVersion().getPathInRepos(), tcTest.getUrl() + "/A/B/E/alpha");
3109
3416
assertEquals(conflict.getSrcLeftVersion().getPegRevision(), 1L);
3111
assertEquals(conflict.getSrcRightVersion().getNodeKind(), NodeKind.none);
3112
assertEquals(conflict.getSrcRightVersion().getReposURL(), tcTest.getUrl().toString());
3113
assertEquals(conflict.getSrcRightVersion().getPegRevision(), 2L);
3418
if (conflict.getSrcRightVersion() != null)
3420
assertEquals(conflict.getSrcLeftVersion().getReposUUID(),
3421
conflict.getSrcRightVersion().getReposUUID());
3422
assertEquals(conflict.getSrcRightVersion().getNodeKind(), NodeKind.none);
3423
assertEquals(conflict.getSrcRightVersion().getReposURL(), tcTest.getUrl().toString());
3424
assertEquals(conflict.getSrcRightVersion().getPegRevision(), 2L);