build: Downgrade to Java 1.7
Downgrading is necessary to keep compatibility with Android
Change-Id: I9269d3ec32fd87bdd487ec91fab0f6fa87c7de23
diff --git a/.travis.yml b/.travis.yml
index 9bcf999..e358d25 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,3 +1,3 @@
language: java
jdk:
- - oraclejdk8
+ - oraclejdk7
diff --git a/nb-configuration.xml b/nb-configuration.xml
index 36ad590..932be69 100644
--- a/nb-configuration.xml
+++ b/nb-configuration.xml
@@ -29,6 +29,6 @@
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.text-line-wrap>none</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.text-line-wrap>
<org-netbeans-modules-editor-indent.text.x-fortran.CodeStyle.project.text-limit-width>132</org-netbeans-modules-editor-indent.text.x-fortran.CodeStyle.project.text-limit-width>
<netbeans.compile.on.save>all</netbeans.compile.on.save>
- <netbeans.hint.jdkPlatform>JDK_1.8</netbeans.hint.jdkPlatform>
+ <netbeans.hint.jdkPlatform>JDK_1.7</netbeans.hint.jdkPlatform>
</properties>
</project-shared-configuration>
diff --git a/pom.xml b/pom.xml
index 5e4b3b1..ef45a8f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -53,8 +53,8 @@
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <maven.compiler.source>1.8</maven.compiler.source>
- <maven.compiler.target>1.8</maven.compiler.target>
+ <maven.compiler.source>1.7</maven.compiler.source>
+ <maven.compiler.target>1.7</maven.compiler.target>
</properties>
<build>
<plugins>
diff --git a/src/test/java/com/intel/jndn/utils/client/impl/AdvancedClientFileTestIT.java b/src/integration-test/java/com/intel/jndn/utils/client/impl/AdvancedClientFileTestIT.java
similarity index 92%
rename from src/test/java/com/intel/jndn/utils/client/impl/AdvancedClientFileTestIT.java
rename to src/integration-test/java/com/intel/jndn/utils/client/impl/AdvancedClientFileTestIT.java
index 45572a7..6710711 100644
--- a/src/test/java/com/intel/jndn/utils/client/impl/AdvancedClientFileTestIT.java
+++ b/src/integration-test/java/com/intel/jndn/utils/client/impl/AdvancedClientFileTestIT.java
@@ -18,6 +18,7 @@
import com.intel.jndn.utils.server.impl.SegmentedServerHelper;
import java.io.ByteArrayInputStream;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.CompletableFuture;
@@ -68,14 +69,21 @@
long startTime = System.currentTimeMillis();
AdvancedClient client = new AdvancedClient();
List<CompletableFuture<Data>> requests = expressInterests(client, consumer, PREFIX, NUM_MESSAGES);
- List<Data> datas = requests.stream().map((f) -> TestHelper.retrieve(f)).collect(Collectors.toList());
+ List<Data> datas = new ArrayList<>();
+ for (CompletableFuture<Data> f : requests) {
+ datas.add(TestHelper.retrieve(f));
+ }
long endTime = System.currentTimeMillis();
logger.info(String.format("Transfered %d bytes in %d ms", MESSAGE_SIZE_BYTES * NUM_MESSAGES, endTime - startTime));
}
private List<CompletableFuture<Data>> expressInterests(Client client, Face face, Name name, int count) {
- return IntStream.range(0, count).boxed().map((i) -> client.getAsync(face, name)).collect(Collectors.toList());
+ List<CompletableFuture<Data>> list = new ArrayList<>();
+ for (int i = 0; i < count; i++) {
+ list.add(client.getAsync(face, name));
+ }
+ return list;
}
private class AdvancedDataServer implements OnInterestCallback {
diff --git a/src/test/java/com/intel/jndn/utils/client/impl/AdvancedClientStressTestIT.java b/src/integration-test/java/com/intel/jndn/utils/client/impl/AdvancedClientStressTestIT.java
similarity index 92%
rename from src/test/java/com/intel/jndn/utils/client/impl/AdvancedClientStressTestIT.java
rename to src/integration-test/java/com/intel/jndn/utils/client/impl/AdvancedClientStressTestIT.java
index 6a99599..e66daae 100644
--- a/src/test/java/com/intel/jndn/utils/client/impl/AdvancedClientStressTestIT.java
+++ b/src/integration-test/java/com/intel/jndn/utils/client/impl/AdvancedClientStressTestIT.java
@@ -18,6 +18,7 @@
import com.intel.jndn.utils.server.impl.SegmentedServerHelper;
import java.io.ByteArrayInputStream;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.CompletableFuture;
@@ -68,14 +69,22 @@
long startTime = System.currentTimeMillis();
AdvancedClient client = new AdvancedClient();
List<CompletableFuture<Data>> requests = expressInterests(client, consumer, PREFIX, NUM_MESSAGES);
- List<Data> datas = requests.stream().map((f) -> TestHelper.retrieve(f)).collect(Collectors.toList());
+
+ List<Data> datas = new ArrayList<>();
+ for (CompletableFuture<Data> f : requests) {
+ datas.add(TestHelper.retrieve(f));
+ }
long endTime = System.currentTimeMillis();
logger.info(String.format("Transfered %d bytes in %d ms", MESSAGE_SIZE_BYTES * NUM_MESSAGES, endTime - startTime));
}
private List<CompletableFuture<Data>> expressInterests(Client client, Face face, Name name, int count) {
- return IntStream.range(0, count).boxed().map((i) -> client.getAsync(face, name)).collect(Collectors.toList());
+ List<CompletableFuture<Data>> list = new ArrayList<>();
+ for (int i = 0; i < count; i++) {
+ list.add(client.getAsync(face, name));
+ }
+ return list;
}
private class RandomDataServer implements OnInterestCallback {
diff --git a/src/test/java/com/intel/jndn/utils/client/impl/SimpleClientTestIT.java b/src/integration-test/java/com/intel/jndn/utils/client/impl/SimpleClientTestIT.java
similarity index 90%
rename from src/test/java/com/intel/jndn/utils/client/impl/SimpleClientTestIT.java
rename to src/integration-test/java/com/intel/jndn/utils/client/impl/SimpleClientTestIT.java
index f49525b..7e53d77 100644
--- a/src/test/java/com/intel/jndn/utils/client/impl/SimpleClientTestIT.java
+++ b/src/integration-test/java/com/intel/jndn/utils/client/impl/SimpleClientTestIT.java
@@ -16,11 +16,14 @@
import com.intel.jndn.utils.client.impl.SimpleClient;
import com.intel.jndn.utils.TestHelper;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.concurrent.CompletableFuture;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.IntStream;
import java.util.stream.Stream;
+
+import com.intel.jndn.utils.processing.impl.CompressionStage;
import net.named_data.jndn.Data;
import net.named_data.jndn.Face;
import net.named_data.jndn.Interest;
@@ -106,12 +109,16 @@
Thread.sleep(500);
// request all packets
- Stream<CompletableFuture<Data>> futures = IntStream.range(0, numInterests)
- .boxed().map((i) -> instance.getAsync(consumerFace, PREFIX_RETRIEVE_MULTIPLE));
+ ArrayList<CompletableFuture<Data>> futures = new ArrayList<>();
+ for (int i = 0; i < numInterests; i++) {
+ futures.add(instance.getAsync(consumerFace, PREFIX_RETRIEVE_MULTIPLE));
+ }
// check all returned packets
- futures.map((f) -> TestHelper.retrieve(f))
- .forEach((d) -> assertEquals(servedData.getContent().toString(), d.getContent().toString()));
+ for (CompletableFuture<Data> f : futures) {
+ Data d = TestHelper.retrieve(f);
+ assertEquals(servedData.getContent().toString(), d.getContent().toString());
+ }
}
private class DataServer implements OnInterestCallback {
diff --git a/src/test/java/com/intel/jndn/utils/server/impl/SegmentedServerTestIT.java b/src/integration-test/java/com/intel/jndn/utils/server/impl/SegmentedServerTestIT.java
similarity index 100%
rename from src/test/java/com/intel/jndn/utils/server/impl/SegmentedServerTestIT.java
rename to src/integration-test/java/com/intel/jndn/utils/server/impl/SegmentedServerTestIT.java
diff --git a/src/main/java/com/intel/jndn/utils/client/impl/AdvancedClient.java b/src/main/java/com/intel/jndn/utils/client/impl/AdvancedClient.java
index be1e876..d5d8c8e 100644
--- a/src/main/java/com/intel/jndn/utils/client/impl/AdvancedClient.java
+++ b/src/main/java/com/intel/jndn/utils/client/impl/AdvancedClient.java
@@ -94,10 +94,10 @@
*/
@Override
public CompletableFuture<Data> getAsync(Face face, Interest interest) {
- CompletableFuture<Data> future = new CompletableFuture<>();
+ final CompletableFuture<Data> future = new CompletableFuture<>();
try {
- DataStream stream = getSegmentsAsync(face, interest);
+ final DataStream stream = getSegmentsAsync(face, interest);
stream.observe(new OnException() {
public void onException(Exception exception) {
diff --git a/src/main/java/com/intel/jndn/utils/client/impl/DefaultStreamingClient.java b/src/main/java/com/intel/jndn/utils/client/impl/DefaultStreamingClient.java
index 55fa0f0..e40e4e7 100644
--- a/src/main/java/com/intel/jndn/utils/client/impl/DefaultStreamingClient.java
+++ b/src/main/java/com/intel/jndn/utils/client/impl/DefaultStreamingClient.java
@@ -70,9 +70,9 @@
* @return
* @throws IOException
*/
- public InputStream getStreamAsync(DataStream onDataStream, OnException onException) throws IOException {
+ public InputStream getStreamAsync(final DataStream onDataStream, OnException onException) throws IOException {
PipedInputStream in = new PipedInputStream();
- PipedOutputStream out = new PipedOutputStream(in);
+ final PipedOutputStream out = new PipedOutputStream(in);
onDataStream.observe(onException);
diff --git a/src/main/java/com/intel/jndn/utils/client/impl/SegmentedDataStream.java b/src/main/java/com/intel/jndn/utils/client/impl/SegmentedDataStream.java
index 41fd86a..45200f3 100644
--- a/src/main/java/com/intel/jndn/utils/client/impl/SegmentedDataStream.java
+++ b/src/main/java/com/intel/jndn/utils/client/impl/SegmentedDataStream.java
@@ -16,19 +16,16 @@
import com.intel.jndn.utils.client.OnComplete;
import com.intel.jndn.utils.client.OnException;
import com.intel.jndn.utils.client.DataStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
+
+import java.util.*;
+import java.util.function.Consumer;
+import java.util.function.Predicate;
import java.util.logging.Logger;
import java.util.stream.Collectors;
-import net.named_data.jndn.Data;
-import net.named_data.jndn.Interest;
-import net.named_data.jndn.Name;
-import net.named_data.jndn.OnData;
-import net.named_data.jndn.OnTimeout;
+
+import net.named_data.jndn.*;
import net.named_data.jndn.encoding.EncodingException;
+import net.named_data.jndn.sync.ChronoSync2013;
/**
* As packets are received, they are mapped by their last component's segment
@@ -49,7 +46,10 @@
private volatile long current = -1;
private volatile long end = Long.MAX_VALUE;
private Map<Long, Data> packets = new HashMap<>();
- private List<Object> observers = new ArrayList<>();
+ private List<OnData> observersOnData = new ArrayList<>();
+ private List<OnComplete> observersOnComplete = new ArrayList<>();
+ private List<OnException> observersOnException = new ArrayList<>();
+ private List<OnTimeout> observersOnTimeout = new ArrayList<>();
private Exception exception;
@Override
@@ -90,22 +90,22 @@
@Override
public void observe(OnData onData) {
- observers.add(onData);
+ observersOnData.add(onData);
}
@Override
public void observe(OnComplete onComplete) {
- observers.add(onComplete);
+ observersOnComplete.add(onComplete);
}
@Override
public void observe(OnException onException) {
- observers.add(onException);
+ observersOnException.add(onException);
}
@Override
public void observe(OnTimeout onTimeout) {
- observers.add(onTimeout);
+ observersOnTimeout.add(onTimeout);
}
@Override
@@ -145,10 +145,10 @@
do {
current++;
assert (packets.containsKey(current));
- Data retrieved = packets.get(current);
- observersOfType(OnData.class).stream().forEach((OnData cb) -> {
+ final Data retrieved = packets.get(current);
+ for (OnData cb : observersOnData) {
cb.onData(interest, retrieved);
- });
+ }
} while (hasNextPacket());
}
@@ -172,28 +172,24 @@
@Override
public synchronized void onComplete() {
- observersOfType(OnComplete.class).stream().forEach((OnComplete cb) -> {
+ for (OnComplete cb : observersOnComplete) {
cb.onComplete();
- });
+ }
}
@Override
public synchronized void onTimeout(Interest interest) {
- observersOfType(OnTimeout.class).stream().forEach((OnTimeout cb) -> {
+ for (OnTimeout cb : observersOnTimeout) {
cb.onTimeout(interest);
- });
+ }
}
@Override
public synchronized void onException(Exception exception) {
this.exception = exception;
- observersOfType(OnException.class).stream().forEach((OnException cb) -> {
+ for (OnException cb : observersOnException) {
cb.onException(exception);
- });
- }
-
- private <T> List<T> observersOfType(Class<T> type) {
- return observers.stream().filter((Object o) -> type.isAssignableFrom(o.getClass())).map((o) -> (T) o).collect(Collectors.toList());
+ }
}
}
diff --git a/src/test/java/com/intel/jndn/utils/TestHelper.java b/src/test/java/com/intel/jndn/utils/TestHelper.java
index a73aba4..fbf931e 100644
--- a/src/test/java/com/intel/jndn/utils/TestHelper.java
+++ b/src/test/java/com/intel/jndn/utils/TestHelper.java
@@ -24,8 +24,6 @@
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
import net.named_data.jndn.Data;
import net.named_data.jndn.Face;
import net.named_data.jndn.Name;
@@ -51,15 +49,19 @@
}
public static List<CompletableFuture<Data>> buildFutureSegments(Name name, int from, int to) {
- return buildSegments(name, from, to).stream()
- .map((d) -> CompletableFuture.completedFuture(d))
- .collect(Collectors.toList());
+ List<CompletableFuture<Data>> list = new ArrayList<>();
+ for (Data d : buildSegments(name, from, to)) {
+ list.add(CompletableFuture.completedFuture(d));
+ }
+ return list;
}
public static List<Data> buildSegments(Name name, int from, int to) {
- return IntStream.range(from, to).boxed()
- .map((i) -> buildData(new Name(name).appendSegment(i), i.toString(), to - 1))
- .collect(Collectors.toList());
+ List<Data> list = new ArrayList<>();
+ for (Integer i = from; i < to; i++) {
+ list.add(buildData(new Name(name).appendSegment(i), i.toString(), to - 1));
+ }
+ return list;
}
public static Data buildData(Name name, String content) {
diff --git a/src/test/java/com/intel/jndn/utils/client/impl/DefaultSegmentedClientTest.java b/src/test/java/com/intel/jndn/utils/client/impl/DefaultSegmentedClientTest.java
index 2d65724..7ed72d4 100644
--- a/src/test/java/com/intel/jndn/utils/client/impl/DefaultSegmentedClientTest.java
+++ b/src/test/java/com/intel/jndn/utils/client/impl/DefaultSegmentedClientTest.java
@@ -22,6 +22,8 @@
import net.named_data.jndn.Interest;
import net.named_data.jndn.Name;
import static org.junit.Assert.assertEquals;
+
+import net.named_data.jndn.OnData;
import org.junit.Test;
/**
@@ -40,9 +42,12 @@
Interest interest = new Interest(name);
DataStream stream = instance.getSegmentsAsync(face, interest);
- TestCounter counter = new TestCounter();
- stream.observe((i, d) -> {
- counter.count++;
+ final TestCounter counter = new TestCounter();
+ stream.observe(new OnData() {
+ @Override
+ public void onData(Interest interest, Data data) {
+ counter.count++;
+ }
});
for (Data segment : TestHelper.buildSegments(name, 0, 5)) {
@@ -77,9 +82,12 @@
Interest interest = new Interest(name);
DataStream stream = instance.getSegmentsAsync(face, interest);
- TestCounter counter = new TestCounter();
- stream.observe((i, d) -> {
- counter.count++;
+ final TestCounter counter = new TestCounter();
+ stream.observe(new OnData() {
+ @Override
+ public void onData(Interest interest, Data data) {
+ counter.count++;
+ }
});
for (Data segment : TestHelper.buildSegments(name, 0, 5)) {
diff --git a/src/test/java/com/intel/jndn/utils/client/impl/SegmentedDataStreamTest.java b/src/test/java/com/intel/jndn/utils/client/impl/SegmentedDataStreamTest.java
index 2f165b9..9407cfc 100644
--- a/src/test/java/com/intel/jndn/utils/client/impl/SegmentedDataStreamTest.java
+++ b/src/test/java/com/intel/jndn/utils/client/impl/SegmentedDataStreamTest.java
@@ -20,6 +20,7 @@
import net.named_data.jndn.Interest;
import net.named_data.jndn.Name;
import net.named_data.jndn.Name.Component;
+import net.named_data.jndn.OnData;
import net.named_data.jndn.encoding.EncodingException;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
@@ -50,13 +51,16 @@
public void testAddingUnorderedData() throws StreamException {
Name name = new Name("/test/segmented/data/stream");
Interest interest = new Interest(name);
- ArrayList<Long> segments = new ArrayList<>();
+ final ArrayList<Long> segments = new ArrayList<>();
- instance.observe((i, d) -> {
- try {
- segments.add(d.getName().get(-1).toSegment());
- } catch (EncodingException ex) {
- throw new RuntimeException(ex);
+ instance.observe(new OnData() {
+ @Override
+ public void onData(Interest i, Data d) {
+ try {
+ segments.add(d.getName().get(-1).toSegment());
+ } catch (EncodingException ex) {
+ throw new RuntimeException(ex);
+ }
}
});
@@ -99,10 +103,10 @@
@Test
public void testOrderedPackets() {
int end = 10;
- IntStream.range(0, end).forEach((i) -> {
+ for (int i = 0; i < end; i++) {
addPacketToInstance(i);
assertEquals(i, instance.current());
- });
+ };
assertEquals(end, instance.list().length);
}