public void assertColumnDoesNotExist(String table, String column) throws SQLException { try (Connection connection = getConnection(); PreparedStatement stmt = connection.prepareStatement("select * from " + table); ResultSet res = stmt.executeQuery()) { assertThat(getColumnNames(res)).doesNotContain(column); } }
@Test public void hashLookupOnlyDependsOnUsername() throws Exception { User user1 = new User("rod", "koala", true, true, true, true, ROLE_12); Set<UserDetails> users = new HashSet<>(); users.add(user1); assertThat(users).contains(new User("rod", "koala", true, true, true, true, ROLE_12)); assertThat(users).contains(new User("rod", "anotherpass", false, false, false, false, AuthorityUtils.createAuthorityList("ROLE_X"))); assertThat(users).doesNotContain(new User("bod", "koala", true, true, true, true, ROLE_12)); }
@Test public void testRollback() throws SQLException { try (Connection connection = createConnection()) { connection.setAutoCommit(false); try (Statement statement = connection.createStatement()) { statement.execute("CREATE TABLE test_rollback (x bigint)"); } try (Connection otherConnection = createConnection()) { assertThat(listTables(otherConnection)).doesNotContain("test_rollback"); } connection.rollback(); } try (Connection connection = createConnection()) { assertThat(listTables(connection)).doesNotContain("test_rollback"); } }
@Test public void testCommit() throws SQLException { try (Connection connection = createConnection()) { connection.setAutoCommit(false); try (Statement statement = connection.createStatement()) { statement.execute("CREATE TABLE test_commit (x bigint)"); } try (Connection otherConnection = createConnection()) { assertThat(listTables(otherConnection)).doesNotContain("test_commit"); } connection.commit(); } try (Connection connection = createConnection()) { assertThat(listTables(connection)).contains("test_commit"); } }
@Test public void delete_existing_index() { underTest.deleteIndexes("a"); assertThat(loadExistingIndices()) .doesNotContain("a") .contains("b", "c"); assertThat(logTester.logs(LoggerLevel.INFO)) .contains("Drop Elasticsearch index [a]"); }
@Test public void ignore_indices_that_do_not_exist() { underTest.deleteIndexes("a", "xxx", "c"); assertThat(loadExistingIndices()) .doesNotContain("a", "c") .contains("b"); assertThat(logTester.logs(LoggerLevel.INFO)) .contains("Drop Elasticsearch index [a]", "Drop Elasticsearch index [c]") .doesNotContain("Drop Elasticsearch index [xxx]"); }
@Test public void testMatchSlashSingle() { Subscription slashPlusSub = clientSubOnTopic("AnySensor", "/+"); sut.add(slashPlusSub); Subscription anySub = clientSubOnTopic("AnySensor", "+"); sut.add(anySub); // Verify assertThat(sut.matchWithoutQosSharpening(asTopic("/finance"))).containsOnly(slashPlusSub); assertThat(sut.matchWithoutQosSharpening(asTopic("/finance"))).doesNotContain(anySub); }
@Test public void testStartMonitoringNotActive() throws Exception { when(corePlugin.isStagemonitorActive()).thenReturn(false); final MeasurementSession measurementSession = new MeasurementSession("StagemonitorTest", "testHost", "testInstance"); Stagemonitor.reset(measurementSession); assertTrue(Stagemonitor.isDisabled()); assertFalse(Stagemonitor.isStarted()); assertTrue(Stagemonitor.getMeasurementSession().isInitialized()); assertThat(healthCheckRegistry.getNames()).doesNotContain("TestPlugin", "TestExceptionPlugin"); }
@Test public void select_organization_uuids_by_user_id() { OrganizationDto organizationDto1 = db.organizations().insert(); OrganizationDto organizationDto2 = db.organizations().insert(); OrganizationDto organizationDto3 = db.organizations().insert(); underTest.insert(dbSession, create(organizationDto1.getUuid(), 512)); underTest.insert(dbSession, create(organizationDto2.getUuid(), 512)); assertThat(underTest.selectOrganizationUuidsByUser(dbSession, 512)).containsOnly(organizationDto1.getUuid(), organizationDto2.getUuid()) .doesNotContain(organizationDto3.getUuid()); assertThat(underTest.selectOrganizationUuidsByUser(dbSession, 123)).isEmpty(); }
@Test public void testRemovalInnerTopicOffRootDiffClient() { sut.addToTree(clientSubOnTopic("TempSensor1", "temp")); sut.addToTree(clientSubOnTopic("TempSensor2", "temp/1")); //Exercise final Set<Subscription> matchingSubs1 = sut.recursiveMatch(asTopic("temp")); final Set<Subscription> matchingSubs2 = sut.recursiveMatch(asTopic("temp/1")); //Verify final Subscription expectedMatchingsub1 = new Subscription("TempSensor1", asTopic("temp"), MqttQoS.AT_MOST_ONCE); final Subscription expectedMatchingsub2 = new Subscription("TempSensor2", asTopic("temp/1"), MqttQoS.AT_MOST_ONCE); assertThat(matchingSubs1).contains(expectedMatchingsub1); assertThat(matchingSubs2).contains(expectedMatchingsub2); sut.removeFromTree(asTopic("temp"), "TempSensor1"); //Exercise final Set<Subscription> matchingSubs3 = sut.recursiveMatch(asTopic("temp")); final Set<Subscription> matchingSubs4 = sut.recursiveMatch(asTopic("temp/1")); assertThat(matchingSubs3).doesNotContain(expectedMatchingsub1); assertThat(matchingSubs4).contains(expectedMatchingsub2); }
@Test public void testRemovalInnerTopicOffRootSameClient() { sut.addToTree(clientSubOnTopic("TempSensor1", "temp")); sut.addToTree(clientSubOnTopic("TempSensor1", "temp/1")); //Exercise final Set<Subscription> matchingSubs1 = sut.recursiveMatch(asTopic("temp")); final Set<Subscription> matchingSubs2 = sut.recursiveMatch(asTopic("temp/1")); //Verify final Subscription expectedMatchingsub1 = new Subscription("TempSensor1", asTopic("temp"), MqttQoS.AT_MOST_ONCE); final Subscription expectedMatchingsub2 = new Subscription("TempSensor1", asTopic("temp/1"), MqttQoS.AT_MOST_ONCE); assertThat(matchingSubs1).contains(expectedMatchingsub1); assertThat(matchingSubs2).contains(expectedMatchingsub2); sut.removeFromTree(asTopic("temp"), "TempSensor1"); //Exercise final Set<Subscription> matchingSubs3 = sut.recursiveMatch(asTopic("temp")); final Set<Subscription> matchingSubs4 = sut.recursiveMatch(asTopic("temp/1")); assertThat(matchingSubs3).doesNotContain(expectedMatchingsub1); assertThat(matchingSubs4).contains(expectedMatchingsub2); }
@Test public void testRemovalOuterTopicOffRootDiffClient() { sut.addToTree(clientSubOnTopic("TempSensor1", "temp")); sut.addToTree(clientSubOnTopic("TempSensor2", "temp/1")); //Exercise final Set<Subscription> matchingSubs1 = sut.recursiveMatch(asTopic("temp")); final Set<Subscription> matchingSubs2 = sut.recursiveMatch(asTopic("temp/1")); //Verify final Subscription expectedMatchingsub1 = new Subscription("TempSensor1", asTopic("temp"), MqttQoS.AT_MOST_ONCE); final Subscription expectedMatchingsub2 = new Subscription("TempSensor2", asTopic("temp/1"), MqttQoS.AT_MOST_ONCE); assertThat(matchingSubs1).contains(expectedMatchingsub1); assertThat(matchingSubs2).contains(expectedMatchingsub2); sut.removeFromTree(asTopic("temp/1"), "TempSensor2"); //Exercise final Set<Subscription> matchingSubs3 = sut.recursiveMatch(asTopic("temp")); final Set<Subscription> matchingSubs4 = sut.recursiveMatch(asTopic("temp/1")); assertThat(matchingSubs3).contains(expectedMatchingsub1); assertThat(matchingSubs4).doesNotContain(expectedMatchingsub2); } }
private void assertDoesNotHitLine(final int classId, final int... i) { final Collection<Long> actual = CodeCoverageStore.getHits(); for (final int probe : i) { assertThat(actual).doesNotContain( CodeCoverageStore.encode(classId, probe)); } }
@Test public void getMetadataForTablesReturnsWithCorrectCapitalization() { kvs.createTable(UPPER_UPPER, AtlasDbConstants.GENERIC_TABLE_METADATA); assertThat(kvs.getMetadataForTables().keySet()) .contains(UPPER_UPPER) .doesNotContain(LOWER_LOWER); }
@Test public void tablesDelegatedToSourceKvsGetDroppedFromSourceKvsIfMigratable() { fromKvs.createTable(FAKE_ATOMIC_TABLE, AtlasDbConstants.GENERIC_TABLE_METADATA); fromKvs.putUnlessExists(FAKE_ATOMIC_TABLE, ImmutableMap.of(TEST_CELL, TEST_VALUE1)); KeyValueService toTableSplittingKvs = TableSplittingKeyValueService.create( ImmutableList.of(new InMemoryKeyValueService(false), fromKvs), ImmutableMap.of(FAKE_ATOMIC_TABLE, fromKvs)); AtlasDbServices toSplittingServices = createMock(toTableSplittingKvs); ImmutableMigratorSpec spec = ImmutableMigratorSpec.builder() .fromServices(fromServices) .toServices(toSplittingServices) .build(); assertThat(toSplittingServices.getKeyValueService() .get(FAKE_ATOMIC_TABLE, ImmutableMap.of(TEST_CELL, 1L)).get(TEST_CELL).getContents()) .containsExactly(TEST_VALUE1); KeyValueServiceMigrator migrator = KeyValueServiceMigrators.setupMigrator(spec); migrator.setup(); assertThat(fromKvs.getAllTableNames()).doesNotContain(FAKE_ATOMIC_TABLE); }
@Test public void rpcHttpHostWhitelistAcceptsMultipleFlags() { parseCommand("--host-whitelist=a", "--host-whitelist=b"); verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture()); verify(mockRunnerBuilder).build(); assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsWhitelist().size()).isEqualTo(2); assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsWhitelist()).contains("a", "b"); assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsWhitelist()) .doesNotContain("*", "localhost"); assertThat(commandOutput.toString()).isEmpty(); assertThat(commandErrorOutput.toString()).isEmpty(); }
@Test public void rpcHttpHostWhitelistAcceptsDoubleComma() { parseCommand("--host-whitelist", "a,,b"); verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture()); verify(mockRunnerBuilder).build(); assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsWhitelist().size()).isEqualTo(2); assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsWhitelist()).contains("a", "b"); assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsWhitelist()) .doesNotContain("*", "localhost"); assertThat(commandOutput.toString()).isEmpty(); assertThat(commandErrorOutput.toString()).isEmpty(); }
@Test public void toOutputPropertiesShouldReturnTextBodyWhenBodyRequested() { MessageProperties actual = new MessageProperties(Optional.of(ImmutableSet.of("body"))).toOutputProperties(); assertThat(actual.getOptionalMessageProperties()) .hasValueSatisfying(value -> assertThat(value).contains(MessageProperty.textBody).doesNotContain(MessageProperty.body)); }
@Test public void shouldNotAddSelfWhenReceivedPingFromSelf() { startPeerDiscoveryController(); final DiscoveryPeer localPeer = new DiscoveryPeer(this.localPeer.getId(), this.localPeer.getEndpoint()); final Packet pingPacket = mockPingPacket(this.localPeer, this.localPeer); controller.onMessage(pingPacket, localPeer); assertThat(controller.getPeers()).doesNotContain(localPeer); }
@Test public void testNullServletContextInitializer() { JsfClassFactoryConfiguration configuration = JsfClassFactoryConfiguration.builder() .excludeScopedAnnotations(true) .handlesTypes(null) .anotherConfig(null) .build(); Set<Class<?>> classes = new JsfClassFactory(configuration).getAllClasses(); assertThat(classes).doesNotContain(HtmlGridRenderer.class); }