summaryrefslogtreecommitdiffstats
path: root/docproc
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2018-04-17 14:40:30 +0200
committerJon Bratseth <bratseth@oath.com>2018-04-17 14:40:30 +0200
commitc8cdfb65631a6814f2d85e18171badc9144ed33e (patch)
treef807a0a4a9fd288c658611e36e5e9bb25e740b65 /docproc
parent6b9f956080484c22e894ee0ccd2692c2f442a333 (diff)
Remove usage of junit.framework
Diffstat (limited to 'docproc')
-rw-r--r--docproc/src/test/java/com/yahoo/docproc/CallStackTestCase.java38
-rw-r--r--docproc/src/test/java/com/yahoo/docproc/CallbackTestCase.java16
-rw-r--r--docproc/src/test/java/com/yahoo/docproc/DocumentProcessingAbstractTestCase.java9
-rw-r--r--docproc/src/test/java/com/yahoo/docproc/FailingDocumentProcessingTestCase.java12
-rw-r--r--docproc/src/test/java/com/yahoo/docproc/FailingDocumentProcessingWithoutExceptionTestCase.java9
-rw-r--r--docproc/src/test/java/com/yahoo/docproc/FailingPermanentlyDocumentProcessingTestCase.java15
-rw-r--r--docproc/src/test/java/com/yahoo/docproc/FailingWithErrorTestCase.java10
-rw-r--r--docproc/src/test/java/com/yahoo/docproc/NotAcceptingNewProcessingsTestCase.java11
-rw-r--r--docproc/src/test/java/com/yahoo/docproc/ProcessingUpdateTestCase.java9
-rw-r--r--docproc/src/test/java/com/yahoo/docproc/SimpleDocumentProcessingTestCase.java11
-rw-r--r--docproc/src/test/java/com/yahoo/docproc/TransientFailureTestCase.java8
-rw-r--r--docproc/src/test/java/com/yahoo/docproc/proxy/SchemaMappingAndAccessesTest.java33
12 files changed, 127 insertions, 54 deletions
diff --git a/docproc/src/test/java/com/yahoo/docproc/CallStackTestCase.java b/docproc/src/test/java/com/yahoo/docproc/CallStackTestCase.java
index 350b4549c50..20cd935ad9b 100644
--- a/docproc/src/test/java/com/yahoo/docproc/CallStackTestCase.java
+++ b/docproc/src/test/java/com/yahoo/docproc/CallStackTestCase.java
@@ -1,15 +1,24 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.docproc;
+import org.junit.Before;
+import org.junit.Test;
+
import java.util.Iterator;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
/**
* Tests call stacks
*
* @author bratseth
*/
-@SuppressWarnings({"unchecked","rawtypes"})
-public class CallStackTestCase extends junit.framework.TestCase {
+@SuppressWarnings("rawtypes")
+public class CallStackTestCase {
private CallStack callStack, insertStack;
@@ -17,11 +26,8 @@ public class CallStackTestCase extends junit.framework.TestCase {
private DocumentProcessor processor2, noProcessor;
- public CallStackTestCase(String name) {
- super(name);
- }
-
- protected void setUp() {
+ @Before
+ public void setUp() {
callStack = new CallStack();
call1 = new Call(new TestDocumentProcessor());
processor2 = new TestDocumentProcessor();
@@ -39,6 +45,7 @@ public class CallStackTestCase extends junit.framework.TestCase {
insertStack.addLast(insert1).addLast(insert2).addLast(insert3);
}
+ @Test
public void testFind() {
assertSame(call2, callStack.findCall(processor2));
assertSame(call2, callStack.findCall(processor2.getId()));
@@ -47,6 +54,7 @@ public class CallStackTestCase extends junit.framework.TestCase {
assertNull(callStack.findCall(new TestDocumentProcessor()));
}
+ @Test
public void testAddBefore() {
callStack.addBefore(call2, newCall);
Iterator i = callStack.iterator();
@@ -57,6 +65,7 @@ public class CallStackTestCase extends junit.framework.TestCase {
assertFalse(i.hasNext());
}
+ @Test
public void testAddStackBefore() {
callStack.addBefore(call2, insertStack);
Iterator i = callStack.iterator();
@@ -69,6 +78,7 @@ public class CallStackTestCase extends junit.framework.TestCase {
assertFalse(i.hasNext());
}
+ @Test
public void testAddAfter() {
callStack.addAfter(call2, newCall);
Iterator i = callStack.iterator();
@@ -79,6 +89,7 @@ public class CallStackTestCase extends junit.framework.TestCase {
assertFalse(i.hasNext());
}
+ @Test
public void testAddStackAfter() {
callStack.addAfter(call2, insertStack);
Iterator i = callStack.iterator();
@@ -91,6 +102,7 @@ public class CallStackTestCase extends junit.framework.TestCase {
assertFalse(i.hasNext());
}
+ @Test
public void testAddBeforeFirst() {
callStack.addBefore(call1, newCall);
Iterator i = callStack.iterator();
@@ -101,6 +113,7 @@ public class CallStackTestCase extends junit.framework.TestCase {
assertFalse(i.hasNext());
}
+ @Test
public void testAddStackBeforeFirst() {
callStack.addBefore(call1, insertStack);
Iterator i = callStack.iterator();
@@ -113,6 +126,7 @@ public class CallStackTestCase extends junit.framework.TestCase {
assertFalse(i.hasNext());
}
+ @Test
public void testAddAfterLast() {
callStack.addAfter(call3, newCall);
Iterator i = callStack.iterator();
@@ -123,6 +137,7 @@ public class CallStackTestCase extends junit.framework.TestCase {
assertFalse(i.hasNext());
}
+ @Test
public void testAddStackAfterLast() {
callStack.addAfter(call3, insertStack);
Iterator i = callStack.iterator();
@@ -135,6 +150,7 @@ public class CallStackTestCase extends junit.framework.TestCase {
assertFalse(i.hasNext());
}
+ @Test
public void testAddBeforeNonExisting() {
callStack.addBefore(noCall, newCall);
Iterator i = callStack.iterator();
@@ -145,6 +161,7 @@ public class CallStackTestCase extends junit.framework.TestCase {
assertFalse(i.hasNext());
}
+ @Test
public void testAddStackBeforeNonExisting() {
callStack.addBefore(noCall, insertStack);
Iterator i = callStack.iterator();
@@ -157,6 +174,7 @@ public class CallStackTestCase extends junit.framework.TestCase {
assertFalse(i.hasNext());
}
+ @Test
public void testAddAfterNonExisting() {
callStack.addAfter(noCall, newCall);
Iterator i = callStack.iterator();
@@ -167,6 +185,7 @@ public class CallStackTestCase extends junit.framework.TestCase {
assertFalse(i.hasNext());
}
+ @Test
public void testAddStackAfterNonExisting() {
callStack.addAfter(noCall, insertStack);
Iterator i = callStack.iterator();
@@ -179,6 +198,7 @@ public class CallStackTestCase extends junit.framework.TestCase {
assertFalse(i.hasNext());
}
+ @Test
public void testRemove() {
callStack.remove(call1);
Iterator i = callStack.iterator();
@@ -187,6 +207,7 @@ public class CallStackTestCase extends junit.framework.TestCase {
assertFalse(i.hasNext());
}
+ @Test
public void testRemoveNonExisting() {
callStack.remove(noCall);
Iterator i = callStack.iterator();
@@ -196,6 +217,7 @@ public class CallStackTestCase extends junit.framework.TestCase {
assertFalse(i.hasNext());
}
+ @Test
public void testContains() {
callStack.addLast(newCall);
assertTrue(callStack.contains(call1));
@@ -205,6 +227,7 @@ public class CallStackTestCase extends junit.framework.TestCase {
assertFalse(callStack.contains(noCall));
}
+ @Test
public void testPop() {
assertEquals(call1, callStack.pop());
assertEquals(call2, callStack.pop());
@@ -225,6 +248,7 @@ public class CallStackTestCase extends junit.framework.TestCase {
assertNull(callStack.pop());
}
+ @Test
public void testGetLastPopped() {
CallStack stakk = new CallStack();
assertNull(stakk.getLastPopped());
diff --git a/docproc/src/test/java/com/yahoo/docproc/CallbackTestCase.java b/docproc/src/test/java/com/yahoo/docproc/CallbackTestCase.java
index 679c91946f7..929ccf908ed 100644
--- a/docproc/src/test/java/com/yahoo/docproc/CallbackTestCase.java
+++ b/docproc/src/test/java/com/yahoo/docproc/CallbackTestCase.java
@@ -2,26 +2,30 @@
package com.yahoo.docproc;
import com.yahoo.document.DataType;
-import com.yahoo.document.Document;
import com.yahoo.document.DocumentId;
import com.yahoo.document.DocumentOperation;
import com.yahoo.document.DocumentPut;
import com.yahoo.document.DocumentType;
import com.yahoo.document.datatypes.StringFieldValue;
+import org.junit.Before;
+import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
+import static org.junit.Assert.assertEquals;
+
/**
- * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a>
+ * @author Einar M R Rosenvinge
*/
-public class CallbackTestCase extends junit.framework.TestCase {
+public class CallbackTestCase {
+
private DocumentPut put1;
private DocumentPut put2;
private List<DocumentOperation> operations = new ArrayList<>(2);
DocprocService service;
-
+ @Before
public void setUp() {
service = new DocprocService("callback");
service.setCallStack(new CallStack().addNext(new TestCallbackDp()));
@@ -36,6 +40,7 @@ public class CallbackTestCase extends junit.framework.TestCase {
operations.add(new DocumentPut(type, new DocumentId("doc:callback:test:4")));
}
+ @Test
public void testProcessingWithCallbackSingleDoc() {
ProcessingEndpoint drecv = new TestProcessingEndpoint();
@@ -45,6 +50,7 @@ public class CallbackTestCase extends junit.framework.TestCase {
assertEquals(new StringFieldValue("received"), put1.getDocument().getFieldValue("status"));
}
+ @Test
public void testProcessingWithCallbackMultipleDocs() {
ProcessingEndpoint drecv = new TestProcessingEndpoint();
@@ -62,6 +68,7 @@ public class CallbackTestCase extends junit.framework.TestCase {
return processing;
}
+ @Test
public void testProcessingWithCallbackProcessing() {
ProcessingEndpoint drecv = new TestProcessingEndpoint();
@@ -87,4 +94,5 @@ public class CallbackTestCase extends junit.framework.TestCase {
public static class TestCallbackDp extends com.yahoo.docproc.SimpleDocumentProcessor {
}
+
}
diff --git a/docproc/src/test/java/com/yahoo/docproc/DocumentProcessingAbstractTestCase.java b/docproc/src/test/java/com/yahoo/docproc/DocumentProcessingAbstractTestCase.java
index a3ab5614dd3..687dae9f6e9 100644
--- a/docproc/src/test/java/com/yahoo/docproc/DocumentProcessingAbstractTestCase.java
+++ b/docproc/src/test/java/com/yahoo/docproc/DocumentProcessingAbstractTestCase.java
@@ -2,23 +2,20 @@
package com.yahoo.docproc;
import com.yahoo.document.DataType;
-import com.yahoo.document.Document;
import com.yahoo.document.DocumentId;
import com.yahoo.document.DocumentOperation;
import com.yahoo.document.DocumentPut;
import com.yahoo.document.DocumentType;
import com.yahoo.document.datatypes.StringFieldValue;
+import static org.junit.Assert.assertEquals;
+
/**
* Convenience superclass of document processor test cases
*
* @author bratseth
*/
-public abstract class DocumentProcessingAbstractTestCase extends junit.framework.TestCase {
-
- public DocumentProcessingAbstractTestCase(String name) {
- super(name);
- }
+public abstract class DocumentProcessingAbstractTestCase {
/**
* Asserts that a document processing service works
diff --git a/docproc/src/test/java/com/yahoo/docproc/FailingDocumentProcessingTestCase.java b/docproc/src/test/java/com/yahoo/docproc/FailingDocumentProcessingTestCase.java
index 74b6ecb534d..9ab59ae7c34 100644
--- a/docproc/src/test/java/com/yahoo/docproc/FailingDocumentProcessingTestCase.java
+++ b/docproc/src/test/java/com/yahoo/docproc/FailingDocumentProcessingTestCase.java
@@ -2,28 +2,26 @@
package com.yahoo.docproc;
import com.yahoo.document.DataType;
-import com.yahoo.document.Document;
import com.yahoo.document.DocumentId;
-import com.yahoo.document.DocumentOperation;
import com.yahoo.document.DocumentPut;
import com.yahoo.document.DocumentType;
import com.yahoo.document.datatypes.StringFieldValue;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
/**
* Tests a document processing where some processings fail with an exception
*
* @author bratseth
*/
-public class FailingDocumentProcessingTestCase extends junit.framework.TestCase {
-
- public FailingDocumentProcessingTestCase(String name) {
- super(name);
- }
+public class FailingDocumentProcessingTestCase {
/**
* Tests chaining of some processors, and execution of the processors
* on some documents
*/
+ @Test
public void testFailingProcessing() {
// Set up service programmatically
DocprocService service = new DocprocService("failing");
diff --git a/docproc/src/test/java/com/yahoo/docproc/FailingDocumentProcessingWithoutExceptionTestCase.java b/docproc/src/test/java/com/yahoo/docproc/FailingDocumentProcessingWithoutExceptionTestCase.java
index 40d777f324d..920a210f099 100644
--- a/docproc/src/test/java/com/yahoo/docproc/FailingDocumentProcessingWithoutExceptionTestCase.java
+++ b/docproc/src/test/java/com/yahoo/docproc/FailingDocumentProcessingWithoutExceptionTestCase.java
@@ -2,28 +2,25 @@
package com.yahoo.docproc;
import com.yahoo.document.DataType;
-import com.yahoo.document.Document;
import com.yahoo.document.DocumentId;
import com.yahoo.document.DocumentOperation;
import com.yahoo.document.DocumentPut;
import com.yahoo.document.DocumentType;
import com.yahoo.document.datatypes.StringFieldValue;
+import org.junit.Test;
/**
* Tests a document processing where some processings fail with an exception
*
- * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M. R. Rosenvinge</a>
+ * @author Einar M. R. Rosenvinge
*/
public class FailingDocumentProcessingWithoutExceptionTestCase extends junit.framework.TestCase {
- public FailingDocumentProcessingWithoutExceptionTestCase(String name) {
- super(name);
- }
-
/**
* Tests chaining of some processors, and execution of the processors
* on some documents
*/
+ @Test
public void testFailingProcessing() {
// Set up service programmatically
DocprocService service = new DocprocService("failing-no-exception");
diff --git a/docproc/src/test/java/com/yahoo/docproc/FailingPermanentlyDocumentProcessingTestCase.java b/docproc/src/test/java/com/yahoo/docproc/FailingPermanentlyDocumentProcessingTestCase.java
index 3f04a0fa85f..087e5c6856c 100644
--- a/docproc/src/test/java/com/yahoo/docproc/FailingPermanentlyDocumentProcessingTestCase.java
+++ b/docproc/src/test/java/com/yahoo/docproc/FailingPermanentlyDocumentProcessingTestCase.java
@@ -8,22 +8,25 @@ import com.yahoo.document.DocumentOperation;
import com.yahoo.document.DocumentPut;
import com.yahoo.document.DocumentType;
import com.yahoo.document.datatypes.StringFieldValue;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
/**
* Tests a document processing where some processings fail permanently
*
- * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M. R. Rosenvinge</a>
+ * @author Einar M. R. Rosenvinge
*/
-public class FailingPermanentlyDocumentProcessingTestCase extends junit.framework.TestCase {
-
- public FailingPermanentlyDocumentProcessingTestCase(String name) {
- super(name);
- }
+public class FailingPermanentlyDocumentProcessingTestCase {
/**
* Tests chaining of some processors, and execution of the processors
* on some documents
*/
+ @Test
public void testFailingProcessing() {
// Set up service programmatically
DocprocService service = new DocprocService("failing-permanently");
diff --git a/docproc/src/test/java/com/yahoo/docproc/FailingWithErrorTestCase.java b/docproc/src/test/java/com/yahoo/docproc/FailingWithErrorTestCase.java
index f063c11f2c4..59dcb583e2a 100644
--- a/docproc/src/test/java/com/yahoo/docproc/FailingWithErrorTestCase.java
+++ b/docproc/src/test/java/com/yahoo/docproc/FailingWithErrorTestCase.java
@@ -7,12 +7,17 @@ import com.yahoo.document.DocumentId;
import com.yahoo.document.DocumentOperation;
import com.yahoo.document.DocumentPut;
import com.yahoo.document.DocumentType;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
/**
- * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a>
+ * @author Einar M R Rosenvinge
*/
-public class FailingWithErrorTestCase extends junit.framework.TestCase {
+public class FailingWithErrorTestCase {
+ @Test
public void testErrors() {
DocprocService service = new DocprocService("failing");
DocumentProcessor first = new ErrorThrowingProcessor();
@@ -34,7 +39,6 @@ public class FailingWithErrorTestCase extends junit.framework.TestCase {
assertEquals(0, service.getQueueSize());
}
assertEquals(0, service.getQueueSize());
-
}
private class ErrorThrowingProcessor extends DocumentProcessor {
diff --git a/docproc/src/test/java/com/yahoo/docproc/NotAcceptingNewProcessingsTestCase.java b/docproc/src/test/java/com/yahoo/docproc/NotAcceptingNewProcessingsTestCase.java
index d20e372e849..0c7122b417e 100644
--- a/docproc/src/test/java/com/yahoo/docproc/NotAcceptingNewProcessingsTestCase.java
+++ b/docproc/src/test/java/com/yahoo/docproc/NotAcceptingNewProcessingsTestCase.java
@@ -1,11 +1,17 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.docproc;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
/**
- * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a>
+ * @author Einar M R Rosenvinge
*/
-public class NotAcceptingNewProcessingsTestCase extends junit.framework.TestCase {
+public class NotAcceptingNewProcessingsTestCase {
+ @Test
public void testNotAccepting() {
DocprocService service = new DocprocService("habla");
service.setCallStack(new CallStack());
@@ -24,4 +30,5 @@ public class NotAcceptingNewProcessingsTestCase extends junit.framework.TestCase
}
assertEquals(1, service.getQueueSize());
}
+
}
diff --git a/docproc/src/test/java/com/yahoo/docproc/ProcessingUpdateTestCase.java b/docproc/src/test/java/com/yahoo/docproc/ProcessingUpdateTestCase.java
index 131b3fbf865..9a3a29e55b1 100644
--- a/docproc/src/test/java/com/yahoo/docproc/ProcessingUpdateTestCase.java
+++ b/docproc/src/test/java/com/yahoo/docproc/ProcessingUpdateTestCase.java
@@ -14,23 +14,27 @@ import com.yahoo.document.datatypes.StringFieldValue;
import com.yahoo.document.update.AssignValueUpdate;
import com.yahoo.document.update.FieldUpdate;
import com.yahoo.document.update.ValueUpdate;
+import org.junit.Test;
import java.util.List;
import java.util.StringTokenizer;
+import static org.junit.Assert.assertEquals;
+
/**
* Simple test case for testing that processing of both documents and
* document updates works.
*
- * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a>
+ * @author Einar M R Rosenvinge
*/
-public class ProcessingUpdateTestCase extends junit.framework.TestCase {
+public class ProcessingUpdateTestCase {
private DocumentPut put;
private DocumentUpdate update;
private DocumentTypeManager dtm;
+ @Test
public void testProcessingUpdates() {
DocumentType articleType = new DocumentType("article");
articleType.addField(new Field("body", DataType.STRING, true));
@@ -100,4 +104,5 @@ public class ProcessingUpdateTestCase extends junit.framework.TestCase {
return title;
}
}
+
}
diff --git a/docproc/src/test/java/com/yahoo/docproc/SimpleDocumentProcessingTestCase.java b/docproc/src/test/java/com/yahoo/docproc/SimpleDocumentProcessingTestCase.java
index 747da135e76..1f106f09b3f 100644
--- a/docproc/src/test/java/com/yahoo/docproc/SimpleDocumentProcessingTestCase.java
+++ b/docproc/src/test/java/com/yahoo/docproc/SimpleDocumentProcessingTestCase.java
@@ -3,6 +3,10 @@ package com.yahoo.docproc;
import com.yahoo.component.chain.dependencies.After;
import com.yahoo.docproc.Accesses.Field.Tree;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
/**
* Tests the basic operation of the docproc service
@@ -11,14 +15,11 @@ import com.yahoo.docproc.Accesses.Field.Tree;
*/
public class SimpleDocumentProcessingTestCase extends DocumentProcessingAbstractTestCase {
- public SimpleDocumentProcessingTestCase(String name) {
- super(name);
- }
-
/**
* Tests chaining of some processors, and execution of the processors
* on some documents
*/
+ @Test
public void testSimpleProcessing() {
// Set up service programmatically
DocprocService service = new DocprocService("simple");
@@ -31,6 +32,7 @@ public class SimpleDocumentProcessingTestCase extends DocumentProcessingAbstract
assertProcessingWorks(service);
}
+ @Test
public void testAnnotationBasic() {
Accesses accesses = MyDocProc.class.getAnnotation(Accesses.class);
After after = MyDocProc.class.getAnnotation(After.class);
@@ -58,5 +60,6 @@ public class SimpleDocumentProcessingTestCase extends DocumentProcessingAbstract
return null;
}
}
+
}
diff --git a/docproc/src/test/java/com/yahoo/docproc/TransientFailureTestCase.java b/docproc/src/test/java/com/yahoo/docproc/TransientFailureTestCase.java
index 64447eea856..706ff0082af 100644
--- a/docproc/src/test/java/com/yahoo/docproc/TransientFailureTestCase.java
+++ b/docproc/src/test/java/com/yahoo/docproc/TransientFailureTestCase.java
@@ -6,18 +6,23 @@ import com.yahoo.document.DocumentId;
import com.yahoo.document.DocumentOperation;
import com.yahoo.document.DocumentPut;
import com.yahoo.document.DocumentType;
+import org.junit.Before;
+import org.junit.Test;
/**
- * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a>
+ * @author Einar M R Rosenvinge
*/
public class TransientFailureTestCase extends junit.framework.TestCase {
+
DocumentType type;
+ @Before
public void setUp() {
type = new DocumentType("test");
type.addField("boo", DataType.STRING);
}
+ @Test
public void testTransientFailures() {
DocprocService service = new DocprocService("transfail");
CallStack stack = new CallStack();
@@ -94,4 +99,5 @@ public class TransientFailureTestCase extends junit.framework.TestCase {
}
}
}
+
}
diff --git a/docproc/src/test/java/com/yahoo/docproc/proxy/SchemaMappingAndAccessesTest.java b/docproc/src/test/java/com/yahoo/docproc/proxy/SchemaMappingAndAccessesTest.java
index ed1304d8cad..05a03480173 100644
--- a/docproc/src/test/java/com/yahoo/docproc/proxy/SchemaMappingAndAccessesTest.java
+++ b/docproc/src/test/java/com/yahoo/docproc/proxy/SchemaMappingAndAccessesTest.java
@@ -33,9 +33,17 @@ import com.yahoo.document.datatypes.StringFieldValue;
import com.yahoo.document.datatypes.Struct;
import com.yahoo.document.datatypes.StructuredFieldValue;
import com.yahoo.document.update.FieldUpdate;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
@SuppressWarnings("unchecked")
-public class SchemaMappingAndAccessesTest extends junit.framework.TestCase {
+public class SchemaMappingAndAccessesTest {
private Document getDoc() {
DocumentType type = new DocumentType("album");
@@ -79,6 +87,7 @@ public class SchemaMappingAndAccessesTest extends junit.framework.TestCase {
return doc;
}
+ @Test
public void testMappingArrays() {
Document doc = getDoc();
DocumentProcessor proc = new TestMappingArrayProcessor();
@@ -111,6 +120,7 @@ public class SchemaMappingAndAccessesTest extends junit.framework.TestCase {
assertEquals(new StringFieldValue("tylden"), ((Array<StringFieldValue>) doc.getFieldValue("labels")).get(1));
}
+ @Test
public void testMappingStructsInArrays() {
Document doc = getDoc();
DocumentProcessor proc = new TestMappingStructInArrayProcessor();
@@ -183,7 +193,7 @@ public class SchemaMappingAndAccessesTest extends junit.framework.TestCase {
}
-
+ @Test
public void testMappingSpanTrees() {
Document doc = getDoc();
Map<String, String> fieldMap = new HashMap<>();
@@ -224,6 +234,7 @@ public class SchemaMappingAndAccessesTest extends junit.framework.TestCase {
//assertSame(bona, mapped.getFieldValue("a"));
}
+ @Test
public void testMappedDoc() {
Document doc = getDoc();
Map<String, String> fieldMap = new HashMap<>();
@@ -268,6 +279,7 @@ public class SchemaMappingAndAccessesTest extends junit.framework.TestCase {
assertEquals(mapped.getFieldValue("a"), null);
}
+ @Test
public void testMappedDocAPI() {
Document doc = getDoc();
Map<String, String> fieldMap = new HashMap<>();
@@ -310,7 +322,8 @@ public class SchemaMappingAndAccessesTest extends junit.framework.TestCase {
mapped.setDataType(new DocumentType("newType"));
assertEquals(doc.getDataType().getName(), "newType");
}
-
+
+ @Test
public void testMappedDocUpdateAPI() {
Document doc = getDoc();
DocumentType type = doc.getDataType();
@@ -336,7 +349,8 @@ public class SchemaMappingAndAccessesTest extends junit.framework.TestCase {
assertEquals(pup.size(), dud.size());
assertEquals(pup.getWrappedDocumentOperation().getId().toString(), "doc:map:test:1");
}
-
+
+ @Test
public void testMappedDocStruct() {
StructDataType materialsStructType = new StructDataType("materialstype");
materialsStructType.addField(new com.yahoo.document.Field("ceiling", DataType.STRING));
@@ -388,6 +402,7 @@ public class SchemaMappingAndAccessesTest extends junit.framework.TestCase {
//assertEquals(new StringFieldValue("LevangerKommuneStyre"), mapped.getFieldValue("c"));
}
+ @Test
public void testSchemaMap() {
SchemaMap map = new SchemaMap();
map.addMapping("mychain", "com.yahoo.MyDocProc", "mydoctype", "inDoc1", "inProc1");
@@ -408,6 +423,7 @@ public class SchemaMappingAndAccessesTest extends junit.framework.TestCase {
assertEquals("inDoc2", dMap.get("inProc2"));
}
+ @Test
public void testSchemaMapKey() {
SchemaMap map = new SchemaMap(null);
SchemaMap.SchemaMapKey key1 = map.new SchemaMapKey("chain", "docproc", "doctype", "from");
@@ -416,7 +432,8 @@ public class SchemaMappingAndAccessesTest extends junit.framework.TestCase {
assertTrue(key1.equals(key1_1));
assertFalse(key1.equals(key2));
}
-
+
+ @Test
public void testSchemaMapConfig() {
SchemaMap map = new SchemaMap(null);
SchemamappingConfig.Builder scb = new SchemamappingConfig.Builder();
@@ -425,7 +442,8 @@ public class SchemaMappingAndAccessesTest extends junit.framework.TestCase {
map.configure(new SchemamappingConfig(scb));
assertEquals(map.chainMap("mychain", "mydocproc").get(new Pair<>("mydoctype", "myinprocessor")), "myindoc");
}
-
+
+ @Test
public void testSchemaMapNoDocType() {
SchemaMap map = new SchemaMap(null);
map.addMapping("mychain", "com.yahoo.MyDocProc", null, "inDoc1", "inProc1");
@@ -438,6 +456,7 @@ public class SchemaMappingAndAccessesTest extends junit.framework.TestCase {
assertEquals("inDoc2", dMap.get("inProc2"));
}
+ @Test
public void testProxyAndSecure() {
DocumentProcessor procOK = new TestDPSecure();
Map<Pair<String, String>, String> fieldMap = new HashMap<>();
@@ -449,6 +468,7 @@ public class SchemaMappingAndAccessesTest extends junit.framework.TestCase {
assertEquals(proxyDoc.getFieldValue("title").toString(), "MyTitle MyTitle");
}
+ @Test
public void testProxyAndSecureSecureFailing() {
DocumentProcessor procInsecure = new TestDPInsecure();
Map<Pair<String, String>, String> fieldMap = new HashMap<>();
@@ -469,6 +489,7 @@ public class SchemaMappingAndAccessesTest extends junit.framework.TestCase {
* To make it less likely to break schema mapping, we enforce that ProxyDocument does wrap every public
* non-static, non-final method on Document and StructuredFieldValue
*/
+ @Test
public void testVerifyProxyDocumentOverridesEverything() {
List<Method> allPublicFromProxyDocument = new ArrayList<>();
for (Method m : ProxyDocument.class.getDeclaredMethods()) {