Skip to content

Commit

Permalink
#6 Tests for SeiImplementationMissingFailureAnalyzer and SeiImplement…
Browse files Browse the repository at this point in the history
…ingClassNotFoundException.
  • Loading branch information
jonashackt committed Nov 8, 2016
1 parent e47e239 commit 1077ecc
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package de.codecentric.cxf.autodetection;

import de.codecentric.cxf.common.BootStarterCxfException;
import de.codecentric.cxf.diagnostics.SeiImplementingClassNotFoundException;
import de.codecentric.namespace.weatherservice.WeatherService;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.springframework.test.context.junit4.SpringRunner;

import javax.xml.namespace.QName;
Expand All @@ -13,11 +18,22 @@
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.when;


@RunWith(SpringRunner.class)
public class WebServiceAutoDetectorTest {

@Mock
private WebServiceAutoDetector webServiceAutoDetector;

@Before
public void setUp() {
webServiceAutoDetector = Mockito.mock(WebServiceAutoDetector.class);
}

@Test
public void isServiceEndpointInterfaceSuccessfullyDetected() throws BootStarterCxfException {

Expand Down Expand Up @@ -48,8 +64,15 @@ public void isWebServiceClientSuccessfullyFoundAndInstantiated() throws BootStar
assertThat(serviceNameQName.getLocalPart(), is(equalTo("Weather")));
}

@Test
public void shouldReactWithCustomStartupFailureMessagePresentedInConsoleIfSeiImplementingClassIsMissing() {
@Test(expected = SeiImplementingClassNotFoundException.class)
public void shouldReactWithCustomStartupFailureMessagePresentedInConsoleIfSeiImplementingClassIsMissing() throws BootStarterCxfException {
Class serviceEndpointInterface = WebServiceAutoDetector.searchServiceEndpointInterface();

SeiImplementingClassNotFoundException seiNotFoundException = new SeiImplementingClassNotFoundException("No SEI implementing class found");
seiNotFoundException.setNotFoundClassName(serviceEndpointInterface.getName());

throw seiNotFoundException;


}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package de.codecentric.cxf.diagnostics;

import de.codecentric.cxf.autodetection.WebServiceAutoDetector;
import org.junit.Test;
import org.springframework.boot.diagnostics.FailureAnalysis;

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;


public class SeiImplementationMissingFailureAnalyzerTest {

private SeiImplementationMissingFailureAnalyzer analyzer = new SeiImplementationMissingFailureAnalyzer();

@Test
public void doesAnalysisContainCorrectDescription() throws Exception {

Class serviceEndpointInterface = WebServiceAutoDetector.searchServiceEndpointInterface();

SeiImplementingClassNotFoundException seiNotFoundException = new SeiImplementingClassNotFoundException("No SEI implementing class found");
seiNotFoundException.setNotFoundClassName(serviceEndpointInterface.getName());

FailureAnalysis failureAnalysis = analyzer.analyze(seiNotFoundException);

assertThat(failureAnalysis.getDescription(), containsString("There was no SEI implementing class found"));
}



}

0 comments on commit 1077ecc

Please sign in to comment.