package com.levelup.java.string;

import static org.junit.Assert.assertEquals;

import org.apache.commons.lang3.StringUtils;
import org.junit.Test;

import com.google.common.base.CharMatcher;

/**
 * This java example will demonstrate trimming trailing
 * spaces in a string.
 *  
 * 
 * @author Justin Musgrove
 * @see <a href='http://www.leveluplunch.com/java/examples/trim-'></a>
 * 
 */
public class RightTrimString {

	@Test
	public void trim_trailing_spaces_from_string_guava () {
		
		String rightTrimmedString = CharMatcher.WHITESPACE.trimTrailingFrom("       Something in the air       ");
		assertEquals("       Something in the air", rightTrimmedString);
	}

	@Test
	public void trim_trailing_spaces_from_string_apache_commons () {
		
		String rightTrimmedString = StringUtils.stripEnd("           Learning to fly          ", " ");
		assertEquals("           Learning to fly", rightTrimmedString);
	}

	@Test
	public void trim_trailing_spaces_from_string_spring_with_trimtrailingWhiteSpace () {
		
		String rightTrimmedString = org.springframework.util.StringUtils.trimTrailingWhitespace("      Don't come around here no more          ");
		assertEquals("      Don't come around here no more", rightTrimmedString);
	}
	
	@Test
	public void trim_trailing_spaces_from_string_spring_with_trim_trailing_character () {
		
		String rightTrimmedString = org.springframework.util.StringUtils.trimTrailingCharacter("      The waiting        ", ' ');
		assertEquals("      The waiting", rightTrimmedString);
	}
	
	
}

@@ -368,15 +368,45 @@
 les/
-trim-'%3E
+right-trim-string/'%3ERight trim string
 %3C/a%3E
@@ -565,16 +565,21 @@
 ITESPACE
+%0A%09%09%09%09
 .trimTra
@@ -619,32 +619,35 @@
 e air       %22);%0A
+%09%09%0A
 %09%09assertEquals(%22
@@ -818,16 +818,21 @@
 ingUtils
+%0A%09%09%09%09
 .stripEn
@@ -875,24 +875,27 @@
    %22, %22 %22);%0A
+%09%09%0A
 %09%09assertEqua
@@ -1094,32 +1094,37 @@
 ngframework.util
+%0A%09%09%09%09
 .StringUtils.tri
@@ -1194,16 +1194,19 @@
     %22);%0A
+%09%09%0A
 %09%09assert
@@ -1429,16 +1429,21 @@
 ork.util
+%0A%09%09%09%09
 .StringU
@@ -1504,16 +1504,19 @@
 , ' ');%0A
+%09%09%0A
 %09%09assert

format added url