Return relative URLs for FileUploadServiceHandler

As of RAP 2.3, service handler URLs are relative (bug 406428).
We don't need to remove the path anymore.
diff --git a/bundles/org.eclipse.rap.addons.fileupload/src/org/eclipse/rap/addons/fileupload/internal/FileUploadServiceHandler.java b/bundles/org.eclipse.rap.addons.fileupload/src/org/eclipse/rap/addons/fileupload/internal/FileUploadServiceHandler.java
index 578f9d9..7ae44ea 100644
--- a/bundles/org.eclipse.rap.addons.fileupload/src/org/eclipse/rap/addons/fileupload/internal/FileUploadServiceHandler.java
+++ b/bundles/org.eclipse.rap.addons.fileupload/src/org/eclipse/rap/addons/fileupload/internal/FileUploadServiceHandler.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2002, 2012 EclipseSource and others.
+ * Copyright (c) 2002, 2014 EclipseSource and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -57,15 +57,13 @@
   }
 
   public static String getUrl( String token ) {
-    StringBuffer url = new StringBuffer();
-    url.append( RWT.getServiceManager().getServiceHandlerUrl( SERVICE_HANDLER_ID ) );
-    url.append( '&' );
-    url.append( PARAMETER_TOKEN ).append( '=' ).append( token );
-    int relativeIndex = url.lastIndexOf( "/" );
-    if( relativeIndex > -1 ) {
-      url.delete( 0, relativeIndex + 1 );
-    }
-    return url.toString();
+    String serviceHandlerUrl = RWT.getServiceManager().getServiceHandlerUrl( SERVICE_HANDLER_ID );
+    return new StringBuilder( serviceHandlerUrl )
+      .append( '&' )
+      .append( PARAMETER_TOKEN )
+      .append( '=' )
+      .append( token )
+      .toString();
   }
 
 }
diff --git a/tests/org.eclipse.rap.addons.fileupload.test/src/org/eclipse/rap/addons/fileupload/internal/FileUploadServiceHandler_Test.java b/tests/org.eclipse.rap.addons.fileupload.test/src/org/eclipse/rap/addons/fileupload/internal/FileUploadServiceHandler_Test.java
index eff13d6..83d4265 100644
--- a/tests/org.eclipse.rap.addons.fileupload.test/src/org/eclipse/rap/addons/fileupload/internal/FileUploadServiceHandler_Test.java
+++ b/tests/org.eclipse.rap.addons.fileupload.test/src/org/eclipse/rap/addons/fileupload/internal/FileUploadServiceHandler_Test.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011, 2013 EclipseSource and others.
+ * Copyright (c) 2011, 2014 EclipseSource and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -10,10 +10,17 @@
  ******************************************************************************/
 package org.eclipse.rap.addons.fileupload.internal;
 
+import static java.util.Arrays.asList;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.startsWith;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
+import java.util.List;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletResponse;
@@ -204,14 +211,26 @@
     assertEquals( "some.txt", uploadedItem.getFileDetails()[ 0 ].getFileName() );
   }
 
-  @Test
-  public void testGetURL() {
-    String head = "rap?servicehandler=org.eclipse.rap.fileupload&token=";
 
-    assertEquals( head, FileUploadServiceHandler.getUrl( "" ) );
-    assertEquals( head + "<>&?", FileUploadServiceHandler.getUrl( "<>&?" ) );
-    assertEquals( head + "testToken", FileUploadServiceHandler.getUrl( "testToken" ) );
-    assertEquals( head + "123456789abcdef", FileUploadServiceHandler.getUrl( "123456789abcdef" ) );
+  @Test
+  public void testGetURL_returnsRelativeUrl() {
+    String url = FileUploadServiceHandler.getUrl( "token" );
+
+    assertThat( url, not( containsString( "/" ) ) );
+  }
+
+  @Test
+  public void testGetURL_includesToken() {
+    String url = FileUploadServiceHandler.getUrl( "foo" );
+
+    assertThat( getQueryParameters( url ), hasItem( "token=foo" ) );
+  }
+
+  @Test
+  public void testGetURL_isServiceHandlerUrl() {
+    String url = FileUploadServiceHandler.getUrl( "foo" );
+
+    assertThat( getQueryParameters( url ), hasItem( startsWith( "servicehandler=" ) ) );
   }
 
   private void fakeUploadRequest( String token ) {
@@ -223,6 +242,12 @@
     FileUploadTestUtil.fakeUploadRequest( token, content, contentType, fileName );
   }
 
+  private static List<String> getQueryParameters( String url ) {
+    int queryIndex = url.indexOf( '?' );
+    String queryString = queryIndex == -1 ? "" : url.substring( queryIndex + 1 );
+    return asList( queryString.split( "\\&" ) );
+  }
+
   private static int getResponseErrorStatus() {
     TestResponse response = ( TestResponse )RWT.getResponse();
     return response.getErrorStatus();
@@ -236,4 +261,5 @@
     }
     return new String( bytes );
   }
+
 }