Remove PowerMock from asterix-external-data
PowerMock prevents jacoco from collecting coverage information.
Hence, it is better not to use it. However, using Mockito is fine.
In addition, this change fixes the BTree frame writer unit test.
Change-Id: I69cff2827b1f2cc57e0fec0316b2b997f806787c
Reviewed-on: https://asterix-gerrit.ics.uci.edu/875
Reviewed-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: abdullah alamoudi <bamousaa@gmail.com>
diff --git a/asterixdb/asterix-external-data/pom.xml b/asterixdb/asterix-external-data/pom.xml
index 5217846..7e82491 100644
--- a/asterixdb/asterix-external-data/pom.xml
+++ b/asterixdb/asterix-external-data/pom.xml
@@ -306,17 +306,5 @@
<version>2.0.2-beta</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito</artifactId>
- <version>1.6.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module-junit4</artifactId>
- <version>1.6.2</version>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
\ No newline at end of file
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/dataflow/FeedRuntimeInputHandler.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/dataflow/FeedRuntimeInputHandler.java
index d201a6a..8ed2bf9 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/dataflow/FeedRuntimeInputHandler.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/dataflow/FeedRuntimeInputHandler.java
@@ -202,7 +202,7 @@
return;
}
}
- if (((numDiscarded + 1.0) / total) > fpa.getMaxFractionDiscard()) {
+ if ((numDiscarded + 1.0) / total > fpa.getMaxFractionDiscard()) {
if (DEBUG) {
LOGGER.info("in discard(frame). Discard allowance has been consumed. --> Stalling");
}
@@ -383,14 +383,6 @@
}
}
- public Mode getMode() {
- return mode;
- }
-
- public void setMode(Mode mode) {
- this.mode = mode;
- }
-
@Override
public void flush() throws HyracksDataException {
synchronized (writer) {
diff --git a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/feed/test/ConcurrentFramePoolUnitTest.java b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/feed/test/ConcurrentFramePoolUnitTest.java
index 444d8a5..49042b8 100644
--- a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/feed/test/ConcurrentFramePoolUnitTest.java
+++ b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/feed/test/ConcurrentFramePoolUnitTest.java
@@ -29,15 +29,12 @@
import org.apache.asterix.external.feed.management.ConcurrentFramePool;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.junit.Assert;
-import org.junit.runner.RunWith;
import org.mockito.Mockito;
-import org.powermock.modules.junit4.PowerMockRunner;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-@RunWith(PowerMockRunner.class)
public class ConcurrentFramePoolUnitTest extends TestCase {
private static final int DEFAULT_FRAME_SIZE = 32768;
diff --git a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/feed/test/FeedSpillerUnitTest.java b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/feed/test/FeedSpillerUnitTest.java
index 8751439..31e49a7 100644
--- a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/feed/test/FeedSpillerUnitTest.java
+++ b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/feed/test/FeedSpillerUnitTest.java
@@ -29,14 +29,11 @@
import org.apache.hyracks.test.support.TestUtils;
import org.apache.wicket.util.file.File;
import org.junit.Assert;
-import org.junit.runner.RunWith;
-import org.powermock.modules.junit4.PowerMockRunner;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-@RunWith(PowerMockRunner.class)
public class FeedSpillerUnitTest extends TestCase {
private static final int DEFAULT_FRAME_SIZE = 32768;
private static final int NUM_FRAMES = 3096;
diff --git a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/feed/test/InputHandlerTest.java b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/feed/test/InputHandlerTest.java
index 1312721..c00db7a 100644
--- a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/feed/test/InputHandlerTest.java
+++ b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/feed/test/InputHandlerTest.java
@@ -42,15 +42,12 @@
import org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor;
import org.apache.hyracks.test.support.TestUtils;
import org.junit.Assert;
-import org.junit.runner.RunWith;
import org.mockito.Mockito;
-import org.powermock.modules.junit4.PowerMockRunner;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-@RunWith(PowerMockRunner.class)
public class InputHandlerTest extends TestCase {
private static final int DEFAULT_FRAME_SIZE = 32768;
@@ -352,7 +349,7 @@
while (nextShouldDiscard) {
handler.nextFrame(frame.getBuffer());
numDiscarded++;
- nextShouldDiscard = ((numDiscarded + 1.0) / (handler.getTotal() + 1.0)) <= fpa.getMaxFractionDiscard();
+ nextShouldDiscard = (numDiscarded + 1.0) / (handler.getTotal() + 1.0) <= fpa.getMaxFractionDiscard();
}
Assert.assertEquals(0, framePool.remaining());
Assert.assertEquals((int) (numberOfMemoryFrames + numberOfSpillFrames + numDiscarded), handler.getTotal());
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/test/java/org/apache/hyracks/api/test/TestControlledFrameWriter.java b/hyracks-fullstack/hyracks/hyracks-api/src/test/java/org/apache/hyracks/api/test/TestControlledFrameWriter.java
index 2a3f70d..bf168c2 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/test/java/org/apache/hyracks/api/test/TestControlledFrameWriter.java
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/test/java/org/apache/hyracks/api/test/TestControlledFrameWriter.java
@@ -49,7 +49,8 @@
duration = ms;
}
- public synchronized void unfreeze() {
+ public synchronized void unfreeze() throws InterruptedException {
+ wait(10);
frozen = false;
notify();
}
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/test/java/org/apache/hyracks/storage/am/btree/test/FramewriterTest.java b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/test/java/org/apache/hyracks/storage/am/btree/test/FramewriterTest.java
index d3e7a3a..378ea65 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/test/java/org/apache/hyracks/storage/am/btree/test/FramewriterTest.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/test/java/org/apache/hyracks/storage/am/btree/test/FramewriterTest.java
@@ -26,6 +26,7 @@
import org.apache.hyracks.api.comm.IFrameTupleAppender;
import org.apache.hyracks.api.comm.IFrameWriter;
import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.dataflow.IOperatorNodePushable;
import org.apache.hyracks.api.dataflow.value.IRecordDescriptorProvider;
import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
@@ -219,6 +220,7 @@
testBTreeSearchOperatorNodePushable();
} catch (Throwable th) {
th.printStackTrace();
+ Assert.fail(th.toString());
}
System.out.println("Number of passed tests: " + successes);
System.out.println("Number of failed tests: " + failures);
@@ -446,7 +448,8 @@
private ISearchOperationCallbackFactory[] mockSearchOpCallbackFactories() throws HyracksDataException {
ISearchOperationCallback searchOpCallback = mockSearchOpCallback();
ISearchOperationCallbackFactory searchOpCallbackFactory = Mockito.mock(ISearchOperationCallbackFactory.class);
- Mockito.when(searchOpCallbackFactory.createSearchOperationCallback(Mockito.anyLong(), Mockito.any(), null))
+ Mockito.when(searchOpCallbackFactory.createSearchOperationCallback(Mockito.anyLong(),
+ Mockito.any(IHyracksTaskContext.class), Mockito.isNull(IOperatorNodePushable.class)))
.thenReturn(searchOpCallback);
return new ISearchOperationCallbackFactory[] { searchOpCallbackFactory };
}