Search in sources :

Example 1 with StringConversionService

use of org.springframework.integration.service.StringConversionService in project spring-integration-samples by spring-projects.

the class StringConversionServiceTest method testConvertStringToUpperCase.

@Test
public void testConvertStringToUpperCase() {
    final ApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/spring/integration/spring-integration-context.xml", StringConversionServiceTest.class);
    final StringConversionService service = context.getBean(StringConversionService.class);
    final String stringToConvert = "I love Spring Integration";
    final String expectedResult = "I LOVE SPRING INTEGRATION";
    final String convertedString = service.convertToUpperCase(stringToConvert);
    Assert.assertEquals("Expecting that the string is converted to upper case.", expectedResult, convertedString);
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) StringConversionService(org.springframework.integration.service.StringConversionService) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) Test(org.junit.Test)

Example 2 with StringConversionService

use of org.springframework.integration.service.StringConversionService in project spring-integration-samples by spring-projects.

the class Main method executeSample1.

private static void executeSample1() {
    final Scanner scanner = new Scanner(System.in);
    final GenericXmlApplicationContext context = new GenericXmlApplicationContext();
    context.load("classpath:META-INF/spring/integration/spring-integration-sample1-context.xml");
    context.registerShutdownHook();
    context.refresh();
    final StringConversionService service = context.getBean(StringConversionService.class);
    final String message = "\n=========================================================" + "\n                                                         " + "\n    Please press 'q + Enter' to quit the application.    " + "\n                                                         " + "\n=========================================================" + "\n\n Please enter a string and press <enter>: ";
    System.out.print(message);
    while (!scanner.hasNext("q")) {
        String input = scanner.nextLine();
        System.out.println("Converting String to Uppcase using Stored Procedure...");
        String inputUpperCase = service.convertToUpperCase(input);
        System.out.println("Retrieving Numeric value via Sql Function...");
        Integer number = service.getNumber();
        System.out.println(String.format("Converted '%s' - End Result: '%s_%s'.", input, inputUpperCase, number));
        System.out.print("To try again, please enter a string and press <enter>:");
    }
    scanner.close();
    context.close();
    System.out.println("Back to main menu.");
}
Also used : Scanner(java.util.Scanner) StringConversionService(org.springframework.integration.service.StringConversionService) GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext)

Example 3 with StringConversionService

use of org.springframework.integration.service.StringConversionService in project spring-integration-samples by spring-projects.

the class StringConversionServiceTest method testConvertStringToUpperCase.

@Test
public void testConvertStringToUpperCase() {
    final ApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/spring/integration/spring-integration-context.xml", StringConversionServiceTest.class);
    final StringConversionService service = context.getBean(StringConversionService.class);
    final String stringToConvert = "I love Spring Integration";
    final String expectedResult = "I LOVE SPRING INTEGRATION";
// final String convertedString = service.convertToUpperCase(stringToConvert);
// assertEquals("Expecting that the string is converted to upper case.",
// dd                expectedResult, convertedString);
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) StringConversionService(org.springframework.integration.service.StringConversionService) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) Test(org.junit.Test)

Aggregations

StringConversionService (org.springframework.integration.service.StringConversionService)3 Test (org.junit.Test)2 ApplicationContext (org.springframework.context.ApplicationContext)2 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)2 Scanner (java.util.Scanner)1 GenericXmlApplicationContext (org.springframework.context.support.GenericXmlApplicationContext)1