diff options
author | Sauli Tähkäpää <sauli@vaadin.com> | 2014-03-13 08:52:37 +0200 |
---|---|---|
committer | Sauli Tähkäpää <sauli@vaadin.com> | 2014-03-13 09:11:31 +0200 |
commit | 49973354b22e8aba9cc71f83571020b0414c54e0 (patch) | |
tree | ab10e93151f12830b5f12382cfc03651c907f3fc /shared | |
parent | 94d33ad7c732f620c9e98502b896a65852479b7d (diff) | |
download | vaadin-framework-49973354b22e8aba9cc71f83571020b0414c54e0.tar.gz vaadin-framework-49973354b22e8aba9cc71f83571020b0414c54e0.zip |
Fixed trailing slash trimming in VaadinPortletService.
Change-Id: Ia9f6230219adfb1fcb29b88ad819e3209770e1fc
Diffstat (limited to 'shared')
-rw-r--r-- | shared/build.xml | 5 | ||||
-rw-r--r-- | shared/ivy.xml | 2 | ||||
-rw-r--r-- | shared/src/com/vaadin/shared/util/SharedUtil.java | 9 | ||||
-rw-r--r-- | shared/tests/src/com/vaadin/shared/util/SharedUtilTests.java | 43 |
4 files changed, 56 insertions, 3 deletions
diff --git a/shared/build.xml b/shared/build.xml index 73a0a8df7f..966d250d66 100644 --- a/shared/build.xml +++ b/shared/build.xml @@ -15,7 +15,7 @@ <property name="src.filtered" location="${result.dir}/filtered-src" /> <property name="src" location="${src.filtered}" /> <path id="classpath.compile.custom" /> - + <path id="classpath.test.custom" /> <target name="jar"> <property name="shared.osgi.import" value="org.json;version="0.0.20080701", com.google.gwt.thirdparty.guava.common.annotations;version="10.0.1.rebased", com.google.gwt.thirdparty.guava.common.base;version="10.0.1.rebased", com.google.gwt.thirdparty.guava.common.base.internal;version="10.0.1.rebased", com.google.gwt.thirdparty.guava.common.cache;version="10.0.1.rebased", com.google.gwt.thirdparty.guava.common.collect;version="10.0.1.rebased", com.google.gwt.thirdparty.guava.common.eventbus;version="10.0.1.rebased", com.google.gwt.thirdparty.guava.common.io;version="10.0.1.rebased", com.google.gwt.thirdparty.guava.common.net;version="10.0.1.rebased", com.google.gwt.thirdparty.guava.common.primitives;version="10.0.1.rebased", com.google.gwt.thirdparty.guava.common.util.concurrent;version="10.0.1.rebased", com.google.gwt.thirdparty.streamhtmlparser;version="0.1.5.r10-rebased", com.google.gwt.thirdparty.streamhtmlparser.impl;version="0.1.5.r10-rebased", com.google.gwt.thirdparty.streamhtmlparser.util;version="0.1.5.r10-rebased", org.w3c.flute.parser;version="1.3.0.gg2", org.w3c.flute.parser.selectors;version="1.3.0.gg2", org.w3c.flute.util;version="1.3.0.gg2"" /> @@ -57,8 +57,7 @@ </target> <target name="test" depends="checkstyle"> - <!--<antcall target="common.test.run" /> --> - <echo>WHAT? No tests for ${module.name}!</echo> + <antcall target="common.test.run" /> </target> </project> diff --git a/shared/ivy.xml b/shared/ivy.xml index 3b044e9ab4..b4b5878294 100644 --- a/shared/ivy.xml +++ b/shared/ivy.xml @@ -22,6 +22,8 @@ <dependencies> <dependency org="com.vaadin" name="vaadin-shared-deps" rev="1.0.2" conf="build,ide,test->default" /> + <dependency org="junit" name="junit" rev="4.11" + conf="test,ide -> default" /> </dependencies> </ivy-module> diff --git a/shared/src/com/vaadin/shared/util/SharedUtil.java b/shared/src/com/vaadin/shared/util/SharedUtil.java index 80efe68d83..449685705f 100644 --- a/shared/src/com/vaadin/shared/util/SharedUtil.java +++ b/shared/src/com/vaadin/shared/util/SharedUtil.java @@ -44,4 +44,13 @@ public class SharedUtil implements Serializable { return o1.equals(o2); } + /** + * Trims trailing slashes (if any) from a string. + * @param value The string value to be trimmed. Cannot be null. + * @return String value without trailing slashes. + */ + public static String trimTrailingSlashes(String value) { + return value.replaceAll("/*$", ""); + } + } diff --git a/shared/tests/src/com/vaadin/shared/util/SharedUtilTests.java b/shared/tests/src/com/vaadin/shared/util/SharedUtilTests.java new file mode 100644 index 0000000000..b593032bd6 --- /dev/null +++ b/shared/tests/src/com/vaadin/shared/util/SharedUtilTests.java @@ -0,0 +1,43 @@ +package com.vaadin.shared.util; + +import org.junit.Before; +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +public class SharedUtilTests { + + private SharedUtil sut; + + @Before + public void setup() { + sut = new SharedUtil(); + } + + @Test + public void trailingSlashIsTrimmed() { + assertThat(sut.trimTrailingSlashes("/path/"), is("/path")); + } + + @Test + public void noTrailingSlashForTrimming() { + assertThat(sut.trimTrailingSlashes("/path"), is("/path")); + } + + @Test + public void trailingSlashesAreTrimmed() { + assertThat(sut.trimTrailingSlashes("/path///"), is("/path")); + } + + @Test + public void emptyStringIsHandled() { + assertThat(sut.trimTrailingSlashes(""), is("")); + } + + @Test + public void rootSlashIsTrimmed() { + assertThat(sut.trimTrailingSlashes("/"), is("")); + } + +} |