/** * {@inheritDoc} */ @Override public SELF containsOnlyElementsOf(Iterable<? extends ELEMENT> iterable) { return containsOnly(toArray(iterable)); }
/** * {@inheritDoc} */ @Override public SELF containsOnlyElementsOf(Iterable<? extends ELEMENT> iterable) { return containsOnly(toArray(iterable)); }
public MultiSelectListPreferenceAssert hasValues(String... values) { isNotNull(); Set<String> actualValues = actual.getValues(); assertThat(actualValues) // .overridingErrorMessage("Expected values <%s> but was <%s>.", values, actualValues) // .containsOnly(values); return this; } }
@Test public void execute_populate_tmp_last_key_columns_from_type_and_component_uuid_columns() throws SQLException { String type = randomAlphabetic(6); String oldComponentUuid = randomAlphabetic(7); String tmpComponentUuid = randomAlphabetic(8); String tmpMainComponentUuid = randomAlphabetic(9); String taskWithComponentUuid = insertCeActivity(type, oldComponentUuid, tmpComponentUuid, tmpMainComponentUuid); String taskWithInconsistentComponentUuid = insertCeActivity(type, null, tmpComponentUuid, tmpMainComponentUuid); String taskNoComponentUuid = insertCeActivity(type, null, null, null); underTest.execute(); assertThatTmpLastKeyAndMainLastKeyOf(taskWithComponentUuid).containsOnly(tuple(type + tmpComponentUuid, type + tmpMainComponentUuid)); assertThatTmpLastKeyAndMainLastKeyOf(taskWithInconsistentComponentUuid).containsOnly(tuple(type, type)); assertThatTmpLastKeyAndMainLastKeyOf(taskNoComponentUuid).containsOnly(tuple(type, type)); assertThatTmpIsLastAndMainIsLastOf(taskWithComponentUuid).containsOnly(tuple(false, false)); assertThatTmpIsLastAndMainIsLastOf(taskWithInconsistentComponentUuid).containsOnly(tuple(false, false)); assertThatTmpIsLastAndMainIsLastOf(taskNoComponentUuid).containsOnly(tuple(false, false)); } @Test
assertThat(content.getDispatchedEventHandlers()).containsOnly(focusedHandler); assertThat(content.getDispatchedEventHandlers()).containsOnly(unfocusedHandler); assertThat(content.getDispatchedEventHandlers()).containsOnly(focusedHandler); assertThat(content.getDispatchedEventHandlers()).containsOnly(unfocusedHandler);
@Test(groups = "unit") public void should_filter_init_hosts_with_predicate() { Predicate<Host> predicate = Predicates.in(Lists.newArrayList(host1, host2)); HostFilterPolicy policy = new HostFilterPolicy(wrappedPolicy, predicate); policy.init(cluster, Lists.newArrayList(host1, host2, host3)); verify(wrappedPolicy).init(eq(cluster), hostsCaptor.capture()); assertThat(hostsCaptor.getValue()).containsOnly(host1, host2); }
@Test(groups = "short") public void should_delete_set_element() throws Exception { // given session().execute("INSERT INTO test_coll (k, c) VALUES (1, {'foo','bar','qix'})"); // when BuiltStatement statement = delete().setElt("c", "foo").from("test_coll").where(eq("k", 1)); session().execute(statement); // then Set<String> actual = session().execute("SELECT c FROM test_coll WHERE k = 1").one().getSet("c", String.class); assertThat(actual).containsOnly("bar", "qix"); }
@Test(groups = "short", dataProvider = "serverSideErrors") public void should_try_next_host_on_server_side_error( Result error, Class<? extends DriverException> exception) { simulateError(1, error); simulateError(2, error); simulateError(3, error); try { query(); Fail.fail("expected a NoHostAvailableException"); } catch (NoHostAvailableException e) { assertThat(e.getErrors().keySet()) .hasSize(3) .containsOnly( host1.getSocketAddress(), host2.getSocketAddress(), host3.getSocketAddress()); assertThat(e.getErrors().values()).hasOnlyElementsOfType(exception); } assertOnRequestErrorWasCalled(3, exception); assertThat(errors.getOthers().getCount()).isEqualTo(3); assertThat(errors.getRetries().getCount()).isEqualTo(3); assertThat(errors.getRetriesOnOtherErrors().getCount()).isEqualTo(3); assertQueried(1, 1); assertQueried(2, 1); assertQueried(3, 1); }
@Test(groups = "short", dataProvider = "connectionErrors") public void should_try_next_host_on_connection_error(ClosedConnectionConfig.CloseType closeType) { simulateError(1, closed_connection, new ClosedConnectionConfig(closeType)); simulateError(2, closed_connection, new ClosedConnectionConfig(closeType)); simulateError(3, closed_connection, new ClosedConnectionConfig(closeType)); try { query(); Fail.fail("expected a NoHostAvailableException"); } catch (NoHostAvailableException e) { assertThat(e.getErrors().keySet()) .hasSize(3) .containsOnly( host1.getSocketAddress(), host2.getSocketAddress(), host3.getSocketAddress()); assertThat(e.getErrors().values()).hasOnlyElementsOfType(TransportException.class); } assertOnRequestErrorWasCalled(3, TransportException.class); assertThat(errors.getRetries().getCount()).isEqualTo(3); assertThat(errors.getConnectionErrors().getCount()).isEqualTo(3); assertThat(errors.getIgnoresOnConnectionError().getCount()).isEqualTo(0); assertThat(errors.getRetriesOnConnectionError().getCount()).isEqualTo(3); assertQueried(1, 1); assertQueried(2, 1); assertQueried(3, 1); }
@Test(groups = "short", dataProvider = "connectionErrors") public void should_retry_on_connection_error_if_statement_idempotent( ClosedConnectionConfig.CloseType closeType) { simulateError(1, closed_connection, new ClosedConnectionConfig(closeType)); simulateError(2, closed_connection, new ClosedConnectionConfig(closeType)); simulateError(3, closed_connection, new ClosedConnectionConfig(closeType)); try { session.execute(new SimpleStatement("mock query").setIdempotent(true)); Fail.fail("expected a TransportException"); } catch (NoHostAvailableException e) { assertThat(e.getErrors().keySet()) .hasSize(3) .containsOnly( host1.getSocketAddress(), host2.getSocketAddress(), host3.getSocketAddress()); assertThat(e.getErrors().values()).hasOnlyElementsOfType(TransportException.class); } assertOnRequestErrorWasCalled(3, TransportException.class); assertThat(errors.getRetries().getCount()).isEqualTo(3); assertThat(errors.getConnectionErrors().getCount()).isEqualTo(3); assertThat(errors.getIgnoresOnConnectionError().getCount()).isEqualTo(0); assertThat(errors.getRetriesOnConnectionError().getCount()).isEqualTo(3); assertQueried(1, 1); assertQueried(2, 1); assertQueried(3, 1); }
@SuppressWarnings("UnusedParameters") @Test(groups = "short", dataProvider = "serverSideErrors") public void should_retry_on_server_error_if_statement_idempotent( Result error, Class<? extends DriverException> exception) { simulateError(1, error); simulateError(2, error); simulateError(3, error); try { session.execute(new SimpleStatement("mock query").setIdempotent(true)); fail("expected a NoHostAvailableException"); } catch (NoHostAvailableException e) { assertThat(e.getErrors().keySet()) .hasSize(3) .containsOnly( host1.getSocketAddress(), host2.getSocketAddress(), host3.getSocketAddress()); assertThat(e.getErrors().values()).hasOnlyElementsOfType(exception); } assertOnRequestErrorWasCalled(3, exception); assertThat(errors.getOthers().getCount()).isEqualTo(3); assertThat(errors.getRetries().getCount()).isEqualTo(3); assertThat(errors.getRetriesOnOtherErrors().getCount()).isEqualTo(3); assertQueried(1, 1); assertQueried(2, 1); assertQueried(3, 1); }
/** * Ensures that when handling a connection error caused by the connection closing during a request * in a way described by {@link #connectionErrors} that the next host is tried. * * @param closeType The way the connection should be closed during the request. */ @Test(groups = "short", dataProvider = "connectionErrors") public void should_try_next_host_on_connection_error(ClosedConnectionConfig.CloseType closeType) { simulateError(1, closed_connection, new ClosedConnectionConfig(closeType)); simulateError(2, closed_connection, new ClosedConnectionConfig(closeType)); simulateError(3, closed_connection, new ClosedConnectionConfig(closeType)); try { query(); Fail.fail("expected a TransportException"); } catch (NoHostAvailableException e) { assertThat(e.getErrors().keySet()) .hasSize(3) .containsOnly( host1.getSocketAddress(), host2.getSocketAddress(), host3.getSocketAddress()); assertThat(e.getErrors().values()).hasOnlyElementsOfType(TransportException.class); } assertOnRequestErrorWasCalled(3, TransportException.class); assertThat(errors.getRetries().getCount()).isEqualTo(3); assertThat(errors.getConnectionErrors().getCount()).isEqualTo(3); assertThat(errors.getIgnoresOnConnectionError().getCount()).isEqualTo(0); assertThat(errors.getRetriesOnConnectionError().getCount()).isEqualTo(3); assertQueried(1, 1); assertQueried(2, 1); assertQueried(3, 1); }
assertThat(e.getErrors().keySet()) .hasSize(3) .containsOnly( host1.getSocketAddress(), host2.getSocketAddress(), host3.getSocketAddress()); assertThat(e.getErrors().values()).hasOnlyElementsOfType(exception);
@Test(groups = "short") public void should_delete_set_element_with_bind_marker() throws Exception { // given session().execute("INSERT INTO test_coll (k, c) VALUES (1, {'foo','bar','qix'})"); // when BuiltStatement statement = delete().setElt("c", bindMarker()).from("test_coll").where(eq("k", 1)); PreparedStatement ps = session().prepare(statement); session().execute(ps.bind("foo")); // then Set<String> actual = session().execute("SELECT c FROM test_coll WHERE k = 1").one().getSet("c", String.class); assertThat(actual).containsOnly("bar", "qix"); }
/** JAVA-684: Empty TokenRange returned in a one token cluster */ @Test(groups = "short") public void should_return_single_non_empty_range_when_cluster_has_one_single_token() { cluster().manager.controlConnection.refreshNodeListAndTokenMap(); Metadata metadata = cluster().getMetadata(); Set<TokenRange> tokenRanges = metadata.getTokenRanges(); assertThat(tokenRanges).hasSize(1); TokenRange tokenRange = tokenRanges.iterator().next(); assertThat(tokenRange) .startsWith(Token.M3PToken.FACTORY.minToken()) .endsWith(Token.M3PToken.FACTORY.minToken()) .isNotEmpty() .isNotWrappedAround(); Set<Host> hostsForRange = metadata.getReplicas(keyspace, tokenRange); Host host1 = TestUtils.findHost(cluster(), 1); assertThat(hostsForRange).containsOnly(host1); ByteBuffer randomPartitionKey = Bytes.fromHexString("0xCAFEBABE"); Set<Host> hostsForKey = metadata.getReplicas(keyspace, randomPartitionKey); assertThat(hostsForKey).containsOnly(host1); Set<TokenRange> rangesForHost = metadata.getTokenRanges(keyspace, host1); assertThat(rangesForHost).containsOnly(tokenRange); } }
assertThat(initHostsCaptor.getValue()).containsOnly(host1, host3);
assertThat(initHostsCaptor.getValue()).containsOnly(host1, host3);
assertThat(initHostsCaptor.getValue()).containsOnly(host1);
assertThat(e.getErrors().keySet()) .hasSize(3) .containsOnly( host1.getSocketAddress(), host2.getSocketAddress(), host3.getSocketAddress()); assertThat(e.getErrors().values())
queryCounts.add(queryTracker.queryCount(sCluster, 2, i)); assertThat(queryCounts).containsOnly(0, 0, 0, 25, 25); } finally { cluster.close();