1 package ch
.cyberduck
.core
;
4 * Copyright (c) 2002-2013 David Kocher. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * Bug fixes, suggestions and comments should be sent to feedback@cyberduck.ch
20 import org
.junit
.Test
;
22 import java
.util
.EnumSet
;
24 import static org
.junit
.Assert
.assertEquals
;
29 public class DefaultPathReferenceTest
extends AbstractTestCase
{
32 public void testUnique() throws Exception
{
33 final Path t
= new Path("/", EnumSet
.of(Path
.Type
.directory
));
34 assertEquals("[directory]-/", new DefaultPathReference(t
).toString());
35 t
.attributes().setVersionId("1");
36 assertEquals("[directory]-1/", new DefaultPathReference(t
).toString());
37 t
.attributes().setRegion("r");
38 assertEquals("[directory]-1/", new DefaultPathReference(t
).toString());
39 t
.attributes().setVersionId(null);
40 assertEquals("[directory]-/", new DefaultPathReference(t
).toString());
44 public void testUniqueSymbolicLInk() throws Exception
{
45 final Path t
= new Path("/", EnumSet
.of(Path
.Type
.directory
, Path
.Type
.symboliclink
));
46 assertEquals("[directory, symboliclink]-/", new DefaultPathReference(t
).toString());
50 public void testtoStringContainer() throws Exception
{
51 final Path t
= new Path("/container", EnumSet
.of(Path
.Type
.directory
));
52 assertEquals("[directory]-/container", new DefaultPathReference(t
).toString());
53 t
.attributes().setVersionId("1");
54 assertEquals("[directory]-1/container", new DefaultPathReference(t
).toString());
55 t
.attributes().setRegion("r");
56 assertEquals("[directory]-r1/container", new DefaultPathReference(t
).toString());
57 t
.attributes().setVersionId(null);
58 assertEquals("[directory]-r/container", new DefaultPathReference(t
).toString());
62 public void testAttributes() throws Exception
{
63 final Path t
= new Path("/f", EnumSet
.of(Path
.Type
.file
));
64 t
.attributes().setRegion("r");
65 assertEquals("r", new DefaultPathReference(t
).attributes());
66 t
.attributes().setVersionId("1");
67 assertEquals("r1", new DefaultPathReference(t
).attributes());