You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mnemonic.apache.org by ga...@apache.org on 2018/03/11 06:24:25 UTC
mnemonic git commit: MNEMONIC-472: Refactor test cases of
computing-services module using EntityFactoryProxyHelper
Repository: mnemonic
Updated Branches:
refs/heads/master 7c8ab1f1e -> b837b8813
MNEMONIC-472: Refactor test cases of computing-services module using EntityFactoryProxyHelper
Project: http://git-wip-us.apache.org/repos/asf/mnemonic/repo
Commit: http://git-wip-us.apache.org/repos/asf/mnemonic/commit/b837b881
Tree: http://git-wip-us.apache.org/repos/asf/mnemonic/tree/b837b881
Diff: http://git-wip-us.apache.org/repos/asf/mnemonic/diff/b837b881
Branch: refs/heads/master
Commit: b837b8813736f6e823eb48aeba5a118bfd5b1871
Parents: 7c8ab1f
Author: Wang, Gang(Gary) <ga...@apache.org>
Authored: Sat Mar 10 22:10:20 2018 -0800
Committer: Wang, Gang(Gary) <ga...@apache.org>
Committed: Sat Mar 10 22:10:20 2018 -0800
----------------------------------------------------------------------
.../DurableSinglyLinkedListNGPrintTest.java | 94 ++------------------
.../DurableSinglyLinkedListNGSortTest.java | 94 ++------------------
2 files changed, 16 insertions(+), 172 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mnemonic/blob/b837b881/mnemonic-computing-services/mnemonic-utilities-service/src/test/java/org/apache/mnemonic/service/computing/DurableSinglyLinkedListNGPrintTest.java
----------------------------------------------------------------------
diff --git a/mnemonic-computing-services/mnemonic-utilities-service/src/test/java/org/apache/mnemonic/service/computing/DurableSinglyLinkedListNGPrintTest.java b/mnemonic-computing-services/mnemonic-utilities-service/src/test/java/org/apache/mnemonic/service/computing/DurableSinglyLinkedListNGPrintTest.java
index 9005022..51f28c9 100644
--- a/mnemonic-computing-services/mnemonic-utilities-service/src/test/java/org/apache/mnemonic/service/computing/DurableSinglyLinkedListNGPrintTest.java
+++ b/mnemonic-computing-services/mnemonic-utilities-service/src/test/java/org/apache/mnemonic/service/computing/DurableSinglyLinkedListNGPrintTest.java
@@ -24,16 +24,13 @@ import java.util.List;
import java.util.Random;
import java.nio.file.Files;
import java.nio.file.Paths;
-import org.apache.commons.lang3.tuple.Pair;
+import org.apache.mnemonic.EntityFactoryProxyHelper;
import org.apache.mnemonic.NonVolatileMemAllocator;
-import org.apache.mnemonic.RestorableAllocator;
-import org.apache.mnemonic.Durable;
import org.apache.mnemonic.EntityFactoryProxy;
import org.apache.mnemonic.Utils;
import org.apache.mnemonic.DurableType;
import org.apache.mnemonic.collections.DurableSinglyLinkedList;
import org.apache.mnemonic.collections.DurableSinglyLinkedListFactory;
-import org.apache.mnemonic.ParameterHolder;
import org.apache.mnemonic.collections.SinglyLinkedNode;
import org.apache.mnemonic.collections.SinglyLinkedNodeFactory;
@@ -71,34 +68,12 @@ public class DurableSinglyLinkedListNGPrintTest {
@SuppressWarnings("unchecked")
@Test(enabled = true)
- public void testDurableSinglyLinkedListWithPerson() {
+ public void testDurableSinglyLinkedListWithPerson() throws NoSuchMethodException, ClassNotFoundException {
int elem_count = 10;
DurableType listgftypes[] = {DurableType.DURABLE};
- EntityFactoryProxy listefproxies[] = {new EntityFactoryProxy() {
- @Override
- public <A extends RestorableAllocator<A>> Durable restore(A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, long phandler, boolean autoreclaim) {
- return PersonFactory.restore(allocator, factoryproxys, gfields, phandler, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable restore(ParameterHolder<A> ph) {
- return PersonFactory.restore(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getHandler(), ph.getAutoReclaim());
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable create(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, boolean autoreclaim) {
- return PersonFactory.create(allocator, factoryproxys, gfields, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable create(ParameterHolder<A> ph) {
- return PersonFactory.create(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getAutoReclaim());
- }
- } };
+ EntityFactoryProxy listefproxies[] = {new EntityFactoryProxyHelper<Person>(Person.class)};
SinglyLinkedNode<Person<Long>> firstnv = SinglyLinkedNodeFactory.create(m_act, listefproxies,
listgftypes, false);
@@ -162,7 +137,7 @@ public class DurableSinglyLinkedListNGPrintTest {
}
@Test(enabled = true)
- public void testDurableSinglyLinkedListValue() {
+ public void testDurableSinglyLinkedListValue() throws NoSuchMethodException, ClassNotFoundException {
long[][] fieldinfo = null;
int elem_count = 10;
@@ -172,65 +147,12 @@ public class DurableSinglyLinkedListNGPrintTest {
EntityFactoryProxy[] elem_efproxies = null;
DurableType linkedgftypes[] = {DurableType.DURABLE, DurableType.DOUBLE};
- EntityFactoryProxy linkedefproxies[] = {new EntityFactoryProxy() {
- @Override
- public <A extends RestorableAllocator<A>> Durable restore(A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, long phandler, boolean autoreclaim) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(gfields, factoryproxys, 1);
- return SinglyLinkedNodeFactory.restore(allocator, dpt.getRight(), dpt.getLeft(), phandler, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable restore(ParameterHolder<A> ph) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(ph.getGenericTypes(),
- ph.getEntityFactoryProxies(), 1);
- return SinglyLinkedNodeFactory.restore(ph.getAllocator(),
- dpt.getRight(), dpt.getLeft(), ph.getHandler(), ph.getAutoReclaim());
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable create(A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, boolean autoreclaim) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(gfields, factoryproxys, 1);
- return SinglyLinkedNodeFactory.create(allocator, dpt.getRight(), dpt.getLeft(), autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable create(ParameterHolder<A> ph) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(ph.getGenericTypes(),
- ph.getEntityFactoryProxies(), 1);
- return SinglyLinkedNodeFactory.create(ph.getAllocator(),
- dpt.getRight(), dpt.getLeft(), ph.getAutoReclaim());
- }
- } };
+ EntityFactoryProxy linkedefproxies[] = {
+ new EntityFactoryProxyHelper<SinglyLinkedNode>(SinglyLinkedNode.class, 1)};
DurableType listgftypes[] = {DurableType.DURABLE, DurableType.DOUBLE};
- EntityFactoryProxy listefproxies[] = {new EntityFactoryProxy() {
- @Override
- public <A extends RestorableAllocator<A>> Durable restore(A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields,
- long phandler, boolean autoreclaim) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(gfields, factoryproxys, 1);
- return DurableSinglyLinkedListFactory.restore(allocator, dpt.getRight(), dpt.getLeft(), phandler, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable restore(ParameterHolder<A> ph) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(ph.getGenericTypes(),
- ph.getEntityFactoryProxies(), 1);
- return DurableSinglyLinkedListFactory.restore(ph.getAllocator(),
- dpt.getRight(), dpt.getLeft(), ph.getHandler(), ph.getAutoReclaim());
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable create(A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, boolean autoreclaim) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(gfields, factoryproxys, 1);
- return DurableSinglyLinkedListFactory.create(allocator, dpt.getRight(), dpt.getLeft(), autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable create(ParameterHolder<A> ph) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(ph.getGenericTypes(),
- ph.getEntityFactoryProxies(), 1);
- return DurableSinglyLinkedListFactory.create(ph.getAllocator(),
- dpt.getRight(), dpt.getLeft(), ph.getAutoReclaim());
- }
- } };
+ EntityFactoryProxy listefproxies[] = {
+ new EntityFactoryProxyHelper<DurableSinglyLinkedList>(DurableSinglyLinkedList.class, 1)};
SinglyLinkedNode<SinglyLinkedNode<Double>> nextnv = null, pre_nextnv = null;
SinglyLinkedNode<Double> elem = null, pre_elem = null, first_elem = null;
http://git-wip-us.apache.org/repos/asf/mnemonic/blob/b837b881/mnemonic-computing-services/mnemonic-utilities-service/src/test/java/org/apache/mnemonic/service/computing/DurableSinglyLinkedListNGSortTest.java
----------------------------------------------------------------------
diff --git a/mnemonic-computing-services/mnemonic-utilities-service/src/test/java/org/apache/mnemonic/service/computing/DurableSinglyLinkedListNGSortTest.java b/mnemonic-computing-services/mnemonic-utilities-service/src/test/java/org/apache/mnemonic/service/computing/DurableSinglyLinkedListNGSortTest.java
index 182b243..06d9427 100644
--- a/mnemonic-computing-services/mnemonic-utilities-service/src/test/java/org/apache/mnemonic/service/computing/DurableSinglyLinkedListNGSortTest.java
+++ b/mnemonic-computing-services/mnemonic-utilities-service/src/test/java/org/apache/mnemonic/service/computing/DurableSinglyLinkedListNGSortTest.java
@@ -24,14 +24,11 @@ import java.util.List;
import java.util.Random;
import java.nio.file.Files;
import java.nio.file.Paths;
-import org.apache.commons.lang3.tuple.Pair;
+import org.apache.mnemonic.EntityFactoryProxyHelper;
import org.apache.mnemonic.NonVolatileMemAllocator;
-import org.apache.mnemonic.RestorableAllocator;
-import org.apache.mnemonic.Durable;
import org.apache.mnemonic.EntityFactoryProxy;
import org.apache.mnemonic.Utils;
import org.apache.mnemonic.DurableType;
-import org.apache.mnemonic.ParameterHolder;
import org.apache.mnemonic.collections.DurableSinglyLinkedList;
import org.apache.mnemonic.collections.DurableSinglyLinkedListFactory;
import org.apache.mnemonic.collections.SinglyLinkedNode;
@@ -72,34 +69,12 @@ public class DurableSinglyLinkedListNGSortTest {
@SuppressWarnings("unchecked")
@Test(enabled = true)
- public void testDurableSinglyLinkedListWithPerson() {
+ public void testDurableSinglyLinkedListWithPerson() throws NoSuchMethodException, ClassNotFoundException {
int elem_count = 20;
DurableType listgftypes[] = {DurableType.DURABLE};
- EntityFactoryProxy listefproxies[] = {new EntityFactoryProxy() {
- @Override
- public <A extends RestorableAllocator<A>> Durable restore(A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, long phandler, boolean autoreclaim) {
- return PersonFactory.restore(allocator, factoryproxys, gfields, phandler, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable restore(ParameterHolder<A> ph) {
- return PersonFactory.restore(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getHandler(), ph.getAutoReclaim());
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable create(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, boolean autoreclaim) {
- return PersonFactory.create(allocator, factoryproxys, gfields, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable create(ParameterHolder<A> ph) {
- return PersonFactory.create(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getAutoReclaim());
- }
- } };
+ EntityFactoryProxy listefproxies[] = {new EntityFactoryProxyHelper<Person>(Person.class)};
SinglyLinkedNode<Person<Long>> firstnv = SinglyLinkedNodeFactory.create(m_act, listefproxies,
listgftypes, false);
@@ -187,7 +162,7 @@ public class DurableSinglyLinkedListNGSortTest {
}
@Test(enabled = true)
- public void testDurableSinglyLinkedListValue() {
+ public void testDurableSinglyLinkedListValue() throws NoSuchMethodException, ClassNotFoundException {
long[][] fieldinfo = null;
int elem_count = 20;
@@ -197,65 +172,12 @@ public class DurableSinglyLinkedListNGSortTest {
EntityFactoryProxy[] elem_efproxies = null;
DurableType linkedgftypes[] = {DurableType.DURABLE, DurableType.DOUBLE};
- EntityFactoryProxy linkedefproxies[] = {new EntityFactoryProxy() {
- @Override
- public <A extends RestorableAllocator<A>> Durable restore(A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, long phandler, boolean autoreclaim) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(gfields, factoryproxys, 1);
- return SinglyLinkedNodeFactory.restore(allocator, dpt.getRight(), dpt.getLeft(), phandler, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable restore(ParameterHolder<A> ph) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(ph.getGenericTypes(),
- ph.getEntityFactoryProxies(), 1);
- return SinglyLinkedNodeFactory.restore(ph.getAllocator(),
- dpt.getRight(), dpt.getLeft(), ph.getHandler(), ph.getAutoReclaim());
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable create(A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, boolean autoreclaim) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(gfields, factoryproxys, 1);
- return SinglyLinkedNodeFactory.create(allocator, dpt.getRight(), dpt.getLeft(), autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable create(ParameterHolder<A> ph) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(ph.getGenericTypes(),
- ph.getEntityFactoryProxies(), 1);
- return SinglyLinkedNodeFactory.create(ph.getAllocator(),
- dpt.getRight(), dpt.getLeft(), ph.getAutoReclaim());
- }
- } };
+ EntityFactoryProxy linkedefproxies[] = {
+ new EntityFactoryProxyHelper<SinglyLinkedNode>(SinglyLinkedNode.class, 1)};
DurableType listgftypes[] = {DurableType.DURABLE, DurableType.DOUBLE};
- EntityFactoryProxy listefproxies[] = {new EntityFactoryProxy() {
- @Override
- public <A extends RestorableAllocator<A>> Durable restore(A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields,
- long phandler, boolean autoreclaim) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(gfields, factoryproxys, 1);
- return DurableSinglyLinkedListFactory.restore(allocator, dpt.getRight(), dpt.getLeft(), phandler, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable restore(ParameterHolder<A> ph) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(ph.getGenericTypes(),
- ph.getEntityFactoryProxies(), 1);
- return DurableSinglyLinkedListFactory.restore(ph.getAllocator(),
- dpt.getRight(), dpt.getLeft(), ph.getHandler(), ph.getAutoReclaim());
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable create(A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, boolean autoreclaim) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(gfields, factoryproxys, 1);
- return DurableSinglyLinkedListFactory.create(allocator, dpt.getRight(), dpt.getLeft(), autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable create(ParameterHolder<A> ph) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(ph.getGenericTypes(),
- ph.getEntityFactoryProxies(), 1);
- return DurableSinglyLinkedListFactory.create(ph.getAllocator(),
- dpt.getRight(), dpt.getLeft(), ph.getAutoReclaim());
- }
- } };
+ EntityFactoryProxy listefproxies[] = {
+ new EntityFactoryProxyHelper<DurableSinglyLinkedList>(DurableSinglyLinkedList.class, 1)};
SinglyLinkedNode<SinglyLinkedNode<Double>> nextnv = null, pre_nextnv = null;
SinglyLinkedNode<Double> elem = null, pre_elem = null, first_elem = null;