chibenwa commented on code in PR #3213: URL: https://github.com/apache/james-project/pull/3213#discussion_r4143492615
########## server/mailrepository/mailrepository-blob/src/test/java/org/apache/james/mailrepository/blob/BlobMailRepositoryV2Test.java: ########## @@ -0,0 +1,87 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ + +package org.apache.james.mailrepository.blob; + +import org.apache.james.blob.api.PlainBlobId; +import org.apache.james.blob.mail.MimeMessageStore; +import org.apache.james.blob.memory.MemoryBlobStoreDAO; +import org.apache.james.blob.memory.MemoryBlobStoreFactory; +import org.apache.james.mailrepository.MailRepositoryContract; +import org.apache.james.mailrepository.api.MailRepository; +import org.apache.james.mailrepository.api.MailRepositoryPath; +import org.apache.james.mailrepository.api.MailRepositoryUrl; +import org.apache.james.mailrepository.api.Protocol; +import org.jetbrains.annotations.NotNull; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Skeleton contract test for {@link BlobMailRepositoryV2}. + * + * Mirrors {@link BlobMailRepositoryTest}: this only exercises the + * generic {@link MailRepositoryContract} behaviour. V2-specific + * isolation/GC-reference scenarios are intentionally left out of this + * PR's scope and will be addressed in a follow-up PR, per review + * feedback (cf feedback.md / PR #3213 discussion with @chibenwa). + */ +class BlobMailRepositoryV2Test implements MailRepositoryContract { + + private MailRepository blobMailRepositoryV2; + private PlainBlobId.Factory blobIdFactory; + private MemoryBlobStoreDAO blobStore; + private MimeMessageStore.Factory mimeMessageStoreFactory; + private BlobMailRepositoryV2Factory blobMailRepositoryV2Factory; + + @BeforeEach + void setup() { + blobIdFactory = new PlainBlobId.Factory(); + blobStore = new MemoryBlobStoreDAO(); + var mimeMessageBlobStore = MemoryBlobStoreFactory.builder() + .blobIdFactory(blobIdFactory) + .defaultBucketName() + .passthrough(); + mimeMessageStoreFactory = new MimeMessageStore.Factory(mimeMessageBlobStore); + MailRepositoryPath path = MailRepositoryPath.from("var/mail/error"); + blobMailRepositoryV2Factory = new BlobMailRepositoryV2Factory(blobStore, blobIdFactory, mimeMessageBlobStore.getDefaultBucketName()); + blobMailRepositoryV2 = buildBlobMailRepositoryV2(path); + } + + @NotNull + private MailRepository buildBlobMailRepositoryV2(MailRepositoryPath path) { + return blobMailRepositoryV2Factory.create(MailRepositoryUrl.fromPathAndProtocol(new Protocol("blobv2"), path)); + } + + @Override + public MailRepository retrieveRepository() { + return blobMailRepositoryV2; + } + + @Override + public MailRepository retrieveRepository(MailRepositoryPath path) { + return buildBlobMailRepositoryV2(path); + } + + @Test + @Disabled("This repository removes blobs rather than mails: it can not tell which of them back a mail") + @Override + public void removeAllShouldReportTheRemovedMails() { + } Review Comment: That's a pity can't we manage to solve this one in v2 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
