@Test public void issuerWhenContainsTrailingSlashThenSuccess() throws Exception { assertThat(registration("")).isNotNull(); assertThat(this.issuer).endsWith("/"); }
@Test public void stacktraceHeaderTraceDescription() { StringBuilder sb = new StringBuilder(); AssemblySnapshot e = new AssemblySnapshot("1234", Traces.callSiteSupplierFactory.get()); FluxOnAssembly.fillStacktraceHeader(sb, String.class, e); assertThat(sb.toString()) .startsWith("\nAssembly trace from producer [java.lang.String]") .endsWith(", described as [1234] :\n"); }
@Test public void protectedIndividualOptionsRedact() { String arg; arg = "-Dgemfire.security-password=secret"; assertThat(redact(arg)).endsWith("password=********"); arg = "--J=-Dsome.highly.qualified.password=secret"; assertThat(redact(arg)).endsWith("password=********"); arg = "--password=foo"; assertThat(redact(arg)).isEqualToIgnoringWhitespace("--password=********"); arg = "-Dgemfire.security-properties=\"c:\\Program Files (x86)\\My Folder\""; assertThat(redact(arg)).isEqualTo(arg); }
@Test public void issuerWhenContainsTrailingSlashThenSuccess() { prepareOpenIdConfigurationResponse(); this.server.enqueue(new MockResponse().setBody(JWK_SET)); assertThat(JwtDecoders.fromOidcIssuerLocation(this.issuer)).isNotNull(); assertThat(this.issuer).endsWith("/"); }
@Test public void missingAuthenticationManagerGivesSensibleErrorMessage() { try { setContext("<http auto-config='true' />"); fail(); } catch (BeanCreationException e) { Throwable cause = ultimateCause(e); assertThat(cause instanceof NoSuchBeanDefinitionException).isTrue(); NoSuchBeanDefinitionException nsbe = (NoSuchBeanDefinitionException) cause; assertThat(nsbe.getBeanName()).isEqualTo(BeanIds.AUTHENTICATION_MANAGER); assertThat(nsbe.getMessage()).endsWith( AuthenticationManagerFactoryBean.MISSING_BEAN_ERROR_MESSAGE); } }
@Test public void headlessModeShouldRedirectBothJDKAndGFSHLoggers() { gfsh = new Gfsh(false, null, new GfshConfig()); LogManager logManager = LogManager.getLogManager(); Enumeration<String> loggerNames = logManager.getLoggerNames(); while (loggerNames.hasMoreElements()) { String loggerName = loggerNames.nextElement(); Logger logger = logManager.getLogger(loggerName); // make sure jdk's logging goes to the gfsh log file if (loggerName.startsWith("java")) { assertThat(logger.getParent().getName()).endsWith("LogWrapper"); } // make sure Gfsh's logging goes to the gfsh log file else if (loggerName.endsWith(".Gfsh")) { assertThat(logger.getParent().getName()).endsWith("LogWrapper"); } // make sure SimpleParser's logging will still show up in the console else if (loggerName.endsWith(".SimpleParser")) { assertThat(logger.getParent().getName()).doesNotEndWith("LogWrapper"); } } } }
@Test public void customConfiguerFormLogin() throws Exception { loadContext(Config.class); request.setPathInfo("/requires-authentication"); springSecurityFilterChain.doFilter(request, response, chain); assertThat(response.getRedirectedUrl()).endsWith("/custom"); }
@Test public void customConfiguerCustomizeFormLogin() throws Exception { loadContext(ConfigCustomize.class); request.setPathInfo("/requires-authentication"); springSecurityFilterChain.doFilter(request, response, chain); assertThat(response.getRedirectedUrl()).endsWith("/other"); }
@Test public void consoleModeShouldRedirectOnlyJDKLoggers() { gfsh = new Gfsh(true, null, new GfshConfig()); LogManager logManager = LogManager.getLogManager(); Enumeration<String> loggerNames = logManager.getLoggerNames(); // when initialized in console mode, all log messages will show up in console // initially. so that we see messages when "start locator", "start server" command // are executed. Only after connection, JDK's logging is turned off while (loggerNames.hasMoreElements()) { String loggerName = loggerNames.nextElement(); Logger logger = logManager.getLogger(loggerName); // make sure jdk's logging goes to the gfsh log file if (loggerName.startsWith("java")) { assertThat(logger.getParent().getName()).endsWith("LogWrapper"); } // make sure Gfsh's logging goes to the gfsh log file else if (loggerName.endsWith(".Gfsh")) { assertThat(logger.getParent().getName()).doesNotEndWith("LogWrapper"); } // make sure SimpleParser's logging will still show up in the console else if (loggerName.endsWith(".SimpleParser")) { assertThat(logger.getParent().getName()).doesNotEndWith("LogWrapper"); } } } }
@Test public void parallelFluxCheckpointDescriptionIsLight() { StringWriter sw = new StringWriter(); Flux<Integer> tested = Flux.range(1, 10) .parallel(2) .composeGroup(g -> g.map(i -> (Integer) null)) .checkpoint("light checkpoint identifier") .sequential() .doOnError(t -> t.printStackTrace(new PrintWriter(sw))); StepVerifier.create(tested) .verifyError(); String debugStack = sw.toString(); assertThat(debugStack).endsWith("Assembly site of producer [reactor.core.publisher.ParallelSource] is identified by light checkpoint [light checkpoint identifier].\n"); }
@Test public void debuggingActivatedWithDeepTraceback() { Hooks.onOperatorDebug(); try { StringWriter sw = new StringWriter(); FakeRepository.findAllUserByName(Flux.just("pedro", "simon", "stephane")) .transform(FakeUtils1.applyFilters) .transform(FakeUtils2.enrichUser) .subscribe(System.out::println, t -> t.printStackTrace(new PrintWriter(sw)) ); String debugStack = sw.toString(); assertThat(debugStack) .endsWith("Error has been observed by the following operator(s):\n" + "\t|_\tFlux.map ⇢ reactor.guide.FakeRepository.findAllUserByName(FakeRepository.java:27)\n" + "\t|_\tFlux.map ⇢ reactor.guide.FakeRepository.findAllUserByName(FakeRepository.java:28)\n" + "\t|_\tFlux.filter ⇢ reactor.guide.FakeUtils1.lambda$static$1(FakeUtils1.java:29)\n" + "\t|_\tFlux.transform ⇢ reactor.guide.GuideDebuggingExtraTests.debuggingActivatedWithDeepTraceback(GuideDebuggingExtraTests.java:40)\n" + "\t|_\tFlux.elapsed ⇢ reactor.guide.FakeUtils2.lambda$static$0(FakeUtils2.java:30)\n" + "\t|_\tFlux.transform ⇢ reactor.guide.GuideDebuggingExtraTests.debuggingActivatedWithDeepTraceback(GuideDebuggingExtraTests.java:41)\n\n"); } finally { Hooks.resetOnOperatorDebug(); } } }
@Test public void parallelFluxCheckpointDescriptionAndForceStack() { StringWriter sw = new StringWriter(); Flux<Integer> tested = Flux.range(1, 10) .parallel(2) .composeGroup(g -> g.map(i -> (Integer) null)) .checkpoint("descriptionCorrelation1234", true) .sequential() .doOnError(t -> t.printStackTrace(new PrintWriter(sw))); StepVerifier.create(tested) .verifyError(); String debugStack = sw.toString(); assertThat(debugStack).contains("Assembly trace from producer [reactor.core.publisher.ParallelSource], described as [descriptionCorrelation1234] :\n" + "\treactor.core.publisher.ParallelFlux.checkpoint(ParallelFlux.java:223)\n" + "\treactor.core.publisher.FluxOnAssemblyTest.parallelFluxCheckpointDescriptionAndForceStack(FluxOnAssemblyTest.java:225)\n"); assertThat(debugStack).endsWith("Error has been observed by the following operator(s):\n" + "\t|_\tParallelFlux.checkpoint ⇢ reactor.core.publisher.FluxOnAssemblyTest.parallelFluxCheckpointDescriptionAndForceStack(FluxOnAssemblyTest.java:225)\n\n"); }
.as("wip-requested padding") .hasSize(15) .allSatisfy(fl -> assertThat(fl.name()).startsWith("p").endsWith("a"));
@Test public void testToString() { OffHeapStoredObject chunk = createValueAsUnserializedStoredObject(getValue()); String expected = ":<dataSize=" + chunk.getDataSize() + " refCount=" + chunk.getRefCount() + " addr=" + Long.toHexString(chunk.getAddress()) + ">"; assertThat(chunk.toString()).endsWith(expected); chunk.release(); }
@Test public void scanName() { Scheduler fixedThreadPool = Schedulers.fromExecutorService(Executors.newFixedThreadPool(3)); Scheduler cachedThreadPool = Schedulers.fromExecutorService(Executors.newCachedThreadPool()); Scheduler singleThread = Schedulers.fromExecutorService(Executors.newSingleThreadExecutor()); try { assertThat(Scannable.from(fixedThreadPool).scan(Scannable.Attr.NAME)) .as("fixedThreadPool") .startsWith("fromExecutorService(java.util.concurrent.ThreadPoolExecutor@") .endsWith("[Running, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0])"); assertThat(Scannable.from(cachedThreadPool).scan(Scannable.Attr.NAME)) .as("cachedThreadPool") .startsWith("fromExecutorService(java.util.concurrent.ThreadPoolExecutor@") .endsWith("[Running, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0])"); assertThat(Scannable.from(singleThread).scan(Scannable.Attr.NAME)) .as("singleThread") .startsWith("fromExecutorService(java.util.concurrent.Executors$FinalizableDelegatedExecutorService@") .endsWith(")"); } finally { fixedThreadPool.dispose(); cachedThreadPool.dispose(); singleThread.dispose(); } }
@Test public void assertNext() throws Exception { Flux<String> flux = Flux.just("foo"); assertThatExceptionOfType(AssertionError.class) .isThrownBy(() -> StepVerifier.create(flux) .assertNext(s -> assertThat(s).endsWith("ooz")) .expectComplete() .verify()) .withMessage("\nExpecting:\n <\"foo\">\nto end with:\n <\"ooz\">\n"); }
@Test public void authenticationSuccess() { SecurityWebFilterChain securityWebFilter = this.http .authorizeExchange() .anyExchange().authenticated() .and() .formLogin() .authenticationSuccessHandler(new RedirectServerAuthenticationSuccessHandler("/custom")) .and() .build(); WebTestClient webTestClient = WebTestClientBuilder .bindToWebFilters(securityWebFilter) .build(); WebDriver driver = WebTestClientHtmlUnitDriverBuilder .webTestClientSetup(webTestClient) .build(); DefaultLoginPage loginPage = DefaultLoginPage.to(driver) .assertAt(); HomePage homePage = loginPage.loginForm() .username("user") .password("password") .submit(HomePage.class); assertThat(driver.getCurrentUrl()).endsWith("/custom"); }
@Test public void testKafkaStreamsCustomizer(@Autowired KafkaStreamsConfiguration configuration, @Autowired KafkaStreamsConfig config) { KafkaStreams.State state = this.streamsBuilderFactoryBean.getKafkaStreams().state(); assertThat(STATE_LISTENER.getCurrentState()).isEqualTo(state); Properties properties = configuration.asProperties(); assertThat(properties.getProperty(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG)).isEqualTo(config.brokerAddresses); assertThat(properties.getProperty(StreamsConfig.DEFAULT_DESERIALIZATION_EXCEPTION_HANDLER_CLASS_CONFIG)) .endsWith("Foo"); assertThat(properties.getProperty(StreamsConfig.CACHE_MAX_BYTES_BUFFERING_CONFIG)) .isEqualTo("1000"); }
@Test void parseFromTraceParentHeaderNotRecorded() { final TraceContext traceContext = TraceContext.with64BitId(mock(ElasticApmTracer.class)); final String header = "00-0af7651916cd43dd8448eb211c80319c-b9c7c989f97918e1-00"; assertThat(traceContext.asChildOf(header)).isTrue(); assertThat(traceContext.isSampled()).isFalse(); assertThat(traceContext.getOutgoingTraceParentHeader().toString()).endsWith("-00"); }
@Test public void shouldMakeNonUniqueOperationIdsUnique() { final Swagger swagger = new Swagger().path("/path", new Path().get(new Operation().operationId("foo")) .post(new Operation().operationId("foo")).put(new Operation().operationId("bar"))); final Connector generated = generator.configureConnector(SWAGGER_TEMPLATE, new Connector.Builder().id("connector1").build(), createSettingsFrom(swagger)); final List<ConnectorAction> actions = generated.getActions(); assertThat(actions).hasSize(3); assertThat(actions.get(0).getId()).hasValueSatisfying(id -> assertThat(id).endsWith("foo")); assertThat(actions.get(1).getId()).hasValueSatisfying(id -> assertThat(id).endsWith("foo1")); assertThat(actions.get(2).getId()).hasValueSatisfying(id -> assertThat(id).endsWith("bar")); }