Repository: james-project Updated Branches: refs/heads/master b99d96654 -> c0ea1007f
JAMES-2426 Introduce skeleton and first test Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/ecb7c94f Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/ecb7c94f Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/ecb7c94f Branch: refs/heads/master Commit: ecb7c94fabf5017fc020c1ea6d490f3cd0b0847d Parents: d2b4143 Author: Raphael Ouazana <[email protected]> Authored: Wed Jun 13 17:44:22 2018 +0200 Committer: benwa <[email protected]> Committed: Tue Jun 19 15:05:22 2018 +0700 ---------------------------------------------------------------------- mailbox/backup/pom.xml | 79 ++++++++++++++++++++ .../org/apache/james/mailbox/backup/Backup.java | 30 ++++++++ .../org/apache/james/mailbox/backup/Zipper.java | 36 +++++++++ .../apache/james/mailbox/backup/ZipperTest.java | 53 +++++++++++++ mailbox/pom.xml | 1 + 5 files changed, 199 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/ecb7c94f/mailbox/backup/pom.xml ---------------------------------------------------------------------- diff --git a/mailbox/backup/pom.xml b/mailbox/backup/pom.xml new file mode 100644 index 0000000..613dcfc --- /dev/null +++ b/mailbox/backup/pom.xml @@ -0,0 +1,79 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <artifactId>apache-james-mailbox</artifactId> + <groupId>org.apache.james</groupId> + <version>3.1.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>backup</artifactId> + <packaging>jar</packaging> + + <name>Apache James :: Mailbox :: Backup</name> + + <dependencies> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>apache-james-mailbox-api</artifactId> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>apache-james-mailbox-store</artifactId> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>james-server-testing</artifactId> + </dependency> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + </dependency> + <dependency> + <groupId>nl.jqno.equalsverifier</groupId> + <artifactId>equalsverifier</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-compress</artifactId> + <version>1.17</version> + </dependency> + <dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-engine</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit.platform</groupId> + <artifactId>junit-platform-launcher</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + +</project> http://git-wip-us.apache.org/repos/asf/james-project/blob/ecb7c94f/mailbox/backup/src/main/java/org/apache/james/mailbox/backup/Backup.java ---------------------------------------------------------------------- diff --git a/mailbox/backup/src/main/java/org/apache/james/mailbox/backup/Backup.java b/mailbox/backup/src/main/java/org/apache/james/mailbox/backup/Backup.java new file mode 100644 index 0000000..2f2d6a4 --- /dev/null +++ b/mailbox/backup/src/main/java/org/apache/james/mailbox/backup/Backup.java @@ -0,0 +1,30 @@ +/**************************************************************** + * 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.mailbox.backup; + +import java.io.File; +import java.io.IOException; +import java.util.List; + +import org.apache.james.mailbox.store.mail.model.MailboxMessage; + +public interface Backup { + + void archive(List<MailboxMessage> messages, File destination) throws IOException; +} http://git-wip-us.apache.org/repos/asf/james-project/blob/ecb7c94f/mailbox/backup/src/main/java/org/apache/james/mailbox/backup/Zipper.java ---------------------------------------------------------------------- diff --git a/mailbox/backup/src/main/java/org/apache/james/mailbox/backup/Zipper.java b/mailbox/backup/src/main/java/org/apache/james/mailbox/backup/Zipper.java new file mode 100644 index 0000000..c3ee4fb --- /dev/null +++ b/mailbox/backup/src/main/java/org/apache/james/mailbox/backup/Zipper.java @@ -0,0 +1,36 @@ +/**************************************************************** + * 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.mailbox.backup; + +import java.io.File; +import java.io.IOException; +import java.util.List; + +import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; +import org.apache.james.mailbox.store.mail.model.MailboxMessage; + +public class Zipper implements Backup { + + @Override + public void archive(List<MailboxMessage> messages, File destination) throws IOException { + try (ZipArchiveOutputStream archiveOutputStream = new ZipArchiveOutputStream(destination)) { + archiveOutputStream.finish(); + } + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/ecb7c94f/mailbox/backup/src/test/java/org/apache/james/mailbox/backup/ZipperTest.java ---------------------------------------------------------------------- diff --git a/mailbox/backup/src/test/java/org/apache/james/mailbox/backup/ZipperTest.java b/mailbox/backup/src/test/java/org/apache/james/mailbox/backup/ZipperTest.java new file mode 100644 index 0000000..25d2fbb --- /dev/null +++ b/mailbox/backup/src/test/java/org/apache/james/mailbox/backup/ZipperTest.java @@ -0,0 +1,53 @@ +/**************************************************************** + * 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.mailbox.backup; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.File; + +import org.apache.commons.compress.archivers.zip.ZipFile; +import org.apache.james.junit.TemporaryFolderExtension; +import org.apache.james.junit.TemporaryFolderExtension.TemporaryFolder; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import com.google.common.collect.ImmutableList; + +@ExtendWith(TemporaryFolderExtension.class) +public class ZipperTest { + private Zipper testee; + + @BeforeEach + void beforeEach() { + testee = new Zipper(); + } + + @Test + void archiveShouldWriteEmptyValidArchiveWhenNoMessage(TemporaryFolder temporaryFolder) throws Exception { + File destination = File.createTempFile("backup-test", ".zip", temporaryFolder.getTempDir()); + testee.archive(ImmutableList.of(), destination); + + try (ZipFile zipFile = new ZipFile(destination)) { + assertThat(zipFile.getEntries().hasMoreElements()).isFalse(); + } + } + +} http://git-wip-us.apache.org/repos/asf/james-project/blob/ecb7c94f/mailbox/pom.xml ---------------------------------------------------------------------- diff --git a/mailbox/pom.xml b/mailbox/pom.xml index 2fa50dd..a542075 100644 --- a/mailbox/pom.xml +++ b/mailbox/pom.xml @@ -36,6 +36,7 @@ <modules> <module>api</module> + <module>backup</module> <module>caching</module> <module>cassandra</module> <module>elasticsearch</module> --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
