public void Extract() { var mocks = new MockRepository(); var connection = mocks.StrictMock <ISolrConnection>(); var executer = mocks.StrictMock <ISolrQueryExecuter <TestDocumentWithoutUniqueKey> >(); var headerParser = mocks.StrictMock <ISolrHeaderResponseParser>(); var extractResponseParser = mocks.StrictMock <ISolrExtractResponseParser>(); var docSerializer = new SolrDocumentSerializer <TestDocumentWithoutUniqueKey>(new AttributesMappingManager(), new DefaultFieldSerializer()); var parameters = new ExtractParameters(null, "1", "test.doc"); With.Mocks(mocks) .Expecting(() => { Expect.On(connection) .Call(connection.PostStream("/update/extract", null, parameters.Content, new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("literal.id", parameters.Id), new KeyValuePair <string, string>("resource.name", parameters.ResourceName), })) .Repeat.Once() .Return(EmbeddedResource.GetEmbeddedString(GetType(), "Resources.responseWithExtractContent.xml")); Expect.On(extractResponseParser) .Call(extractResponseParser.Parse(null)) .IgnoreArguments() .Return(new ExtractResponse(null)); }) .Verify(() => { var ops = new SolrBasicServer <TestDocumentWithoutUniqueKey>(connection, executer, docSerializer, null, headerParser, null, null, extractResponseParser); ops.Extract(parameters); }); }
public void ExecuteWithAllParameters() { var parameters = new ExtractParameters(null, "1", "text.doc"); var conn = new MSolrConnection(); conn.postStream += new Moroco.MFunc <string, string, System.IO.Stream, System.Collections.Generic.IEnumerable <System.Collections.Generic.KeyValuePair <string, string> >, string>((url, type, stream, kvs) => { Assert.Equal("/update/extract", url); Assert.Equal("application/word-document", type); var p = new[] { KV.Create("literal.id", parameters.Id), KV.Create("resource.name", parameters.ResourceName), KV.Create("literal.field1", "value1"), KV.Create("literal.field2", "value2"), KV.Create("stream.type", "application/word-document"), KV.Create("commit", "true"), KV.Create("uprefix", "pref"), KV.Create("defaultField", "field1"), KV.Create("extractOnly", "true"), KV.Create("extractFormat", "text"), KV.Create("capture", "html"), KV.Create("captureAttr", "true"), KV.Create("xpath", "body"), KV.Create("lowernames", "true") }; Assert.Equal(p, kvs); //ignore order should be added return(""); }); var cmd = new ExtractCommand(new ExtractParameters(null, "1", "text.doc") { AutoCommit = true, Capture = "html", CaptureAttributes = true, DefaultField = "field1", ExtractOnly = true, ExtractFormat = ExtractFormat.Text, Fields = new[] { new ExtractField("field1", "value1"), new ExtractField("field2", "value2") }, LowerNames = true, XPath = "body", Prefix = "pref", StreamType = "application/word-document" }); cmd.Execute(conn); Assert.Equal(1, conn.postStream.Calls); }
public void ExecuteWithAllParameters() { var parameters = new ExtractParameters(null, "1", "text.doc"); var conn = new MSolrConnection(); conn.postStream += (url, type, stream, kvs) => { Assert.AreEqual("/update/extract", url); Assert.AreEqual("application/word-document", type); var p = new[] { KV.Create("literal.id", parameters.Id), KV.Create("resource.name", parameters.ResourceName), KV.Create("literal.field1", "value1"), KV.Create("literal.field2", "value2"), KV.Create("stream.type", "application/word-document"), KV.Create("commit", "true"), KV.Create("uprefix", "pref"), KV.Create("defaultField", "field1"), KV.Create("extractOnly", "true"), KV.Create("extractFormat", "text"), KV.Create("capture", "html"), KV.Create("captureAttr", "true"), KV.Create("xpath", "body"), KV.Create("lowernames", "true") }; CollectionAssert.AreEquivalent(p, kvs); return(""); }; var cmd = new ExtractCommand(new ExtractParameters(null, "1", "text.doc") { AutoCommit = true, Capture = "html", CaptureAttributes = true, DefaultField = "field1", ExtractOnly = true, ExtractFormat = ExtractFormat.Text, Fields = new[] { new ExtractField("field1", "value1"), new ExtractField("field2", "value2") }, LowerNames = true, XPath = "body", Prefix = "pref", StreamType = "application/word-document" }); cmd.Execute(conn); Assert.AreEqual(1, conn.postStream.Calls); }
public void ExecuteWithAllParameters() { var parameters = new ExtractParameters(null, "1", "text.doc"); var conn = new MSolrConnection(); conn.postStream += (url, type, stream, kvs) => { Assert.AreEqual("/update/extract", url); Assert.AreEqual("application/word-document", type); var p = new[] { KV.Create("literal.id", parameters.Id), KV.Create("resource.name", parameters.ResourceName), KV.Create("literal.field1", "value1"), KV.Create("literal.field2", "value2"), KV.Create("stream.type", "application/word-document"), KV.Create("commit", "true"), KV.Create("uprefix", "pref"), KV.Create("defaultField", "field1"), KV.Create("extractOnly", "true"), KV.Create("extractFormat", "text"), KV.Create("capture", "html"), KV.Create("captureAttr", "true"), KV.Create("xpath", "body"), KV.Create("lowernames", "true") }; CollectionAssert.AreEquivalent(p, kvs); return ""; }; var cmd = new ExtractCommand(new ExtractParameters(null, "1", "text.doc") { AutoCommit = true, Capture = "html", CaptureAttributes = true, DefaultField = "field1", ExtractOnly = true, ExtractFormat = ExtractFormat.Text, Fields = new[] { new ExtractField("field1", "value1"), new ExtractField("field2", "value2") }, LowerNames = true, XPath = "body", Prefix = "pref", StreamType = "application/word-document" }); cmd.Execute(conn); Assert.AreEqual(1, conn.postStream.Calls); }
public void Execute() { var parameters = new ExtractParameters(null, "1", "text.doc"); var conn = new MSolrConnection(); conn.postStream += (url, b, stream, kvs) => { Assert.AreEqual("/update/extract", url); var p = new[] { KV.Create("literal.id", parameters.Id), KV.Create("resource.name", parameters.ResourceName), }; Assert.AreElementsEqualIgnoringOrder(p, kvs); return ""; }; var cmd = new ExtractCommand(parameters); cmd.Execute(conn); Assert.AreEqual(1, conn.postStream.Calls); }
public void ExecuteWithAllParameters() { var mocks = new MockRepository(); var conn = mocks.StrictMock <ISolrConnection>(); var parameters = new ExtractParameters(null, "1", "text.doc"); With.Mocks(mocks).Expecting(() => { Expect.Call(conn.PostStream("/update/extract", "application/word-document", null, new List <KeyValuePair <string, string> > { KV.Create("literal.id", parameters.Id), KV.Create("resource.name", parameters.ResourceName), KV.Create("literal.field1", "value1"), KV.Create("literal.field2", "value2"), KV.Create("stream.type", "application/word-document"), KV.Create("commit", "true"), KV.Create("uprefix", "pref"), KV.Create("defaultField", "field1"), KV.Create("extractOnly", "true"), KV.Create("extractFormat", "text"), KV.Create("capture", "html"), KV.Create("captureAttr", "true"), KV.Create("xpath", "body"), KV.Create("lowernames", "true") })) .Repeat.Once() .Return(""); }) .Verify(() => { var cmd = new ExtractCommand(new ExtractParameters(null, "1", "text.doc") { AutoCommit = true, Capture = "html", CaptureAttributes = true, DefaultField = "field1", ExtractOnly = true, ExtractFormat = ExtractFormat.Text, Fields = new[] { new ExtractField("field1", "value1"), new ExtractField("field2", "value2") }, LowerNames = true, XPath = "body", Prefix = "pref", StreamType = "application/word-document" }); cmd.Execute(conn); }); }
public void ExecuteWithAllParameters() { var mocks = new MockRepository(); var conn = mocks.StrictMock<ISolrConnection>(); var parameters = new ExtractParameters(null, "1", "text.doc"); With.Mocks(mocks).Expecting(() => { Expect.Call(conn.PostStream("/update/extract", "application/word-document", null, new List<KeyValuePair<string, string>> { KV.Create("literal.id", parameters.Id), KV.Create("resource.name", parameters.ResourceName), KV.Create("literal.field1", "value1"), KV.Create("literal.field2", "value2"), KV.Create("stream.type", "application/word-document"), KV.Create("commit", "true"), KV.Create("uprefix", "pref"), KV.Create("defaultField", "field1"), KV.Create("extractOnly", "true"), KV.Create("extractFormat", "text"), KV.Create("capture", "html"), KV.Create("captureAttr", "true"), KV.Create("xpath", "body"), KV.Create("lowernames", "true") })) .Repeat.Once() .Return(""); }) .Verify(() => { var cmd = new ExtractCommand(new ExtractParameters(null, "1", "text.doc") { AutoCommit = true, Capture = "html", CaptureAttributes = true, DefaultField = "field1", ExtractOnly = true, ExtractFormat = ExtractFormat.Text, Fields = new[] { new ExtractField("field1", "value1"), new ExtractField("field2", "value2") }, LowerNames = true, XPath = "body", Prefix = "pref", StreamType = "application/word-document" }); cmd.Execute(conn); }); }
public void Execute() { var mocks = new MockRepository(); var conn = mocks.StrictMock<ISolrConnection>(); var parameters = new ExtractParameters(null, "1", "text.doc"); With.Mocks(mocks).Expecting(() => { Expect.Call(conn.PostStream("/update/extract", null, null, new List<KeyValuePair<string, string>> { KV.Create("literal.id", parameters.Id), KV.Create("resource.name", parameters.ResourceName), })) .Repeat.Once() .Return(""); }) .Verify(() => { var cmd = new ExtractCommand(new ExtractParameters(null, "1", "text.doc")); cmd.Execute(conn); }); }
public void Execute() { var parameters = new ExtractParameters(null, "1", "text.doc"); var conn = new MSolrConnection(); conn.postStream += (url, b, stream, kvs) => { Assert.AreEqual("/update/extract", url); var p = new[] { KV.Create("literal.id", parameters.Id), KV.Create("resource.name", parameters.ResourceName), }; CollectionAssert.AreEquivalent(p, kvs); return(""); }; var cmd = new ExtractCommand(parameters); cmd.Execute(conn); Assert.AreEqual(1, conn.postStream.Calls); }
public void Execute() { var parameters = new ExtractParameters(null, "1", "text.doc"); var conn = new MSolrConnection(); conn.postStream += new Moroco.MFunc <string, string, System.IO.Stream, System.Collections.Generic.IEnumerable <System.Collections.Generic.KeyValuePair <string, string> >, string>((url, b, stream, kvs) => { Assert.Equal("/update/extract", url); var p = new[] { KV.Create("literal.id", parameters.Id), KV.Create("resource.name", parameters.ResourceName), }; Assert.Equal(p, kvs); //ignore order should be added return(""); }); var cmd = new ExtractCommand(parameters); cmd.Execute(conn); Assert.Equal(1, conn.postStream.Calls); }
public void Execute() { var mocks = new MockRepository(); var conn = mocks.StrictMock <ISolrConnection>(); var parameters = new ExtractParameters(null, "1", "text.doc"); With.Mocks(mocks).Expecting(() => { Expect.Call(conn.PostStream("/update/extract", null, null, new List <KeyValuePair <string, string> > { KV("literal.id", parameters.Id), KV("resource.name", parameters.ResourceName), })) .Repeat.Once() .Return(""); }) .Verify(() => { var cmd = new ExtractCommand(new ExtractParameters(null, "1", "text.doc")); cmd.Execute(conn); }); }
public void IndexRichText(string path, string id, ICollection <string> acl, ICollection <string> languages, DateTime startPublish, DateTime endPublish, string cmsContentId = null) { Path.GetFileName(path); try { ISolrOperations <CmsSearchResultItem> instance = ServiceLocator.Current.GetInstance <ISolrOperations <CmsSearchResultItem> >(); using (Stream file = this.cmsIndexer.GetFile(path)) { ExtractParameters parameters = new ExtractParameters(file, "media" + id, path) { ExtractFormat = ExtractFormat.Text, ExtractOnly = false, Fields = (IEnumerable <ExtractField>) new ExtractField[3] { new ExtractField("doctypes", "media"), new ExtractField("start_publish", startPublish.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")), new ExtractField("end_publish", endPublish.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")) } }; List <ExtractField> list = parameters.Fields.ToList <ExtractField>(); if (!string.IsNullOrEmpty(cmsContentId)) { list.Add(new ExtractField("content_ref", cmsContentId)); } foreach (string str in (IEnumerable <string>)acl) { list.Add(new ExtractField("acl", str)); } foreach (string language in (IEnumerable <string>)languages) { list.Add(new ExtractField("lang", language)); } parameters.Fields = (IEnumerable <ExtractField>)list; instance.Extract(parameters); } instance.Commit(); } catch (Exception ex) { this.log.AddLogentry(SolisSearch.Log.Enum.LogLevel.Error, string.Format("Error indexing data from richtext document {0} with id {1}", (object)path, (object)id), ex); } }
public void Extract() { var parameters = new ExtractParameters(null, "1", "test.doc"); var connection = new MSolrConnection(); connection.postStream += (url, contentType, content, param) => { Assert.AreEqual("/update/extract", url); Assert.AreEqual(parameters.Content, content); var expectedParams = new[] { KV.Create("literal.id", parameters.Id), KV.Create("resource.name", parameters.ResourceName), }; CollectionAssert.AreEquivalent(expectedParams, param); return(EmbeddedResource.GetEmbeddedString(GetType(), "Resources.responseWithExtractContent.xml")); }; var docSerializer = new SolrDocumentSerializer <TestDocumentWithoutUniqueKey>(new AttributesMappingManager(), new DefaultFieldSerializer()); var extractResponseParser = new MSolrExtractResponseParser { parse = _ => new ExtractResponse(null) }; var ops = new SolrBasicServer <TestDocumentWithoutUniqueKey>(connection, null, docSerializer, null, null, null, null, extractResponseParser); ops.Extract(parameters); Assert.AreEqual(1, connection.postStream.Calls); }
public Task <ExtractResponse> ExtractAsync(ExtractParameters parameters) { SetLastOperation(); return(Task.FromResult <ExtractResponse>(null)); }
public Task <ExtractResponse> ExtractAsync(ExtractParameters parameters) => PerformOperation(operations => operations.ExtractAsync(parameters));
public ExtractResponse Extract(ExtractParameters parameters) { return(PerformOperation(operations => operations.Extract(parameters), true)); }
public ExtractResponse Extract(ExtractParameters parameters) { var cmd = new ExtractCommand(parameters); return(SendAndParseExtract(cmd)); }
public ExtractCommand(ExtractParameters parameters) { this.parameters = parameters; }
public ExtractResponse Extract(ExtractParameters parameters) { return(basicServer.Extract(parameters)); }
public Task<ExtractResponse> ExtractAsync(ExtractParameters parameters) { SetLastOperation(); return null; }
public ExtractResponse Extract(ExtractParameters parameters) { throw new NotImplementedException(); }
public Task <ExtractResponse> ExtractAsync(ExtractParameters parameters) { throw new NotImplementedException(); }
public void Extract() { var parameters = new ExtractParameters(null, "1", "test.doc"); var connection = new MSolrConnection(); connection.postStream += (url, contentType, content, param) => { Assert.AreEqual("/update/extract", url); Assert.AreEqual(parameters.Content, content); var expectedParams = new[] { KV.Create("literal.id", parameters.Id), KV.Create("resource.name", parameters.ResourceName), }; Assert.AreElementsEqualIgnoringOrder(expectedParams, param); return EmbeddedResource.GetEmbeddedString(GetType(), "Resources.responseWithExtractContent.xml"); }; var docSerializer = new SolrDocumentSerializer<TestDocumentWithoutUniqueKey>(new AttributesMappingManager(), new DefaultFieldSerializer()); var extractResponseParser = new MSolrExtractResponseParser { parse = _ => new ExtractResponse(null) }; var ops = new SolrBasicServer<TestDocumentWithoutUniqueKey>(connection, null, docSerializer, null, null, null, null, extractResponseParser); ops.Extract(parameters); Assert.AreEqual(1, connection.postStream.Calls); }
public ExtractResponse Extract(ExtractParameters parameters) { provider.LastOperation = "Extract"; return(null); }
public Task <ExtractResponse> ExtractAsync(ExtractParameters parameters) => basicServer.ExtractAsync(parameters);
public ExtractResponse Extract(ExtractParameters parameters) { return(Balance(operations => operations.Extract(parameters), true)); }
public ExtractResponse Extract(ExtractParameters parameters) { SetLastOperation(); return(null); }
public void Extract() { var mocks = new MockRepository(); var connection = mocks.StrictMock<ISolrConnection>(); var executer = mocks.StrictMock<ISolrQueryExecuter<TestDocumentWithoutUniqueKey>>(); var headerParser = mocks.StrictMock<ISolrHeaderResponseParser>(); var extractResponseParser = mocks.StrictMock<ISolrExtractResponseParser>(); var docSerializer = new SolrDocumentSerializer<TestDocumentWithoutUniqueKey>(new AttributesMappingManager(), new DefaultFieldSerializer()); var parameters = new ExtractParameters(null, "1", "test.doc"); With.Mocks(mocks) .Expecting(() => { Expect.On(connection) .Call(connection.PostStream("/update/extract", null, parameters.Content, new List<KeyValuePair<string, string>> { new KeyValuePair<string, string>("literal.id", parameters.Id), new KeyValuePair<string, string>("resource.name", parameters.ResourceName), })) .Repeat.Once() .Return(EmbeddedResource.GetEmbeddedString(GetType(), "Resources.responseWithExtractContent.xml")); Expect.On(extractResponseParser) .Call(extractResponseParser.Parse(null)) .IgnoreArguments() .Return(new ExtractResponse(null)); }) .Verify(() => { var ops = new SolrBasicServer<TestDocumentWithoutUniqueKey>(connection, executer, docSerializer, null, headerParser, null, null, extractResponseParser); ops.Extract(parameters); }); }
/// <inheritdoc /> public Task <ExtractResponse> ExtractAsync(ExtractParameters parameters) { var cmd = new ExtractCommand(parameters); return(SendAndParseExtractAsync(cmd)); }