File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55
66import org .springframework .web .util .UriComponentsBuilder ;
77
8+ import java .io .File ;
89import java .net .URI ;
910
1011import static com .gooddata .util .Validate .notEmpty ;
@@ -52,8 +53,9 @@ public URI getUriPrefix() {
5253 */
5354 public URI mergeUris (URI uri ) {
5455 notNull (uri , "uri" );
56+ final String path = new File (uriPrefix .getRawPath (), uri .getRawPath ()).getAbsolutePath ();
5557 return UriComponentsBuilder .fromUri (uriPrefix )
56- .path ( uri . getRawPath () )
58+ .replacePath ( path )
5759 .query (uri .getRawQuery ())
5860 .fragment (uri .getRawFragment ())
5961 .build ().toUri ();
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved.
3+ */
4+ package com .gooddata ;
5+
6+ import org .testng .annotations .Test ;
7+
8+ import java .net .URI ;
9+
10+ import static org .hamcrest .CoreMatchers .is ;
11+ import static org .hamcrest .MatcherAssert .assertThat ;
12+
13+ public class UriPrefixerTest {
14+
15+ @ Test
16+ public void testMergeUrisWithSlash () throws Exception {
17+ final UriPrefixer prefixer = new UriPrefixer ("http://localhost:1/uploads" );
18+ final URI result = prefixer .mergeUris ("/test" );
19+ assertThat (result .toString (), is ("http://localhost:1/uploads/test" ));
20+ }
21+
22+ @ Test
23+ public void testMergeUrisWithoutSlash () throws Exception {
24+ final UriPrefixer prefixer = new UriPrefixer ("http://localhost:1/uploads" );
25+ final URI result = prefixer .mergeUris ("test" );
26+ assertThat (result .toString (), is ("http://localhost:1/uploads/test" ));
27+ }
28+ }
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ public void shouldUploadAbsolute() throws Exception {
3636 gd .getDataStoreService ().upload ("/test" , content );
3737 }
3838
39- @ Test ( enabled = false ) // todo #91
39+ @ Test
4040 public void shouldUploadRelative () throws Exception {
4141 gd .getDataStoreService ().upload ("test" , content );
4242 }
You can’t perform that action at this time.
0 commit comments