Repository: incubator-reef Updated Branches: refs/heads/master 9cab34166 -> 3325748dc
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/3325748d/lang/java/reef-io/src/test/java/org/apache/reef/services/storage/ExternalMapTest.java ---------------------------------------------------------------------- diff --git a/lang/java/reef-io/src/test/java/org/apache/reef/services/storage/ExternalMapTest.java b/lang/java/reef-io/src/test/java/org/apache/reef/services/storage/ExternalMapTest.java deleted file mode 100644 index 38655c0..0000000 --- a/lang/java/reef-io/src/test/java/org/apache/reef/services/storage/ExternalMapTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.reef.services.storage; - -import org.apache.reef.io.ExternalMap; -import org.apache.reef.io.serialization.Codec; -import org.apache.reef.io.storage.ram.CodecRamMap; -import org.apache.reef.io.storage.ram.RamMap; -import org.apache.reef.io.storage.ram.RamStorageService; -import org.apache.reef.io.storage.util.IntegerCodec; -import org.junit.Assert; -import org.junit.Test; - -import java.util.*; - - -public class ExternalMapTest { - @Test - public void testCodecRamMap() { - final RamStorageService ramStore = new RamStorageService(); - final Codec<Integer> c = new IntegerCodec(); - final ExternalMap<Integer> m = new CodecRamMap<>(ramStore, c); - genericTest(m); - } - - @Test - public void testRamMap() { - final RamStorageService ramStore = new RamStorageService(); - final ExternalMap<Integer> m = new RamMap<>(ramStore); - genericTest(m); - } - - - void genericTest(final ExternalMap<Integer> m) { - m.put("foo", 42); - final Map<String, Integer> smallMap = new HashMap<>(); - smallMap.put("bar", 43); - smallMap.put("baz", 44); - - m.putAll(smallMap); - - Assert.assertEquals(44, (int) m.get("baz")); - Assert.assertEquals(43, (int) m.get("bar")); - Assert.assertEquals(42, (int) m.get("foo")); - Assert.assertNull(m.get("quuz")); - - Assert.assertTrue(m.containsKey("bar")); - Assert.assertFalse(m.containsKey("quuz")); - - final Set<String> barBaz = new HashSet<>(); - barBaz.add("bar"); - barBaz.add("baz"); - barBaz.add("quuz"); - - final Iterable<Map.Entry<CharSequence, Integer>> it = m.getAll(barBaz); - - final Map<CharSequence, Integer> found = new TreeMap<>(); - - for (final Map.Entry<CharSequence, Integer> e : it) { - found.put(e.getKey(), e.getValue()); - } - final Iterator<CharSequence> it2 = found.keySet().iterator(); - Assert.assertTrue(it2.hasNext()); - CharSequence s = it2.next(); - Assert.assertEquals(s, "bar"); - Assert.assertEquals((int) found.get(s), 43); - Assert.assertTrue(it2.hasNext()); - s = it2.next(); - Assert.assertEquals(s, "baz"); - Assert.assertEquals((int) found.get(s), 44); - Assert.assertFalse(it2.hasNext()); - - Assert.assertEquals(44, (int) m.remove("baz")); - Assert.assertFalse(m.containsKey("baz")); - - } - -} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/3325748d/lang/java/reef-io/src/test/java/org/apache/reef/services/storage/FramingTest.java ---------------------------------------------------------------------- diff --git a/lang/java/reef-io/src/test/java/org/apache/reef/services/storage/FramingTest.java b/lang/java/reef-io/src/test/java/org/apache/reef/services/storage/FramingTest.java deleted file mode 100644 index e8722de..0000000 --- a/lang/java/reef-io/src/test/java/org/apache/reef/services/storage/FramingTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.reef.services.storage; - -import org.apache.reef.exception.evaluator.ServiceException; -import org.apache.reef.io.Accumulator; -import org.apache.reef.io.storage.FramingInputStream; -import org.apache.reef.io.storage.FramingOutputStream; -import org.junit.Assert; -import org.junit.Test; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.Arrays; - -public class FramingTest { - - @Test - public void frameRoundTripTest() throws IOException, ServiceException { - final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - final ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); - final FramingOutputStream o = new FramingOutputStream(baos); - final FramingOutputStream o2 = new FramingOutputStream(baos2); - final Accumulator<byte[]> a = o2.accumulator(); - int offset = 0; - for (int i = 0; i < 256; i++) { - final byte[] b = new byte[i]; - Arrays.fill(b, (byte) i); - o.write(b); - if (i == 255) { - o.close(); - } else { - o.nextFrame(); - } - offset += (4 + i); - Assert.assertEquals(offset, o.getCurrentOffset()); - a.add(b); - Assert.assertEquals(offset, o2.getCurrentOffset()); - } - a.close(); - o2.close(); - final byte[] b1 = baos.toByteArray(); - final byte[] b2 = baos2.toByteArray(); - Assert.assertArrayEquals(b1, b2); - final FramingInputStream inA1 = new FramingInputStream(new ByteArrayInputStream(b1)); - final FramingInputStream inA2 = new FramingInputStream(new ByteArrayInputStream(b2)); - for (int i = 0; i <= 256; i++) { - final byte[] b = new byte[i]; - Arrays.fill(b, (byte) i); - final byte[] f = inA1.readFrame(); - final byte[] g = inA2.readFrame(); - if (i == 256) { - Assert.assertNull(f); - Assert.assertNull(g); - } else { - Assert.assertArrayEquals(b, f); - Assert.assertArrayEquals(b, g); - } - } - inA2.close(); - inA1.close(); - - final FramingInputStream inB1 = new FramingInputStream(new ByteArrayInputStream(b1)); - int i = 0; - for (final byte[] bin : inB1) { - final byte[] b = new byte[i]; - Arrays.fill(b, (byte) i); - Assert.assertArrayEquals(b, bin); - i++; - } - Assert.assertEquals(256, i); - inB1.close(); - - final FramingInputStream inB2 = new FramingInputStream(new ByteArrayInputStream(b2)); - i = 0; - for (final byte[] bin : inB2) { - final byte[] b = new byte[i]; - Arrays.fill(b, (byte) i); - Assert.assertArrayEquals(b, bin); - i++; - } - Assert.assertEquals(256, i); - inB2.close(); - Assert.assertArrayEquals(b1, b2); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/3325748d/lang/java/reef-io/src/test/java/org/apache/reef/services/storage/MergingIteratorTest.java ---------------------------------------------------------------------- diff --git a/lang/java/reef-io/src/test/java/org/apache/reef/services/storage/MergingIteratorTest.java b/lang/java/reef-io/src/test/java/org/apache/reef/services/storage/MergingIteratorTest.java deleted file mode 100644 index bfab073..0000000 --- a/lang/java/reef-io/src/test/java/org/apache/reef/services/storage/MergingIteratorTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.reef.services.storage; - -import org.apache.reef.io.storage.MergingIterator; -import org.junit.Assert; -import org.junit.Test; - -import java.util.Arrays; -import java.util.Comparator; -import java.util.Iterator; - -public class MergingIteratorTest { - - @Test - public void testMergingIterator() { - Comparator<Integer> cmp = new Comparator<Integer>() { - - @Override - public int compare(final Integer o1, final Integer o2) { - return Integer.compare(o1, o2); - } - }; - @SuppressWarnings("unchecked") - Iterator<Integer>[] its = new Iterator[]{ - Arrays.asList(new Integer[]{1, 4, 7, 10}).iterator(), - Arrays.asList(new Integer[]{2, 5, 8, 11}).iterator(), - Arrays.asList(new Integer[]{3, 6, 9, 12}).iterator() - }; - MergingIterator<Integer> merge = new MergingIterator<Integer>(cmp, its); - int i = 1; - while (merge.hasNext()) { - Assert.assertEquals(i, (int) merge.next()); - i++; - } - Assert.assertEquals(13, i); - } -} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/3325748d/lang/java/reef-io/src/test/java/org/apache/reef/services/storage/SortingSpoolTest.java ---------------------------------------------------------------------- diff --git a/lang/java/reef-io/src/test/java/org/apache/reef/services/storage/SortingSpoolTest.java b/lang/java/reef-io/src/test/java/org/apache/reef/services/storage/SortingSpoolTest.java deleted file mode 100644 index 6e43683..0000000 --- a/lang/java/reef-io/src/test/java/org/apache/reef/services/storage/SortingSpoolTest.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.reef.services.storage; - -import org.apache.reef.exception.evaluator.ServiceException; -import org.apache.reef.io.Accumulator; -import org.apache.reef.io.Spool; -import org.apache.reef.io.storage.ram.SortingRamSpool; -import org.junit.Assert; -import org.junit.Test; - -import java.util.*; - -public class SortingSpoolTest { - - @Test - public void testRamSpool() throws ServiceException { - genericTest(new SortingRamSpool<Integer>(), new Comparator<Integer>() { - - @Override - public int compare(final Integer o1, final Integer o2) { - return Integer.compare(o1, o2); - } - - }); - } - - @Test - public void testRamSpoolComparator() throws ServiceException { - final Comparator<Integer> backwards = new Comparator<Integer>() { - - @Override - public int compare(final Integer o1, final Integer o2) { - return -1 * o1.compareTo(o2); - } - - }; - genericTest(new SortingRamSpool<Integer>(backwards), backwards); - } - - @Test(expected = IllegalStateException.class) - public void testRamSpoolAddAfterClose() throws ServiceException { - final Spool<Integer> s = new SortingRamSpool<>(); - genericAddAfterCloseTest(s); - } - - @Test(expected = UnsupportedOperationException.class) - public void testRamSpoolCantRemove() throws ServiceException { - final Spool<Integer> s = new SortingRamSpool<>(); - genericCantRemove(s); - } - - @Test(expected = IllegalStateException.class) - public void testIteratorBeforeClose() throws ServiceException { - final Spool<Integer> s = new SortingRamSpool<>(); - genericIteratorBeforeClose(s); - } - - void genericTest(final Spool<Integer> s, final Comparator<Integer> comparator) - throws ServiceException { - final List<Integer> l = new ArrayList<Integer>(); - final Random r = new Random(42); - while (l.size() < 100) { - l.add(r.nextInt(75)); - } - final Accumulator<Integer> a = s.accumulator(); - for (int i = 0; i < 100; i++) { - a.add(l.get(i)); - } - a.close(); - final List<Integer> m = new ArrayList<Integer>(); - for (final int i : s) { - m.add(i); - } - final Integer[] sorted = l.toArray(new Integer[0]); - Arrays.sort(sorted, 0, sorted.length, comparator); - final Integer[] shouldBeSorted = m.toArray(new Integer[0]); - Assert.assertArrayEquals(sorted, shouldBeSorted); - } - - void genericAddAfterCloseTest(final Spool<?> s) throws ServiceException { - final Accumulator<?> a = s.accumulator(); - a.close(); - a.add(null); - } - - void genericCantRemove(final Spool<Integer> s) throws ServiceException { - final Accumulator<Integer> a = s.accumulator(); - a.add(10); - a.close(); - final Iterator<?> it = s.iterator(); - it.remove(); - } - - void genericIteratorBeforeClose(final Spool<Integer> s) throws ServiceException { - final Accumulator<Integer> a = s.accumulator(); - a.add(10); - s.iterator(); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/3325748d/lang/java/reef-io/src/test/java/org/apache/reef/services/storage/SpoolFileTest.java ---------------------------------------------------------------------- diff --git a/lang/java/reef-io/src/test/java/org/apache/reef/services/storage/SpoolFileTest.java b/lang/java/reef-io/src/test/java/org/apache/reef/services/storage/SpoolFileTest.java deleted file mode 100644 index edd9ac1..0000000 --- a/lang/java/reef-io/src/test/java/org/apache/reef/services/storage/SpoolFileTest.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.reef.services.storage; - -import org.apache.reef.exception.evaluator.ServiceException; -import org.apache.reef.io.Accumulable; -import org.apache.reef.io.Accumulator; -import org.apache.reef.io.Spool; -import org.apache.reef.io.serialization.Codec; -import org.apache.reef.io.serialization.Deserializer; -import org.apache.reef.io.serialization.Serializer; -import org.apache.reef.io.storage.local.CodecFileAccumulable; -import org.apache.reef.io.storage.local.CodecFileIterable; -import org.apache.reef.io.storage.local.LocalStorageService; -import org.apache.reef.io.storage.local.SerializerFileSpool; -import org.apache.reef.io.storage.ram.RamSpool; -import org.apache.reef.io.storage.ram.RamStorageService; -import org.apache.reef.io.storage.util.IntegerCodec; -import org.apache.reef.tang.ConfigurationBuilder; -import org.apache.reef.tang.Tang; -import org.apache.reef.tang.exceptions.BindException; -import org.apache.reef.tang.exceptions.InjectionException; -import org.apache.reef.tang.formats.AvroConfigurationSerializer; -import org.apache.reef.tang.formats.ConfigurationModule; -import org.apache.reef.tang.formats.ConfigurationModuleBuilder; -import org.junit.Assert; -import org.junit.Test; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Iterator; - -public class SpoolFileTest { - private final Serializer<Integer, OutputStream> serializer = new Serializer<Integer, OutputStream>() { - @Override - public Accumulable<Integer> create(final OutputStream out) { - return new Accumulable<Integer>() { - - @Override - public Accumulator<Integer> accumulator() { - return new Accumulator<Integer>() { - - @Override - public void add(final Integer datum) { - try { - final int d = datum; - out.write(new byte[]{(byte) (d >>> 24), (byte) (d >>> 16), - (byte) (d >>> 8), (byte) d}); - } catch (final IOException e) { - throw new IllegalStateException(e); - } - } - - @Override - public void close() { - try { - out.flush(); - } catch (final IOException e) { - throw new IllegalStateException(e); - } - } - }; - } - }; - } - }; - private final Deserializer<Integer, InputStream> deserializer = new Deserializer<Integer, InputStream>() { - @Override - public Iterable<Integer> create(final InputStream in) { - return new Iterable<Integer>() { - @Override - public Iterator<Integer> iterator() { - final Iterator<Integer> it = new Iterator<Integer>() { - private final byte[] inb = new byte[4]; - private Integer nextInt; - - @Override - public boolean hasNext() { - return nextInt != null; - } - - private void prime() { - final int read; - try { - read = in.read(inb); - } catch (final IOException e) { - throw new IllegalStateException(e); - } - if (read != 4) { - nextInt = null; - } else { - nextInt = ((inb[0] & 0xFF) << 24) + ((inb[1] & 0xFF) << 16) - + ((inb[2] & 0xFF) << 8) + (inb[3] & 0xFF); - } - - } - - @Override - public Integer next() { - final Integer ret = nextInt; - prime(); - return ret; - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - }; - it.next(); // calls prime - return it; - } - }; - } - }; - - @Test - public void testRam() throws BindException, InjectionException, ServiceException, IOException { - final Tang t = Tang.Factory.getTang(); - final ConfigurationBuilder configurationBuilderOne = t.newConfigurationBuilder(RamConf.CONF.build()); - - final AvroConfigurationSerializer avroSerializer = new AvroConfigurationSerializer(); - final String serializedConfiguration = avroSerializer.toString(configurationBuilderOne.build()); - final ConfigurationBuilder configurationBuilderTwo = - t.newConfigurationBuilder(avroSerializer.fromString(serializedConfiguration)); - - @SuppressWarnings("unchecked") - final Spool<Integer> f = (Spool<Integer>) t.newInjector(configurationBuilderTwo.build()).getInstance( - Spool.class); - test(f); - } - - @Test - public void testFile() throws ServiceException { - final LocalStorageService service = new LocalStorageService("spoolTest", "file"); - final Spool<Integer> f = new SerializerFileSpool<Integer>(service, serializer, - deserializer); - test(f); - service.getScratchSpace().delete(); - } - - @Test - public void testInterop() throws ServiceException { - final LocalStorageService service = new LocalStorageService("spoolTest", "file"); - final Codec<Integer> c = new IntegerCodec(); - - - final CodecFileAccumulable<Integer, Codec<Integer>> f = new CodecFileAccumulable<Integer, Codec<Integer>>( - service, c); - final CodecFileIterable<Integer, Codec<Integer>> g = new CodecFileIterable<Integer, Codec<Integer>>( - new File(f.getName()), c); - test(f, g); - service.getScratchSpace().delete(); - } - - protected void test(final Spool<Integer> f) throws ServiceException { - test(f, f); - } - - protected void test(final Accumulable<Integer> f, final Iterable<Integer> g) throws ServiceException { - - try (Accumulator<Integer> acc = f.accumulator()) { - for (int i = 0; i < 1000; i++) { - acc.add(i); - } - } - int i = 0; - for (final int j : g) { - Assert.assertEquals(i, j); - i++; - } - final Iterator<Integer> itA = g.iterator(); - final Iterator<Integer> itB = g.iterator(); - - for (i = 0; i < 1000; i++) { - Assert.assertEquals((int) itA.next(), i); - Assert.assertEquals((int) itB.next(), i); - } - Assert.assertFalse(itA.hasNext()); - Assert.assertFalse(itB.hasNext()); - } - - public static final class RamConf extends ConfigurationModuleBuilder { - public static final ConfigurationModule CONF = new RamConf() - .bindImplementation(RamStorageService.class, RamStorageService.class) - .bindImplementation(Spool.class, RamSpool.class) - .build(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/3325748d/lang/java/reef-io/src/test/java/org/apache/reef/services/storage/TupleSerializerTest.java ---------------------------------------------------------------------- diff --git a/lang/java/reef-io/src/test/java/org/apache/reef/services/storage/TupleSerializerTest.java b/lang/java/reef-io/src/test/java/org/apache/reef/services/storage/TupleSerializerTest.java deleted file mode 100644 index 1c4e48a..0000000 --- a/lang/java/reef-io/src/test/java/org/apache/reef/services/storage/TupleSerializerTest.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.reef.services.storage; - -import org.apache.reef.exception.evaluator.ServiceException; -import org.apache.reef.io.Accumulator; -import org.apache.reef.io.Tuple; -import org.apache.reef.io.serialization.Deserializer; -import org.apache.reef.io.serialization.Serializer; -import org.apache.reef.io.storage.FramingTupleDeserializer; -import org.apache.reef.io.storage.FramingTupleSerializer; -import org.apache.reef.io.storage.util.IntegerDeserializer; -import org.apache.reef.io.storage.util.IntegerSerializer; -import org.apache.reef.io.storage.util.StringDeserializer; -import org.apache.reef.io.storage.util.StringSerializer; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import java.io.*; -import java.util.Iterator; -import java.util.NoSuchElementException; - -public class TupleSerializerTest { - - private Serializer<Integer, OutputStream> keySerializer; - private Serializer<String, OutputStream> valSerializer; - private Deserializer<Integer, InputStream> keyDeserializer; - private Deserializer<String, InputStream> valDeserializer; - private FramingTupleSerializer<Integer, String> fts; - private ByteArrayOutputStream baos; - private FramingTupleDeserializer<Integer, String> ftd; - private Iterable<Tuple<Integer, String>> iterable; - - @Before - public void setup() throws ServiceException { - - keySerializer = new IntegerSerializer(); - valSerializer = new StringSerializer(); - keyDeserializer = new IntegerDeserializer(); - valDeserializer = new StringDeserializer(); - - fts = new FramingTupleSerializer<Integer, String>( - keySerializer, valSerializer); - - baos = new ByteArrayOutputStream(); - final Accumulator<Tuple<Integer, String>> acc = fts.create(baos).accumulator(); - for (int i = 0; i < 100; i++) { - acc.add(new Tuple<>(i, i + "")); - } - acc.close(); - - ftd = new FramingTupleDeserializer<Integer, String>( - keyDeserializer, valDeserializer); - iterable = ftd.create(new ByteArrayInputStream(baos.toByteArray())); - } - - @Test - public void testFramingSerializer() throws ServiceException, IOException { - int i = 0; - for (final Tuple<Integer, String> t : iterable) { - final Tuple<Integer, String> u = new Tuple<>(i, i + ""); - Assert.assertEquals(u, t); - i++; - } - Assert.assertEquals(100, i); - } - - @Test(expected = NoSuchElementException.class) - public void testReadOffEnd() { - final Iterator<Tuple<Integer, String>> it = iterable.iterator(); - try { - while (it.hasNext()) { - it.next(); - it.hasNext(); - } - } catch (final NoSuchElementException e) { - throw new IllegalStateException("Errored out too early!", e); - } - it.next(); - } - - @Test(expected = UnsupportedOperationException.class) - public void testCantRemove() { - final Iterator<Tuple<Integer, String>> it = iterable.iterator(); - it.next(); - it.remove(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/3325748d/lang/java/reef-io/src/test/java/org/apache/reef/services/storage/package-info.java ---------------------------------------------------------------------- diff --git a/lang/java/reef-io/src/test/java/org/apache/reef/services/storage/package-info.java b/lang/java/reef-io/src/test/java/org/apache/reef/services/storage/package-info.java deleted file mode 100644 index 15f78cd..0000000 --- a/lang/java/reef-io/src/test/java/org/apache/reef/services/storage/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/** - * TODO: Document. - */ -package org.apache.reef.services.storage;
