Java Code Examples for java.util.Collections#checkedSet()
The following examples show how to use
java.util.Collections#checkedSet() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: camel-cookbook-examples File: SplitReaggregateSpringTest.java License: Apache License 2.0 | 6 votes |
private void assertBooksByCategory(Exchange exchange) { Message in = exchange.getIn(); @SuppressWarnings("unchecked") Set<String> books = Collections.checkedSet(in.getBody(Set.class), String.class); String category = in.getHeader("category", String.class); switch (category) { case "Tech": assertTrue(books.containsAll(Collections.singletonList("Apache Camel Developer's Cookbook"))); break; case "Cooking": assertTrue(books.containsAll(Arrays.asList("Camel Cookbook", "Double decadence with extra cream", "Cooking with Butter"))); break; default: fail(); break; } }
Example 2
Source Project: camel-cookbook-examples File: SplitReaggregateTest.java License: Apache License 2.0 | 6 votes |
private void assertBooksByCategory(Exchange exchange) { Message in = exchange.getIn(); @SuppressWarnings("unchecked") Set<String> books = Collections.checkedSet(in.getBody(Set.class), String.class); String category = in.getHeader("category", String.class); switch (category) { case "Tech": assertTrue(books.containsAll(Collections.singletonList("Apache Camel Developer's Cookbook"))); break; case "Cooking": assertTrue(books.containsAll(Arrays.asList("Camel Cookbook", "Double decadence with extra cream", "Cooking with Butter"))); break; default: fail(); break; } }
Example 3
Source Project: camel-cookbook-examples File: AggregateCompletionConditionTest.java License: Apache License 2.0 | 5 votes |
@Test public void testAggregation() throws InterruptedException { MockEndpoint mockOut = getMockEndpoint("mock:out"); mockOut.setExpectedMessageCount(2); template.sendBodyAndHeader("direct:in", "One", "group", "odd"); template.sendBodyAndHeader("direct:in", "Two", "group", "even"); template.sendBodyAndHeader("direct:in", "Three", "group", "odd"); template.sendBodyAndHeader("direct:in", "Four", "group", "even"); template.sendBodyAndHeader("direct:in", "Five", "group", "odd"); template.sendBodyAndHeader("direct:in", "Six", "group", "even"); template.sendBodyAndHeader("direct:in", "Seven", "group", "odd"); template.sendBodyAndHeader("direct:in", "Eight", "group", "even"); template.sendBodyAndHeader("direct:in", "Nine", "group", "odd"); template.sendBodyAndHeader("direct:in", "Ten", "group", "even"); assertMockEndpointsSatisfied(); List<Exchange> receivedExchanges = mockOut.getReceivedExchanges(); @SuppressWarnings("unchecked") Set<String> odd = Collections.checkedSet(receivedExchanges.get(0).getIn().getBody(Set.class), String.class); assertTrue(odd.containsAll(Arrays.asList("One", "Three", "Five", "Seven", "Nine"))); @SuppressWarnings("unchecked") Set<String> even = Collections.checkedSet(receivedExchanges.get(1).getIn().getBody(Set.class), String.class); assertTrue(even.containsAll(Arrays.asList("Two", "Four", "Six", "Eight", "Ten"))); }
Example 4
Source Project: camel-cookbook-examples File: SplitAggregateExceptionHandlingTest.java License: Apache License 2.0 | 5 votes |
@Test public void testHandlesException() throws Exception { String[] array = new String[]{"one", "two", "three"}; MockEndpoint mockOut = getMockEndpoint("mock:out"); mockOut.expectedMessageCount(1); template.sendBody("direct:in", array); assertMockEndpointsSatisfied(); Exchange exchange = mockOut.getReceivedExchanges().get(0); @SuppressWarnings("unchecked") Set<String> backendResponses = Collections.checkedSet(exchange.getIn().getBody(Set.class), String.class); assertTrue(backendResponses.containsAll(Arrays.asList("Processed: one", "Failed: two", "Processed: three"))); }
Example 5
Source Project: camel-cookbook-examples File: AggregateSimpleTest.java License: Apache License 2.0 | 5 votes |
@Test public void testAggregation() throws InterruptedException { MockEndpoint mockOut = getMockEndpoint("mock:out"); mockOut.setExpectedMessageCount(2); template.sendBodyAndHeader("direct:in", "One", "group", "odd"); template.sendBodyAndHeader("direct:in", "Two", "group", "even"); template.sendBodyAndHeader("direct:in", "Three", "group", "odd"); template.sendBodyAndHeader("direct:in", "Four", "group", "even"); template.sendBodyAndHeader("direct:in", "Five", "group", "odd"); template.sendBodyAndHeader("direct:in", "Six", "group", "even"); template.sendBodyAndHeader("direct:in", "Seven", "group", "odd"); template.sendBodyAndHeader("direct:in", "Eight", "group", "even"); template.sendBodyAndHeader("direct:in", "Nine", "group", "odd"); template.sendBodyAndHeader("direct:in", "Ten", "group", "even"); assertMockEndpointsSatisfied(); List<Exchange> receivedExchanges = mockOut.getReceivedExchanges(); @SuppressWarnings("unchecked") Set<String> odd = Collections.checkedSet(receivedExchanges.get(0).getIn().getBody(Set.class), String.class); assertTrue(odd.containsAll(Arrays.asList("One", "Three", "Five", "Seven", "Nine"))); @SuppressWarnings("unchecked") Set<String> even = Collections.checkedSet(receivedExchanges.get(1).getIn().getBody(Set.class), String.class); assertTrue(even.containsAll(Arrays.asList("Two", "Four", "Six", "Eight", "Ten"))); }
Example 6
Source Project: camel-cookbook-examples File: AggregateCompletionTimeoutSpringTest.java License: Apache License 2.0 | 5 votes |
@Test public void testAggregation() throws InterruptedException { MockEndpoint mockOut = getMockEndpoint("mock:out"); mockOut.setExpectedMessageCount(2); template.sendBodyAndHeader("direct:in", "One", "group", "odd"); template.sendBodyAndHeader("direct:in", "Two", "group", "even"); template.sendBodyAndHeader("direct:in", "Three", "group", "odd"); template.sendBodyAndHeader("direct:in", "Four", "group", "even"); template.sendBodyAndHeader("direct:in", "Five", "group", "odd"); template.sendBodyAndHeader("direct:in", "Six", "group", "even"); template.sendBodyAndHeader("direct:in", "Seven", "group", "odd"); template.sendBodyAndHeader("direct:in", "Eight", "group", "even"); template.sendBodyAndHeader("direct:in", "Nine", "group", "odd"); template.sendBodyAndHeader("direct:in", "Ten", "group", "even"); assertMockEndpointsSatisfied(); for (Exchange exchange : mockOut.getReceivedExchanges()) { @SuppressWarnings("unchecked") Set<String> set = Collections.checkedSet(exchange.getIn().getBody(Set.class), String.class); if (set.contains("One")) { // odd assertTrue(set.containsAll(Arrays.asList("One", "Three", "Five", "Seven", "Nine"))); } else { // even assertTrue(set.containsAll(Arrays.asList("Two", "Four", "Six", "Eight", "Ten"))); } } }
Example 7
Source Project: camel-cookbook-examples File: AggregateSimpleSpringTest.java License: Apache License 2.0 | 5 votes |
@Test public void testAggregation() throws InterruptedException { MockEndpoint mockOut = getMockEndpoint("mock:out"); mockOut.setExpectedMessageCount(2); template.sendBodyAndHeader("direct:in", "One", "group", "odd"); template.sendBodyAndHeader("direct:in", "Two", "group", "even"); template.sendBodyAndHeader("direct:in", "Three", "group", "odd"); template.sendBodyAndHeader("direct:in", "Four", "group", "even"); template.sendBodyAndHeader("direct:in", "Five", "group", "odd"); template.sendBodyAndHeader("direct:in", "Six", "group", "even"); template.sendBodyAndHeader("direct:in", "Seven", "group", "odd"); template.sendBodyAndHeader("direct:in", "Eight", "group", "even"); template.sendBodyAndHeader("direct:in", "Nine", "group", "odd"); template.sendBodyAndHeader("direct:in", "Ten", "group", "even"); assertMockEndpointsSatisfied(); List<Exchange> receivedExchanges = mockOut.getReceivedExchanges(); @SuppressWarnings("unchecked") Set<String> odd = Collections.checkedSet(receivedExchanges.get(0).getIn().getBody(Set.class), String.class); assertTrue(odd.containsAll(Arrays.asList("One", "Three", "Five", "Seven", "Nine"))); @SuppressWarnings("unchecked") Set<String> even = Collections.checkedSet(receivedExchanges.get(1).getIn().getBody(Set.class), String.class); assertTrue(even.containsAll(Arrays.asList("Two", "Four", "Six", "Eight", "Ten"))); }
Example 8
Source Project: camel-cookbook-examples File: AggregateCompletionConditionSpringTest.java License: Apache License 2.0 | 5 votes |
@Test public void testAggregation() throws InterruptedException { MockEndpoint mockOut = getMockEndpoint("mock:out"); mockOut.setExpectedMessageCount(2); template.sendBodyAndHeader("direct:in", "One", "group", "odd"); template.sendBodyAndHeader("direct:in", "Two", "group", "even"); template.sendBodyAndHeader("direct:in", "Three", "group", "odd"); template.sendBodyAndHeader("direct:in", "Four", "group", "even"); template.sendBodyAndHeader("direct:in", "Five", "group", "odd"); template.sendBodyAndHeader("direct:in", "Six", "group", "even"); template.sendBodyAndHeader("direct:in", "Seven", "group", "odd"); template.sendBodyAndHeader("direct:in", "Eight", "group", "even"); template.sendBodyAndHeader("direct:in", "Nine", "group", "odd"); template.sendBodyAndHeader("direct:in", "Ten", "group", "even"); assertMockEndpointsSatisfied(); List<Exchange> receivedExchanges = mockOut.getReceivedExchanges(); @SuppressWarnings("unchecked") Set<String> odd = Collections.checkedSet(receivedExchanges.get(0).getIn().getBody(Set.class), String.class); assertTrue(odd.containsAll(Arrays.asList("One", "Three", "Five", "Seven", "Nine"))); @SuppressWarnings("unchecked") Set<String> even = Collections.checkedSet(receivedExchanges.get(1).getIn().getBody(Set.class), String.class); assertTrue(even.containsAll(Arrays.asList("Two", "Four", "Six", "Eight", "Ten"))); }
Example 9
Source Project: dragonwell8_jdk File: java_util_Collections_CheckedSet.java License: GNU General Public License v2.0 | 4 votes |
protected Set<String> getObject() { Set<String> set = Collections.singleton("string"); return Collections.checkedSet(set, String.class); }
Example 10
Source Project: jdk8u-dev-jdk File: java_util_Collections_CheckedSet.java License: GNU General Public License v2.0 | 4 votes |
protected Set<String> getObject() { Set<String> set = Collections.singleton("string"); return Collections.checkedSet(set, String.class); }
Example 11
Source Project: TencentKona-8 File: java_util_Collections_CheckedSet.java License: GNU General Public License v2.0 | 4 votes |
protected Set<String> getAnotherObject() { Set<String> set = Collections.emptySet(); return Collections.checkedSet(set, String.class); }
Example 12
Source Project: protostuff File: AbstractRuntimeObjectSchemaTest.java License: Apache License 2.0 | 4 votes |
PojoWithObjectCollectionFields fill() { LinkedList<String> ll = new LinkedList<String>(); ll.add("zero"); HashMap<String, Boolean> empty = newMap(); TreeSet<String> ts = new TreeSet<String>(); ts.add("two"); EnumSet<Size> es = EnumSet.allOf(Size.class); emptySet = Collections.emptySet(); emptyList = Collections.emptyList(); singletonSet = Collections.singleton("three"); singletonList = Collections.singletonList("four"); setFromMap = Collections.newSetFromMap(empty); copiesList = Collections.nCopies(1, "five"); unmodifiableCollection = Collections .unmodifiableCollection(Collections.emptyList()); // no // equals // impl unmodifiableSet = Collections.unmodifiableSet(Collections .emptySet()); unmodifiableSortedSet = Collections.unmodifiableSortedSet(ts); unmodifiableList = Collections.unmodifiableList(ll); unmodifiableRandomAccessList = Collections .unmodifiableList(newList("six")); assertTrue(unmodifiableRandomAccessList.getClass().getName() .endsWith("RandomAccessList")); synchronizedCollection = Collections .synchronizedCollection(Collections.emptyList()); // no // equals // impl synchronizedSet = Collections.synchronizedSet(es); synchronizedSortedSet = Collections.synchronizedSortedSet(ts); synchronizedList = Collections.synchronizedList(ll); synchronizedRandomAccessList = Collections .synchronizedList(newList("seven")); assertTrue(synchronizedRandomAccessList.getClass().getName() .endsWith("RandomAccessList")); checkedCollection = Collections.checkedCollection(newList("eight"), String.class); // no equals impl checkedSet = Collections.checkedSet(es, Size.class); checkedSortedSet = Collections.checkedSortedSet(ts, String.class); checkedList = Collections.checkedList(ll, String.class); checkedRandomAccessList = Collections.checkedList(newList("nine"), String.class); assertTrue(checkedRandomAccessList.getClass().getName() .endsWith("RandomAccessList")); return this; }
Example 13
Source Project: jdk8u-jdk File: java_util_Collections_CheckedSet.java License: GNU General Public License v2.0 | 4 votes |
protected Set<String> getAnotherObject() { Set<String> set = Collections.emptySet(); return Collections.checkedSet(set, String.class); }
Example 14
Source Project: camel-cookbook-examples File: AggregateExecutorServiceSpringTest.java License: Apache License 2.0 | 4 votes |
@Test public void testAggregation() throws InterruptedException { MockEndpoint mockOut = getMockEndpoint("mock:out"); mockOut.setExpectedMessageCount(2); template.sendBodyAndHeader("direct:in", "One", "group", "odd"); template.sendBodyAndHeader("direct:in", "Two", "group", "even"); template.sendBodyAndHeader("direct:in", "Three", "group", "odd"); template.sendBodyAndHeader("direct:in", "Four", "group", "even"); template.sendBodyAndHeader("direct:in", "Five", "group", "odd"); template.sendBodyAndHeader("direct:in", "Six", "group", "even"); template.sendBodyAndHeader("direct:in", "Seven", "group", "odd"); template.sendBodyAndHeader("direct:in", "Eight", "group", "even"); template.sendBodyAndHeader("direct:in", "Nine", "group", "odd"); template.sendBodyAndHeader("direct:in", "Ten", "group", "even"); assertMockEndpointsSatisfied(); final List<Exchange> receivedExchanges = mockOut.getReceivedExchanges(); final Message message1 = receivedExchanges.get(0).getIn(); final Message message2 = receivedExchanges.get(1).getIn(); log.info("exchange(0).header.group = {}", message1.getHeader("group")); log.info("exchange(0).property.CamelAggregatedCompletedBy = {}", message1.getExchange().getProperty("CamelAggregatedCompletedBy")); log.info("exchange(1).header.group = {}", message2.getHeader("group")); log.info("exchange(1).property.CamelAggregatedCompletedBy = {}", message2.getExchange().getProperty("CamelAggregatedCompletedBy")); final List<String> odd = Arrays.asList("One", "Three", "Five", "Seven", "Nine"); final List<String> even = Arrays.asList("Two", "Four", "Six", "Eight", "Ten"); @SuppressWarnings("unchecked") final Set<String> set1 = Collections.checkedSet(message1.getBody(Set.class), String.class); @SuppressWarnings("unchecked") final Set<String> set2 = Collections.checkedSet(message2.getBody(Set.class), String.class); if ("odd".equals(message1.getHeader("group"))) { assertTrue(set1.containsAll(odd)); assertTrue(set2.containsAll(even)); } else { assertTrue(set1.containsAll(even)); assertTrue(set2.containsAll(odd)); } }
Example 15
Source Project: camel-cookbook-examples File: AggregateParallelProcessingTest.java License: Apache License 2.0 | 4 votes |
@Test public void testAggregation() throws InterruptedException { MockEndpoint mockOut = getMockEndpoint("mock:out"); mockOut.setExpectedMessageCount(2); template.sendBodyAndHeader("direct:in", "One", "group", "odd"); template.sendBodyAndHeader("direct:in", "Two", "group", "even"); template.sendBodyAndHeader("direct:in", "Three", "group", "odd"); template.sendBodyAndHeader("direct:in", "Four", "group", "even"); template.sendBodyAndHeader("direct:in", "Five", "group", "odd"); template.sendBodyAndHeader("direct:in", "Six", "group", "even"); template.sendBodyAndHeader("direct:in", "Seven", "group", "odd"); template.sendBodyAndHeader("direct:in", "Eight", "group", "even"); template.sendBodyAndHeader("direct:in", "Nine", "group", "odd"); template.sendBodyAndHeader("direct:in", "Ten", "group", "even"); assertMockEndpointsSatisfied(); final List<Exchange> receivedExchanges = mockOut.getReceivedExchanges(); final Message message1 = receivedExchanges.get(0).getIn(); final Message message2 = receivedExchanges.get(1).getIn(); log.info("exchange(0).header.group = {}", message1.getHeader("group")); log.info("exchange(0).property.CamelAggregatedCompletedBy = {}", message1.getExchange().getProperty("CamelAggregatedCompletedBy")); log.info("exchange(1).header.group = {}", message2.getHeader("group")); log.info("exchange(1).property.CamelAggregatedCompletedBy = {}", message2.getExchange().getProperty("CamelAggregatedCompletedBy")); final List<String> odd = Arrays.asList("One", "Three", "Five", "Seven", "Nine"); final List<String> even = Arrays.asList("Two", "Four", "Six", "Eight", "Ten"); @SuppressWarnings("unchecked") final Set<String> set1 = Collections.checkedSet(message1.getBody(Set.class), String.class); @SuppressWarnings("unchecked") final Set<String> set2 = Collections.checkedSet(message2.getBody(Set.class), String.class); if ("odd".equals(message1.getHeader("group"))) { assertTrue(set1.containsAll(odd)); assertTrue(set2.containsAll(even)); } else { assertTrue(set1.containsAll(even)); assertTrue(set2.containsAll(odd)); } }
Example 16
Source Project: openjdk-8-source File: java_util_Collections_CheckedSet.java License: GNU General Public License v2.0 | 4 votes |
protected Set<String> getObject() { Set<String> set = Collections.singleton("string"); return Collections.checkedSet(set, String.class); }
Example 17
Source Project: jdk8u-jdk File: java_util_Collections_CheckedSet.java License: GNU General Public License v2.0 | 4 votes |
protected Set<String> getObject() { Set<String> set = Collections.singleton("string"); return Collections.checkedSet(set, String.class); }
Example 18
Source Project: jdk8u-jdk File: java_util_Collections_CheckedSet.java License: GNU General Public License v2.0 | 4 votes |
protected Set<String> getAnotherObject() { Set<String> set = Collections.emptySet(); return Collections.checkedSet(set, String.class); }
Example 19
Source Project: jdk8u-dev-jdk File: java_util_Collections_CheckedSet.java License: GNU General Public License v2.0 | 4 votes |
protected Set<String> getAnotherObject() { Set<String> set = Collections.emptySet(); return Collections.checkedSet(set, String.class); }
Example 20
Source Project: jdk8u_jdk File: java_util_Collections_CheckedSet.java License: GNU General Public License v2.0 | 4 votes |
protected Set<String> getAnotherObject() { Set<String> set = Collections.emptySet(); return Collections.checkedSet(set, String.class); }