@Test
    public void testCloseOperationOnTwoSeqs() {
        Consumer<BiFunction<Seq<Integer>, Seq<Integer>, Seq<?>>> test = f -> {
            AtomicBoolean closed1 = new AtomicBoolean();
            AtomicBoolean closed2 = new AtomicBoolean();
            
            Seq<Integer> s1 = seq(Stream.of(1, 2).onClose(() -> closed1.set(true)));
            Seq<Integer> s2 = seq(Stream.of(3).onClose(() -> closed2.set(true)));
            
            try (Seq<?> s3 = f.apply(s1, s2)) {
                s3.limit(1000).collect(Collectors.toList());
            }

            assertTrue(closed1.get());
            assertTrue(closed2.get());
        };
        
        test.accept((s1, s2) -> s1.concat(s2));
        test.accept((s1, s2) -> s1.append(s2));
        test.accept((s1, s2) -> s1.prepend(s2));
        test.accept((s1, s2) -> s1.removeAll(s2));
        test.accept((s1, s2) -> s1.retainAll(s2));
        test.accept((s1, s2) -> s1.crossJoin(s2));
        test.accept((s1, s2) -> s1.innerJoin(s2, (a, b) -> true));
        test.accept((s1, s2) -> s1.leftOuterJoin(s2, (a, b) -> true));
        test.accept((s1, s2) -> s1.rightOuterJoin(s2, (a, b) -> true));
        test.accept((s1, s2) -> s1.zip(s2));
        test.accept((s1, s2) -> Seq.zipAll(s1, s2, 1, 2));
        test.accept((s1, s2) -> Seq.zipAll(s1, s2, 1, 2, (a, b) -> a + b));
    }
@author Lukas Eder
@author Roman Tkalenko
jOOL-java-8/src/test/java/org/jooq/lambda/SeqTest.java