Exemplo n.º 1
0
        public void TestLargeDocumentSplitOk()
        {
            GlobalOptions options = MongoDbPopulatorTestHelper.GetNewMongoDbPopulatorOptions();

            options.MongoDbPopulatorOptions.MongoDbFlushTime = int.MaxValue / 1000;

            var adapter   = new MongoDbAdapter("ImageProcessor", options.MongoDatabases.ExtractionStoreOptions, "largeDocumentTest");
            var processor = new ImageMessageProcessor(options.MongoDbPopulatorOptions, adapter, 2, null);
            var mockModel = Mock.Of <IModel>();

            processor.Model = mockModel;

            var dataset = new DicomDataset
            {
                new DicomUnlimitedText(DicomTag.SelectorUTValue, new string('x', 15 * 1024 * 1024))
            };

            var largeMessage = new DicomFileMessage
            {
                SeriesInstanceUID           = "",
                StudyInstanceUID            = "",
                SOPInstanceUID              = "",
                NationalPACSAccessionNumber = "",
                DicomFilePath = "",
                DicomDataset  = DicomTypeTranslater.SerializeDatasetToJson(dataset)
            };

            processor.AddToWriteQueue(largeMessage, new MessageHeader(), 1);
            processor.AddToWriteQueue(largeMessage, new MessageHeader(), 2);
        }
Exemplo n.º 2
0
        public void TestImageDocumentFormat()
        {
            GlobalOptions options = MongoDbPopulatorTestHelper.GetNewMongoDbPopulatorOptions();

            options.MongoDbPopulatorOptions.MongoDbFlushTime = int.MaxValue / 1000;

            string collectionName = MongoDbPopulatorTestHelper.GetCollectionNameForTest("TestImageDocumentFormat");
            var    testAdapter    = new MongoDbAdapter("TestImageDocumentFormat", options.MongoDatabases.DicomStoreOptions, collectionName);

            var callbackUsed = false;
            Action <Exception> exceptionCallback = (exception) => { callbackUsed = true; };

            var processor = new ImageMessageProcessor(options.MongoDbPopulatorOptions, testAdapter, 1, exceptionCallback)
            {
                Model = Mock.Of <IModel>()
            };

            var header = new MessageHeader();

            // Max queue size set to 1 so will immediately process this
            processor.AddToWriteQueue(_helper.TestImageMessage, header, 1);

            Assert.False(callbackUsed);
            Assert.True(processor.AckCount == 1);

            IMongoCollection <BsonDocument> imageCollection = _helper.TestDatabase.GetCollection <BsonDocument>(collectionName + "_SR");

            Assert.True(imageCollection.CountDocuments(new BsonDocument()) == 1);

            BsonDocument doc = imageCollection.FindAsync(FilterDefinition <BsonDocument> .Empty).Result.Single();

            Validate(_helper.TestImageMessage, header, doc);
        }
Exemplo n.º 3
0
        public void TestSeriesDocumentFormat()
        {
            GlobalOptions options = MongoDbPopulatorTestHelper.GetNewMongoDbPopulatorOptions();

            options.MongoDbPopulatorOptions.MongoDbFlushTime = int.MaxValue;

            string collectionName = MongoDbPopulatorTestHelper.GetCollectionNameForTest("TestSeriesDocumentFormat");
            var    testAdapter    = new MongoDbAdapter("TestSeriesDocumentFormat", options.MongoDatabases.DicomStoreOptions, collectionName);

            var callbackUsed = false;
            Action <Exception> exceptionCallback = (exception) => { callbackUsed = true; };

            var processor = new SeriesMessageProcessor(options.MongoDbPopulatorOptions, testAdapter, 1, exceptionCallback)
            {
                Model = Mock.Of <IModel>()
            };

            // Max queue size set to 1 so will immediately process this
            processor.AddToWriteQueue(_helper.TestSeriesMessage, new MessageHeader(), 1);

            Assert.False(callbackUsed);
            Assert.True(processor.AckCount == 1);

            IMongoCollection <BsonDocument> collection = _helper.TestDatabase.GetCollection <BsonDocument>(collectionName);

            Assert.True(collection.CountDocuments(new BsonDocument()) == 1);

            BsonDocument document = collection.Find(_ => true).ToList()[0];

            Validate(_helper.TestSeriesMessage, document);
        }
Exemplo n.º 4
0
        public void TestMissingMongoConnectionOnStartup()
        {
            GlobalOptions options = MongoDbPopulatorTestHelper.GetNewMongoDbPopulatorOptions();

            options.MongoDatabases.DicomStoreOptions.Port = 12345;

            // ReSharper disable once ObjectCreationAsStatement
            Assert.Throws <ArgumentException>(() => new MongoDbPopulatorMessageConsumer <DicomFileMessage>(options.MongoDatabases.DicomStoreOptions, options.MongoDbPopulatorOptions, null));
        }
Exemplo n.º 5
0
        public void TestLargeMessageNack()
        {
            GlobalOptions options = MongoDbPopulatorTestHelper.GetNewMongoDbPopulatorOptions();

            options.MongoDbPopulatorOptions.MongoDbFlushTime = int.MaxValue / 1000;

            var adapter   = new MongoDbAdapter("ImageProcessor", options.MongoDatabases.ExtractionStoreOptions, "largeDocumentTest");
            var processor = new ImageMessageProcessor(options.MongoDbPopulatorOptions, adapter, 1, null);
            var mockModel = Mock.Of <IModel>();

            processor.Model = mockModel;

            var dataset = new DicomDataset
            {
                new DicomUnlimitedText(DicomTag.SelectorUTValue, new string('x', 16 * 1024 * 1024))
            };

            string json = DicomTypeTranslater.SerializeDatasetToJson(dataset);

            var largeMessage = new DicomFileMessage
            {
                SeriesInstanceUID           = "",
                StudyInstanceUID            = "",
                SOPInstanceUID              = "",
                NationalPACSAccessionNumber = "",
                DicomFilePath = "",
                DicomDataset  = json
            };

            Assert.Throws <ApplicationException>(() => processor.AddToWriteQueue(largeMessage, new MessageHeader(), 1));

            dataset = new DicomDataset
            {
                // Should be ok, getting close to the threshold
                new DicomUnlimitedText(DicomTag.SelectorUTValue, new string('x', 15 * 1024 * 1024 + 512))
            };

            json = DicomTypeTranslater.SerializeDatasetToJson(dataset);
            largeMessage.DicomDataset = json;

            processor.AddToWriteQueue(largeMessage, new MessageHeader(), 2);
            Assert.True(processor.AckCount == 1);
        }