diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-08-21 07:59:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-21 07:59:11 +0200 |
commit | 415e9e002e4207809247b6bd5f9419960ab43ed1 (patch) | |
tree | 0111e27fb0b3e494401a98279d36c58b48c3d265 /document/src/tests | |
parent | be5759f30affe0e38ea4c442586a457f9cb698f8 (diff) |
Revert "doc: -> id:"
Diffstat (limited to 'document/src/tests')
94 files changed, 1021 insertions, 234 deletions
diff --git a/document/src/tests/base/documentid_test.cpp b/document/src/tests/base/documentid_test.cpp index 741a490210f..9994fa5b60b 100644 --- a/document/src/tests/base/documentid_test.cpp +++ b/document/src/tests/base/documentid_test.cpp @@ -42,6 +42,11 @@ void checkType(const string &id, const string &doc_type) { EXPECT_EQUAL(doc_type, doc_id.getDocType()); } +TEST("require that doc id can be parsed") { + const string id = "doc:" + ns + ":" + ns_id; + checkId(id, IdString::DOC, ns, ns_id); +} + TEST("require that id id can be parsed") { const string id = "id:" + ns + ":" + type + "::" + ns_id; checkId(id, IdString::ID, ns, ns_id); @@ -53,6 +58,10 @@ TEST("require that we allow ':' in namespace specific part") { string id="id:" + ns + ":" + type + "::" + nss; checkId(id, IdString::ID, ns, nss); checkType(id, type); + + id="doc:" + ns + ":" + nss; + checkId(id, IdString::DOC, ns, nss); + } TEST("require that id id can specify location") { @@ -148,6 +157,11 @@ TEST("require that id strings reports features (hasNumber, hasGroup)") { EXPECT_FALSE(none.getScheme().hasGroup()); EXPECT_EQUAL("foo", none.getScheme().getNamespaceSpecific()); + none = DocumentId("doc:ns:foo"); + EXPECT_FALSE(none.getScheme().hasNumber()); + EXPECT_FALSE(none.getScheme().hasGroup()); + EXPECT_EQUAL("foo", none.getScheme().getNamespaceSpecific()); + DocumentId user("id:ns:type:n=42:foo"); EXPECT_TRUE(user.getScheme().hasNumber()); EXPECT_FALSE(user.getScheme().hasGroup()); diff --git a/document/src/tests/buckettest.cpp b/document/src/tests/buckettest.cpp index 763575ece4c..72e0a38c749 100644 --- a/document/src/tests/buckettest.cpp +++ b/document/src/tests/buckettest.cpp @@ -79,10 +79,9 @@ TEST(BucketTest, testGetBit) TEST(BucketTest, testBucketGeneration) { BucketIdFactory factory; - DocumentId doc1("id:ns:type::1"); - DocumentId doc2("id:ns2:type::1"); - DocumentId doc3("id:ns:type2::1"); - DocumentId doc4("id:ns:type::2"); + DocumentId doc1("doc:ns:spec"); + DocumentId doc2("doc:ns2:spec"); + DocumentId doc3("doc:ns:spec2"); DocumentId userDoc1("id:ns:mytype:n=18:spec"); DocumentId userDoc2("id:ns2:mytype:n=18:spec2"); DocumentId userDoc3("id:ns:mytype:n=19:spec"); @@ -90,10 +89,9 @@ TEST(BucketTest, testBucketGeneration) DocumentId groupDoc2("id:ns2:mytype:g=yahoo.com:spec2"); DocumentId groupDoc3("id:ns:mytype:g=yahoo:spec"); - BucketId docBucket1 = factory.getBucketId(doc1); - BucketId docBucket2 = factory.getBucketId(doc2); - BucketId docBucket3 = factory.getBucketId(doc3); - BucketId docBucket4 = factory.getBucketId(doc4); + BucketId docBucket1(factory.getBucketId(doc1)); + BucketId docBucket2(factory.getBucketId(doc2)); + BucketId docBucket3(factory.getBucketId(doc3)); BucketId userDocBucket1(factory.getBucketId(userDoc1)); BucketId userDocBucket2(factory.getBucketId(userDoc2)); BucketId userDocBucket3(factory.getBucketId(userDoc3)); @@ -123,30 +121,28 @@ TEST(BucketTest, testBucketGeneration) groupDocBucket3.setUsedBits(16); EXPECT_EQ(Hex(0x4000000000001f24ull), Hex(groupDocBucket3.getId())); - EXPECT_EQ(Hex(0xe9362c053842cac4ull), Hex(docBucket1.getRawId())); - EXPECT_EQ(Hex(0xe960b5773842cac4ull), Hex(docBucket2.getRawId())); - EXPECT_EQ(Hex(0xe8daaf763842cac4ull), Hex(docBucket3.getRawId())); - EXPECT_EQ(Hex(0xeb5016ab8d721ec8ull), Hex(docBucket4.getRawId())); + EXPECT_EQ(Hex(0xe980c9abd5fd8d11ull), Hex(docBucket1.getRawId())); + EXPECT_EQ(Hex(0xeafe870c5f9c37b9ull), Hex(docBucket2.getRawId())); + EXPECT_EQ(Hex(0xeaebe9473ecbcd69ull), Hex(docBucket3.getRawId())); docBucket1.setUsedBits(16); - EXPECT_EQ(Hex(0x400000000000cac4ull), Hex(docBucket1.getId())); + EXPECT_EQ(Hex(0x4000000000008d11ull), Hex(docBucket1.getId())); docBucket2.setUsedBits(16); - EXPECT_EQ(Hex(0x400000000000cac4ull), Hex(docBucket2.getId())); + EXPECT_EQ(Hex(0x40000000000037b9ull), Hex(docBucket2.getId())); docBucket3.setUsedBits(16); - EXPECT_EQ(Hex(0x400000000000cac4ull), Hex(docBucket3.getId())); - docBucket4.setUsedBits(16); - EXPECT_EQ(Hex(0x4000000000001ec8ull), Hex(docBucket4.getId())); + EXPECT_EQ(Hex(0x400000000000cd69ull), Hex(docBucket3.getId())); } TEST(BucketTest, testBucketSerialization) { BucketIdFactory factory; - DocumentId doc("id:ns:test::1"); + DocumentId doc(DocIdString("ns", "spec")); BucketId bucket(factory.getBucketId(doc)); std::ostringstream ost; ost << bucket.getRawId(); - EXPECT_EQ(std::string("16910189189155441348"), ost.str()); + EXPECT_EQ(std::string("16825669947722927377"), + ost.str()); BucketId::Type id; std::istringstream ist(ost.str()); diff --git a/document/src/tests/cpp-globalidbucketids.txt b/document/src/tests/cpp-globalidbucketids.txt index 0798f88faf8..40bb505ad16 100644 --- a/document/src/tests/cpp-globalidbucketids.txt +++ b/document/src/tests/cpp-globalidbucketids.txt @@ -1,3 +1,26 @@ +doc:ns:specific - gid(0x2c01a21163cb7d0ce85fddd6) - BucketId(0xeadd5fe811a2012c) +doc:another:specific - gid(0xcd2ba528d1135e40605ce372) - BucketId(0xeae35c6028a52bcd) +doc:ns:another - gid(0x1d5324270601e76a7a1f58b7) - BucketId(0xeb581f7a2724531d) +doc:ns:0 - gid(0x87817cf2f6d05976505e74be) - BucketId(0xea745e50f27c8187) +doc:ns:1 - gid(0x911a03b253cb5b1c283b2024) - BucketId(0xe8203b28b2031a91) +doc:ns:2 - gid(0x1d82e56be428cda364ed6875) - BucketId(0xe968ed646be5821d) +doc:ns:3 - gid(0xf8d223e4e68e0d571b95a6d8) - BucketId(0xe8a6951be423d2f8) +doc:ns:4 - gid(0xdab024c2e41747dc92a1b8e3) - BucketId(0xebb8a192c224b0da) +doc:ns:5 - gid(0xdb9023e3080c94901734f948) - BucketId(0xe8f93417e32390db) +doc:ns:6 - gid(0xbd84ae30c63f7fdef9edbf69) - BucketId(0xe9bfedf930ae84bd) +doc:ns:7 - gid(0x463977cf070d06e204b8166f) - BucketId(0xeb16b804cf773946) +doc:ns:8 - gid(0x46cf1241cec694a0c07af5e2) - BucketId(0xeaf57ac04112cf46) +doc:ns:9 - gid(0x909b77593ef7b309a06d22ef) - BucketId(0xeb226da059779b90) +doc:ns:10 - gid(0x4888f0b3796031003a8840fb) - BucketId(0xeb40883ab3f08848) +doc:ns:11 - gid(0x18fae4cbc359765470c10fcd) - BucketId(0xe90fc170cbe4fa18) +doc:ns:12 - gid(0xc902059d4ac551616aea5431) - BucketId(0xe954ea6a9d0502c9) +doc:ns:13 - gid(0x639b6aa505018e29ca4e342d) - BucketId(0xe9344ecaa56a9b63) +doc:ns:14 - gid(0x5fa1f02be952a9d0811e8ddd) - BucketId(0xe98d1e812bf0a15f) +doc:ns:15 - gid(0xfbc851f81830365c84229c49) - BucketId(0xe99c2284f851c8fb) +doc:ns:16 - gid(0x06313edc8072f4495329fb5b) - BucketId(0xebfb2953dc3e3106) +doc:ns:17 - gid(0x3d9df3e147de3a5fbd5664e4) - BucketId(0xe86456bde1f39d3d) +doc:ns:18 - gid(0x75512f41a8dbde1c8f86a97d) - BucketId(0xe9a9868f412f5175) +doc:ns:19 - gid(0x15ae3aa9919b2e1e46d84ada) - BucketId(0xea4ad846a93aae15) id:ns:type::specific - gid(0x2067d966823ebdfb79537da1) - BucketId(0xe97d537966d96720) id:another:type::specific - gid(0x2067d9664809eb39a3b72218) - BucketId(0xe822b7a366d96720) id:ns:type::another - gid(0xb32d73e53e034c30c58a01ff) - BucketId(0xeb018ac5e5732db3) diff --git a/document/src/tests/data/document-cpp-currentversion-lz4-9.dat b/document/src/tests/data/document-cpp-currentversion-lz4-9.dat Binary files differindex 7b0650996db..5f31ac0ab78 100644 --- a/document/src/tests/data/document-cpp-currentversion-lz4-9.dat +++ b/document/src/tests/data/document-cpp-currentversion-lz4-9.dat diff --git a/document/src/tests/data/document-cpp-currentversion-uncompressed.dat b/document/src/tests/data/document-cpp-currentversion-uncompressed.dat Binary files differindex 2b39c42f8a4..6a5c5e90b84 100644 --- a/document/src/tests/data/document-cpp-currentversion-uncompressed.dat +++ b/document/src/tests/data/document-cpp-currentversion-uncompressed.dat diff --git a/document/src/tests/data/document-cpp-v7-uncompressed.dat b/document/src/tests/data/document-cpp-v7-uncompressed.dat Binary files differnew file mode 100644 index 00000000000..5f073e33438 --- /dev/null +++ b/document/src/tests/data/document-cpp-v7-uncompressed.dat diff --git a/document/src/tests/data/document-cpp-v8-uncompressed.dat b/document/src/tests/data/document-cpp-v8-uncompressed.dat Binary files differindex 2b39c42f8a4..429334fc102 100644 --- a/document/src/tests/data/document-cpp-v8-uncompressed.dat +++ b/document/src/tests/data/document-cpp-v8-uncompressed.dat diff --git a/document/src/tests/data/serialize-fieldpathupdate-cpp.dat b/document/src/tests/data/serialize-fieldpathupdate-cpp.dat Binary files differindex 025882da825..cf5f20f7a0c 100644 --- a/document/src/tests/data/serialize-fieldpathupdate-cpp.dat +++ b/document/src/tests/data/serialize-fieldpathupdate-cpp.dat diff --git a/document/src/tests/data/serialize-fieldpathupdate-java.dat b/document/src/tests/data/serialize-fieldpathupdate-java.dat Binary files differindex 025882da825..cf5f20f7a0c 100644 --- a/document/src/tests/data/serialize-fieldpathupdate-java.dat +++ b/document/src/tests/data/serialize-fieldpathupdate-java.dat diff --git a/document/src/tests/data/serializejava-compressed.dat b/document/src/tests/data/serializejava-compressed.dat Binary files differindex 0ac391422ff..0f6cb55ff85 100644 --- a/document/src/tests/data/serializejava-compressed.dat +++ b/document/src/tests/data/serializejava-compressed.dat diff --git a/document/src/tests/data/serializejava.dat b/document/src/tests/data/serializejava.dat Binary files differindex 10873c9d905..53ef6a8fbc2 100644 --- a/document/src/tests/data/serializejava.dat +++ b/document/src/tests/data/serializejava.dat diff --git a/document/src/tests/data/serializejavawithannotations.dat b/document/src/tests/data/serializejavawithannotations.dat Binary files differindex fe683d1580e..a648b72404f 100644 --- a/document/src/tests/data/serializejavawithannotations.dat +++ b/document/src/tests/data/serializejavawithannotations.dat diff --git a/document/src/tests/data/serializeupdatecpp.dat b/document/src/tests/data/serializeupdatecpp.dat Binary files differindex f972b505fb4..73d83b2ab45 100644 --- a/document/src/tests/data/serializeupdatecpp.dat +++ b/document/src/tests/data/serializeupdatecpp.dat diff --git a/document/src/tests/data/serializeupdatejava.dat b/document/src/tests/data/serializeupdatejava.dat Binary files differindex cef1ad96812..20c56228bde 100644 --- a/document/src/tests/data/serializeupdatejava.dat +++ b/document/src/tests/data/serializeupdatejava.dat diff --git a/document/src/tests/data/serializev6.dat b/document/src/tests/data/serializev6.dat Binary files differnew file mode 100644 index 00000000000..555acb9ecc7 --- /dev/null +++ b/document/src/tests/data/serializev6.dat diff --git a/document/src/tests/documentcalculatortestcase.cpp b/document/src/tests/documentcalculatortestcase.cpp index b6ca27f6bc7..744a7556f1b 100644 --- a/document/src/tests/documentcalculatortestcase.cpp +++ b/document/src/tests/documentcalculatortestcase.cpp @@ -24,7 +24,7 @@ TEST_F(DocumentCalculatorTest, testConstant) { auto variables = std::make_unique<select::VariableMap>(); DocumentCalculator calc(getRepo(), "4.0"); - Document doc(*_testRepo.getDocumentType("testdoctype1"), DocumentId("id:ns:testdoctype1::foo")); + Document doc(*_testRepo.getDocumentType("testdoctype1"), DocumentId("doc:test:foo")); EXPECT_EQ(4.0, calc.evaluate(doc, std::move(variables))); } @@ -32,7 +32,7 @@ TEST_F(DocumentCalculatorTest, testSimple) { auto variables = std::make_unique<select::VariableMap>(); DocumentCalculator calc(getRepo(), "(3 + 5) / 2"); - Document doc(*_testRepo.getDocumentType("testdoctype1"), DocumentId("id:ns:testdoctype1::foo")); + Document doc(*_testRepo.getDocumentType("testdoctype1"), DocumentId("doc:test:foo")); EXPECT_EQ(4.0, calc.evaluate(doc, std::move(variables))); } @@ -42,7 +42,7 @@ TEST_F(DocumentCalculatorTest, testVariables) { (*variables)["y"] = 5.0; DocumentCalculator calc(getRepo(), "($x + $y) / 2"); - Document doc(*_testRepo.getDocumentType("testdoctype1"), DocumentId("id:ns:testdoctype1::foo")); + Document doc(*_testRepo.getDocumentType("testdoctype1"), DocumentId("doc:test:foo")); EXPECT_EQ(4.0, calc.evaluate(doc, std::move(variables))); } @@ -53,7 +53,7 @@ TEST_F(DocumentCalculatorTest, testFields) { DocumentCalculator calc(getRepo(), "(testdoctype1.headerval + testdoctype1" ".hfloatval) / testdoctype1.headerlongval"); - Document doc(*_testRepo.getDocumentType("testdoctype1"), DocumentId("id:ns:testdoctype1::foo")); + Document doc(*_testRepo.getDocumentType("testdoctype1"), DocumentId("doc:test:foo")); doc.setValue(doc.getField("headerval"), IntFieldValue(5)); doc.setValue(doc.getField("hfloatval"), FloatFieldValue(3.0)); doc.setValue(doc.getField("headerlongval"), LongFieldValue(2)); @@ -67,7 +67,7 @@ TEST_F(DocumentCalculatorTest, testFieldsDivZero) { DocumentCalculator calc(getRepo(), "(testdoctype1.headerval + testdoctype1" ".hfloatval) / testdoctype1.headerlongval"); - Document doc(*_testRepo.getDocumentType("testdoctype1"), DocumentId("id:ns:testdoctype1::foo")); + Document doc(*_testRepo.getDocumentType("testdoctype1"), DocumentId("doc:test:foo")); doc.setValue(doc.getField("headerval"), IntFieldValue(5)); doc.setValue(doc.getField("hfloatval"), FloatFieldValue(3.0)); doc.setValue(doc.getField("headerlongval"), LongFieldValue(0)); @@ -79,7 +79,7 @@ TEST_F(DocumentCalculatorTest, testDivideByZero) { auto variables = std::make_unique<select::VariableMap>(); DocumentCalculator calc(getRepo(), "(3 + 5) / 0"); - Document doc(*_testRepo.getDocumentType("testdoctype1"), DocumentId("id:ns:testdoctype1::foo")); + Document doc(*_testRepo.getDocumentType("testdoctype1"), DocumentId("doc:test:foo")); EXPECT_THROW(calc.evaluate(doc, std::move(variables)), vespalib::IllegalArgumentException); } @@ -88,7 +88,7 @@ TEST_F(DocumentCalculatorTest, testModByZero) { auto variables = std::make_unique<select::VariableMap>(); DocumentCalculator calc(getRepo(), "(3 + 5) % 0"); - Document doc(*_testRepo.getDocumentType("testdoctype1"), DocumentId("id:ns:testdoctype1::foo")); + Document doc(*_testRepo.getDocumentType("testdoctype1"), DocumentId("doc:test:foo")); EXPECT_THROW(calc.evaluate(doc, std::move(variables)), vespalib::IllegalArgumentException); } @@ -98,7 +98,7 @@ TEST_F(DocumentCalculatorTest, testFieldNotSet) { DocumentCalculator calc(getRepo(), "(testdoctype1.headerval + testdoctype1" ".hfloatval) / testdoctype1.headerlongval"); - Document doc(*_testRepo.getDocumentType("testdoctype1"), DocumentId("id:ns:testdoctype1::foo")); + Document doc(*_testRepo.getDocumentType("testdoctype1"), DocumentId("doc:test:foo")); doc.setValue(doc.getField("hfloatval"), FloatFieldValue(3.0)); doc.setValue(doc.getField("headerlongval"), LongFieldValue(2)); EXPECT_THROW(calc.evaluate(doc, std::move(variables)), @@ -111,7 +111,7 @@ TEST_F(DocumentCalculatorTest, testFieldNotFound) { "(testdoctype1.mynotfoundfield + testdoctype1" ".hfloatval) / testdoctype1.headerlongval"); - Document doc(*_testRepo.getDocumentType("testdoctype1"), DocumentId("id:ns:testdoctype1::foo")); + Document doc(*_testRepo.getDocumentType("testdoctype1"), DocumentId("doc:test:foo")); doc.setValue(doc.getField("hfloatval"), FloatFieldValue(3.0)); doc.setValue(doc.getField("headerlongval"), LongFieldValue(2)); EXPECT_THROW(calc.evaluate(doc, std::move(variables)), @@ -122,7 +122,7 @@ TEST_F(DocumentCalculatorTest, testByteSubtractionZeroResult) { auto variables = std::make_unique<select::VariableMap>(); DocumentCalculator calc(getRepo(), "testdoctype1.byteval - 3"); - Document doc(*_testRepo.getDocumentType("testdoctype1"), DocumentId("id:ns:testdoctype1::foo")); + Document doc(*_testRepo.getDocumentType("testdoctype1"), DocumentId("doc:test:foo")); doc.setValue(doc.getField("byteval"), ByteFieldValue(3)); EXPECT_EQ(0.0, calc.evaluate(doc, std::move(variables))); } diff --git a/document/src/tests/documentidtest.cpp b/document/src/tests/documentidtest.cpp index a6255cc148a..9befac431f6 100644 --- a/document/src/tests/documentidtest.cpp +++ b/document/src/tests/documentidtest.cpp @@ -23,6 +23,14 @@ TEST(DocumentIdTest, generateJavaComplianceFile) { // Generate file with globalids and bucket ID of various document ids, // which java will use to ensure equal implementations. std::ostringstream ost; + writeGlobalIdBucketId(ost, "doc:ns:specific"); + writeGlobalIdBucketId(ost, "doc:another:specific"); + writeGlobalIdBucketId(ost, "doc:ns:another"); + for (uint32_t i=0; i<20; ++i) { + std::ostringstream ost2; + ost2 << i; + writeGlobalIdBucketId(ost, "doc:ns:"+ost2.str()); + } writeGlobalIdBucketId(ost, "id:ns:type::specific"); writeGlobalIdBucketId(ost, "id:another:type::specific"); writeGlobalIdBucketId(ost, "id:ns:type::another"); @@ -43,16 +51,17 @@ TEST(DocumentIdTest, generateJavaComplianceFile) TEST(DocumentIdTest, testOutput) { - DocumentId id("id:ns:news::crawler:http://www.yahoo.com"); + DocumentId id(DocIdString("crawler", "http://www.yahoo.com")); std::ostringstream ost; ost << id; - std::string expected("id:ns:news::crawler:http://www.yahoo.com"); + std::string expected("doc:crawler:http://www.yahoo.com"); EXPECT_EQ(expected, ost.str()); EXPECT_EQ(vespalib::string(expected), id.toString()); - expected = "DocumentId(id = id:ns:news::crawler:http://www.yahoo.com, gid(0xa516a5abd7c7fa26944b72f7))"; + expected = "DocumentId(id = doc:crawler:http://www.yahoo.com, " + "gid(0x928baffb39cf32004542fb60))"; EXPECT_EQ(expected, static_cast<Printable&>(id).toString(true)); } @@ -68,11 +77,11 @@ namespace { TEST(DocumentIdTest, testEqualityOperator) { - std::string uri("id:ns:news::crawler:http://www.yahoo.com"); + std::string uri(DocIdString("crawler", "http://www.yahoo.com").toString()); DocumentId id1(uri); DocumentId id2(uri); - DocumentId id3("id:ns:news::crawler:http://www.yahoo.no/"); + DocumentId id3("doc:crawler:http://www.yahoo.no/"); EXPECT_EQ(id1, id2); EXPECT_NE(id1, id3); @@ -80,11 +89,11 @@ TEST(DocumentIdTest, testEqualityOperator) TEST(DocumentIdTest, testCopying) { - std::string uri("id:crawler:news::http://www.yahoo.com"); + std::string uri(DocIdString("crawler", "http://www.yahoo.com/").toString()); DocumentId id1(uri); DocumentId id2(id1); - DocumentId id3("id:ns:foo::"); + DocumentId id3("doc:ns:foo"); id3 = id2; EXPECT_EQ(id1, id2); @@ -93,8 +102,21 @@ TEST(DocumentIdTest, testCopying) TEST(DocumentIdTest, checkNtnuGlobalId) { - DocumentId id("id:ns:news::crawler:http://www.ntnu.no/"); - EXPECT_EQ(vespalib::string("gid(0x1e9d7fc69ac6c1da44dd87e0)"), id.getGlobalId().toString()); + DocumentId id("doc:crawler:http://www.ntnu.no/"); + EXPECT_EQ(vespalib::string("gid(0xb8863740be14221c0ac77896)"), id.getGlobalId().toString()); +} + +TEST(DocumentIdTest, testDocGlobalId) +{ + // Test that location of doc scheme documents are set correctly, such + // that the location is the first bytes of the original GID. + std::string id("doc:crawler:http://www.ntnu.no/"); + DocumentId did(id); + + unsigned char key[16]; + fastc_md5sum(reinterpret_cast<const unsigned char*>(id.c_str()), id.size(), key); + + EXPECT_EQ(GlobalId(key), did.getGlobalId()); } TEST(DocumentIdTest, freestandingLocationFromGroupNameFuncMatchesIdLocation) diff --git a/document/src/tests/documentselectparsertest.cpp b/document/src/tests/documentselectparsertest.cpp index 79b849c5ba9..97921109c60 100644 --- a/document/src/tests/documentselectparsertest.cpp +++ b/document/src/tests/documentselectparsertest.cpp @@ -132,8 +132,10 @@ void DocumentSelectParserTest::createDocs() { _doc.clear(); - _doc.push_back(createDoc("testdoctype1", "id:myspace:testdoctype1::anything", 24, 2.0, "foo", "bar", 0)); // DOC 0 - _doc.push_back(createDoc("testdoctype1", "id:anotherspace:testdoctype1::foo", 13, 4.1, "bar", "foo", 0)); // DOC 1 + _doc.push_back(createDoc( + "testdoctype1", "doc:myspace:anything", 24, 2.0, "foo", "bar", 0)); // DOC 0 + _doc.push_back(createDoc( + "testdoctype1", "doc:anotherspace:foo", 13, 4.1, "bar", "foo", 0)); // DOC 1 // Add some arrays and structs to doc 1 { StructFieldValue sval(_doc.back()->getField("mystruct").getDataType()); @@ -206,8 +208,10 @@ DocumentSelectParserTest::createDocs() _doc.back()->getField("structarray").getDataType()); _doc.back()->setValue("structarray", aval); } - _doc.push_back(createDoc("testdoctype1", "id:myspace:testdoctype1:g=yahoo:bar", 14, 2.4, "Yet", "\xE4\xB8\xBA\xE4\xBB\x80", 0)); // DOC 3 - _doc.push_back(createDoc("testdoctype2", "id:myspace:testdoctype2::inheriteddoc", 10, 1.4, "inherited", "")); // DOC 4 + _doc.push_back(createDoc( + "testdoctype1", "id:myspace:testdoctype1:g=yahoo:bar", 14, 2.4, "Yet", "\xE4\xB8\xBA\xE4\xBB\x80", 0)); // DOC 3 + _doc.push_back(createDoc( + "testdoctype2", "doc:myspace:inheriteddoc", 10, 1.4, "inherited", "")); // DOC 4 _doc.push_back(createDoc( "testdoctype1", "id:footype:testdoctype1:n=123456789:aardvark", 10, 1.4, "inherited", "", 0)); // DOC 5 @@ -218,7 +222,7 @@ DocumentSelectParserTest::createDocs() "testdoctype1", "id:footype:testdoctype1:n=1234:highlong", 10, 1.4, "inherited", "", -2651257743)); // DOC 7 _doc.push_back(createDoc( // DOC 8. As DOC 0 but with version 2. - "testdoctype1", "id:myspace:testdoctype1::anything", 24, 2.0, "foo", "bar", 0)); + "testdoctype1", "doc:myspace:anything", 24, 2.0, "foo", "bar", 0)); _doc.push_back(createDoc( "testdoctype1", "id:footype:testdoctype1:n=12345:foo", 10, 1.4, "inherited", "", 42)); // DOC 9 @@ -227,11 +231,16 @@ DocumentSelectParserTest::createDocs() 10, 1.4, "inherited", "", 42)); // DOC 10 _update.clear(); - _update.push_back(createUpdate("testdoctype1", "id:myspace:testdoctype1::anything", 20, "hmm")); - _update.push_back(createUpdate("testdoctype1", "id:anotherspace:testdoctype1::foo", 10, "foo")); - _update.push_back(createUpdate("testdoctype1", "id:myspace:testdoctype1:n=1234:footype1", 0, "foo")); - _update.push_back(createUpdate("testdoctype1", "id:myspace:testdoctype1:g=yahoo:bar", 3, "\xE4\xBA\xB8\xE4\xBB\x80")); - _update.push_back(createUpdate("testdoctype2", "id:myspace:testdoctype2::inheriteddoc", 10, "bar")); + _update.push_back(createUpdate( + "testdoctype1", "doc:myspace:anything", 20, "hmm")); + _update.push_back(createUpdate( + "testdoctype1", "doc:anotherspace:foo", 10, "foo")); + _update.push_back(createUpdate( + "testdoctype1", "id:myspace:testdoctype1:n=1234:footype1", 0, "foo")); + _update.push_back(createUpdate( + "testdoctype1", "id:myspace:testdoctype1:g=yahoo:bar", 3, "\xE4\xBA\xB8\xE4\xBB\x80")); + _update.push_back(createUpdate( + "testdoctype2", "doc:myspace:inheriteddoc", 10, "bar")); } namespace { @@ -613,14 +622,14 @@ void DocumentSelectParserTest::testOperators2() createDocs(); // Id values - PARSEI("id == \"id:myspace:testdoctype1::anything\"", *_doc[0], True); - PARSEI(" iD== \"id:myspace:testdoctype1::anything\" ", *_doc[0], True); - PARSEI("id == \"id:myspa:testdoctype1::nything\"", *_doc[0], False); - PARSEI("Id.scHeme == \"doc\"", *_doc[0], False); - PARSEI("id.scheme == \"id\"", *_doc[0], True); + PARSEI("id == \"doc:myspace:anything\"", *_doc[0], True); + PARSEI(" iD== \"doc:myspace:anything\" ", *_doc[0], True); + PARSEI("id == \"doc:myspa:nything\"", *_doc[0], False); + PARSEI("Id.scHeme == \"doc\"", *_doc[0], True); + PARSEI("id.scheme == \"id\"", *_doc[0], False); PARSEI("id.type == \"testdoctype1\"", *_doc[9], True); PARSEI("id.type == \"wrong_type\"", *_doc[9], False); - PARSEI("id.type == \"unknown\"", *_doc[0], False); + PARSEI("id.type == \"unknown\"", *_doc[0], Invalid); PARSEI("Id.namespaCe == \"myspace\"", *_doc[0], True); PARSEI("id.NaMespace == \"pace\"", *_doc[0], False); PARSEI("id.specific == \"anything\"", *_doc[0], True); @@ -638,17 +647,17 @@ void DocumentSelectParserTest::testOperators3() createDocs(); { std::ostringstream ost; - ost << "id.bucket == " << BucketId(16, 0xe1f0).getId() ; + ost << "id.bucket == " << BucketId(16, 4006).getId() ; PARSEI(ost.str(), *_doc[0], True); } { std::ostringstream ost; - ost << "id.bucket == " << BucketId(18, 0xe1f0).getId() ; + ost << "id.bucket == " << BucketId(17, 4006).getId() ; PARSEI(ost.str(), *_doc[0], False); } { std::ostringstream ost; - ost << "id.bucket == " << BucketId(18, 0x2e1f0).getId() ; + ost << "id.bucket == " << BucketId(17, 69542).getId() ; PARSEI(ost.str(), *_doc[0], True); } { @@ -1099,11 +1108,11 @@ void DocumentSelectParserTest::testDocumentUpdates2() createDocs(); // Id values - PARSEI("id == \"id:myspace:testdoctype1::anything\"", *_update[0], True); - PARSEI(" iD== \"id:myspace:testdoctype1::anything\" ", *_update[0], True); - PARSEI("id == \"id:myspa:testdoctype1::nything\"", *_update[0], False); - PARSEI("Id.scHeme == \"doc\"", *_update[0], False); - PARSEI("id.scheme == \"id\"", *_update[0], True); + PARSEI("id == \"doc:myspace:anything\"", *_update[0], True); + PARSEI(" iD== \"doc:myspace:anything\" ", *_update[0], True); + PARSEI("id == \"doc:myspa:nything\"", *_update[0], False); + PARSEI("Id.scHeme == \"doc\"", *_update[0], True); + PARSEI("id.scheme == \"id\"", *_update[0], False); PARSEI("Id.namespaCe == \"myspace\"", *_update[0], True); PARSEI("id.NaMespace == \"pace\"", *_update[0], False); PARSEI("id.specific == \"anything\"", *_update[0], True); @@ -1114,7 +1123,7 @@ void DocumentSelectParserTest::testDocumentUpdates2() PARSEI("id.bucket == 1234", *_update[0], False); { std::ostringstream ost; - ost << "id.bucket == " << BucketId(16, 0xe1f0).getId(); + ost << "id.bucket == " << BucketId(16, 4006).getId(); PARSEI(ost.str(), *_update[0], True); } PARSEI("id.bucket == \"foo\"", *_update[0], Invalid); @@ -1192,7 +1201,8 @@ TEST_F(DocumentSelectParserTest, testUtf8) // boost::u32regex rx = boost::make_u32regex("H.kon"); // EXPECT_EQ(true, boost::u32regex_match(utf8name, rx)); - _doc.push_back(createDoc("testdoctype1", "id:myspace:testdoctype1::utf8doc", 24, 2.0, utf8name, "bar")); + _doc.push_back(createDoc( + "testdoctype1", "doc:myspace:utf8doc", 24, 2.0, utf8name, "bar")); // PARSE("testdoctype1.hstringval = \"H?kon\"", *_doc[_doc.size()-1], True); // PARSE("testdoctype1.hstringval =~ \"H.kon\"", *_doc[_doc.size()-1], True); } diff --git a/document/src/tests/documenttestcase.cpp b/document/src/tests/documenttestcase.cpp index fa59358f6d3..089ab5a2a2d 100644 --- a/document/src/tests/documenttestcase.cpp +++ b/document/src/tests/documenttestcase.cpp @@ -112,7 +112,7 @@ TEST(DocumentTest, testTraversing) type.addField(primitive1); type.addField(structl1s1); - Document doc(type, DocumentId("id:ns:test::1")); + Document doc(type, DocumentId("doc::testdoc")); doc.setValue(primitive1, IntFieldValue(1)); StructFieldValue l1s1(struct3); @@ -184,7 +184,7 @@ TEST(DocumentTest, testVariables) iiiaV.add(iiaV); } - Document doc(type, DocumentId("id:ns:test::1")); + Document doc(type, DocumentId("doc::testdoc")); doc.setValue(iiiarrF, iiiaV); { @@ -291,7 +291,7 @@ TEST(DocumentTest, testModifyDocument) type.addField(primitive1); type.addField(structl1s1); - Document::UP doc(new Document(type, DocumentId("id:ns:test::1"))); + Document::UP doc(new Document(type, DocumentId("doc::testdoc"))); doc->setValue(primitive1, IntFieldValue(1)); StructFieldValue l1s1(struct3); @@ -364,7 +364,7 @@ TEST(DocumentTest, testSimpleUsage) type->addField(strF); DocumentTypeRepo repo(*type); - Document value(*repo.getDocumentType("test"), DocumentId("id:ns:test::1")); + Document value(*repo.getDocumentType("test"), DocumentId("doc::testdoc")); // Initially empty EXPECT_EQ(size_t(0), value.getSetFieldCount()); @@ -393,7 +393,7 @@ TEST(DocumentTest, testSimpleUsage) value2.deserialize(repo, *buffer); EXPECT_TRUE(value2.hasValue(intF)); EXPECT_EQ(value, value2); - EXPECT_EQ(DocumentId("id:ns:test::1"), value2.getId()); + EXPECT_EQ(DocumentId("doc::testdoc"), value2.getId()); // Various ways of removing { @@ -446,11 +446,11 @@ TEST(DocumentTest, testSimpleUsage) // Output EXPECT_EQ( - std::string("Document(id:ns:test::1, DocumentType(test))"), + std::string("Document(doc::testdoc, DocumentType(test))"), value.toString(false)); EXPECT_EQ( std::string( -" Document(id:ns:test::1\n" +" Document(doc::testdoc\n" " DocumentType(test, id -877171244)\n" " : DocumentType(document) {\n" " StructDataType(test.header, id 306916075) {\n" @@ -465,7 +465,7 @@ TEST(DocumentTest, testSimpleUsage) " " + value.toString(true, " ")); EXPECT_EQ( std::string( - "<document documenttype=\"test\" documentid=\"id:ns:test::1\">\n" + "<document documenttype=\"test\" documentid=\"doc::testdoc\">\n" " <int>1</int>\n" " <long>2</long>\n" "</document>"), @@ -483,10 +483,11 @@ TEST(DocumentTest, testSimpleUsage) // Refuse to accept non-document types try{ StructDataType otherType("foo", 4); - Document value6(otherType, DocumentId("id:ns:foo::1")); + Document value6(otherType, DocumentId("doc::")); FAIL() << "Didn't complain about non-document type"; } catch (std::exception& e) { - EXPECT_THAT(e.what(), HasSubstr("Cannot generate a document with non-document type")); + EXPECT_THAT(e.what(), HasSubstr("Cannot generate a document with " + "non-document type")); } // Refuse to set wrong types @@ -562,7 +563,7 @@ TEST(DocumentTest, testReadSerializedFile) ByteBuffer buf(len); lseek(fd,0,SEEK_SET); if (read(fd, buf.getBuffer(), len) != (ssize_t)len) { - throw vespalib::Exception("read failed"); + throw vespalib::Exception("read failed"); } close(fd); @@ -596,7 +597,7 @@ TEST(DocumentTest, testReadSerializedFileCompressed) ByteBuffer buf(len); lseek(fd,0,SEEK_SET); if (read(fd, buf.getBuffer(), len) != len) { - throw vespalib::Exception("read failed"); + throw vespalib::Exception("read failed"); } close(fd); @@ -644,7 +645,6 @@ namespace { * When adding new fields to the documents, use the version tagged with each * file to ignore these field for old types. */ - TEST(DocumentTest,testReadSerializedAllVersions) { const int array_id = 1650586661; @@ -679,7 +679,8 @@ TEST(DocumentTest,testReadSerializedAllVersions) // Create a memory instance of document { - Document doc(*docType, DocumentId("id:ns:serializetest::http://test.doc.id/")); + Document doc(*docType, + DocumentId("doc:serializetest:http://test.doc.id/")); doc.set("intfield", 5); doc.set("floatfield", -9.23); doc.set("stringfield", "This is a string."); @@ -687,7 +688,8 @@ TEST(DocumentTest,testReadSerializedAllVersions) doc.set("doublefield", 98374532.398820); doc.set("bytefield", -2); doc.setValue("rawfield", RawFieldValue("RAW DATA", 8)); - Document docInDoc(*docInDocType, DocumentId("id:ns:docindoc::http://doc.in.doc/")); + Document docInDoc(*docInDocType, + DocumentId("doc:serializetest:http://doc.in.doc/")); docInDoc.set("stringindocfield", "Elvis is dead"); //docInDoc.setCompression(CompressionConfig(CompressionConfig::NONE, 0, 0)); doc.setValue("docfield", docInDoc); @@ -733,6 +735,7 @@ TEST(DocumentTest,testReadSerializedAllVersions) std::vector<TestDoc> tests; tests.push_back(TestDoc(TEST_PATH("data/document-cpp-v8-uncompressed.dat"), 8)); + tests.push_back(TestDoc(TEST_PATH("data/document-cpp-v7-uncompressed.dat"), 7)); tests.push_back(TestDoc(jpath + "document-java-v8-uncompressed.dat", 8)); for (uint32_t i=0; i<tests.size(); ++i) { int version = tests[i]._createdVersion; @@ -746,7 +749,7 @@ TEST(DocumentTest,testReadSerializedAllVersions) ByteBuffer buf(len); lseek(fd,0,SEEK_SET); if (read(fd, buf.getBuffer(), len) != len) { - throw vespalib::Exception("read failed"); + throw vespalib::Exception("read failed"); } close(fd); @@ -830,7 +833,9 @@ TEST(DocumentTest, testGenerateSerializedFile) { const std::string file_name = TEST_PATH("data/crossplatform-java-cpp-doctypes.cfg"); DocumentTypeRepo repo(readDocumenttypesConfig(file_name)); - Document doc(*repo.getDocumentType("serializetest"), DocumentId("id:ns:serializetest::http://test.doc.id/")); + Document doc(*repo.getDocumentType("serializetest"), + DocumentId(DocIdString("serializetest", + "http://test.doc.id/"))); doc.set("intfield", 5); doc.set("floatfield", -9.23); @@ -843,7 +848,8 @@ TEST(DocumentTest, testGenerateSerializedFile) const DocumentType *docindoc_type = repo.getDocumentType("docindoc"); EXPECT_TRUE(docindoc_type); - Document embedDoc(*docindoc_type, DocumentId("id:ns:docindoc::http://embedded")); + Document embedDoc(*docindoc_type, + DocumentId(DocIdString("docindoc", "http://embedded"))); doc.setValue("docfield", embedDoc); @@ -868,7 +874,7 @@ TEST(DocumentTest, testGenerateSerializedFile) int fd = open((serializedDir + "/serializecpp.dat").c_str(), O_WRONLY | O_TRUNC | O_CREAT, 0644); if (write(fd, buf->getBuffer(), buf->getPos()) != (ssize_t)buf->getPos()) { - throw vespalib::Exception("write failed"); + throw vespalib::Exception("write failed"); } close(fd); @@ -877,16 +883,16 @@ TEST(DocumentTest, testGenerateSerializedFile) fd = open((serializedDir + "/serializecppsplit_header.dat").c_str(), O_WRONLY | O_TRUNC | O_CREAT, 0644); if (write(fd, hBuf.getBuffer(), hBuf.getPos()) != (ssize_t)hBuf.getPos()) { - throw vespalib::Exception("write failed"); + throw vespalib::Exception("write failed"); } close(fd); ByteBuffer bBuf(getSerializedSizeBody(doc)); doc.serializeBody(bBuf); - fd = open((serializedDir+ "/serializecppsplit_body.dat").c_str(), + fd = open(TEST_PATH("/serializecppsplit_body.dat").c_str(), O_WRONLY | O_TRUNC | O_CREAT, 0644); if (write(fd, bBuf.getBuffer(), bBuf.getPos()) != (ssize_t)bBuf.getPos()) { - throw vespalib::Exception("write failed"); + throw vespalib::Exception("write failed"); } close(fd); @@ -898,10 +904,10 @@ TEST(DocumentTest, testGenerateSerializedFile) doc.serialize(lz4buf); lz4buf.flip(); - fd = open((serializedDir + "/serializecpp-lz4-level9.dat").c_str(), + fd = open(TEST_PATH("/serializecpp-lz4-level9.dat").c_str(), O_WRONLY | O_TRUNC | O_CREAT, 0644); if (write(fd, lz4buf.getBufferAtPos(), lz4buf.getRemaining()) != (ssize_t)lz4buf.getRemaining()) { - throw vespalib::Exception("write failed"); + throw vespalib::Exception("write failed"); } close(fd); } @@ -909,14 +915,15 @@ TEST(DocumentTest, testGenerateSerializedFile) TEST(DocumentTest, testGetURIFromSerialized) { TestDocRepo test_repo; - Document doc(*test_repo.getDocumentType("testdoctype1"), DocumentId("id:ns:testdoctype1::1")); + Document doc(*test_repo.getDocumentType("testdoctype1"), + DocumentId("doc:ns:testdoc")); { std::unique_ptr<ByteBuffer> serialized = doc.serialize(); serialized->flip(); EXPECT_EQ( - vespalib::string("id:ns:testdoctype1::1"), + vespalib::string(DocIdString("ns", "testdoc").toString()), Document::getIdFromSerialized(*serialized).toString()); EXPECT_EQ(vespalib::string("testdoctype1"), @@ -930,7 +937,8 @@ TEST(DocumentTest, testGetURIFromSerialized) serialized->flip(); Document doc2(test_repo.getTypeRepo(), *serialized, false, NULL); - EXPECT_EQ(vespalib::string("id:ns:testdoctype1::1"), doc2.getId().toString()); + EXPECT_EQ( + vespalib::string(DocIdString("ns", "testdoc").toString()), doc2.getId().toString()); EXPECT_EQ(vespalib::string("testdoctype1"), doc2.getType().getName()); } } @@ -939,7 +947,8 @@ TEST(DocumentTest, testBogusserialize) { TestDocRepo test_repo; try { - auto buf = std::make_unique<ByteBuffer>("aoifjweprjwoejr203r+2+4r823++!",100); + std::unique_ptr<ByteBuffer> buf( + new ByteBuffer("aoifjweprjwoejr203r+2+4r823++!",100)); Document doc(test_repo.getTypeRepo(), *buf); FAIL() << "Failed to throw exception deserializing bogus data"; } catch (DeserializeException& e) { @@ -947,7 +956,7 @@ TEST(DocumentTest, testBogusserialize) } try { - auto buf = std::make_unique<ByteBuffer>("",0); + std::unique_ptr<ByteBuffer> buf(new ByteBuffer("",0)); Document doc(test_repo.getTypeRepo(), *buf); FAIL() << "Failed to throw exception deserializing empty buffer"; } catch (DeserializeException& e) { @@ -958,17 +967,19 @@ TEST(DocumentTest, testBogusserialize) TEST(DocumentTest, testCRC32) { TestDocRepo test_repo; - Document doc(*test_repo.getDocumentType("testdoctype1"), DocumentId("id:ns:testdoctype1::crawler:http://www.ntnu.no/")); + Document doc(*test_repo.getDocumentType("testdoctype1"), + DocumentId(DocIdString("crawler", "http://www.ntnu.no/"))); - doc.setValue(doc.getField("hstringval"), StringFieldValue("bla bla bla bla bla")); + doc.setValue(doc.getField("hstringval"), + StringFieldValue("bla bla bla bla bla")); uint32_t crc = doc.calculateChecksum(); - EXPECT_EQ(3987392271u, crc); + EXPECT_EQ(277496115u, crc); std::unique_ptr<ByteBuffer> buf = doc.serialize(); buf->flip(); - int pos = 30; + int pos = 20; // Corrupt serialization. buf->getBuffer()[pos] ^= 72; @@ -991,11 +1002,12 @@ TEST(DocumentTest, testHasChanged) { TestDocRepo test_repo; Document doc(*test_repo.getDocumentType("testdoctype1"), - DocumentId("id:ns:testdoctype1::crawler:http://www.ntnu.no/")); + DocumentId(DocIdString("crawler", "http://www.ntnu.no/"))); // Before deserialization we are changed. EXPECT_TRUE(doc.hasChanged()); - doc.setValue(doc.getField("hstringval"), StringFieldValue("bla bla bla bla bla")); + doc.setValue(doc.getField("hstringval"), + StringFieldValue("bla bla bla bla bla")); // Still changed after setting a value of course. EXPECT_TRUE(doc.hasChanged()); @@ -1066,7 +1078,8 @@ TEST(DocumentTest, testSliceSerialize) // bytebuffer. TestDocMan testDocMan; Document::UP doc = testDocMan.createDocument(); - Document::UP doc2 = testDocMan.createDocument("Some other content", "id:ns:testdoctype1::anotherdoc"); + Document::UP doc2 = testDocMan.createDocument( + "Some other content", "doc:test:anotherdoc"); ArrayFieldValue val(doc2->getField("rawarray").getDataType()); val.add(RawFieldValue("hei", 3)); @@ -1078,13 +1091,15 @@ TEST(DocumentTest, testSliceSerialize) doc->serialize(buf); EXPECT_EQ(getSerializedSize(*doc), buf.getPos()); doc2->serialize(buf); - EXPECT_EQ(getSerializedSize(*doc) + getSerializedSize(*doc2), buf.getPos()); + EXPECT_EQ(getSerializedSize(*doc) + getSerializedSize(*doc2), + buf.getPos()); buf.flip(); Document doc3(testDocMan.getTypeRepo(), buf); EXPECT_EQ(getSerializedSize(*doc), buf.getPos()); Document doc4(testDocMan.getTypeRepo(), buf); - EXPECT_EQ(getSerializedSize(*doc) + getSerializedSize(*doc2), buf.getPos()); + EXPECT_EQ(getSerializedSize(*doc) + getSerializedSize(*doc2), + buf.getPos()); EXPECT_EQ(*doc, doc3); EXPECT_EQ(*doc2, doc4); @@ -1127,8 +1142,9 @@ TEST(DocumentTest, testCompressionConfigured) Struct("serializetest.body").setId(45) .addField("stringfield", DataType::T_STRING)); DocumentTypeRepo repo(builder.config()); - Document doc_uncompressed(*repo.getDocumentType("serializetest"), - DocumentId("id:ns:serializetest::1")); + Document doc_uncompressed( + *repo.getDocumentType("serializetest"), + DocumentId("doc:test:test")); std::string bigString("compress me"); for (int i = 0; i < 8; ++i) { bigString += bigString; } @@ -1190,7 +1206,7 @@ TEST(DocumentTest, testUnknownEntries) DocumentTypeRepo repo(type2); - Document doc1(type1, DocumentId("id:ns:test::1")); + Document doc1(type1, DocumentId("doc::testdoc")); doc1.setValue(field1, IntFieldValue(1)); doc1.setValue(field2, IntFieldValue(2)); doc1.setValue(field3, IntFieldValue(3)); @@ -1219,12 +1235,12 @@ TEST(DocumentTest, testUnknownEntries) doc3.deserializeBody(repo, body); EXPECT_EQ(std::string( - "<document documenttype=\"test\" documentid=\"id:ns:test::1\">\n" + "<document documenttype=\"test\" documentid=\"doc::testdoc\">\n" "<int3>3</int3>\n" "<int4>4</int4>\n" "</document>"), doc2.toXml()); EXPECT_EQ(std::string( - "<document documenttype=\"test\" documentid=\"id:ns:test::1\">\n" + "<document documenttype=\"test\" documentid=\"doc::testdoc\">\n" "<int3>3</int3>\n" "<int4>4</int4>\n" "</document>"), doc3.toXml()); @@ -1281,7 +1297,7 @@ TEST(DocumentTest, testAnnotationDeserialization) ByteBuffer buf(len); lseek(fd,0,SEEK_SET); if (read(fd, buf.getBuffer(), len) != len) { - throw vespalib::Exception("read failed"); + throw vespalib::Exception("read failed"); } close(fd); diff --git a/document/src/tests/documenttypetestcase.cpp b/document/src/tests/documenttypetestcase.cpp index caddfbc70fc..649367d76f3 100644 --- a/document/src/tests/documenttypetestcase.cpp +++ b/document/src/tests/documenttypetestcase.cpp @@ -118,7 +118,7 @@ TEST(DocumentTypeTest, testMultipleInheritance) EXPECT_TRUE(docType3->hasField("tmp")); EXPECT_TRUE(docType3->hasField("tall")); - Document doc(*docType3, DocumentId("id:ns:test3::1")); + Document doc(*docType3, DocumentId(DocIdString("test", "test"))); IntFieldValue intVal(3); doc.setValue(doc.getField("nalle"), intVal); diff --git a/document/src/tests/documentupdatetestcase.cpp b/document/src/tests/documentupdatetestcase.cpp index b22edfd1ad6..b9568d546c5 100644 --- a/document/src/tests/documentupdatetestcase.cpp +++ b/document/src/tests/documentupdatetestcase.cpp @@ -140,14 +140,14 @@ TEST(DocumentUpdateTest, testSimpleUsage) EXPECT_EQ(fieldUpdate, fieldUpdateCopy); // Test that a document update can be serialized - DocumentUpdate docUpdate(repo, *docType, DocumentId("id:ns:test::1")); + DocumentUpdate docUpdate(repo, *docType, DocumentId("doc::testdoc")); docUpdate.addUpdate(fieldUpdateCopy); ByteBuffer::UP docBuf = serializeHEAD(docUpdate); docBuf->flip(); auto docUpdateCopy(DocumentUpdate::createHEAD(repo, nbostream(docBuf->getBufferAtPos(), docBuf->getRemaining()))); // Create a test document - Document doc(*docType, DocumentId("id:ns:test::1")); + Document doc(*docType, DocumentId("doc::testdoc")); doc.set("bytef", 0); doc.set("intf", 5); ArrayFieldValue array(*arrayType); @@ -158,7 +158,7 @@ TEST(DocumentUpdateTest, testSimpleUsage) // Verify that we can apply simple updates to it { Document updated(doc); - DocumentUpdate upd(repo, *docType, DocumentId("id:ns:test::1")); + DocumentUpdate upd(repo, *docType, DocumentId("doc::testdoc")); upd.addUpdate(FieldUpdate(docType->getField("intf")).addUpdate(ClearValueUpdate())); upd.applyTo(updated); EXPECT_NE(doc, updated); @@ -166,7 +166,7 @@ TEST(DocumentUpdateTest, testSimpleUsage) } { Document updated(doc); - DocumentUpdate upd(repo, *docType, DocumentId("id:ns:test::1")); + DocumentUpdate upd(repo, *docType, DocumentId("doc::testdoc")); upd.addUpdate(FieldUpdate(docType->getField("intf")).addUpdate(AssignValueUpdate(IntFieldValue(15)))); upd.applyTo(updated); EXPECT_NE(doc, updated); @@ -174,7 +174,7 @@ TEST(DocumentUpdateTest, testSimpleUsage) } { Document updated(doc); - DocumentUpdate upd(repo, *docType, DocumentId("id:ns:test::1")); + DocumentUpdate upd(repo, *docType, DocumentId("doc::testdoc")); upd.addUpdate(FieldUpdate(docType->getField("intf")).addUpdate(ArithmeticValueUpdate(ArithmeticValueUpdate::Add, 15))); upd.applyTo(updated); EXPECT_NE(doc, updated); @@ -182,7 +182,7 @@ TEST(DocumentUpdateTest, testSimpleUsage) } { Document updated(doc); - DocumentUpdate upd(repo, *docType, DocumentId("id:ns:test::1")); + DocumentUpdate upd(repo, *docType, DocumentId("doc::testdoc")); upd.addUpdate(FieldUpdate(docType->getField("intarr")).addUpdate(AddValueUpdate(IntFieldValue(4)))); upd.applyTo(updated); EXPECT_NE(doc, updated); @@ -192,7 +192,7 @@ TEST(DocumentUpdateTest, testSimpleUsage) } { Document updated(doc); - DocumentUpdate upd(repo, *docType, DocumentId("id:ns:test::1")); + DocumentUpdate upd(repo, *docType, DocumentId("doc::testdoc")); upd.addUpdate(FieldUpdate(docType->getField("intarr")).addUpdate(RemoveValueUpdate(IntFieldValue(3)))); upd.applyTo(updated); EXPECT_NE(doc, updated); @@ -202,7 +202,7 @@ TEST(DocumentUpdateTest, testSimpleUsage) } { Document updated(doc); - DocumentUpdate upd(repo, *docType, DocumentId("id:ns:test::1")); + DocumentUpdate upd(repo, *docType, DocumentId("doc::testdoc")); upd.addUpdate(FieldUpdate(docType->getField("bytef")) .addUpdate(ArithmeticValueUpdate(ArithmeticValueUpdate::Add, 15))); upd.applyTo(updated); @@ -409,9 +409,9 @@ WeightedSetAutoCreateFixture::~WeightedSetAutoCreateFixture() = default; WeightedSetAutoCreateFixture::WeightedSetAutoCreateFixture() : repo(makeConfig()), docType(repo.getDocumentType("test")), - doc(*docType, DocumentId("id:ns:test::1")), + doc(*docType, DocumentId("doc::testdoc")), field(docType->getField("strwset")), - update(repo, *docType, DocumentId("id:ns:test::1")) + update(repo, *docType, DocumentId("doc::testdoc")) { update.addUpdate(FieldUpdate(field) .addUpdate(MapValueUpdate(StringFieldValue("foo"), @@ -475,7 +475,7 @@ TEST(DocumentUpdateTest, testReadSerializedFile) DocumentUpdate& upd(*updp); const DocumentType *type = repo.getDocumentType("serializetest"); - EXPECT_EQ(DocumentId("id:ns:serializetest::update"), upd.getId()); + EXPECT_EQ(DocumentId(DocIdString("update", "test")), upd.getId()); EXPECT_EQ(*type, upd.getType()); // Verify assign value update. @@ -533,7 +533,7 @@ TEST(DocumentUpdateTest, testGenerateSerializedFile) DocumentTypeRepo repo(readDocumenttypesConfig(file_name)); const DocumentType *type(repo.getDocumentType("serializetest")); - DocumentUpdate upd(repo, *type, DocumentId("id:ns:serializetest::update")); + DocumentUpdate upd(repo, *type, DocumentId(DocIdString("update", "test"))); upd.addUpdate(FieldUpdate(type->getField("intfield")) .addUpdate(AssignValueUpdate(IntFieldValue(4)))); upd.addUpdate(FieldUpdate(type->getField("floatfield")) diff --git a/document/src/tests/fieldpathupdatetestcase.cpp b/document/src/tests/fieldpathupdatetestcase.cpp index 36a1c339ebb..74e2c20ad86 100644 --- a/document/src/tests/fieldpathupdatetestcase.cpp +++ b/document/src/tests/fieldpathupdatetestcase.cpp @@ -83,7 +83,7 @@ createTestDocument(const DocumentTypeRepo &repo) const DataType* structmap(repo.getDataType(*type, "Map<String,struct2>")); const DataType* wset(repo.getDataType(*type, "WeightedSet<String>")); const DataType* structwset(repo.getDataType(*type, "WeightedSet<struct2>")); - Document::UP doc(new Document(*type, DocumentId("id:ns:test::1"))); + Document::UP doc(new Document(*type, DocumentId("doc::testdoc"))); doc->setRepo(repo); doc->setValue("primitive1", IntFieldValue(1)); StructFieldValue l1s1(*struct3); @@ -296,12 +296,12 @@ TEST_F(FieldPathUpdateTestCase, testNoIterateMapValues) TEST_F(FieldPathUpdateTestCase, testRemoveField) { - Document::UP doc(new Document(_foobar_type, DocumentId("id:ns:foobar::things:thangs"))); + Document::UP doc(new Document(_foobar_type, DocumentId("doc:things:thangs"))); EXPECT_TRUE(doc->hasValue("strfoo") == false); doc->setValue("strfoo", StringFieldValue("cocacola")); EXPECT_EQ(vespalib::string("cocacola"), doc->getValue("strfoo")->getAsString()); //doc->print(std::cerr, true, ""); - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); docUp.addFieldPathUpdate(FieldPathUpdate::CP(new RemoveFieldPathUpdate("strfoo"))); docUp.applyTo(*doc); EXPECT_TRUE(doc->hasValue("strfoo") == false); @@ -309,7 +309,7 @@ TEST_F(FieldPathUpdateTestCase, testRemoveField) TEST_F(FieldPathUpdateTestCase, testApplyRemoveMultiList) { - Document::UP doc(new Document(_foobar_type, DocumentId("id:ns:foobar::things:thangs"))); + Document::UP doc(new Document(_foobar_type, DocumentId("doc:things:thangs"))); doc->setRepo(*_repo); EXPECT_TRUE(doc->hasValue("strarray") == false); { @@ -321,7 +321,7 @@ TEST_F(FieldPathUpdateTestCase, testApplyRemoveMultiList) } EXPECT_TRUE(doc->hasValue("strarray")); //doc->print(std::cerr, true, ""); - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); docUp.addFieldPathUpdate(FieldPathUpdate::CP( new RemoveFieldPathUpdate("strarray[$x]", "foobar.strarray[$x] == \"remove val 1\""))); docUp.applyTo(*doc); @@ -335,7 +335,7 @@ TEST_F(FieldPathUpdateTestCase, testApplyRemoveMultiList) TEST_F(FieldPathUpdateTestCase, testApplyRemoveMultiList2) { - Document::UP doc(new Document(_foobar_type, DocumentId("id:ns:foobar::things:thangs"))); + Document::UP doc(new Document(_foobar_type, DocumentId("doc:things:thangs"))); doc->setRepo(*_repo); EXPECT_TRUE(doc->hasValue("strarray") == false); { @@ -347,7 +347,7 @@ TEST_F(FieldPathUpdateTestCase, testApplyRemoveMultiList2) } EXPECT_TRUE(doc->hasValue("strarray")); //doc->print(std::cerr, true, ""); - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); docUp.addFieldPathUpdate(FieldPathUpdate::CP( new RemoveFieldPathUpdate("strarray[$x]", "foobar.strarray[$x] == \"remove val 1\""))); docUp.applyTo(*doc); @@ -360,7 +360,7 @@ TEST_F(FieldPathUpdateTestCase, testApplyRemoveMultiList2) TEST_F(FieldPathUpdateTestCase, testApplyRemoveEntireListField) { - Document::UP doc(new Document(_foobar_type, DocumentId("id:ns:foobar::things:thangs"))); + Document::UP doc(new Document(_foobar_type, DocumentId("doc:things:thangs"))); EXPECT_TRUE(doc->hasValue("strarray") == false); { ArrayFieldValue strArray(doc->getType().getField("strarray").getDataType()); @@ -370,7 +370,7 @@ TEST_F(FieldPathUpdateTestCase, testApplyRemoveEntireListField) doc->setValue("strarray", strArray); } //doc->print(std::cerr, true, ""); - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); docUp.addFieldPathUpdate(FieldPathUpdate::CP(new RemoveFieldPathUpdate("strarray", ""))); docUp.applyTo(*doc); EXPECT_TRUE(!doc->hasValue("strarray")); @@ -378,7 +378,7 @@ TEST_F(FieldPathUpdateTestCase, testApplyRemoveEntireListField) TEST_F(FieldPathUpdateTestCase, testApplyRemoveMultiWset) { - Document::UP doc(new Document(_foobar_type, DocumentId("id:ns:foobar::helan:halvan"))); + Document::UP doc(new Document(_foobar_type, DocumentId("doc:helan:halvan"))); EXPECT_TRUE(doc->hasValue("strwset") == false); { WeightedSetFieldValue strWset(doc->getType().getField("strwset").getDataType()); @@ -388,7 +388,7 @@ TEST_F(FieldPathUpdateTestCase, testApplyRemoveMultiWset) } EXPECT_TRUE(doc->hasValue("strwset")); //doc->print(std::cerr, true, ""); - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); docUp.addFieldPathUpdate(FieldPathUpdate::CP(new RemoveFieldPathUpdate("strwset{remove val 1}"))); docUp.applyTo(*doc); { @@ -400,17 +400,17 @@ TEST_F(FieldPathUpdateTestCase, testApplyRemoveMultiWset) TEST_F(FieldPathUpdateTestCase, testApplyAssignSingle) { - Document::UP doc(new Document(_foobar_type, DocumentId("id:ns:foobar::drekka:karsk"))); + Document::UP doc(new Document(_foobar_type, DocumentId("doc:drekka:karsk"))); EXPECT_TRUE(doc->hasValue("strfoo") == false); // Test assignment of non-existing - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); docUp.addFieldPathUpdate(FieldPathUpdate::CP( new AssignFieldPathUpdate(*doc->getDataType(), "strfoo", std::string(), StringFieldValue("himert")))); docUp.applyTo(*doc); EXPECT_TRUE(doc->hasValue("strfoo")); EXPECT_EQ(vespalib::string("himert"), doc->getValue("strfoo")->getAsString()); // Test overwriting existing - DocumentUpdate docUp2(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp2(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); docUp2.addFieldPathUpdate(FieldPathUpdate::CP( new AssignFieldPathUpdate(*doc->getDataType(), "strfoo", std::string(), StringFieldValue("wunderbaum")))); docUp2.applyTo(*doc); @@ -419,10 +419,10 @@ TEST_F(FieldPathUpdateTestCase, testApplyAssignSingle) TEST_F(FieldPathUpdateTestCase, testApplyAssignMath) { - Document::UP doc(new Document(_foobar_type, DocumentId("id:ns:foobar::bat:man"))); + Document::UP doc(new Document(_foobar_type, DocumentId("doc:bat:man"))); doc->setValue("num", IntFieldValue(34)); - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); docUp.addFieldPathUpdate(FieldPathUpdate::CP(new AssignFieldPathUpdate("num", "", "($value * 2) / $value"))); docUp.applyTo(*doc); EXPECT_EQ(static_cast<const FieldValue&>(IntFieldValue(2)), *doc->getValue("num")); @@ -430,10 +430,10 @@ TEST_F(FieldPathUpdateTestCase, testApplyAssignMath) TEST_F(FieldPathUpdateTestCase, testApplyAssignMathByteToZero) { - Document::UP doc(new Document(_foobar_type, DocumentId("id:ns:foobar::bat:man"))); + Document::UP doc(new Document(_foobar_type, DocumentId("doc:bat:man"))); doc->setValue("byteval", ByteFieldValue(3)); - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); docUp.addFieldPathUpdate(FieldPathUpdate::CP(new AssignFieldPathUpdate("byteval", "", "$value - 3"))); docUp.applyTo(*doc); EXPECT_EQ(static_cast<const FieldValue&>(ByteFieldValue(0)), *doc->getValue("byteval")); @@ -442,10 +442,10 @@ TEST_F(FieldPathUpdateTestCase, testApplyAssignMathByteToZero) TEST_F(FieldPathUpdateTestCase, testApplyAssignMathNotModifiedOnUnderflow) { int low_value = -126; - Document::UP doc(new Document(_foobar_type, DocumentId("id:ns:foobar::bat:man"))); + Document::UP doc(new Document(_foobar_type, DocumentId("doc:bat:man"))); doc->setValue("byteval", ByteFieldValue(low_value)); - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); docUp.addFieldPathUpdate(FieldPathUpdate::CP(new AssignFieldPathUpdate("byteval", "", "$value - 4"))); docUp.applyTo(*doc); // Over/underflow will happen. You must have control of your data types. @@ -454,10 +454,10 @@ TEST_F(FieldPathUpdateTestCase, testApplyAssignMathNotModifiedOnUnderflow) TEST_F(FieldPathUpdateTestCase, testApplyAssignMathNotModifiedOnOverflow) { - Document::UP doc(new Document(_foobar_type, DocumentId("id:ns:foobar::bat:man"))); + Document::UP doc(new Document(_foobar_type, DocumentId("doc:bat:man"))); doc->setValue("byteval", ByteFieldValue(127)); - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); docUp.addFieldPathUpdate(FieldPathUpdate::CP(new AssignFieldPathUpdate("byteval", "", "$value + 200"))); docUp.applyTo(*doc); // Over/underflow will happen. You must have control of your data types. @@ -466,11 +466,11 @@ TEST_F(FieldPathUpdateTestCase, testApplyAssignMathNotModifiedOnOverflow) TEST_F(FieldPathUpdateTestCase, testApplyAssignMathDivZero) { - Document::UP doc(new Document(_foobar_type, DocumentId("id:ns:foobar::bat:man"))); + Document::UP doc(new Document(_foobar_type, DocumentId("doc:bat:man"))); EXPECT_TRUE(doc->hasValue("num") == false); doc->setValue("num", IntFieldValue(10)); - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); docUp.addFieldPathUpdate(FieldPathUpdate::CP(new AssignFieldPathUpdate("num", "", "$value / ($value - 10)"))); docUp.applyTo(*doc); EXPECT_EQ(static_cast<const FieldValue&>(IntFieldValue(10)), *doc->getValue("num")); @@ -478,12 +478,12 @@ TEST_F(FieldPathUpdateTestCase, testApplyAssignMathDivZero) TEST_F(FieldPathUpdateTestCase, testApplyAssignFieldNotExistingInExpression) { - Document::UP doc(new Document(_foobar_type, DocumentId("id:ns:foobar::bat:man"))); + Document::UP doc(new Document(_foobar_type, DocumentId("doc:bat:man"))); doc->setRepo(*_repo); EXPECT_TRUE(doc->hasValue("num") == false); doc->setValue("num", IntFieldValue(10)); - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); docUp.addFieldPathUpdate(FieldPathUpdate::CP(new AssignFieldPathUpdate("num", "", "foobar.num2 + $value"))); docUp.applyTo(*doc); EXPECT_EQ(static_cast<const FieldValue&>(IntFieldValue(10)), *doc->getValue("num")); @@ -491,10 +491,10 @@ TEST_F(FieldPathUpdateTestCase, testApplyAssignFieldNotExistingInExpression) TEST_F(FieldPathUpdateTestCase, testApplyAssignFieldNotExistingInPath) { - Document::UP doc(new Document(_foobar_type, DocumentId("id:ns:foobar::bat:man"))); + Document::UP doc(new Document(_foobar_type, DocumentId("doc:bat:man"))); doc->setRepo(*_repo); - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); try { docUp.addFieldPathUpdate(FieldPathUpdate::CP(new AssignFieldPathUpdate("nosuchnum", "", "foobar.num + $value"))); docUp.applyTo(*doc); @@ -505,10 +505,10 @@ TEST_F(FieldPathUpdateTestCase, testApplyAssignFieldNotExistingInPath) TEST_F(FieldPathUpdateTestCase, testApplyAssignTargetNotExisting) { - Document::UP doc(new Document(_foobar_type, DocumentId("id:ns:foobar::bat:man"))); + Document::UP doc(new Document(_foobar_type, DocumentId("doc:bat:man"))); EXPECT_TRUE(doc->hasValue("num") == false); - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); docUp.addFieldPathUpdate(FieldPathUpdate::CP(new AssignFieldPathUpdate("num", "", "$value + 5"))); docUp.applyTo(*doc); EXPECT_EQ(static_cast<const FieldValue&>(IntFieldValue(5)), *doc->getValue("num")); @@ -516,7 +516,7 @@ TEST_F(FieldPathUpdateTestCase, testApplyAssignTargetNotExisting) TEST_F(FieldPathUpdateTestCase, testAssignSimpleMapValueWithVariable) { - Document::UP doc(new Document(_foobar_type, DocumentId("id:ns:foobar::bug:hunter"))); + Document::UP doc(new Document(_foobar_type, DocumentId("doc:bug:hunter"))); doc->setRepo(*_repo); MapFieldValue mfv(doc->getType().getField("strmap").getDataType()); @@ -524,7 +524,7 @@ TEST_F(FieldPathUpdateTestCase, testAssignSimpleMapValueWithVariable) mfv.put(StringFieldValue("baz"), StringFieldValue("bananas")); doc->setValue("strmap", mfv); - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); // Select on value, not key docUp.addFieldPathUpdate(FieldPathUpdate::CP( new AssignFieldPathUpdate(*doc->getDataType(), @@ -544,12 +544,12 @@ TEST_F(FieldPathUpdateTestCase, testAssignSimpleMapValueWithVariable) TEST_F(FieldPathUpdateTestCase, testApplyAssignMathRemoveIfZero) { - Document::UP doc(new Document(_foobar_type, DocumentId("id:ns:foobar::bat:man"))); + Document::UP doc(new Document(_foobar_type, DocumentId("doc:bat:man"))); EXPECT_TRUE(doc->hasValue("num") == false); doc->setValue("num", IntFieldValue(34)); EXPECT_TRUE(doc->hasValue("num") == true); - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); FieldPathUpdate::CP up1(new AssignFieldPathUpdate("num", "", "($value * 2) / $value - 2")); static_cast<AssignFieldPathUpdate&>(*up1).setRemoveIfZero(true); docUp.addFieldPathUpdate(up1); @@ -560,7 +560,7 @@ TEST_F(FieldPathUpdateTestCase, testApplyAssignMathRemoveIfZero) TEST_F(FieldPathUpdateTestCase, testApplyAssignMultiList) { - Document::UP doc(new Document(_foobar_type, DocumentId("id:ns:foobar::fest:skinnvest"))); + Document::UP doc(new Document(_foobar_type, DocumentId("doc:fest:skinnvest"))); EXPECT_TRUE(doc->hasValue("strarray") == false); { @@ -575,7 +575,7 @@ TEST_F(FieldPathUpdateTestCase, testApplyAssignMultiList) updateArray.add(StringFieldValue("assigned val 0")); updateArray.add(StringFieldValue("assigned val 1")); - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); docUp.addFieldPathUpdate(FieldPathUpdate::CP( new AssignFieldPathUpdate(*doc->getDataType(), "strarray", std::string(), updateArray))); docUp.applyTo(*doc); @@ -591,7 +591,7 @@ TEST_F(FieldPathUpdateTestCase, testApplyAssignMultiList) TEST_F(FieldPathUpdateTestCase, testApplyAssignMultiWset) { - Document::UP doc(new Document(_foobar_type, DocumentId("id:ns:foobar::fest:skinnvest"))); + Document::UP doc(new Document(_foobar_type, DocumentId("doc:fest:skinnvest"))); EXPECT_TRUE(doc->hasValue("strarray") == false); { @@ -606,7 +606,7 @@ TEST_F(FieldPathUpdateTestCase, testApplyAssignMultiWset) assignWset.add(StringFieldValue("assigned val 0"), 5); assignWset.add(StringFieldValue("assigned val 1"), 10); - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); docUp.addFieldPathUpdate(FieldPathUpdate::CP( new AssignFieldPathUpdate(*doc->getDataType(), "strwset", std::string(), assignWset))); //doc->print(std::cerr, true, ""); @@ -622,7 +622,7 @@ TEST_F(FieldPathUpdateTestCase, testApplyAssignMultiWset) TEST_F(FieldPathUpdateTestCase, testAssignWsetRemoveIfZero) { - Document::UP doc(new Document(_foobar_type, DocumentId("id:ns:foobar::tronder:bataljon"))); + Document::UP doc(new Document(_foobar_type, DocumentId("doc:tronder:bataljon"))); EXPECT_TRUE(doc->hasValue("strarray") == false); { @@ -634,7 +634,7 @@ TEST_F(FieldPathUpdateTestCase, testAssignWsetRemoveIfZero) } { - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); IntFieldValue zeroWeight(0); FieldPathUpdate::CP assignUpdate( new AssignFieldPathUpdate(*doc->getDataType(), "strwset{you say goodbye}", std::string(), zeroWeight)); @@ -653,7 +653,7 @@ TEST_F(FieldPathUpdateTestCase, testAssignWsetRemoveIfZero) TEST_F(FieldPathUpdateTestCase, testApplyAddMultiList) { - Document::UP doc(new Document(_foobar_type, DocumentId("id:ns:foobar::george:costanza"))); + Document::UP doc(new Document(_foobar_type, DocumentId("doc:george:costanza"))); EXPECT_TRUE(doc->hasValue("strarray") == false); ArrayFieldValue adds(doc->getType().getField("strarray").getDataType()); @@ -661,7 +661,7 @@ TEST_F(FieldPathUpdateTestCase, testApplyAddMultiList) adds.add(StringFieldValue("a festivus for the rest of us")); adds.add(StringFieldValue("george is getting upset!")); - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); docUp.addFieldPathUpdate(FieldPathUpdate::CP( new AddFieldPathUpdate(*doc->getDataType(), "strarray", std::string(), adds))); //doc->print(std::cerr, true, ""); @@ -672,7 +672,7 @@ TEST_F(FieldPathUpdateTestCase, testApplyAddMultiList) TEST_F(FieldPathUpdateTestCase, testAddAndAssignList) { - Document::UP doc(new Document(_foobar_type, DocumentId("id:ns:foobar::fancy:pants"))); + Document::UP doc(new Document(_foobar_type, DocumentId("doc:fancy:pants"))); EXPECT_TRUE(doc->hasValue("strarray") == false); { @@ -683,7 +683,7 @@ TEST_F(FieldPathUpdateTestCase, testAddAndAssignList) EXPECT_TRUE(doc->hasValue("strarray")); } - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); docUp.addFieldPathUpdate(FieldPathUpdate::CP( new AssignFieldPathUpdate(*doc->getDataType(), "strarray[1]", std::string(), StringFieldValue("assigned val 1")))); @@ -730,9 +730,9 @@ struct Fixture { Fixture(const DocumentType &doc_type, const Keys &k); }; -Fixture::~Fixture() = default; +Fixture::~Fixture() { } Fixture::Fixture(const DocumentType &doc_type, const Keys &k) - : doc(new Document(doc_type, DocumentId("id:ns:" + doc_type.getName() + "::planet:express"))), + : doc(new Document(doc_type, DocumentId("doc:planet:express"))), mfv(getMapType(doc_type)), fv1(getMapType(doc_type).getValueType()), fv2(getMapType(doc_type).getValueType()), @@ -764,7 +764,7 @@ TEST_F(FieldPathUpdateTestCase, testAssignMap) Keys k; Fixture f(_foobar_type, k); - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); docUp.addFieldPathUpdate(FieldPathUpdate::CP( new AssignFieldPathUpdate(*f.doc->getDataType(), "structmap{" + k.key2 + "}", std::string(), f.fv4))); docUp.applyTo(*f.doc); @@ -784,7 +784,7 @@ TEST_F(FieldPathUpdateTestCase, testAssignMapStruct) Keys k; Fixture f(_foobar_type, k); - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); docUp.addFieldPathUpdate(FieldPathUpdate::CP( new AssignFieldPathUpdate(*f.doc->getDataType(), "structmap{" + k.key2 + "}.rating", std::string(), IntFieldValue(48)))); @@ -805,7 +805,7 @@ TEST_F(FieldPathUpdateTestCase, testAssignMapStructVariable) Keys k; Fixture f(_foobar_type, k); - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); docUp.addFieldPathUpdate(FieldPathUpdate::CP( new AssignFieldPathUpdate(*f.doc->getDataType(), "structmap{$x}.rating", "foobar.structmap{$x}.title == \"farnsworth\"", IntFieldValue(48)))); @@ -824,14 +824,14 @@ TEST_F(FieldPathUpdateTestCase, testAssignMapStructVariable) TEST_F(FieldPathUpdateTestCase, testAssignMapNoExist) { - Document::UP doc(new Document(_foobar_type, DocumentId("id:ns:foobar::planet:express"))); + Document::UP doc(new Document(_foobar_type, DocumentId("doc:planet:express"))); MapFieldValue mfv(doc->getType().getField("structmap").getDataType()); StructFieldValue fv1(dynamic_cast<const MapDataType&>(*mfv.getDataType()).getValueType()); fv1.setValue("title", StringFieldValue("fry")); fv1.setValue("rating", IntFieldValue(30)); - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); docUp.addFieldPathUpdate(FieldPathUpdate::CP( new AssignFieldPathUpdate(*doc->getDataType(), "structmap{foo}", std::string(), fv1))); //doc->print(std::cerr, true, ""); @@ -846,14 +846,14 @@ TEST_F(FieldPathUpdateTestCase, testAssignMapNoExist) TEST_F(FieldPathUpdateTestCase, testAssignMapNoExistNoCreate) { - Document::UP doc(new Document(_foobar_type, DocumentId("id:ns:foobar::planet:express"))); + Document::UP doc(new Document(_foobar_type, DocumentId("doc:planet:express"))); MapFieldValue mfv(doc->getType().getField("structmap").getDataType()); StructFieldValue fv1(dynamic_cast<const MapDataType&>(*mfv.getDataType()).getValueType()); fv1.setValue("title", StringFieldValue("fry")); fv1.setValue("rating", IntFieldValue(30)); - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); FieldPathUpdate::CP assignUpdate( new AssignFieldPathUpdate(*doc->getDataType(), "structmap{foo}", std::string(), fv1)); static_cast<AssignFieldPathUpdate&>(*assignUpdate).setCreateMissingPath(false); @@ -874,7 +874,7 @@ TEST_F(FieldPathUpdateTestCase, testQuotedStringKey) const char field_path[] = "structmap{\"here is a \\\"fancy\\\" 'map' :-} key :-{\"}"; Fixture f(_foobar_type, k); - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); docUp.addFieldPathUpdate(FieldPathUpdate::CP( new AssignFieldPathUpdate(*f.doc->getDataType(), field_path, std::string(), f.fv4))); docUp.applyTo(*f.doc); @@ -891,7 +891,7 @@ TEST_F(FieldPathUpdateTestCase, testQuotedStringKey) TEST_F(FieldPathUpdateTestCase, testEqualityComparison) { - Document::UP doc(new Document(_foobar_type, DocumentId("id:ns:foobar::foo:zoo"))); + Document::UP doc(new Document(_foobar_type, DocumentId("doc:foo:zoo"))); MapFieldValue mfv(doc->getType().getField("structmap").getDataType()); StructFieldValue fv4(dynamic_cast<const MapDataType&>(*mfv.getDataType()).getValueType()); @@ -899,8 +899,8 @@ TEST_F(FieldPathUpdateTestCase, testEqualityComparison) fv4.setValue("rating", IntFieldValue(95)); { - DocumentUpdate docUp1(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); - DocumentUpdate docUp2(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp1(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); + DocumentUpdate docUp2(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); EXPECT_TRUE(docUp1 == docUp2); FieldPathUpdate::CP assignUp1(new AssignFieldPathUpdate(*doc->getDataType(), @@ -911,8 +911,8 @@ TEST_F(FieldPathUpdateTestCase, testEqualityComparison) EXPECT_TRUE(docUp1 == docUp2); } { - DocumentUpdate docUp1(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); - DocumentUpdate docUp2(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp1(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); + DocumentUpdate docUp2(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); // where-clause diff FieldPathUpdate::CP assignUp1(new AssignFieldPathUpdate(*doc->getDataType(), "structmap{here be dragons}", std::string(), fv4)); @@ -923,8 +923,8 @@ TEST_F(FieldPathUpdateTestCase, testEqualityComparison) EXPECT_TRUE(docUp1 != docUp2); } { - DocumentUpdate docUp1(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); - DocumentUpdate docUp2(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp1(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); + DocumentUpdate docUp2(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); // fieldpath diff FieldPathUpdate::CP assignUp1(new AssignFieldPathUpdate(*doc->getDataType(), "structmap{here be dragons}", std::string(), fv4)); @@ -939,7 +939,7 @@ TEST_F(FieldPathUpdateTestCase, testEqualityComparison) TEST_F(FieldPathUpdateTestCase, testAffectsDocumentBody) { - Document::UP doc(new Document(_foobar_type, DocumentId("id:ns:foobar::things:stuff"))); + Document::UP doc(new Document(_foobar_type, DocumentId("doc:things:stuff"))); MapFieldValue mfv(doc->getType().getField("structmap").getDataType()); StructFieldValue fv4(dynamic_cast<const MapDataType&>(*mfv.getDataType()).getValueType()); @@ -948,7 +948,7 @@ TEST_F(FieldPathUpdateTestCase, testAffectsDocumentBody) // structmap is body field { - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); FieldPathUpdate::CP update1(new AssignFieldPathUpdate(*doc->getDataType(), "structmap{janitor}", std::string(), fv4)); @@ -958,7 +958,7 @@ TEST_F(FieldPathUpdateTestCase, testAffectsDocumentBody) // strfoo is header field { - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); FieldPathUpdate::CP update1(new AssignFieldPathUpdate(*doc->getDataType(), "strfoo", std::string(), StringFieldValue("helloworld"))); static_cast<AssignFieldPathUpdate&>(*update1).setCreateMissingPath(true); @@ -969,10 +969,10 @@ TEST_F(FieldPathUpdateTestCase, testAffectsDocumentBody) TEST_F(FieldPathUpdateTestCase, testIncompatibleDataTypeFails) { - Document::UP doc(new Document(_foobar_type, DocumentId("id:ns:foobar::things:stuff"))); + Document::UP doc(new Document(_foobar_type, DocumentId("doc:things:stuff"))); MapFieldValue mfv(doc->getType().getField("structmap").getDataType()); - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); try { FieldPathUpdate::CP update1(new AssignFieldPathUpdate(*doc->getDataType(), "structmap{foo}", @@ -985,14 +985,14 @@ TEST_F(FieldPathUpdateTestCase, testIncompatibleDataTypeFails) TEST_F(FieldPathUpdateTestCase, testSerializeAssign) { - Document::UP doc(new Document(_foobar_type, DocumentId("id:ns:foobar::weloveto:serializestuff"))); + Document::UP doc(new Document(_foobar_type, DocumentId("doc:weloveto:serializestuff"))); MapFieldValue mfv(doc->getType().getField("structmap").getDataType()); StructFieldValue val(dynamic_cast<const MapDataType&>(*mfv.getDataType()).getValueType()); val.setValue("title", StringFieldValue("cool frog")); val.setValue("rating", IntFieldValue(100)); - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); FieldPathUpdate::CP update1(new AssignFieldPathUpdate(*doc->getDataType(), "structmap{ribbit}", "true", val)); static_cast<AssignFieldPathUpdate&>(*update1).setCreateMissingPath(true); @@ -1003,7 +1003,7 @@ TEST_F(FieldPathUpdateTestCase, testSerializeAssign) TEST_F(FieldPathUpdateTestCase, testSerializeAdd) { - Document::UP doc(new Document(_foobar_type, DocumentId("id:ns:foobar::george:costanza"))); + Document::UP doc(new Document(_foobar_type, DocumentId("doc:george:costanza"))); EXPECT_TRUE(doc->hasValue("strarray") == false); ArrayFieldValue adds(doc->getType().getField("strarray").getDataType()); @@ -1011,7 +1011,7 @@ TEST_F(FieldPathUpdateTestCase, testSerializeAdd) adds.add(StringFieldValue("a festivus for the rest of us")); adds.add(StringFieldValue("george is getting upset!")); - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); FieldPathUpdate::CP update1(new AddFieldPathUpdate(*doc->getDataType(), "strarray", std::string(), adds)); docUp.addFieldPathUpdate(update1); @@ -1021,10 +1021,10 @@ TEST_F(FieldPathUpdateTestCase, testSerializeAdd) TEST_F(FieldPathUpdateTestCase, testSerializeRemove) { - Document::UP doc(new Document(_foobar_type, DocumentId("id:ns:foobar::weloveto:serializestuff"))); + Document::UP doc(new Document(_foobar_type, DocumentId("doc:weloveto:serializestuff"))); MapFieldValue mfv(doc->getType().getField("structmap").getDataType()); - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); FieldPathUpdate::CP update1(new RemoveFieldPathUpdate("structmap{ribbit}", std::string())); docUp.addFieldPathUpdate(update1); @@ -1034,11 +1034,11 @@ TEST_F(FieldPathUpdateTestCase, testSerializeRemove) TEST_F(FieldPathUpdateTestCase, testSerializeAssignMath) { - Document::UP doc(new Document(_foobar_type, DocumentId("id:ns:foobar::bat:man"))); + Document::UP doc(new Document(_foobar_type, DocumentId("doc:bat:man"))); EXPECT_TRUE(doc->hasValue("num") == false); doc->setValue("num", IntFieldValue(34)); - DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("id:ns:foobar::barbar:foofoo")); + DocumentUpdate docUp(*_repo, _foobar_type, DocumentId("doc:barbar:foofoo")); docUp.addFieldPathUpdate(FieldPathUpdate::CP(new AssignFieldPathUpdate("num", "", "($value * 2) / $value"))); testSerialize(*_repo, docUp); } @@ -1047,7 +1047,7 @@ DocumentUpdate::UP FieldPathUpdateTestCase::createDocumentUpdateForSerialization(const DocumentTypeRepo& repo) { const DocumentType *docType(repo.getDocumentType("serializetest")); - DocumentUpdate::UP docUp(new DocumentUpdate(repo, *docType, DocumentId("id:ns:serializetest::xlanguage"))); + DocumentUpdate::UP docUp(new DocumentUpdate(repo, *docType, DocumentId("doc:serialization:xlanguage"))); FieldPathUpdate::CP assign(new AssignFieldPathUpdate("intfield", "", "3")); static_cast<AssignFieldPathUpdate&>(*assign).setRemoveIfZero(true); diff --git a/document/src/tests/fieldsettest.cpp b/document/src/tests/fieldsettest.cpp index b0cad61b72a..0297e7bdda4 100644 --- a/document/src/tests/fieldsettest.cpp +++ b/document/src/tests/fieldsettest.cpp @@ -169,7 +169,7 @@ FieldSetTest::doCopyFields(const Document& src, const std::string& fieldSetStr, Document* dest) const { - Document destDoc(src.getType(), DocumentId("id:ns:" + src.getType().getName() + "::fieldset")); + Document destDoc(src.getType(), DocumentId("doc:test:fieldsdest")); if (!dest) { dest = &destDoc; } @@ -195,7 +195,7 @@ Document::UP FieldSetTest::createTestDocument(const TestDocMan& testDocMan) const { Document::UP doc(testDocMan.createDocument("megafoo megabar", - "id:ns:testdoctype1::1", + "doc:test:fieldssrc", "testdoctype1")); doc->setValue(doc->getField("headerval"), IntFieldValue(5678)); doc->setValue(doc->getField("hstringval"), @@ -225,7 +225,7 @@ TEST_F(FieldSetTest, testCopyDocumentFields) doCopyFields(*src, repo, "testdoctype1:hstringval,content")); // Test that we overwrite already set fields in destination document { - Document dest(src->getType(), DocumentId("id:ns:" + src->getType().getName() + "::bar")); + Document dest(src->getType(), DocumentId("doc:foo:bar")); dest.setValue(dest.getField("content"), StringFieldValue("overwriteme")); EXPECT_EQ(std::string("content: megafoo megabar\n"), doCopyFields(*src, repo, "[body]", &dest)); diff --git a/document/src/tests/fieldvalue/referencefieldvalue_test.cpp b/document/src/tests/fieldvalue/referencefieldvalue_test.cpp index 17fb5ac74e6..d34bbff8a54 100644 --- a/document/src/tests/fieldvalue/referencefieldvalue_test.cpp +++ b/document/src/tests/fieldvalue/referencefieldvalue_test.cpp @@ -23,8 +23,8 @@ struct Fixture { ~Fixture(); }; - Fixture::Fixture() = default; - Fixture::~Fixture() = default; + Fixture::Fixture() { } + Fixture::~Fixture() { } } using vespalib::IllegalArgumentException; @@ -60,6 +60,17 @@ TEST_F("Exception is thrown if constructor doc ID type does not match referenced "to reference of document type 'foo'"); } +TEST_F("Exception is thrown if doc ID does not have a type", Fixture) { + // Could have had a special cased message for this, but type-less IDs are + // not expected to be allowed through the feed pipeline at all. We just + // want to ensure it fails in a controlled fashion if encountered. + EXPECT_EXCEPTION( + ReferenceFieldValue(f.refType, DocumentId("doc:foo:bario")), + IllegalArgumentException, + "Can't assign document ID 'doc:foo:bario' (of type '') " + "to reference of document type 'foo'"); +} + TEST_F("assign()ing a non-reference field value throws exception", Fixture) { ReferenceFieldValue fv(f.refType); EXPECT_EXCEPTION(fv.assign(StringFieldValue("waluigi time!!")), diff --git a/document/src/tests/globalidtest.cpp b/document/src/tests/globalidtest.cpp index f612b9e341c..ab2af875e9f 100644 --- a/document/src/tests/globalidtest.cpp +++ b/document/src/tests/globalidtest.cpp @@ -88,9 +88,9 @@ TEST_F(GlobalIdTest, testBucketIdConversion) verifyDocumentId("id:ns:test:n=1000:abc"); verifyDocumentId("id:hsgf:test:n=18446744073700000000:dfdfsdfg"); verifyDocumentId("id:ns:mytype:g=somegroup:hmm"); - verifyDocumentId("id:ns:test::"); - verifyDocumentId("id:myns:test::http://foo.bar"); - verifyDocumentId("id:ns:test::jsrthsdf:a234aleingzldkifvasdfgadf"); + verifyDocumentId("doc::test"); + verifyDocumentId("doc:myns:http://foo.bar"); + verifyDocumentId("doc:jsrthsdf:a234aleingzldkifvasdfgadf"); } void @@ -155,7 +155,7 @@ TEST_F(GlobalIdTest, testGidRangeConversion) } uint32_t scheme = randomizer.nextUint32(0, 2); switch (scheme) { - case 0: ost << "id:" << name_space.str() << ":mytype::"; + case 0: ost << "doc:" << name_space.str() << ":"; break; case 1: ost << "id:" << name_space.str() << ":mytype:n="; ost << randomizer.nextUint32() << ":"; diff --git a/document/src/tests/serialization/vespadocumentserializer_test.cpp b/document/src/tests/serialization/vespadocumentserializer_test.cpp index 98a03b0ac89..b83c59fdaec 100644 --- a/document/src/tests/serialization/vespadocumentserializer_test.cpp +++ b/document/src/tests/serialization/vespadocumentserializer_test.cpp @@ -33,9 +33,11 @@ #include <vespa/document/repo/configbuilder.h> #include <vespa/document/repo/fixedtyperepo.h> #include <vespa/document/repo/documenttyperepo.h> +#include <vespa/document/serialization/util.h> #include <vespa/document/serialization/vespadocumentdeserializer.h> #include <vespa/document/serialization/vespadocumentserializer.h> #include <vespa/document/serialization/annotationserializer.h> +#include <vespa/eval/tensor/types.h> #include <vespa/eval/tensor/tensor.h> #include <vespa/eval/tensor/default_tensor_engine.h> #include <vespa/vespalib/io/fileutil.h> @@ -61,12 +63,12 @@ using namespace document::config_builder; namespace { const int doc_type_id = 1234; -const string doc_name = "my_doctype"; +const string doc_name = "my document"; const int body_id = 94; const int inner_type_id = 95; const int outer_type_id = 96; -const string type_name = "outer_doc"; -const string inner_name = "inner_doc"; +const string type_name = "outer doc"; +const string inner_name = "inner doc"; const int a_id = 12345; const string a_name = "annotation"; const int predicate_doc_type_id = 321; @@ -81,9 +83,9 @@ constexpr uint16_t serialization_version = Document::getNewestSerializationVersi DocumenttypesConfig getDocTypesConfig() { DocumenttypesConfigBuilderHelper builder; builder.document(doc_type_id, doc_name, - Struct(doc_name + ".header") + Struct("my document.header") .addField("header field", DataType::T_INT), - Struct(doc_name + ".body") + Struct("my document.body") .addField("body field", DataType::T_STRING)) .annotationType(42, "foo_type", DataType::T_INT); builder.document(inner_type_id, inner_name, @@ -574,7 +576,7 @@ template <typename T, int N> int arraysize(const T (&)[N]) { return N; } TEST("requireThatDocumentCanBeSerialized") { const DocumentType &type = repo.getDocumentType(); - DocumentId doc_id("id:ns:" + type.getName() + "::"); + DocumentId doc_id("doc::testdoc"); Document value(type, doc_id); value.setValue(type.getField("header field"), IntFieldValue(42)); @@ -587,7 +589,7 @@ TEST("requireThatDocumentCanBeSerialized") { uint32_t size; stream >> read_version >> size; EXPECT_EQUAL(serialization_version, read_version); - EXPECT_EQUAL(70u, size); + EXPECT_EQUAL(65u, size); EXPECT_EQUAL(doc_id.getScheme().toString(), stream.peek()); stream.adjustReadPos(doc_id.getScheme().toString().size() + 1); uint8_t content_code; @@ -602,7 +604,7 @@ TEST("requireThatDocumentCanBeSerialized") { TEST("requireThatOldVersionDocumentCanBeDeserialized") { uint16_t old_version = 6; uint16_t data_size = 432; - string doc_id = "id:ns:my_doctype::"; + string doc_id = "doc::testdoc"; uint8_t content_code = 0x01; uint32_t crc = 42; @@ -626,19 +628,19 @@ TEST("requireThatUnmodifiedDocumentRetainsUnknownFieldOnSerialization") { DocumenttypesConfigBuilderHelper builder1, builder2; builder1.document(doc_type_id, doc_name, - Struct("my_doctype.header") + Struct("my document.header") .addField("field2", DataType::T_STRING), - Struct("my_doctype.body")); + Struct("my document.body")); builder2.document(doc_type_id, doc_name, - Struct("my_doctype.header") + Struct("my document.header") .addField("field1", DataType::T_INT) .addField("field2", DataType::T_STRING), - Struct("my_doctype.body")); + Struct("my document.body")); DocumentTypeRepo repo1Field(builder1.config()); DocumentTypeRepo repo2Fields(builder2.config()); - DocumentId doc_id("id:ns:my_doctype::"); + DocumentId doc_id("doc::testdoc"); Document value(*repo2Fields.getDocumentType(doc_type_id), doc_id); value.setValue("field1", IntFieldValue(42)); @@ -682,20 +684,21 @@ TEST("requireThatDocumentWithDocumentCanBeSerialized") { const DocumentTypeRepo &my_repo = repo.getDocumentTypeRepo(); const DocumentType *inner_type = my_repo.getDocumentType(inner_type_id); ASSERT_TRUE(inner_type); - const AnnotationType *a_type =my_repo.getAnnotationType(*inner_type, a_id); + const AnnotationType *a_type = + my_repo.getAnnotationType(*inner_type, a_id); StringFieldValue str("foo"); - auto tree = std::make_unique<SpanTree>("name", std::make_unique<Span>(0, 3)); - tree->annotate(std::make_unique<Annotation>(*a_type)); + SpanTree::UP tree(new SpanTree("name", Span::UP(new Span(0, 3)))); + tree->annotate(Annotation::UP(new Annotation(*a_type))); setSpanTree(str, *tree); const Field str_field("str", *DataType::STRING, false); - Document inner(*inner_type, DocumentId("id:ns:" + inner_type->getName() + "::")); + Document inner(*inner_type, DocumentId("doc::in")); inner.setValue(str_field, str); const DocumentType *type = my_repo.getDocumentType(outer_type_id); ASSERT_TRUE(type); - DocumentId doc_id("id:ns:" + type->getName() + "::"); + DocumentId doc_id("doc::testdoc"); Document value(*type, doc_id); const Field doc_field(inner_name, *inner_type, false); value.setValue(doc_field, inner); @@ -1037,7 +1040,8 @@ TEST_F("Empty ReferenceFieldValue can be roundtrip serialized", RefFixture) { } TEST_F("ReferenceFieldValue with ID can be roundtrip serialized", RefFixture) { - ReferenceFieldValue ref_with_id(f.ref_type(), DocumentId("id:ns:" + doc_name + "::foo")); + ReferenceFieldValue ref_with_id( + f.ref_type(), DocumentId("id:ns:" + doc_name + "::foo")); nbostream stream; serializeAndDeserialize(ref_with_id, stream, f.fixed_repo); } @@ -1051,7 +1055,8 @@ TEST_F("Empty ReferenceFieldValue has changed-flag cleared after deserialization } TEST_F("ReferenceFieldValue with ID has changed-flag cleared after deserialization", RefFixture) { - ReferenceFieldValue src(f.ref_type(), DocumentId("id:ns:" + doc_name + "::foo")); + ReferenceFieldValue src( + f.ref_type(), DocumentId("id:ns:" + doc_name + "::foo")); ReferenceFieldValue dest(f.ref_type()); f.roundtrip_serialize(src, dest); @@ -1064,13 +1069,14 @@ TEST_F("Empty ReferenceFieldValue serialization matches Java", RefFixture) { } TEST_F("ReferenceFieldValue with ID serialization matches Java", RefFixture) { - ReferenceFieldValue value(f.ref_type(), DocumentId("id:ns:" + doc_name + "::bar")); + ReferenceFieldValue value( + f.ref_type(), DocumentId("id:ns:" + doc_name + "::bar")); f.verify_cross_language_serialization("reference_with_id", value); } struct AssociatedDocumentRepoFixture { const DocumentType& doc_type{repo.getDocumentType()}; - DocumentId doc_id{"id:ns:" + doc_type.getName() + "::"}; + DocumentId doc_id{"doc::testdoc"}; Document source_doc{doc_type, doc_id}; std::unique_ptr<Document> roundtrip_serialize_source_document() { diff --git a/document/src/tests/struct_anno/document.dat b/document/src/tests/struct_anno/document.dat Binary files differindex 2a372d19f10..243b5f05a92 100644 --- a/document/src/tests/struct_anno/document.dat +++ b/document/src/tests/struct_anno/document.dat diff --git a/document/src/tests/testxml.cpp b/document/src/tests/testxml.cpp index e6c8716b251..cf1c783e582 100644 --- a/document/src/tests/testxml.cpp +++ b/document/src/tests/testxml.cpp @@ -24,7 +24,7 @@ Document::UP createTestDocument(const DocumentTypeRepo& repo) const DocumentType* type(repo.getDocumentType("testdoc")); Document::UP doc(new Document(*type, - DocumentId("id:ns:testdoc::crawler/http://www.ntnu.no/"))); + DocumentId("doc:crawler/http://www.ntnu.no/"))); doc->setRepo(repo); std::string s("humlepungens buffer"); ByteBuffer bb(s.c_str(), s.size()); @@ -48,7 +48,7 @@ Document::UP createTestDocument(const DocumentTypeRepo& repo) doc->setValue(doc->getField("rawarrayattr"), val); Document::UP doc2(new Document(*type, DocumentId( - "id:ns:testdoc::crawler/http://www.ntnu.no/2"))); + "doc:crawler/http://www.ntnu.no/2"))); doc2->setValue(doc2->getField("stringattr"), StringFieldValue("tjo hei paa du")); doc->setValue(doc->getField("docfield"), *doc2); @@ -59,7 +59,7 @@ DocumentUpdate::UP createTestDocumentUpdate(const DocumentTypeRepo& repo) { const DocumentType* type(repo.getDocumentType("testdoc")); - DocumentId id("id:ns:testdoc::crawler/http://www.ntnu.no/"); + DocumentId id("doc:crawler/http://www.ntnu.no/"); DocumentUpdate::UP up(new DocumentUpdate(repo, *type, id)); up->addUpdate(FieldUpdate(type->getField("intattr")) @@ -86,7 +86,7 @@ TEST(TestXml, testSimpleUsage) doc1->setValue(doc1->getField("stringattr"), StringFieldValue("tjohei���")); std::string expected = - "<document documenttype=\"testdoc\" documentid=\"id:ns:testdoc::crawler/http://www.ntnu.no/\">\n" + "<document documenttype=\"testdoc\" documentid=\"doc:crawler/http://www.ntnu.no/\">\n" " <doubleattr>17.7862</doubleattr>\n" " <intattr>50</intattr>\n" " <floatattr>3.56</floatattr>\n" @@ -100,7 +100,7 @@ TEST(TestXml, testSimpleUsage) " <rawattr binaryencoding=\"base64\">cmVhZGFibA==</rawattr>\n" " <stringattr>tjohei���</stringattr>\n" " <docfield>\n" - " <document documenttype=\"testdoc\" documentid=\"id:ns:testdoc::crawler/http://www.ntnu.no/2\">\n" + " <document documenttype=\"testdoc\" documentid=\"doc:crawler/http://www.ntnu.no/2\">\n" " <stringattr>tjo hei paa du</stringattr>\n" " </document>\n" " </docfield>\n" @@ -114,7 +114,7 @@ TEST(TestXml, testDocumentUpdate) DocumentUpdate::UP up1(createTestDocumentUpdate(repo)); std::string expected = - "<document type=\"testdoc\" id=\"id:ns:testdoc::crawler/http://www.ntnu.no/\">\n" + "<document type=\"testdoc\" id=\"doc:crawler/http://www.ntnu.no/\">\n" " <alter field=\"intattr\">\n" " <assign>7</assign>\n" " </alter>\n" diff --git a/document/src/tests/vespaxml/fieldpathupdates.xml b/document/src/tests/vespaxml/fieldpathupdates.xml index 6c9719a86b9..3b81aaf4ba2 100644..100755 --- a/document/src/tests/vespaxml/fieldpathupdates.xml +++ b/document/src/tests/vespaxml/fieldpathupdates.xml @@ -1,6 +1,6 @@ <!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> <vespafeed> - <update documenttype="news" documentid="id:ns:news::http://www.ntnu.no/"> + <update documenttype="news" documentid="doc:test:http://www.ntnu.no/"> <assign fieldpath="url">assignUrl</assign> <assign fieldpath="title">assignTitle</assign> <assign fieldpath="last_downloaded">1</assign> diff --git a/document/src/tests/vespaxml/test1.expected.xml b/document/src/tests/vespaxml/test1.expected.xml new file mode 100644 index 00000000000..198ed29690d --- /dev/null +++ b/document/src/tests/vespaxml/test1.expected.xml @@ -0,0 +1,5 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<document documenttype="news" documentid="doc:crawler:http://www.ntnu.no/"> + <title>TestTitle</title> + <last_downloaded>100</last_downloaded> +</document> diff --git a/document/src/tests/vespaxml/test1.xml b/document/src/tests/vespaxml/test1.xml new file mode 100644 index 00000000000..1ec09a0b61f --- /dev/null +++ b/document/src/tests/vespaxml/test1.xml @@ -0,0 +1,9 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <vespaadd idprefix="doc:crawler:"> + <document documenttype="news" documentid="http://www.ntnu.no/"> + <title>TestTitle</title> + <last_downloaded>100</last_downloaded> + </document> + </vespaadd> +</vespafeed> diff --git a/document/src/tests/vespaxml/test10.xml b/document/src/tests/vespaxml/test10.xml new file mode 100644 index 00000000000..832734faf48 --- /dev/null +++ b/document/src/tests/vespaxml/test10.xml @@ -0,0 +1,9 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <vespaadd> + <document type="news" id="doc:crawler/http://www.ntnu.no/"> + <title>Test<Title</title> + <last_downloaded>hundred</last_downloaded> + </document> + </vespaadd> +</vespafeed> diff --git a/document/src/tests/vespaxml/test11.xml b/document/src/tests/vespaxml/test11.xml new file mode 100644 index 00000000000..10daff34be3 --- /dev/null +++ b/document/src/tests/vespaxml/test11.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <vesparemove> + <document type="news" id="doc:crawler/http://www.ntnu���.no/"> + </document> + </vesparemove> +</vespafeed> diff --git a/document/src/tests/vespaxml/test12.xml b/document/src/tests/vespaxml/test12.xml new file mode 100644 index 00000000000..3bfd2658404 --- /dev/null +++ b/document/src/tests/vespaxml/test12.xml @@ -0,0 +1,9 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <vespaadd> + <document type="news" id="doc:crawler/http://www.ntnu.no/"> + <title></title> + <last_downloaded></last_downloaded> + </document> + </vespaadd> +</vespafeed> diff --git a/document/src/tests/vespaxml/test13.xml b/document/src/tests/vespaxml/test13.xml new file mode 100644 index 00000000000..4e55558abc6 --- /dev/null +++ b/document/src/tests/vespaxml/test13.xml @@ -0,0 +1,7 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <document type="news" id="doc:crawler:http://www.ntnu.no/"> + <title>TestTitle</title> + <last_downloaded>100</last_downloaded> + </document> +</vespa> diff --git a/document/src/tests/vespaxml/test14.xml b/document/src/tests/vespaxml/test14.xml new file mode 100644 index 00000000000..8b345f8c654 --- /dev/null +++ b/document/src/tests/vespaxml/test14.xml @@ -0,0 +1,8 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <vespaadd> + <document type="news" id="doc:crawler/http://www.ntnu.no/"> + <last_downloaded>123</last_downloaded> + </doc> + </vespaadd> +</vespafeed> diff --git a/document/src/tests/vespaxml/test15.xml b/document/src/tests/vespaxml/test15.xml new file mode 100644 index 00000000000..32707f1636b --- /dev/null +++ b/document/src/tests/vespaxml/test15.xml @@ -0,0 +1,8 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <vespaadd> + <document type="news" id="doc:crawler/http://www.ntnu.no/"> + <title>TestTitle</tit> + </document> + </vespaadd> +</vespafeed> diff --git a/document/src/tests/vespaxml/test16.xml b/document/src/tests/vespaxml/test16.xml new file mode 100644 index 00000000000..3b3179446e9 --- /dev/null +++ b/document/src/tests/vespaxml/test16.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <vespaadd> + <documentid type="news" id="doc:crawler:http://www.ntnu.no/"> + </documentid> + </vespaadd> +</vespafeed> diff --git a/document/src/tests/vespaxml/test17.xml b/document/src/tests/vespaxml/test17.xml new file mode 100644 index 00000000000..aefcc5708e7 --- /dev/null +++ b/document/src/tests/vespaxml/test17.xml @@ -0,0 +1,9 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> + <vespaadd> + <document type="news" id="doc:crawler/http://www.ntnu.no/1"> + </document> + </vespaadd> + <vespaadd> + <document type="news" id="doc:crawler/http://www.ntnu.no/2"> + </document> + </vespaadd> diff --git a/document/src/tests/vespaxml/test18.xml b/document/src/tests/vespaxml/test18.xml new file mode 100644 index 00000000000..852dd55c134 --- /dev/null +++ b/document/src/tests/vespaxml/test18.xml @@ -0,0 +1,9 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <vespaadd> + <document type="article" id="doc:crawler/http://www.ntnu.no/"> + <title>TestTitle</title> + <last_downloaded>100</last_downloaded> + </document> + </vespaadd> +</vespafeed> diff --git a/document/src/tests/vespaxml/test2.expected.xml b/document/src/tests/vespaxml/test2.expected.xml new file mode 100644 index 00000000000..198ed29690d --- /dev/null +++ b/document/src/tests/vespaxml/test2.expected.xml @@ -0,0 +1,5 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<document documenttype="news" documentid="doc:crawler:http://www.ntnu.no/"> + <title>TestTitle</title> + <last_downloaded>100</last_downloaded> +</document> diff --git a/document/src/tests/vespaxml/test2.xml b/document/src/tests/vespaxml/test2.xml new file mode 100644 index 00000000000..8194fb1de5e --- /dev/null +++ b/document/src/tests/vespaxml/test2.xml @@ -0,0 +1,7 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <document documenttype="news" documentid="doc:crawler:http://www.ntnu.no/"> + <title>TestTitle</title> + <last_downloaded>100</last_downloaded> + </document> +</vespafeed> diff --git a/document/src/tests/vespaxml/test20.xml b/document/src/tests/vespaxml/test20.xml new file mode 100644 index 00000000000..ca502100f67 --- /dev/null +++ b/document/src/tests/vespaxml/test20.xml @@ -0,0 +1,8 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <endoffeed> + <name>default</name> + <generations>10</generations> + <increment>11</increment> + </endoffeed> +</vespafeed> diff --git a/document/src/tests/vespaxml/test21.xml b/document/src/tests/vespaxml/test21.xml new file mode 100644 index 00000000000..45ef52a3e67 --- /dev/null +++ b/document/src/tests/vespaxml/test21.xml @@ -0,0 +1,9 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <vespaadd> + <document type="news" id="doc:crawler/http://www.ntnu.no/"> + <title>TestTitle</title> + <last_downloaded>21474836480</last_downloaded> + </document> + </vespaadd> +</vespafeed> diff --git a/document/src/tests/vespaxml/test22.xml b/document/src/tests/vespaxml/test22.xml new file mode 100644 index 00000000000..c9f5a0af841 --- /dev/null +++ b/document/src/tests/vespaxml/test22.xml @@ -0,0 +1,9 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <vespaadd> + <document type="news" id="doc:crawler:http://www.ntnu.no/"> + <title>TestTitle</title> + <value_long>9223372036854775807</value_long> + </document> + </vespaadd> +</vespafeed> diff --git a/document/src/tests/vespaxml/test23.xml b/document/src/tests/vespaxml/test23.xml new file mode 100644 index 00000000000..e052c3f2c7f --- /dev/null +++ b/document/src/tests/vespaxml/test23.xml @@ -0,0 +1,9 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <vespaadd> + <document type="news" id="doc:crawler:http://www.ntnu.no/"> + <title>TestTitle</title> + <value_long>-9223372036854775807</value_long> + </document> + </vespaadd> +</vespafeed> diff --git a/document/src/tests/vespaxml/test24.xml b/document/src/tests/vespaxml/test24.xml new file mode 100644 index 00000000000..3d36eea7dc8 --- /dev/null +++ b/document/src/tests/vespaxml/test24.xml @@ -0,0 +1,9 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <vespaadd> + <document type="news" id="doc:crawler:http://www.ntnu.no/"> + <title>TestTitle</title> + <value_long>18446744073709551615</value_long> + </document> + </vespaadd> +</vespafeed> diff --git a/document/src/tests/vespaxml/test25.xml b/document/src/tests/vespaxml/test25.xml new file mode 100644 index 00000000000..9a499195a6b --- /dev/null +++ b/document/src/tests/vespaxml/test25.xml @@ -0,0 +1,9 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <vespaadd> + <document type="news" id="doc:crawler/http://www.ntnu.no/"> + <title>TestTitle</title> + <value_long>18446744073709551616</value_long> + </document> + </vespaadd> +</vespafeed> diff --git a/document/src/tests/vespaxml/test26.xml b/document/src/tests/vespaxml/test26.xml new file mode 100644 index 00000000000..2d6ae226c68 --- /dev/null +++ b/document/src/tests/vespaxml/test26.xml @@ -0,0 +1,9 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <vespaadd> + <document type="news" id="doc:crawler:http://www.ntnu.no/"> + <title>TestTitle</title> + <last_downloaded>0x123</last_downloaded> + </document> + </vespaadd> +</vespafeed> diff --git a/document/src/tests/vespaxml/test27.xml b/document/src/tests/vespaxml/test27.xml new file mode 100644 index 00000000000..f8adb8b11f8 --- /dev/null +++ b/document/src/tests/vespaxml/test27.xml @@ -0,0 +1,9 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <vespaadd> + <document type="news" id="doc:crawler/http://www.ntnu.no/"> + <title>TestTitle</title> + <last_downloaded>0x123</last_downloaded> + </document> + </vespaadd> +</vespafeed> diff --git a/document/src/tests/vespaxml/test28.xml b/document/src/tests/vespaxml/test28.xml new file mode 100644 index 00000000000..929ba7415d0 --- /dev/null +++ b/document/src/tests/vespaxml/test28.xml @@ -0,0 +1,10 @@ +<!-- Test content --> +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <vespaadd> + <document type="news" id="doc:crawler:http://www.ntnu.no/"> + <title>TestTitleContent</title> + <value_content contenttype="text/html" encoding="utf-8" language="en"><![CDATA[<html><body><h1>This is the title</h1></body></html>]]></value_content> + </document> + </vespaadd> +</vespafeed> diff --git a/document/src/tests/vespaxml/test29.xml b/document/src/tests/vespaxml/test29.xml new file mode 100644 index 00000000000..1b863e5637e --- /dev/null +++ b/document/src/tests/vespaxml/test29.xml @@ -0,0 +1,18 @@ +<!-- Test field attribute --> +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <vespaadd> + <document type="news"> + <field name="uri">doc:crawler:http://www.ntnu.no/</field> + <field name="title">TestTitleContent</field> + <field name="value_content" contenttype="text/html" encoding="UTF-8" language="NO">This is content</field> + <last_downloaded>345</last_downloaded> + </document> + <document type="news"> + <field name="uri">doc:crawler:http://www.ntnu.no/2</field> + <field name="title">TestTitleContent2</field> + <field name="value_content">This is content2</field> + <last_downloaded>345</last_downloaded> + </document> + </vespaadd> +</vespafeed> diff --git a/document/src/tests/vespaxml/test3.xml b/document/src/tests/vespaxml/test3.xml new file mode 100644 index 00000000000..f328115b5ca --- /dev/null +++ b/document/src/tests/vespaxml/test3.xml @@ -0,0 +1,9 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <vesparemove idprefix="doc:crawler:"> + <documentid type="news"> + <uri>http://www.ntnu.no/</uri> + <last_downloaded></last_downloaded> + </documentid> + </vesparemove> +</vespafeed> diff --git a/document/src/tests/vespaxml/test30.xml b/document/src/tests/vespaxml/test30.xml new file mode 100644 index 00000000000..fa24e99cd83 --- /dev/null +++ b/document/src/tests/vespaxml/test30.xml @@ -0,0 +1,15 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed xmlns:xsd="http://www.w3.org/2001/XMLSchema-datatypes" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <vespaadd> + <document type="news" id="doc:crawler:http://www.ntnu.no/"> + <title xsi:type="xsd:hexBinary">E5AEB6E59BADE3808220044BE680AC</title> + <last_downloaded>100</last_downloaded> + </document> + <document type="news" id="doc:crawler:http://www.ntnu.org/"> + <title xsi:type="xsd:base64Binary">5a625Zut44CCIARL5oCs</title> + <last_downloaded>100</last_downloaded> + </document> + </vespaadd> +</vespafeed> + diff --git a/document/src/tests/vespaxml/test32.xml b/document/src/tests/vespaxml/test32.xml new file mode 100644 index 00000000000..53993f57d19 --- /dev/null +++ b/document/src/tests/vespaxml/test32.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <vesparemove> + <documentid id="doc:crawler:http://www.ntnu���.no/"/> + </vesparemove> +</vespafeed> diff --git a/document/src/tests/vespaxml/test33.xml b/document/src/tests/vespaxml/test33.xml new file mode 100644 index 00000000000..d63c059aa6e --- /dev/null +++ b/document/src/tests/vespaxml/test33.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <vesparemove> + <documentid> + <uri>http://www.ntnu.no/</uri> + </documentid> + </vesparemove> +</vespafeed> diff --git a/document/src/tests/vespaxml/test34.xml b/document/src/tests/vespaxml/test34.xml new file mode 100644 index 00000000000..384c7ae8111 --- /dev/null +++ b/document/src/tests/vespaxml/test34.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <vesparemove> + <documentid id="http://www.ntnu.no/"/> + </vesparemove> +</vespafeed> diff --git a/document/src/tests/vespaxml/test35.xml b/document/src/tests/vespaxml/test35.xml new file mode 100644 index 00000000000..e69f032ef49 --- /dev/null +++ b/document/src/tests/vespaxml/test35.xml @@ -0,0 +1,9 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <vespaadd> + <document type="news" id="doc:crawler:http://www.ntnu.no/"> + <title binaryencoding="base64">VmVzcGEgcnVsZXM=</title> + <last_downloaded>100</last_downloaded> + </document> + </vespaadd> +</vespafeed> diff --git a/document/src/tests/vespaxml/test36.xml b/document/src/tests/vespaxml/test36.xml new file mode 100644 index 00000000000..bfd4547b6c8 --- /dev/null +++ b/document/src/tests/vespaxml/test36.xml @@ -0,0 +1,43 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <vespaadd idprefix="doc:crawler:"> + <document type="news" id="http://www.ntnu.no/1"> + <title>TestTitle1</title> + <last_downloaded>100</last_downloaded> + <stringarr> + <item>one</item> + <item>two</item> + <item>three</item> + <item>four</item> + <item>five</item> + </stringarr> + <intarr> + <item>1</item> + <item>2</item> + <item>3</item> + <item>4</item> + <item>5</item> + </intarr> + </document> + <document type="news" id="http://www.ntnu.no/2"> + <title>TestTitle2</title> + <intarr> + <item>o1</item> + </intarr> + </document> + <document type="news" id="http://www.ntnu.no/3"> + <title>TestTitle3</title> + <intarr> + <tem>1</tem> + </intarr> + </document> + <document type="news" id="http://www.ntnu.no/4"> + <title>TestTitle4</title> + <intarr></intarr> + </document> + <document type="news" id="http://www.ntnu.no/5"> + <title>TestTitle5</title> + <intarr>1</intarr> + </document> + </vespaadd> +</vespafeed> diff --git a/document/src/tests/vespaxml/test37.xml b/document/src/tests/vespaxml/test37.xml new file mode 100644 index 00000000000..8993dd99640 --- /dev/null +++ b/document/src/tests/vespaxml/test37.xml @@ -0,0 +1,23 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <vespaadd idprefix="doc:crawler:"> + <document type="news" id="http://www.ntnu.no/1"> + <title>TestTitle1</title> + <last_downloaded>100</last_downloaded> + <weightedsetstring> + <item>one</item> + <item>two</item> + <item>three</item> + <item>four</item> + <item>five</item> + </weightedsetstring> + <weightedsetint> + <item>1</item> + <item>2</item> + <item>3</item> + <item>4</item> + <item>5</item> + </weightedsetint> + </document> + </vespaadd> +</vespafeed> diff --git a/document/src/tests/vespaxml/test4.xml b/document/src/tests/vespaxml/test4.xml new file mode 100644 index 00000000000..8a4777344d6 --- /dev/null +++ b/document/src/tests/vespaxml/test4.xml @@ -0,0 +1,23 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + + <vespaadd idprefix="doc:crawler:"> + <document type="news" id="http://www.uio.no/"> + <title>TestTitle</title> + <last_downloaded>100</last_downloaded> + </document> + + <document type="news" id="http://www.dagbladet.no/"> + <title>Title2</title> + <last_downloaded>100</last_downloaded> + </document> + </vespaadd> + + <vespaadd> + <document type="news" id="doc:crawler2:http://www.vg.no/"> + <title>Title2</title> + <last_downloaded>100</last_downloaded> + </document> + </vespaadd> + +</vespafeed> diff --git a/document/src/tests/vespaxml/test40.xml b/document/src/tests/vespaxml/test40.xml new file mode 100644 index 00000000000..68210920df2 --- /dev/null +++ b/document/src/tests/vespaxml/test40.xml @@ -0,0 +1,6 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <update documenttype="news" documentid="doc:crawler:http://www.ntnu.no/"> + <assign field="title">TestTitle</assign> + </update> +</vespafeed> diff --git a/document/src/tests/vespaxml/test41.xml b/document/src/tests/vespaxml/test41.xml new file mode 100644 index 00000000000..b92c2e586a8 --- /dev/null +++ b/document/src/tests/vespaxml/test41.xml @@ -0,0 +1,22 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <update documenttype="news" documentid="doc:crawler:http://www.ntnu.no/"> + <assign field="stringarr"> + <item>First</item> + <item>Second</item> + </assign> + <add field="stringarr"> + <item>Third</item> + <item>Fourth</item> + </add> + <remove field="stringarr"> + <item>Fifth</item> + <item>Sixth</item> + </remove> + <assign field="intarr"> + <item>100</item> + <item>200</item> + </assign> + <assign field="intarr"></assign> + </update> +</vespafeed> diff --git a/document/src/tests/vespaxml/test42.xml b/document/src/tests/vespaxml/test42.xml new file mode 100644 index 00000000000..479509776fa --- /dev/null +++ b/document/src/tests/vespaxml/test42.xml @@ -0,0 +1,22 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <update documenttype="news" documentid="doc:crawler:http://www.ntnu.no/"> + <assign field="weightedsetstring"> + <item weight="1">First</item> + <item weight="2">Second</item> + </assign> + <add field="weightedsetstring"> + <item weight="3">Third</item> + <item weight="4">Fourth</item> + </add> + <remove field="weightedsetstring"> + <item>Fifth</item> + <item>Sixth</item> + </remove> + <assign field="weightedsetint"> + <item weight="1">100</item> + <item weight="2">200</item> + </assign> + <assign field="weightedsetint"></assign> + </update> +</vespafeed> diff --git a/document/src/tests/vespaxml/test43.xml b/document/src/tests/vespaxml/test43.xml new file mode 100644 index 00000000000..874deada10c --- /dev/null +++ b/document/src/tests/vespaxml/test43.xml @@ -0,0 +1,32 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <document documenttype="news" documentid="doc:crawler:http://www.ntnu.no/"> + <value_long>1008</value_long> + <weightedsetstring> + <item weight="1">First</item> + <item weight="2">Second</item> + </weightedsetstring> + </document> + <update documenttype="news" documentid="doc:crawler:http://www.ntnu.no/"> + <increment field="value_long" by="1" /> + <decrement field="value_long" by="2" /> + <divide field="value_long" by="3" /> + <multiply field="value_long" by="4" /> + </update> + <update documenttype="news" documentid="doc:crawler:http://www.ntnu.no/"> + <alter field="value_long"> + <increment by="5" /> + <decrement by="6" /> + </alter> + <alter field="value_long"> + <divide by="7" /> + <multiply by="8" /> + </alter> + </update> + <update documenttype="news" documentid="doc:crawler:http://www.ntnu.no/"> + <increment field="weightedsetstring" by="9"> + <key>First</key> + <key>Second</key> + </increment> + </update> +</vespafeed> diff --git a/document/src/tests/vespaxml/test45.xml b/document/src/tests/vespaxml/test45.xml new file mode 100644 index 00000000000..ccc1a475a86 --- /dev/null +++ b/document/src/tests/vespaxml/test45.xml @@ -0,0 +1,6 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <update documenttype="news" documentid="doc:crawler:http://www.ntnu.no/"> + <remove field="floatarr" /> + </update> +</vespafeed> diff --git a/document/src/tests/vespaxml/test46.xml b/document/src/tests/vespaxml/test46.xml new file mode 100644 index 00000000000..118dfdd810d --- /dev/null +++ b/document/src/tests/vespaxml/test46.xml @@ -0,0 +1,10 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <document documenttype="news" documentid="doc:crawler:http://www.blargh.example.com/" lastmodified="98798787"> + <value_long>1008</value_long> + <weightedsetstring> + <item weight="1">First</item> + <item weight="2">Second</item> + </weightedsetstring> + </document> +</vespafeed> diff --git a/document/src/tests/vespaxml/test47.xml b/document/src/tests/vespaxml/test47.xml new file mode 100644 index 00000000000..e9499c32810 --- /dev/null +++ b/document/src/tests/vespaxml/test47.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <!-- VERY BAD: --> + <vespaadd> + <documentid type="news"> + <uri>doc:this:is:very:bad</uri> + </documentid> + </vespaadd> +</vespafeed> diff --git a/document/src/tests/vespaxml/test48.xml b/document/src/tests/vespaxml/test48.xml new file mode 100644 index 00000000000..119d3ea82d4 --- /dev/null +++ b/document/src/tests/vespaxml/test48.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <!-- VERY BAD: --> + <documentid type="news" id="doc:this:is:even:worse" /> +</vespafeed> diff --git a/document/src/tests/vespaxml/test49.xml b/document/src/tests/vespaxml/test49.xml new file mode 100644 index 00000000000..d3fa4dc9637 --- /dev/null +++ b/document/src/tests/vespaxml/test49.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <!-- VERY BAD: --> + <documentid type="news"> + <uri>doc:this:is:very:very:ugly</uri> + </documentid> +</vespafeed> diff --git a/document/src/tests/vespaxml/test5.expected.xml b/document/src/tests/vespaxml/test5.expected.xml new file mode 100644 index 00000000000..5b851a4601e --- /dev/null +++ b/document/src/tests/vespaxml/test5.expected.xml @@ -0,0 +1,3 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<remove documentid="doc:crawler:http://www.ntnu.no/"/> + diff --git a/document/src/tests/vespaxml/test5.xml b/document/src/tests/vespaxml/test5.xml new file mode 100644 index 00000000000..bdfa496cb86 --- /dev/null +++ b/document/src/tests/vespaxml/test5.xml @@ -0,0 +1,6 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <vesparemove> + <documentid documentid="doc:crawler:http://www.ntnu.no/"/> + </vesparemove> +</vespafeed> diff --git a/document/src/tests/vespaxml/test50.xml b/document/src/tests/vespaxml/test50.xml new file mode 100644 index 00000000000..45c4c0a4d13 --- /dev/null +++ b/document/src/tests/vespaxml/test50.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <!-- OK: --> + <vesparemove> + <documentid type="news" id="doc:this:an:ok:removal"/> + </vesparemove> +</vespafeed> diff --git a/document/src/tests/vespaxml/test51.xml b/document/src/tests/vespaxml/test51.xml new file mode 100644 index 00000000000..9e91d45d930 --- /dev/null +++ b/document/src/tests/vespaxml/test51.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <!-- OK: --> + <remove documentid="doc:this:is:also:an:ok:removal"/> +</vespafeed> diff --git a/document/src/tests/vespaxml/test52.xml b/document/src/tests/vespaxml/test52.xml new file mode 100644 index 00000000000..a8617df42da --- /dev/null +++ b/document/src/tests/vespaxml/test52.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <!-- OK: --> + <vespaadd> + <document documentid="doc:blah:blah:blah" documenttype="news"> + <value_long>2345</value_long> + </document> + </vespaadd> +</vespafeed> diff --git a/document/src/tests/vespaxml/test53.xml b/document/src/tests/vespaxml/test53.xml new file mode 100644 index 00000000000..6449436ff54 --- /dev/null +++ b/document/src/tests/vespaxml/test53.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <!-- HALF BAD, BUT NOT ALLOWED: --> + <vespaadd> + <document documentid="doc:blah:blah:blah" documenttype="news"> + <value_long>2345</value_long> + </document> + <documentid type="news" id="doc:half:bad:add"/> + </vespaadd> +</vespafeed> diff --git a/document/src/tests/vespaxml/test54.xml b/document/src/tests/vespaxml/test54.xml new file mode 100644 index 00000000000..7535f4b93ea --- /dev/null +++ b/document/src/tests/vespaxml/test54.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <!-- VERY BAD: --> + <vesparemove> + <document documentid="doc:bluh:bluh:bluh" documenttype="news"> + <value_long>45</value_long> + </document> + </vesparemove> +</vespafeed> diff --git a/document/src/tests/vespaxml/test55.xml b/document/src/tests/vespaxml/test55.xml new file mode 100644 index 00000000000..b2134a29a46 --- /dev/null +++ b/document/src/tests/vespaxml/test55.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <!-- HALF BAD, BUT NOT ALLOWED: --> + <vesparemove> + <documentid type="news" id="doc:this:remove:is:half:bad"/> + <document documentid="doc:bluh:bluh:bluh" documenttype="news"> + <value_long>45</value_long> + </document> + </vesparemove> +</vespafeed> diff --git a/document/src/tests/vespaxml/test56.xml b/document/src/tests/vespaxml/test56.xml new file mode 100644 index 00000000000..1dd36a57b68 --- /dev/null +++ b/document/src/tests/vespaxml/test56.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <!-- VERY BAD: --> + <vesparemove> + <document documentid="doc:bluh:bluh:bluh" documenttype="news" /> + </vesparemove> +</vespafeed> diff --git a/document/src/tests/vespaxml/test57.xml b/document/src/tests/vespaxml/test57.xml new file mode 100644 index 00000000000..d75e6d4d099 --- /dev/null +++ b/document/src/tests/vespaxml/test57.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <!-- OK: --> + <document documentid="doc:blih:blih:blih" documenttype="news"> + <value_long>235</value_long> + </document> +</vespafeed> diff --git a/document/src/tests/vespaxml/test58.xml b/document/src/tests/vespaxml/test58.xml new file mode 100644 index 00000000000..8711a2a49e4 --- /dev/null +++ b/document/src/tests/vespaxml/test58.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + + <document type="news" id="doc:music:http://music.yahoo.com"> + <url>http://music.yahoo.com</url> + <stringarr> + <item>yahoo<item> + <item>hello</item> + </stringarr> + </document> + + + +</vespafeed> diff --git a/document/src/tests/vespaxml/test59.xml b/document/src/tests/vespaxml/test59.xml new file mode 100644 index 00000000000..e7708351c93 --- /dev/null +++ b/document/src/tests/vespaxml/test59.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <update documentid="doc:blih:blih:blih" documenttype="news"> + <increment field="title" by="3549" /> + </update> +</vespafeed> diff --git a/document/src/tests/vespaxml/test6.xml b/document/src/tests/vespaxml/test6.xml new file mode 100644 index 00000000000..3739690d2fe --- /dev/null +++ b/document/src/tests/vespaxml/test6.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <vesparemove> + <documentid type="news" id="doc:crawler:http://www.ntnu���.no/"/> + </vesparemove> +</vespafeed> diff --git a/document/src/tests/vespaxml/test7.xml b/document/src/tests/vespaxml/test7.xml new file mode 100644 index 00000000000..129773678f1 --- /dev/null +++ b/document/src/tests/vespaxml/test7.xml @@ -0,0 +1,9 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed idprefix="doc:crawler:"> + <vespaadd> + <document type="news" id="http://www.ntnu.no/"> + <title>TestTitle</title> + <last_downloaded>100.5</last_downloaded> + </document> + </vespaadd> +</vespafeed> diff --git a/document/src/tests/vespaxml/test8.xml b/document/src/tests/vespaxml/test8.xml new file mode 100644 index 00000000000..272791511c1 --- /dev/null +++ b/document/src/tests/vespaxml/test8.xml @@ -0,0 +1,9 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <vespaadd> + <document type="news" id="doc:crawler:http://www.ntnu.no/"> + <title>TestTitle</title> + <last_downloaded>hundred</last_downloaded> + </document> + </vespaadd> +</vespafeed> diff --git a/document/src/tests/vespaxml/test9.xml b/document/src/tests/vespaxml/test9.xml new file mode 100644 index 00000000000..b733c66a797 --- /dev/null +++ b/document/src/tests/vespaxml/test9.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <vesparemove> + <documentid id="doc:crawler/http://www.ntnu���.no/"/> + </vesparemove> +</vespafeed> diff --git a/document/src/tests/vespaxml/test_arraystruct.xml b/document/src/tests/vespaxml/test_arraystruct.xml new file mode 100644 index 00000000000..ba5c3233e16 --- /dev/null +++ b/document/src/tests/vespaxml/test_arraystruct.xml @@ -0,0 +1,19 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <document documenttype="news" documentid="doc:test:struct"> + <mystructarr> + <item> + <intval>36</intval> + <stringval>test</stringval> + </item> + <item> + <intval>39</intval> + <stringval>test2</stringval> + </item> + <item> + <intval>100</intval> + <stringval>cooool</stringval> + </item> + </mystructarr> + </document> +</vespafeed> diff --git a/document/src/tests/vespaxml/test_doc5.xml b/document/src/tests/vespaxml/test_doc5.xml new file mode 100644 index 00000000000..30ce5f7b8f8 --- /dev/null +++ b/document/src/tests/vespaxml/test_doc5.xml @@ -0,0 +1,8 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <endoffeed> + <name>default</name> + <generation>10</generation> + <increment>20</increment> + </endoffeed> +</vespafeed> diff --git a/document/src/tests/vespaxml/test_doc6.xml b/document/src/tests/vespaxml/test_doc6.xml new file mode 100644 index 00000000000..52015073f96 --- /dev/null +++ b/document/src/tests/vespaxml/test_doc6.xml @@ -0,0 +1,6 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <endoffeed> + <name>default</name> + </endoffeed> +</vespafeed> diff --git a/document/src/tests/vespaxml/test_doc8.xml b/document/src/tests/vespaxml/test_doc8.xml new file mode 100644 index 00000000000..f5c7a2090ae --- /dev/null +++ b/document/src/tests/vespaxml/test_doc8.xml @@ -0,0 +1,9 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <vespaadd> + <document type="news" version="13" id="http://www.ntnu.no/"> + <title>TestTitle</title> + <last_downloaded>100</last_downloaded> + </document> + </vespaadd> +</vespafeed> diff --git a/document/src/tests/vespaxml/test_externalentity.xml b/document/src/tests/vespaxml/test_externalentity.xml new file mode 100644 index 00000000000..014d67d32bc --- /dev/null +++ b/document/src/tests/vespaxml/test_externalentity.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<!DOCTYPE vespafeed [<!ENTITY xxe SYSTEM "xxe.txt">]> +<vespafeed> + <vespaadd idprefix="doc:crawler:"> + <document documenttype="news" documentid="http://www.ntnu.no/"> + <title>&xxe;</title> + <last_downloaded>100</last_downloaded> + </document> + </vespaadd> +</vespafeed> diff --git a/document/src/tests/vespaxml/test_idprefix.xml b/document/src/tests/vespaxml/test_idprefix.xml new file mode 100644 index 00000000000..2b0487d0b94 --- /dev/null +++ b/document/src/tests/vespaxml/test_idprefix.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + + <document type="news" id="http://music.yahoo.com/bobdylan/BestOf"> + <title>Best of Bob Dylan</title> + </document> + + <document type="news" id="http://music.yahoo.com/metallica/BestOf"> + <title>Best of Metallica</title> + </document> + +</vespafeed> diff --git a/document/src/tests/vespaxml/test_struct.xml b/document/src/tests/vespaxml/test_struct.xml new file mode 100644 index 00000000000..251b8b4896d --- /dev/null +++ b/document/src/tests/vespaxml/test_struct.xml @@ -0,0 +1,9 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <document documenttype="news" documentid="doc:test:struct"> + <mystruct> + <intval>36</intval> + <stringval>test</stringval> + </mystruct> + </document> +</vespafeed> diff --git a/document/src/tests/vespaxml/test_update1.xml b/document/src/tests/vespaxml/test_update1.xml new file mode 100644 index 00000000000..89dcb978e3b --- /dev/null +++ b/document/src/tests/vespaxml/test_update1.xml @@ -0,0 +1,12 @@ +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<vespafeed> + <vespaadd idprefix="doc:crawler:"> + <document type="news" id="http://www.ntnu.no/"> + <title>TestTitle</title> + <last_downloaded>100</last_downloaded> + </document> + <update documenttype="news" documentid="http://www.ntnu.no/"> + <divide field="last_downloaded" by="0" /> + </update> + </vespaadd> +</vespafeed> |