diff --git a/.travis.yml b/.travis.yml index 9771061a..4bac75bb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,12 @@ sudo: false language: java -jdk: oraclejdk8 +jdk: openjdk8 cache: apt: true directories: - $HOME/.m2 +services: + - xvfb script: mvn clean verify -Pjacoco coveralls:report -before_install: - - "export DISPLAY=:99.0" - - "sh -e /etc/init.d/xvfb start" notifications: slack: cunyponder:A8GuEoj0voEn2H7MJDL1eNji diff --git a/edu.cuny.hunter.streamrefactoring.tests/pom.xml b/edu.cuny.hunter.streamrefactoring.tests/pom.xml index 3f9b0ca6..6f7e8192 100644 --- a/edu.cuny.hunter.streamrefactoring.tests/pom.xml +++ b/edu.cuny.hunter.streamrefactoring.tests/pom.xml @@ -19,7 +19,7 @@ - ${tycho.testArgLine} -XstartOnFirstThread + ${tycho.testArgLine} -XstartOnFirstThread -Xmx4g -XX:MaxPermSize=1g ${ui.test.vmargs} @@ -33,7 +33,7 @@ ${tycho.testArgLine} - ${ui.test.vmargs} + ${ui.test.vmargs} -Xmx4g -XX:MaxPermSize=1g diff --git a/edu.cuny.hunter.streamrefactoring.tests/resources/ConvertStreamToParallel/testMotivatingExample/in/A.java b/edu.cuny.hunter.streamrefactoring.tests/resources/ConvertStreamToParallel/testMotivatingExample/in/A.java index 21795018..873a99e1 100644 --- a/edu.cuny.hunter.streamrefactoring.tests/resources/ConvertStreamToParallel/testMotivatingExample/in/A.java +++ b/edu.cuny.hunter.streamrefactoring.tests/resources/ConvertStreamToParallel/testMotivatingExample/in/A.java @@ -10,6 +10,8 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; +import p.Widget.Color; + import edu.cuny.hunter.streamrefactoring.annotations.*; class Widget { @@ -59,5 +61,30 @@ void m() { // sequentially skip the first 1000 widgets and // collect the remaining into a list. List skippedWidgetList = orderedWidgets.stream().skip(1000).collect(Collectors.toList()); + + Collection orderedWidgets2 = orderedWidgets; + + // collect the first green widgets into a list. + List firstGreenList = orderedWidgets2.stream().filter(w -> w.getColor() == Color.GREEN).unordered() + .limit(5).collect(Collectors.toList()); + + Collection orderedWidgets3 = orderedWidgets; + + // collect distinct widget weights into a set. + Set distinctWeightSet = orderedWidgets3.stream().parallel().map(Widget::getWeight).distinct() + .collect(Collectors.toCollection(TreeSet::new)); + + // collect distinct widget colors into a HashSet. + Set distinctColorSet = orderedWidgets2.parallelStream().map(Widget::getColor).distinct() + .collect(HashSet::new, Set::add, Set::addAll); + + // collect widget colors matching a regex. + Pattern pattern = Pattern.compile(".*e[a-z]"); + ArrayList results = new ArrayList<>(); + + Collection orderedWidgets4 = orderedWidgets; + + orderedWidgets4.stream().map(w -> w.getColor()).map(c -> c.toString()).filter(s -> pattern.matcher(s).matches()) + .forEach(s -> results.add(s)); } -} \ No newline at end of file +} diff --git a/edu.cuny.hunter.streamrefactoring.tests/test cases/edu/cuny/hunter/streamrefactoring/ui/tests/ConvertStreamToParallelRefactoringTest.java b/edu.cuny.hunter.streamrefactoring.tests/test cases/edu/cuny/hunter/streamrefactoring/ui/tests/ConvertStreamToParallelRefactoringTest.java index dc7e0a94..4ea990f4 100644 --- a/edu.cuny.hunter.streamrefactoring.tests/test cases/edu/cuny/hunter/streamrefactoring/ui/tests/ConvertStreamToParallelRefactoringTest.java +++ b/edu.cuny.hunter.streamrefactoring.tests/test cases/edu/cuny/hunter/streamrefactoring/ui/tests/ConvertStreamToParallelRefactoringTest.java @@ -625,12 +625,32 @@ public void testMotivatingExample() throws Exception { Collections.emptySet()), new StreamAnalysisExpectedResult("orderedWidgets.parallelStream()", EnumSet.of(ExecutionMode.PARALLEL), - EnumSet.of(Ordering.ORDERED), false, false, false, null, null, null, RefactoringStatus.ERROR, + EnumSet.of(Ordering.ORDERED), false, false, true, null, null, null, RefactoringStatus.ERROR, EnumSet.of(PreconditionFailure.NO_STATEFUL_INTERMEDIATE_OPERATIONS)), new StreamAnalysisExpectedResult("orderedWidgets.stream()", EnumSet.of(ExecutionMode.SEQUENTIAL), EnumSet.of(Ordering.ORDERED), false, true, true, null, null, null, RefactoringStatus.ERROR, - EnumSet.of(PreconditionFailure.REDUCE_ORDERING_MATTERS))); + EnumSet.of(PreconditionFailure.REDUCE_ORDERING_MATTERS)), + + new StreamAnalysisExpectedResult("orderedWidgets2.stream()", EnumSet.of(ExecutionMode.SEQUENTIAL), + EnumSet.of(Ordering.UNORDERED), false, true, true, + EnumSet.of(TransformationAction.CONVERT_TO_PARALLEL), PreconditionSuccess.P1, + Refactoring.CONVERT_SEQUENTIAL_STREAM_TO_PARALLEL, RefactoringStatus.OK, + Collections.emptySet()), + + new StreamAnalysisExpectedResult("orderedWidgets3.stream()", EnumSet.of(ExecutionMode.PARALLEL), + EnumSet.of(Ordering.ORDERED), false, true, true, + EnumSet.of(TransformationAction.CONVERT_TO_SEQUENTIAL), PreconditionSuccess.P5, + Refactoring.OPTIMIZE_PARALLEL_STREAM, RefactoringStatus.OK, Collections.emptySet()), + + new StreamAnalysisExpectedResult("orderedWidgets2.parallelStream()", EnumSet.of(ExecutionMode.PARALLEL), + EnumSet.of(Ordering.ORDERED), false, true, false, EnumSet.of(TransformationAction.UNORDER), + PreconditionSuccess.P4, Refactoring.OPTIMIZE_PARALLEL_STREAM, RefactoringStatus.OK, + Collections.emptySet()), + + new StreamAnalysisExpectedResult("orderedWidgets4.stream()", EnumSet.of(ExecutionMode.SEQUENTIAL), + EnumSet.of(Ordering.ORDERED), true, false, false, null, null, null, RefactoringStatus.ERROR, + EnumSet.of(PreconditionFailure.HAS_SIDE_EFFECTS2))); } public void testTerminalOp1() throws Exception { diff --git a/scripts/keep_alive.sh b/scripts/keep_alive.sh new file mode 100755 index 00000000..900c05d7 --- /dev/null +++ b/scripts/keep_alive.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -ev +function write_visual_bells() { + for i in `seq 1 40`; do + echo -en "\a" + sleep 1m + done +} +write_visual_bells& +mvn install