Skip to content

Commit

Permalink
Split Sleuth test into two seperate for basic functionality (sleuth_m…
Browse files Browse the repository at this point in the history
…eta_data_should_be_print_out()) and call time check (call_time_should_be_print_out()).
  • Loading branch information
jonashackt committed Jul 9, 2018
1 parent 0045904 commit e639fdb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Enterprise-ready production-ready SOAP-Webservices powered by Spring Boot & Apac
======================================================================================
[![Build Status](https://travis-ci.org/codecentric/cxf-spring-boot-starter.svg?branch=master)](https://travis-ci.org/codecentric/cxf-spring-boot-starter)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/de.codecentric/cxf-spring-boot-starter/badge.svg)](https://maven-badges.herokuapp.com/maven-central/de.codecentric/cxf-spring-boot-starter/)
[![Dependency Status](https://www.versioneye.com/user/projects/5720e300fcd19a0051856aa7/badge.svg?style=flat)](https://www.versioneye.com/user/projects/5720e300fcd19a0051856aa7)
[![License](http://img.shields.io/:license-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)

> !! This document applies to the next version under development.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import de.codecentric.cxf.TestApplication;
import de.codecentric.cxf.common.XmlUtils;
import de.codecentric.namespace.weatherservice.WeatherException;
import de.codecentric.namespace.weatherservice.WeatherService;
import de.codecentric.namespace.weatherservice.general.GetCityForecastByZIP;
import org.junit.Rule;
Expand All @@ -14,6 +15,7 @@
import org.springframework.core.io.Resource;
import org.springframework.test.context.junit4.SpringRunner;

import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand All @@ -28,8 +30,6 @@
properties = {"server.port:8087"})
public class SleuthLogMessagesTest {

private static final Pattern SLEUTH_LOG_LINE_PATTERN = Pattern.compile("(INFO \\[-,\\w+,\\w+,false].*: Returning a forecast.)");

@Rule
public final SystemOutRule systemOutRule = new SystemOutRule().enableLog();

Expand All @@ -41,14 +41,31 @@ public class SleuthLogMessagesTest {

@Test public void
sleuth_meta_data_should_be_print_out() throws Exception {
GetCityForecastByZIP getCityForecastByZIP = XmlUtils.readSoapMessageFromStreamAndUnmarshallBody2Object(
GetCityForecastByZIPTestXml.getInputStream(), GetCityForecastByZIP.class);
weatherServiceClient.getCityForecastByZIP(getCityForecastByZIP.getForecastRequest());
callSoapService();

String log = systemOutRule.getLog();
assertThat(isSleuthLogLineSomewhereIn(log),is(true));
}

private boolean isSleuthLogLineSomewhereIn(String log) {
Pattern sleuth_log_line_pattern = Pattern.compile("(INFO \\[-,\\w+,\\w+,false].*: Returning a forecast.)");
Matcher loglineMatcher = sleuth_log_line_pattern.matcher(log);
return loglineMatcher.find();
}

@Test public void
call_time_should_be_print_out() throws Exception {
callSoapService();

String log = systemOutRule.getLog();
Matcher foundLoglineMatcher = SLEUTH_LOG_LINE_PATTERN.matcher(log);
assertThat(foundLoglineMatcher.find(),is(true));
assertThat(log,containsString("Call time"));
}

private void callSoapService() throws de.codecentric.cxf.common.BootStarterCxfException, IOException, WeatherException {
GetCityForecastByZIP getCityForecastByZIP = XmlUtils.readSoapMessageFromStreamAndUnmarshallBody2Object(
GetCityForecastByZIPTestXml.getInputStream(), GetCityForecastByZIP.class);

weatherServiceClient.getCityForecastByZIP(getCityForecastByZIP.getForecastRequest());
}

}

0 comments on commit e639fdb

Please sign in to comment.