@RunWith(SpringRunner.class) @SpringBootTest public class DemoApplicationTests { @Test public void contextLoads() { } }
@RunWith(SpringRunner.class) @SpringBootTest public class JibApplicationTests { @Test public void contextLoads() { } }
/** * @author Gary Russell * @since 4.2 */ @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = Application.class) public class ApplicationTests { @Test public void contextLoads() { } }
/** * @author Artem Bilan * @since 3.0 */ @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = Application.class) public class ApplicationTests { @Test public void contextLoads() { } }
@RunWith(SpringRunner.class) @SpringBootTest public class DynamicTcpClientApplicationTests { @Test public void contextLoads() { } }
@RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = Application.class) public class ApplicationTests { @Test public void contextLoads() { } }
/** * @author Artem Bilan * @since 3.0 */ @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = Application.class) public class ApplicationTests { @Test public void testWebSockets() throws InterruptedException { } }
@RunWith(SpringRunner.class) @SpringBootTest(classes = Config.class) public static class DisabledByDefault { @Autowired(required = false) private DiscoveryClientRouteDefinitionLocator locator; @Test public void routeLocatorBeanMissing() { assertThat(locator) .as("DiscoveryClientRouteDefinitionLocator exists") .isNull(); } }
@RunWith(SpringRunner.class) @SpringBootTest public class DemoApplicationTests { @Test public void contextLoads() { } }
@RunWith(SpringRunner.class) @SpringBootTest public class DemoApplicationTests { @Test public void contextLoads() { } }
/** * Created by alexf on 28-Jan-16. */ @RunWith(SpringRunner.class) @SpringBootTest(classes = {DemoApp.class },webEnvironment = NONE ,properties = {"grpc.enabled=false","grpc.inProcessServerName=testServer"} ) public class DisabledGrpcServerTest extends GrpcServerTestBase { @Test public void disabledServerTest() throws Throwable { assertNull(grpcServerRunner); assertNotNull(grpcInprocessServerRunner); } }
/** * Created by alexf on 28-Jan-16. */ @RunWith(SpringRunner.class) @SpringBootTest(classes = {DemoApp.class },webEnvironment = NONE ,properties = {"grpc.enabled=false","grpc.inProcessServerName=testServer"} ) public class DisabledGrpcServerTest extends GrpcServerTestBase { @Test public void disabledServerTest() throws Throwable { assertNull(grpcServerRunner); assertNotNull(grpcInprocessServerRunner); } }
/** * @author Stephane Nicoll * @author Dave Syer */ @SpringBootTest(classes = Config.class, webEnvironment = WebEnvironment.RANDOM_PORT) public abstract class AbstractFullStackInitializrIntegrationTests extends AbstractInitializrIntegrationTests { @LocalServerPort protected int port; protected String host = "localhost"; @Override protected String createUrl(String context) { return "http://" + this.host + ":" + this.port + (context.startsWith("/") ? context : "/" + context); } }
/** * @author Rob Winch */ @SpringBootTest @AutoConfigureMockMvc @RunWith(SpringRunner.class) public class OAuth2WebClientApplicationTests { @Autowired private MockMvc mockMvc; @Test public void annotationExplicitWhenNotAuthenticatedThenLoginRequested() throws Exception { this.mockMvc.perform(get("/annotation/explicit")) .andExpect(status().is3xxRedirection()); } }
/** * @author Rob Winch */ @SpringBootTest @AutoConfigureWebTestClient @RunWith(SpringRunner.class) public class OAuth2WebClientWebFluxApplicationTests { @Autowired private WebTestClient client; @Test public void annotationExplicitWhenNotAuthenticatedThenLoginRequested() { this.client.get().uri("/annotation/explicit") .exchange() .expectStatus().is3xxRedirection(); } }
@RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest @WebAppConfiguration public class UaaMetricsScheduledTest { @Autowired private UaaMetricsEmitter uaaMetricsEmitter; @Test public void emittingMetrics_Is_Scheduled() throws Exception { Scheduled schedulerAnnotation = uaaMetricsEmitter.getClass().getMethod("emitMetrics").getAnnotation(Scheduled.class); Assert.assertEquals(5000, schedulerAnnotation.fixedRate()); } }
/** * @author Filippo Balicchia * @since 4.2 */ @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = Application.class) public class ApplicationTests { @ClassRule public static SplunkWatcher splunkWatcher = new SplunkWatcher(); @Test public void contextLoads() { } }
@RunWith(SpringRunner.class) @SpringBootTest(classes = {DemoApp.class}, webEnvironment = NONE) public class DefaultGrpcPortTest extends GrpcServerTestBase { @LocalRunningGrpcPort int runningPort; @Override protected int getPort() { return runningPort; } @Override protected void beforeGreeting() { Assert.assertEquals(0, gRpcServerProperties.getPort()); Assert.assertEquals(GRpcServerProperties.DEFAULT_GRPC_PORT, runningPort); } }
@RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = RANDOM_PORT) @DirtiesContext @ActiveProfiles("multi-cert-ssl") public class MultiCertSSLTests extends SingleCertSSLTests { }
@RunWith(SpringRunner.class) // this test works because it assumes TLS hand shake cannot be done in 1ms. It takes closer to 80ms @SpringBootTest(webEnvironment = RANDOM_PORT, properties = {"spring.cloud.gateway.httpclient.ssl.handshake-timeout=1ms"}) @DirtiesContext @ActiveProfiles("ssl") public class SSLHandshakeTimeoutTests extends SingleCertSSLTests { @Test @Override // here we validate that it the handshake times out public void testSslTrust() { ResponseSpec responseSpec = testClient.get().uri("/ssltrust").exchange(); responseSpec.expectStatus().is5xxServerError(); JsonPathAssertions jsonPath = responseSpec.expectBody().jsonPath("message"); jsonPath.isEqualTo("handshake timed out"); } }