private static void verifyExportLogsRegionWasDestroyed() { Cache cache = GemFireCacheImpl.getInstance(); assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNull(); }
@Override public void run2() { Cache cache = getCache(); Region<?, ?> pr = cache.getRegion(rName); assertThat(pr).describedAs("Region already destroyed.").isNotNull(); pr.destroyRegion(); assertThat(pr.isDestroyed()).describedAs("Region isDestroyed false").isTrue(); assertThat(cache.getRegion(rName)).describedAs("Region not destroyed.").isNull(); } });
@Test public void getCredentialsShouldReturnNullIfEmptyPeerAuthInit() throws Exception { this.props.setProperty(SECURITY_PEER_AUTH_INIT, ""); Properties credentials = this.authenticator.getCredentials(this.member, this.props); assertThat(credentials).isNull(); }
@Test public void getCredentialsShouldReturnNullIfEmptyPeerAuthInit() throws Exception { this.props.setProperty(SECURITY_PEER_AUTH_INIT, ""); Properties credentials = this.authenticator.getCredentials(this.member, this.props); assertThat(credentials).isNull(); }
@Test public void getCredentialsShouldReturnNullIfNoPeerAuthInit() throws Exception { Properties credentials = this.authenticator.getCredentials(this.member, this.props); assertThat(credentials).isNull(); }
@Test public void getCredentialsShouldReturnNullIfNoPeerAuthInit() throws Exception { Properties credentials = this.authenticator.getCredentials(this.member, this.props); assertThat(credentials).isNull(); }
@Test public void execute_and_log_statement() throws Exception { logTester.setLevel(LoggerLevel.TRACE); Connection connection = mock(Connection.class); when(originDataSource.getConnection()).thenReturn(connection); String sql = "select from dual"; Statement stmt = mock(Statement.class); when(connection.createStatement()).thenReturn(stmt); when(stmt.execute(sql)).thenReturn(true); ProfiledDataSource underTest = new ProfiledDataSource(originDataSource, ProfiledConnectionInterceptor.INSTANCE); assertThat(underTest.getUrl()).isNull(); assertThat(underTest.getConnection().getClientInfo()).isNull(); final Statement statementProxy = underTest.getConnection().createStatement(); assertThat(statementProxy.getConnection()).isNull(); assertThat(statementProxy.execute(sql)).isTrue(); assertThat(logTester.logs(LoggerLevel.TRACE)).hasSize(1); assertThat(logTester.logs(LoggerLevel.TRACE).get(0)) .contains("sql=select from dual"); }
@Test public void execute_and_log_prepared_statement_without_parameters() throws Exception { logTester.setLevel(LoggerLevel.TRACE); Connection connection = mock(Connection.class); when(originDataSource.getConnection()).thenReturn(connection); String sqlWithParams = "select from dual"; PreparedStatement preparedStatement = mock(PreparedStatement.class); when(connection.prepareStatement(sqlWithParams)).thenReturn(preparedStatement); when(preparedStatement.execute()).thenReturn(true); ProfiledDataSource ds = new ProfiledDataSource(originDataSource, ProfiledConnectionInterceptor.INSTANCE); assertThat(ds.getUrl()).isNull(); assertThat(ds.getConnection().getClientInfo()).isNull(); PreparedStatement preparedStatementProxy = ds.getConnection().prepareStatement(sqlWithParams); assertThat(preparedStatementProxy.getConnection()).isNull(); assertThat(preparedStatementProxy.execute()).isTrue(); assertThat(logTester.logs(LoggerLevel.TRACE)).hasSize(1); assertThat(logTester.logs(LoggerLevel.TRACE).get(0)) .contains("sql=select from dual") .doesNotContain("params="); }
@Test public void execute_and_log_prepared_statement_with_parameters() throws Exception { logTester.setLevel(LoggerLevel.TRACE); Connection connection = mock(Connection.class); when(originDataSource.getConnection()).thenReturn(connection); String sqlWithParams = "insert into polop (col1, col2, col3, col4) values (?, ?, ?, ?, ?)"; int param1 = 42; String param2 = "plouf"; Date param3 = new Date(System.currentTimeMillis()); Timestamp param4 = new Timestamp(System.currentTimeMillis()); byte[] param5 = "blob".getBytes(UTF_8); PreparedStatement preparedStatement = mock(PreparedStatement.class); when(connection.prepareStatement(sqlWithParams)).thenReturn(preparedStatement); when(preparedStatement.execute()).thenReturn(true); ProfiledDataSource ds = new ProfiledDataSource(originDataSource, ProfiledConnectionInterceptor.INSTANCE); assertThat(ds.getUrl()).isNull(); assertThat(ds.getConnection().getClientInfo()).isNull(); PreparedStatement preparedStatementProxy = ds.getConnection().prepareStatement(sqlWithParams); preparedStatementProxy.setInt(1, param1); preparedStatementProxy.setString(2, param2); preparedStatementProxy.setDate(3, param3); preparedStatementProxy.setTimestamp(4, param4); preparedStatementProxy.setBlob(5, new ByteArrayInputStream(param5)); assertThat(preparedStatementProxy.getConnection()).isNull(); assertThat(preparedStatementProxy.execute()).isTrue(); assertThat(logTester.logs(LoggerLevel.TRACE)).hasSize(1); assertThat(logTester.logs(LoggerLevel.TRACE).get(0)) .contains("sql=insert into polop (col1, col2, col3, col4) values (?, ?, ?, ?, ?)") .contains("params=42, plouf"); }
@Test public void testListEnvironmentsWithoutEnvironmentNamePrefix() throws Exception { when(environmentDDBRecords.stream()).thenReturn(Stream.of(environmentDDBRecord)); doReturn(environmentDDBRecords) .when(dynamoDBMapper) .query(eq(EnvironmentDDBRecord.class), any()); when(environmentMapper.toEnvironment(environmentDDBRecord)).thenReturn(environment); final List<Environment> result = environmentRepositoryDDB.listEnvironments(cluster, null); verify(dynamoDBMapper) .query(eq(EnvironmentDDBRecord.class), ddbQueryExpressionCaptor.capture()); verify(environmentMapper).toEnvironment(environmentDDBRecord); final EnvironmentDDBRecord queriedEnvironmentDDBRecord = ddbQueryExpressionCaptor.getValue().getHashKeyValues(); assertThat(ddbQueryExpressionCaptor.getValue().getRangeKeyConditions()).isNull(); assertThat(queriedEnvironmentDDBRecord.getAccountIdCluster()) .isEqualTo(cluster.generateAccountIdCluster()); assertThat(result.size()).isEqualTo(1); assertThat(result.get(0)).isEqualTo(environment); }
@Test public void exportLogsRegionIsCleanedUpProperly() throws IOException, ClassNotFoundException { locator.invoke(() -> { GemFireCacheImpl cache = GemFireCacheImpl.getInstance(); ExportLogsFunction.createOrGetExistingExportLogsRegion(true, cache); assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNotNull(); }); server1.invoke(() -> { GemFireCacheImpl cache = GemFireCacheImpl.getInstance(); ExportLogsFunction.createOrGetExistingExportLogsRegion(false, cache); assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNotNull(); }); locator.invoke(() -> { GemFireCacheImpl cache = GemFireCacheImpl.getInstance(); ExportLogsFunction.destroyExportLogsRegion(cache); assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNull(); }); server1.invoke(() -> { Cache cache = GemFireCacheImpl.getInstance(); assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNull(); }); }
@Test public void valuesNotSetTest() { DiskBackupStatusImpl status = new DiskBackupStatusImpl(); assertThat(status.getBackedUpDiskStores()).isNull(); assertThat(status.getOfflineDiskStores()).isNull(); }
private void verifyNoFacet(RuleQuery query, String facet) { SearchIdResult<Integer> result = underTest.search(query, new SearchOptions().addFacets(facet)); assertThat(result.getFacets().get(facet)).isNull(); }
@Test public void testHandlesNulls() { handle.execute("insert into campaigns(id, caps) values (?,?)", 4, null); Map<String, String> newCaps = handle.createQuery("select caps from campaigns where id=?") .bind(0, 4) .mapTo(STRING_MAP) .findOnly(); assertThat(newCaps).isNull(); }
@Test public void index_requires_project_authorization() { NewIndex index = new NewIndex("issues", defaultSettingsConfiguration); index.createType("issue") // creates a second type "authorization" and configures _parent and _routing fields .requireProjectAuthorization(); // issue type NewIndex.NewIndexType issueType = index.getTypes().get("issue"); assertThat(getAttributeAsMap(issueType, "_parent")).containsExactly(entry("type", "authorization")); assertThat(getAttributeAsMap(issueType, "_routing")).containsExactly(entry("required", true)); // authorization type NewIndex.NewIndexType authorizationType = index.getTypes().get("authorization"); assertThat(getAttributeAsMap(authorizationType, "_parent")).isNull(); assertThat(getAttributeAsMap(authorizationType, "_routing")).containsExactly(entry("required", true)); }
@Test public void facet_on_created_at_without_issues() { SearchOptions searchOptions = new SearchOptions().addFacets("createdAt"); SearchResponse result = underTest.search(IssueQuery.builder().build(), searchOptions); Map<String, Long> createdAt = new Facets(result, system2.getDefaultTimeZone()).get("createdAt"); assertThat(createdAt).isNull(); }
@Test public void testHandlesNulls() { handle.execute("insert into campaigns(id, caps) values (?,?)", 4, null); Map<String, String> newCaps = handle.createQuery("select caps from campaigns where id=?") .bind(0, 4) .mapTo(QualifiedType.of(STRING_MAP).with(HStore.class)) .findOnly(); assertThat(newCaps).isNull(); }
@Test public void getResponseHeaderFields_noResponse_null() { final Map<String, List<String>> nullFields = connection.getResponseHeaderFields(); assertThat(nullFields).isNull(); final String nullField = connection.getResponseHeaderField("no-exist-key"); assertThat(nullField).isNull(); }
@Test public void define_fields() { NewIndex index = new NewIndex("issues", defaultSettingsConfiguration); NewIndex.NewIndexType mapping = index.createType("issue"); mapping.setAttribute("dynamic", "true"); mapping.setProperty("foo_field", ImmutableMap.of("type", "keyword")); mapping.createBooleanField("boolean_field"); mapping.createByteField("byte_field"); mapping.createDateTimeField("dt_field"); mapping.createDoubleField("double_field"); mapping.createIntegerField("int_field"); mapping.createLongField("long_field"); mapping.createShortField("short_field"); mapping.createUuidPathField("uuid_path_field"); mapping = index.getTypes().get("issue"); assertThat(mapping).isNotNull(); assertThat(mapping.getAttributes().get("dynamic")).isEqualTo("true"); assertThat(mapping.getProperty("foo_field")).isInstanceOf(Map.class); assertThat((Map) mapping.getProperty("foo_field")).containsEntry("type", "keyword"); assertThat((Map) mapping.getProperty("byte_field")).isNotEmpty(); assertThat((Map) mapping.getProperty("double_field")).isNotEmpty(); assertThat((Map) mapping.getProperty("dt_field")).isNotEmpty(); assertThat((Map) mapping.getProperty("int_field")).containsEntry("type", "integer"); assertThat((Map) mapping.getProperty("long_field")).isNotEmpty(); assertThat((Map) mapping.getProperty("short_field")).isNotEmpty(); assertThat((Map) mapping.getProperty("uuid_path_field")).isNotEmpty(); assertThat((Map) mapping.getProperty("unknown")).isNull(); }
@Test public void configurationCanBeRetrievedButOnlyOnce() { ClientRequest request = ClientRequest.create(HttpMethod.GET, URI.create("/test")) .header(WebTestClient.WEBTESTCLIENT_REQUEST_ID, "1").build(); this.configurer.filter(request, mock(ExchangeFunction.class)); assertThat(WebTestClientRestDocumentationConfigurer .retrieveConfiguration(request.headers())).isNotNull(); assertThat(WebTestClientRestDocumentationConfigurer .retrieveConfiguration(request.headers())).isNull(); }