private static void assertRequestAttributes(ServletRequest request) { assertThat(request.getAttribute(FROM_CUSTOM_MOCK), is(nullValue())); assertThat(request.getAttribute(FROM_MVC_TEST_DEFAULT), is(FROM_MVC_TEST_DEFAULT)); assertThat(request.getAttribute(FROM_MVC_TEST_MOCK), is(FROM_MVC_TEST_MOCK)); }
@Test public void shouldNotSupportClassHavingOnlyVoidReturningSetter() throws IntrospectionException { @SuppressWarnings("unused") class C { public void setFoo(String s) { } } assertThat(factory.getBeanInfo(C.class), nullValue()); }
private void assertMockMvcNotUsed(WebConnection connection, String url) throws Exception { assertThat(getResponse(connection, url), nullValue()); }
/** * Use of @Import to register LowLevelConfig results in ASM-based annotation * processing. */ @Test public void withAsmAnnotationProcessing() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(HighLevelConfig.class); ctx.refresh(); assertThat(ctx.getBean(LowLevelConfig.class).scanned, not(nullValue())); }
@Test public void transaction_not_in_response_on_failure() throws Exception { // begin Response begin = http.POST( "db/data/transaction" ); String commitResource = begin.stringFromContent( "commit" ); // execute valid statement Response valid = http.POST( begin.location(), quotedJson( "{ 'statements': [ { 'statement': 'RETURN 42' } ] }" ) ); assertThat( valid.status(), equalTo( 200 ) ); assertThat( valid.get( "transaction"), notNullValue() ); // execute invalid statement Response invalid = http.POST( begin.location(), quotedJson( "{ 'statements': [ { 'statement': 'RETRUN 42' } ] }" ) ); assertThat( invalid.status(), equalTo( 200 ) ); //transaction has been closed and rolled back assertThat( invalid.get( "transaction"), nullValue() ); // commit Response commit = http.POST( commitResource ); //no transaction open anymore, we have failed assertThat( commit.status(), equalTo( 404 ) ); }
private void doTestModeCannotReplayTuples(KafkaSpoutConfig<String, String> spoutConfig) { KafkaSpout<String, String> spout = SpoutWithMockedConsumerSetupHelper.setupSpout(spoutConfig, conf, contextMock, collectorMock, consumerMock, partition); when(consumerMock.poll(anyLong())).thenReturn(new ConsumerRecords<>(Collections.singletonMap(partition, SpoutWithMockedConsumerSetupHelper.createRecords(partition, 0, 1)))); spout.nextTuple(); ArgumentCaptor<KafkaSpoutMessageId> msgIdCaptor = ArgumentCaptor.forClass(KafkaSpoutMessageId.class); verify(collectorMock).emit(eq(SingleTopicKafkaSpoutConfiguration.STREAM), anyList(), msgIdCaptor.capture()); assertThat("Should have captured a message id", msgIdCaptor.getValue(), not(nullValue())); spout.fail(msgIdCaptor.getValue()); reset(consumerMock); when(consumerMock.poll(anyLong())).thenReturn(new ConsumerRecords<>(Collections.singletonMap(partition, SpoutWithMockedConsumerSetupHelper.createRecords(partition, 1, 1)))); spout.nextTuple(); //The consumer should not be seeking to retry the failed tuple, it should just be continuing from the current position verify(consumerMock, never()).seek(eq(partition), anyLong()); }
@Test void testParam() { URI uri = URI.create("http://localhost/foo?x=a&y=b&z"); assertThat( parameter( "x" ).apply( uri ), equalTo( "a" ) ); assertThat( parameter( "y" ).apply( uri ), equalTo( "b" ) ); assertThat( parameter( "z" ).apply( uri ), equalTo( "true" ) ); assertThat( parameter( "foo" ).apply( uri ), nullValue() ); } }
/** * Direct registration of LowLevelConfig results in reflection-based annotation * processing. */ @Test public void withoutAsmAnnotationProcessing() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(LowLevelConfig.class); ctx.refresh(); assertThat(ctx.getBean(LowLevelConfig.class).scanned, not(nullValue())); }
@Test public void shouldNotSupportClassHavingNonPublicNonVoidReturningIndexedSetter() throws IntrospectionException { @SuppressWarnings("unused") class C { void setBar(String s) { } } assertThat(factory.getBeanInfo(C.class), nullValue()); }
@Test public void shouldNotFindUserAfterDelete() throws Throwable { // Given FileUserRepository users = new FileUserRepository( fs, authFile, logProvider ); User user = new User.Builder( "jake", LegacyCredential.INACCESSIBLE ).withRequiredPasswordChange( true ).build(); users.create( user ); // When users.delete( user ); // Then assertThat( users.getUserByName( user.name() ), nullValue() ); }
@Test public void shouldNotListUnresolvedServerConfig() { // Given: final KsqlConfig config = new KsqlConfig(ImmutableMap.of( "some.random.property", "might be sensitive" )); // When: final Map<String, String> result = config.getAllConfigPropsWithSecretsObfuscated(); // Then: assertThat(result.get("some.random.property"), is(nullValue())); }
private static void assertRequestAttributes(ServletRequest request, boolean withinMockMvc) { if (withinMockMvc) { assertThat(request.getAttribute(FROM_TCF_MOCK), is(nullValue())); assertThat(request.getAttribute(FROM_MVC_TEST_DEFAULT), is(FROM_MVC_TEST_DEFAULT)); assertThat(request.getAttribute(FROM_MVC_TEST_MOCK), is(FROM_MVC_TEST_MOCK)); assertThat(request.getAttribute(FROM_REQUEST_FILTER), is(FROM_REQUEST_FILTER)); assertThat(request.getAttribute(FROM_REQUEST_ATTRIBUTES_FILTER), is(FROM_REQUEST_ATTRIBUTES_FILTER)); } else { assertThat(request.getAttribute(FROM_TCF_MOCK), is(FROM_TCF_MOCK)); assertThat(request.getAttribute(FROM_MVC_TEST_DEFAULT), is(nullValue())); assertThat(request.getAttribute(FROM_MVC_TEST_MOCK), is(nullValue())); assertThat(request.getAttribute(FROM_REQUEST_FILTER), is(nullValue())); assertThat(request.getAttribute(FROM_REQUEST_ATTRIBUTES_FILTER), is(nullValue())); } }
@Test public void testFindNextCommitOffsetWhenTooLowOffsetIsAcked() { OffsetManager startAtHighOffsetManager = new OffsetManager(testTp, 10); emitAndAckMessage(getMessageId(0)); OffsetAndMetadata nextCommitOffset = startAtHighOffsetManager.findNextCommitOffset(COMMIT_METADATA); assertThat("Acking an offset earlier than the committed offset should have no effect", nextCommitOffset, is(nullValue())); }
@Test public void shouldReturnNullForBarrierWhenHandlerIsNotRegistered() throws Exception { assertThat(consumerRepository.getBarrierFor(handler1), is(nullValue())); }
@Test public void shouldNotSupportClassHavingNonVoidReturningParameterlessSetter() throws IntrospectionException { @SuppressWarnings("unused") class C { C setBar() { return this; } } assertThat(factory.getBeanInfo(C.class), nullValue()); }
@Test public void sessionAttributesAreClearedBetweenInvocations() throws Exception { this.mvc.perform(get("/")) .andExpect(content().string(HELLO)) .andExpect(request().sessionAttribute(FOO, nullValue())); this.mvc.perform(get("/").sessionAttr(FOO, BAR)) .andExpect(content().string(HELLO)) .andExpect(request().sessionAttribute(FOO, BAR)); this.mvc.perform(get("/")) .andExpect(content().string(HELLO)) .andExpect(request().sessionAttribute(FOO, nullValue())); }
@After public void verifyCustomRequestAttributesAreRestored() { RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); assertThat(requestAttributes, instanceOf(ServletRequestAttributes.class)); HttpServletRequest request = ((ServletRequestAttributes) requestAttributes).getRequest(); assertThat(request.getAttribute(FROM_CUSTOM_MOCK), is(FROM_CUSTOM_MOCK)); assertThat(request.getAttribute(FROM_MVC_TEST_DEFAULT), is(nullValue())); assertThat(request.getAttribute(FROM_MVC_TEST_MOCK), is(nullValue())); RequestContextHolder.resetRequestAttributes(); this.wac.close(); }