BAEL-1237 String Formatter (#3103)

* Example Code For Evaluation Article

This is an example code for the evaluation article on "Different Types of Bean Injection in Spring"

* Added unit tests

* Minor changes to application context

* Removed code committed for evaluation article

* BAEL-944 Demonstrating the problems with new Url pattern matching in Spring 5

* BAEL-944 Demonstrating the problems with new Url pattern matching in Spring 5

* BAEL-944 Exploring the Spring MVC URL Matching Improvements

* BAEL-944 Exploring the Spring MVC URL Matching Improvements

* BAEL-944 Exploring the Spring MVC URL Matching Improvements

* BAEL-944 Code Formatting and solving build issue

* BAEL-944 Resolving build issue due to change in Spring version

* BAEL-944 Resolving build issue

* BAEL-944 Formatting code

* BAEL-944 Moving tests to correct package

* BAEL-944 Moving tests to correct package

* BAEL-944 Replacing @RequestMapping by @GetMapping

* BAEL-944 Remove unnecessary attribute name, "value" in annotations

* BAEL-79 Intro to Activiti with Spring

* BAEL-79 Intro to Activiti with Spring

* BAEL-79 Adding activiti module to the parent modules

* BAEL-79 Using latest version

* BAEL-79 Update Spring boot version that works with Activiti

* BAEL-79 Replace RequestMapping with GetMapping

* BAEL-79 Use Java 8 Syntax

* BAEL-79 Formatting

* BAEL-79 changed module name

* BAEL-378 A Guide to Activiti with Java

* BAEL-79 Fixed unit tests

* BAEL-79 Simplified the process

* BAEL-79 Fix test cases

* BAEL-1045 Lambda Behave

* BAEL-1045 Lambda Behave

* BAEL-1045 Lambda Behave

* BAEL-1090 Difference between compact and compressed strings in Java 9

* BAEL-1237 String Formatter

* BAEL-1237 String Formatter

* BAEL-1237 String Formatter

* BAEL-1237 String Formatter

* BAEL-1237 Guide to java.util.Formatter

* BAEL-1237 String Formatter

* BAEL-1237 Using platform dependent line separator in new line test
This commit is contained in:
Mansi 2017-11-23 17:57:18 +05:30 committed by Predrag Maric
parent 668f1f1bb3
commit 69613f8e53

View File

@ -14,7 +14,8 @@ public class StringFormatterExampleTests {
public void givenString_whenFormatSpecifierForCalendar_thenGotExpected() {
//Syntax of Format Specifiers for Date/Time Representation
Calendar c = new GregorianCalendar(2017, 11, 10);
String s = String.format("The date is: %1$tm %1$te,%1$tY", c);
String s = String.format("The date is: %tm %1$te,%1$tY", c);
assertEquals("The date is: 12 10,2017", s);
}
@ -84,7 +85,7 @@ public class StringFormatterExampleTests {
public void givenString_whenLineSeparatorConversion_thenConvertedString() {
//Line Separator Conversion
String s = String.format("First Line %nSecond Line");
assertEquals("First Line \n"
assertEquals("First Line " + System.getProperty("line.separator")
+ "Second Line", s);
}
@ -114,10 +115,10 @@ public class StringFormatterExampleTests {
public void givenString_whenSpecifyArgumentIndex_thenGotExpected() {
Calendar c = new GregorianCalendar(2017, 11, 10);
//Argument_Index
String s = String.format("The date is: %1$tm %1$te,%1$tY", c);
String s = String.format("The date is: %tm %1$te,%1$tY", c);
assertEquals("The date is: 12 10,2017", s);
s = String.format("The date is: %1$tm %<te,%<tY", c);
s = String.format("The date is: %tm %<te,%<tY", c);
assertEquals("The date is: 12 10,2017", s);
}
@ -126,8 +127,7 @@ public class StringFormatterExampleTests {
//Using String Formatter with Appendable
StringBuilder sb = new StringBuilder();
Formatter formatter = new Formatter(sb);
formatter.format("I am writting to a %1$s Instance.", sb.getClass());
formatter.format("I am writting to a %s Instance.", sb.getClass());
assertEquals("I am writting to a class java.lang.StringBuilder Instance.", sb.toString());
}