private void assertHasStandardEnvironment(ApplicationContext ctx) { Environment defaultEnv = ctx.getEnvironment(); assertThat(defaultEnv, notNullValue()); assertThat(defaultEnv, instanceOf(StandardEnvironment.class)); }
private void assertHasEnvironment(ApplicationContext ctx, Environment expectedEnv) { // ensure the custom environment took Environment actualEnv = ctx.getEnvironment(); assertThat(actualEnv, notNullValue()); assertThat(actualEnv, is(expectedEnv)); // ensure environment is registered as a bean assertThat(ctx.containsBean(ENVIRONMENT_BEAN_NAME), is(true)); }
@Test public void getWebConnectionDefaultNotNull() { assertThat(this.driver.getWebConnection(), notNullValue()); }
@Test public void shouldLoadApplicationContext() throws Exception { assertThat(controller, is(notNullValue())); }
@Test public void shouldGetOutputStreamForPostWithBody() throws Throwable { final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); final ByteArrayInputStream inputStream = new ByteArrayInputStream(RESPONSE_BODY); when(mockHttpURLConnection.getOutputStream()).thenReturn(outputStream); when(mockHttpURLConnection.getInputStream()).thenReturn(inputStream); assertThat(httpFunction().apply(HTTP_POST_WITH_BODY_REQUEST), is(notNullValue())); verify(mockHttpURLConnection).setDoInput(true); verify(mockHttpURLConnection).disconnect(); assertThat(outputStream.toByteArray(), is(REQUEST_BODY)); }
@Test public void simpValidatorInjected() { ApplicationContext context = loadConfig(SimpleBrokerConfig.class); SimpAnnotationMethodMessageHandler messageHandler = context.getBean(SimpAnnotationMethodMessageHandler.class); assertThat(messageHandler.getValidator(), Matchers.notNullValue(Validator.class)); }
@Test public void testNodeMatcher() throws Exception { new XpathRequestMatchers("/foo/bar", null).node(Matchers.notNullValue()).match(this.request); }
@Test public void testCollectionFieldsDefault() throws Exception { TestBean target = new TestBean(); target.setSomeSet(null); target.setSomeList(null); target.setSomeMap(null); WebRequestDataBinder binder = new WebRequestDataBinder(target); MockHttpServletRequest request = new MockHttpServletRequest(); request.addParameter("_someSet", "visible"); request.addParameter("_someList", "visible"); request.addParameter("_someMap", "visible"); binder.bind(new ServletWebRequest(request)); assertThat(target.getSomeSet(), notNullValue()); assertThat(target.getSomeSet(), isA(Set.class)); assertThat(target.getSomeList(), notNullValue()); assertThat(target.getSomeList(), isA(List.class)); assertThat(target.getSomeMap(), notNullValue()); assertThat(target.getSomeMap(), isA(Map.class)); }
public void resumeOrThrow() { final Runnable runnable = this.runnable; assertThat("delayedExecutor should have queued a Runnable for resumeOrThrow()", runnable, is(notNullValue())); this.runnable = null; //noinspection ConstantConditions runnable.run(); } }
public void check() { test(); assertThat(e, notNullValue()); assertThat(e, isA(MyException.class)); assertThat(e.getMessage(), nullValue()); } }
@Test public void invokeAwareMethodsInImportSelector() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AwareConfig.class); assertThat(SampleImportSelector.beanFactory, is(context.getBeanFactory())); assertThat(SampleImportSelector.classLoader, is(context.getBeanFactory().getBeanClassLoader())); assertThat(SampleImportSelector.resourceLoader, is(notNullValue())); assertThat(SampleImportSelector.environment, is(context.getEnvironment())); }
@Test public void shouldGetOutputStreamForPutWithBody() throws Throwable { final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); final ByteArrayInputStream inputStream = new ByteArrayInputStream(RESPONSE_BODY); when(mockHttpURLConnection.getOutputStream()).thenReturn(outputStream); when(mockHttpURLConnection.getInputStream()).thenReturn(inputStream); assertThat(httpFunction().apply(HTTP_PUT_WITH_BODY_REQUEST), is(notNullValue())); verify(mockHttpURLConnection).setDoInput(true); verify(mockHttpURLConnection).disconnect(); assertThat(outputStream.toByteArray(), is(REQUEST_BODY)); }
@Test public void buildRequestSessionTrue() throws Exception { MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext); HttpSession session = actualRequest.getSession(true); assertThat(session, notNullValue()); }
@Test public void node() throws Exception { new XpathResultMatchers("/foo/bar", null).node(Matchers.notNullValue()).match(getStubMvcResult()); }
private void assertHasStandardServletEnvironment(WebApplicationContext ctx) { // ensure a default servlet environment exists Environment defaultEnv = ctx.getEnvironment(); assertThat(defaultEnv, notNullValue()); assertThat(defaultEnv, instanceOf(StandardServletEnvironment.class)); }
private void assertContent(File targetZipFile, String file, String expectedContent) throws IOException { ZipFile actualZip = new ZipFile(targetZipFile); ZipEntry entry = actualZip.getEntry(file); assertThat(entry, is(notNullValue())); assertThat(IOUtils.toString(actualZip.getInputStream(entry), UTF_8), is(expectedContent)); }
@Test void takeOrAwaitLatchMustNotLetUnrelatedLatchesConflictTooMuch() throws Exception { BinaryLatch latch = latches.takeOrAwaitLatch( 42 ); assertThat( latch, is( notNullValue() ) ); ExecutorService executor = Executors.newSingleThreadExecutor(); Future<BinaryLatch> future = executor.submit( () -> latches.takeOrAwaitLatch( 33 ) ); assertThat( future.get( 1, TimeUnit.SECONDS ), is( notNullValue() ) ); latch.release(); }
@Test public void invokeAwareMethodsInImportGroup() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(GroupedConfig1.class); assertThat(TestImportGroup.beanFactory, is(context.getBeanFactory())); assertThat(TestImportGroup.classLoader, is(context.getBeanFactory().getBeanClassLoader())); assertThat(TestImportGroup.resourceLoader, is(notNullValue())); assertThat(TestImportGroup.environment, is(context.getEnvironment())); }
@Test public void shouldGetIssuer() throws Exception { assertThat(payload, is(notNullValue())); assertThat(payload.getIssuer(), is("issuer")); }
@Test public void buildRequestSessionFalseWithExistingSession() throws Exception { String sessionId = "session-id"; webRequest.setAdditionalHeader("Cookie", "JSESSIONID=" + sessionId); MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext); HttpSession session = actualRequest.getSession(false); assertThat(session, notNullValue()); }