~ubuntu-branches/debian/sid/subversion/sid

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): James McCoy, Peter Samuelson, James McCoy
  • Date: 2014-01-12 19:48:33 UTC
  • mfrom: (0.2.10)
  • Revision ID: package-import@ubuntu.com-20140112194833-w3axfwksn296jn5x
Tags: 1.8.5-1
[ Peter Samuelson ]
* New upstream release.  (Closes: #725787) Rediff patches:
  - Remove apr-abi1 (applied upstream), rename apr-abi2 to apr-abi
  - Remove loosen-sqlite-version-check (shouldn't be needed)
  - Remove java-osgi-metadata (applied upstream)
  - svnmucc prompts for a changelog if none is provided. (Closes: #507430)
  - Remove fix-bdb-version-detection, upstream uses "apu-config --dbm-libs"
  - Remove ruby-test-wc (applied upstream)
  - Fix “svn diff -r N file” when file has svn:mime-type set.
    (Closes: #734163)
  - Support specifying an encoding for mod_dav_svn's environment in which
    hooks are run.  (Closes: #601544)
  - Fix ordering of “svnadmin dump” paths with certain APR versions.
    (Closes: #687291)
  - Provide a better error message when authentication fails with an
    svn+ssh:// URL.  (Closes: #273874)
  - Updated Polish translations.  (Closes: #690815)

[ James McCoy ]
* Remove all traces of libneon, replaced by libserf.
* patches/sqlite_3.8.x_workaround: Upstream fix for wc-queries-test test
  failurse.
* Run configure with --with-apache-libexecdir, which allows removing part of
  patches/rpath.
* Re-enable auth-test as upstream has fixed the problem of picking up
  libraries from the environment rather than the build tree.
  (Closes: #654172)
* Point LD_LIBRARY_PATH at the built auth libraries when running the svn
  command during the build.  (Closes: #678224)
* Add a NEWS entry describing how to configure mod_dav_svn to understand
  UTF-8.  (Closes: #566148)
* Remove ancient transitional package, libsvn-ruby.
* Enable compatibility with Sqlite3 versions back to Wheezy.
* Enable hardening flags.  (Closes: #734918)
* patches/build-fixes: Enable verbose build logs.
* Build against the default ruby version.  (Closes: #722393)

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
import java.io.IOException;
33
33
import java.io.PrintWriter;
34
34
import java.io.ByteArrayOutputStream;
 
35
import java.io.UnsupportedEncodingException;
35
36
import java.text.ParseException;
36
37
import java.util.Collection;
37
38
import java.util.Arrays;
130
131
    }
131
132
 
132
133
    /**
 
134
     * Test SVNClient.getVersionExtended().
 
135
     * @throws Throwable
 
136
     */
 
137
    public void testVersionExtendedQuiet() throws Throwable
 
138
    {
 
139
        try
 
140
        {
 
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");
 
154
        }
 
155
        catch (Exception e)
 
156
        {
 
157
            fail("VersionExtended should always be available unless the " +
 
158
                 "native libraries failed to initialize: " + e);
 
159
        }
 
160
    }
 
161
 
 
162
    /**
 
163
     * Test SVNClient.getVersionExtended().
 
164
     * @throws Throwable
 
165
     */
 
166
    public void testVersionExtendedVerbose() throws Throwable
 
167
    {
 
168
        try
 
169
        {
 
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");
 
174
 
 
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");
 
179
 
 
180
            java.util.Iterator<VersionExtended.LinkedLib> ikl;
 
181
            ikl = vx.getLinkedLibs();
 
182
            if (ikl.hasNext())
 
183
            {
 
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");
 
195
            }
 
196
 
 
197
            java.util.Iterator<VersionExtended.LoadedLib> ill;
 
198
            ill = vx.getLoadedLibs();
 
199
            if (ill.hasNext())
 
200
            {
 
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");
 
209
            }
 
210
        }
 
211
        catch (Exception e)
 
212
        {
 
213
            fail("VersionExtended should always be available unless the " +
 
214
                 "native libraries failed to initialize: " + e);
 
215
        }
 
216
    }
 
217
 
 
218
    /**
133
219
     * Test the JNIError class functionality
134
220
     * @throws Throwable
135
221
     */
147
233
                              CommitItemStateFlags.Add);
148
234
        Set<String> urls = new HashSet<String>(1);
149
235
        urls.add(thisTest.getUrl() + "/Y");
150
 
        try 
 
236
        try
151
237
        {
152
238
            tempclient.mkdir(urls, false, null, new ConstMsg("log_msg"), null);
153
 
        } 
 
239
        }
154
240
        catch(JNIError e)
155
241
        {
156
242
                return; // Test passes!
710
796
    }
711
797
 
712
798
    /**
 
799
     * Test property inheritance.
 
800
     * @throws Throwable
 
801
     */
 
802
    public void testInheritedProperties() throws Throwable
 
803
    {
 
804
        OneTest thisTest = new OneTest();
 
805
        WC wc = thisTest.getWc();
 
806
 
 
807
        String adirPath = fileToSVNPath(new File(thisTest.getWCPath(),
 
808
                                                 "/A"),
 
809
                                        false);
 
810
        String alphaPath = fileToSVNPath(new File(thisTest.getWCPath(),
 
811
                                                  "/A/B/E/alpha"),
 
812
                                         false);
 
813
 
 
814
        String propval = "ybg";
 
815
        setprop(adirPath, "ahqrtz", propval.getBytes());
 
816
 
 
817
        final Map<String, Collection<InheritedProplistCallback.InheritedItem>> ipropMaps =
 
818
            new HashMap<String, Collection<InheritedProplistCallback.InheritedItem>>();
 
819
 
 
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); }
 
826
            });
 
827
        Collection<InheritedProplistCallback.InheritedItem> iprops = ipropMaps.get(alphaPath);
 
828
        for (InheritedProplistCallback.InheritedItem item : iprops)
 
829
        {
 
830
            for (String key : item.properties.keySet())
 
831
            {
 
832
                assertEquals("ahqrtz", key);
 
833
                assertEquals(propval, new String(item.properties.get(key)));
 
834
            }
 
835
        }
 
836
 
 
837
        wc.setItemPropStatus("A", Status.Kind.modified);
 
838
        thisTest.checkStatus();
 
839
    }
 
840
 
 
841
    /**
713
842
     * Test the basic SVNClient.update functionality.
714
843
     * @throws Throwable
715
844
     */
898
1027
        }
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);
 
1031
 
 
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());
902
1045
 
903
1046
        // Commit the changes, and check the state of the WC.
904
1047
        checkCommitRevision(thisTest,
2393
2536
    }
2394
2537
 
2395
2538
    /**
 
2539
     * Test merge with automatic source and revision determination
 
2540
     * (e.g. 'svn merge -g) with implied revision range.
 
2541
     * @throws Throwable
 
2542
     * @since 1.8
 
2543
     */
 
2544
    public void testMergeUsingHistoryImpliedRange() throws Throwable
 
2545
    {
 
2546
        OneTest thisTest = setupAndPerformMerge();
 
2547
 
 
2548
        // Test that getMergeinfo() returns null.
 
2549
        assertNull(client.getMergeinfo(new File(thisTest.getWCPath(), "A")
 
2550
                                       .toString(), Revision.HEAD));
 
2551
 
 
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);
 
2557
 
 
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);
 
2562
 
 
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);
 
2573
    }
 
2574
 
 
2575
    /**
2396
2576
     * Test reintegrating a branch with trunk
2397
2577
     * (e.g. 'svn merge --reintegrate').
2398
2578
     * @throws Throwable
2648
2828
    }
2649
2829
 
2650
2830
    /**
2651
 
     * Test the {@link SVNClientInterface.diff()} APIs.
 
2831
     * Test the {@link ISVNClient.diff()} APIs.
2652
2832
     * @since 1.5
2653
2833
     */
2654
2834
    public void testDiff()
2883
3063
 
2884
3064
    }
2885
3065
 
 
3066
    /**
 
3067
     * Test the {@link ISVNClient.diff()} with {@link DiffOptions}.
 
3068
     * @since 1.8
 
3069
     */
 
3070
    public void testDiffOptions()
 
3071
        throws SubversionException, IOException
 
3072
    {
 
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()),
 
3082
                false);
 
3083
        final String expectedDiffHeader =
 
3084
            "Index: iota" + NL + sepLine +
 
3085
            "--- iota\t(revision 1)" + NL +
 
3086
            "+++ iota\t(working copy)" + NL;
 
3087
 
 
3088
        // make edits to iota
 
3089
        PrintWriter writer = new PrintWriter(new FileOutputStream(iotaPath));
 
3090
        writer.print("This is  the  file 'iota'.");
 
3091
        writer.flush();
 
3092
        writer.close();
 
3093
 
 
3094
        try
 
3095
        {
 
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;
 
3102
 
 
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();
 
3112
        }
 
3113
        catch (ClientException e)
 
3114
        {
 
3115
            fail(e.getMessage());
 
3116
        }
 
3117
 
 
3118
        try
 
3119
        {
 
3120
            final String expectedDiffOutput = "";
 
3121
 
 
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();
 
3132
        }
 
3133
        catch (ClientException e)
 
3134
        {
 
3135
            fail("Using Flag.IgnoreWhitespace: "
 
3136
                  + e.getMessage());
 
3137
        }
 
3138
 
 
3139
        try
 
3140
        {
 
3141
            final String expectedDiffOutput = "";
 
3142
 
 
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();
 
3152
        }
 
3153
        catch (ClientException e)
 
3154
        {
 
3155
            fail("Using Flag.IgnoreSpaceChange: "
 
3156
                 + e.getMessage());
 
3157
        }
 
3158
 
 
3159
        // make edits to iota
 
3160
        writer = new PrintWriter(new FileOutputStream(iotaPath));
 
3161
        writer.print("This is  the  file 'io ta'.");
 
3162
        writer.flush();
 
3163
        writer.close();
 
3164
 
 
3165
        try
 
3166
        {
 
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;
 
3173
 
 
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();
 
3183
        }
 
3184
        catch (ClientException e)
 
3185
        {
 
3186
            fail("Using Flag.IgnoreSpaceChange: "
 
3187
                 + e.getMessage());
 
3188
        }
 
3189
    }
 
3190
 
 
3191
 
2886
3192
    private void assertFileContentsEquals(String msg, String expected,
2887
3193
                                          File actual)
2888
3194
        throws IOException
3061
3367
        }
3062
3368
        client.move(srcPaths,
3063
3369
                    new File(thisTest.getWorkingCopy(), "A/B/F").getPath(),
3064
 
                    false, true, false, null, null, null);
 
3370
                    false, true, false, false, false, null, null, null);
3065
3371
 
3066
3372
        // Commit the changes, and check the state of the WC.
3067
3373
        checkCommitRevision(thisTest,
3102
3408
        ConflictDescriptor conflict = conflicts.iterator().next();
3103
3409
 
3104
3410
        assertNotNull("Conflict should not be null", conflict);
 
3411
        assertNotNull("Repository UUID must be set", conflict.getSrcLeftVersion().getReposUUID());
3105
3412
 
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);
3110
3417
 
3111
 
        assertEquals(conflict.getSrcRightVersion().getNodeKind(), NodeKind.none);
3112
 
        assertEquals(conflict.getSrcRightVersion().getReposURL(), tcTest.getUrl().toString());
3113
 
        assertEquals(conflict.getSrcRightVersion().getPegRevision(), 2L);
3114
 
 
 
3418
        if (conflict.getSrcRightVersion() != null)
 
3419
        {
 
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);
 
3425
        }
3115
3426
    }
3116
3427
 
3117
3428
    /**
3146
3457
 
3147
3458
        // check the status of the working copy
3148
3459
        thisTest.checkStatus();
3149
 
        
 
3460
 
3150
3461
        // now edit the propval directly in the repository
3151
3462
        long baseRev = 2L;
3152
3463
        client.propertySetRemote(thisTest.getUrl()+"/A/D/G/rho", baseRev, PROP, NEWVALUE,
3153
3464
                                 new ConstMsg("edit prop"), false, null, null);
3154
 
        
 
3465
 
3155
3466
        // update the WC and verify that the property was changed
3156
3467
        client.update(thisTest.getWCPathSet(), Revision.HEAD, Depth.infinity, false, false,
3157
3468
                      false, false);
3684
3995
                                      Map<String, byte[]> revprops,
3685
3996
                                      boolean hasChildren)
3686
3997
            {
3687
 
                String author = new String(revprops.get("svn:author"));
3688
 
                String message = new String(revprops.get("svn:log"));
 
3998
                String author, message;
 
3999
                try {
 
4000
                    author = new String(revprops.get("svn:author"), "UTF8");
 
4001
                } catch (UnsupportedEncodingException e) {
 
4002
                    author = new String(revprops.get("svn:author"));
 
4003
                }
 
4004
                try {
 
4005
                    message = new String(revprops.get("svn:log"), "UTF8");
 
4006
                } catch (UnsupportedEncodingException e) {
 
4007
                    message = new String(revprops.get("svn:log"));
 
4008
                }
3689
4009
                long timeMicros;
3690
4010
 
3691
4011
                try {