JAMES-2008 Move away from JUNIT contract tests in Mapper tests
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/e9a73fd1 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/e9a73fd1 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/e9a73fd1 Branch: refs/heads/master Commit: e9a73fd1cb8c07feb708cc60f6d0ae2c727a8fc9 Parents: d8e844e Author: benwa <btell...@linagora.com> Authored: Wed Apr 19 11:55:53 2017 +0700 Committer: Antoine Duprat <adup...@linagora.com> Committed: Tue Apr 25 08:58:13 2017 +0200 ---------------------------------------------------------------------- .../mail/CassandraAnnotationMapperTest.java | 30 +++ .../mail/CassandraAttachmentMapperTest.java | 30 +++ .../mail/CassandraGenericMailboxMapperTest.java | 30 +++ .../cassandra/mail/CassandraMappersTest.java | 59 ------ .../mail/CassandraMessageIdMapperTest.java | 29 +++ .../mail/CassandraMessageMapperTest.java | 30 +++ .../mail/CassandraMessageMoveTest.java | 30 +++ ...assandraMessageWithAttachmentMapperTest.java | 30 +++ .../james/mailbox/jpa/mail/JPAMappersTest.java | 59 ------ .../jpa/mail/JpaAnnotationMapperTest.java | 30 +++ .../mailbox/jpa/mail/JpaMailboxMapperTest.java | 30 +++ .../mailbox/jpa/mail/JpaMessageMapperTest.java | 30 +++ .../inmemory/mail/InMemoryMapperProvider.java | 19 ++ .../mail/MemoryAnnotationMapperTest.java | 30 +++ .../mail/MemoryAttachmentMapperTest.java | 30 +++ .../inmemory/mail/MemoryMailboxMapperTest.java | 30 +++ .../inmemory/mail/MemoryMappersTest.java | 59 ------ .../inmemory/mail/MemoryMessageMapperTest.java | 30 +++ .../inmemory/mail/MemoryMessageMoveTest.java | 31 +++ .../MemoryMessageWithAttachmentMapperTest.java | 30 +++ mailbox/store/pom.xml | 5 - .../store/mail/model/AnnotationMapperTest.java | 69 ++++--- .../store/mail/model/AttachmentMapperTest.java | 41 ++-- .../store/mail/model/MailboxMapperTest.java | 60 +++--- .../store/mail/model/MessageIdMapperTest.java | 116 ++++++----- .../store/mail/model/MessageMapperTest.java | 196 +++++++++---------- .../store/mail/model/MessageMoveTest.java | 32 ++- .../model/MessageWithAttachmentMapperTest.java | 37 ++-- 28 files changed, 769 insertions(+), 463 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/e9a73fd1/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAnnotationMapperTest.java ---------------------------------------------------------------------- diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAnnotationMapperTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAnnotationMapperTest.java new file mode 100644 index 0000000..775ab0a --- /dev/null +++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAnnotationMapperTest.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.cassandra.mail; + +import org.apache.james.mailbox.store.mail.model.AnnotationMapperTest; +import org.apache.james.mailbox.store.mail.model.MapperProvider; + +public class CassandraAnnotationMapperTest extends AnnotationMapperTest { + @Override + protected MapperProvider createMapperProvider() { + return new CassandraMapperProvider(); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/e9a73fd1/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentMapperTest.java ---------------------------------------------------------------------- diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentMapperTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentMapperTest.java new file mode 100644 index 0000000..c144e06 --- /dev/null +++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentMapperTest.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.cassandra.mail; + +import org.apache.james.mailbox.store.mail.model.AttachmentMapperTest; +import org.apache.james.mailbox.store.mail.model.MapperProvider; + +public class CassandraAttachmentMapperTest extends AttachmentMapperTest { + @Override + protected MapperProvider createMapperProvider() { + return new CassandraMapperProvider(); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/e9a73fd1/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraGenericMailboxMapperTest.java ---------------------------------------------------------------------- diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraGenericMailboxMapperTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraGenericMailboxMapperTest.java new file mode 100644 index 0000000..60a1dab --- /dev/null +++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraGenericMailboxMapperTest.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.cassandra.mail; + +import org.apache.james.mailbox.store.mail.model.MailboxMapperTest; +import org.apache.james.mailbox.store.mail.model.MapperProvider; + +public class CassandraGenericMailboxMapperTest extends MailboxMapperTest { + @Override + protected MapperProvider createMapperProvider() { + return new CassandraMapperProvider(); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/e9a73fd1/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMappersTest.java ---------------------------------------------------------------------- diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMappersTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMappersTest.java deleted file mode 100644 index bf2eb64..0000000 --- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMappersTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************** - * 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.cassandra.mail; - -import org.apache.james.mailbox.exception.MailboxException; -import org.junit.runner.RunWith; -import org.xenei.junit.contract.Contract; -import org.xenei.junit.contract.ContractImpl; -import org.xenei.junit.contract.ContractSuite; -import org.xenei.junit.contract.IProducer; - -import com.google.common.base.Throwables; - -@RunWith(ContractSuite.class) -@ContractImpl(CassandraMapperProvider.class) -public class CassandraMappersTest { - - private IProducer<CassandraMapperProvider> producer = new IProducer<CassandraMapperProvider>() { - - private final CassandraMapperProvider cassandraMapperProvider = new CassandraMapperProvider(); - - @Override - public CassandraMapperProvider newInstance() { - return cassandraMapperProvider; - } - - @Override - public void cleanUp() { - try { - cassandraMapperProvider.clearMapper(); - } catch (MailboxException e) { - throw Throwables.propagate(e); - } - } - }; - - @Contract.Inject - public IProducer<CassandraMapperProvider> getProducer() { - return producer; - } - -} http://git-wip-us.apache.org/repos/asf/james-project/blob/e9a73fd1/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapperTest.java ---------------------------------------------------------------------- diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapperTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapperTest.java new file mode 100644 index 0000000..bc4bdfd --- /dev/null +++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapperTest.java @@ -0,0 +1,29 @@ +/**************************************************************** + * 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.cassandra.mail; + +import org.apache.james.mailbox.store.mail.model.MessageIdMapperTest; + +public class CassandraMessageIdMapperTest extends MessageIdMapperTest { + @Override + protected CassandraMapperProvider provideMapper() { + return new CassandraMapperProvider(); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/e9a73fd1/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapperTest.java ---------------------------------------------------------------------- diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapperTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapperTest.java new file mode 100644 index 0000000..391bea1 --- /dev/null +++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapperTest.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.cassandra.mail; + +import org.apache.james.mailbox.store.mail.model.MapperProvider; +import org.apache.james.mailbox.store.mail.model.MessageMapperTest; + +public class CassandraMessageMapperTest extends MessageMapperTest { + @Override + protected MapperProvider createMapperProvider() { + return new CassandraMapperProvider(); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/e9a73fd1/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMoveTest.java ---------------------------------------------------------------------- diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMoveTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMoveTest.java new file mode 100644 index 0000000..2bd7701 --- /dev/null +++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMoveTest.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.cassandra.mail; + +import org.apache.james.mailbox.store.mail.model.MapperProvider; +import org.apache.james.mailbox.store.mail.model.MessageMoveTest; + +public class CassandraMessageMoveTest extends MessageMoveTest { + @Override + protected MapperProvider createMapperProvider() { + return new CassandraMapperProvider(); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/e9a73fd1/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageWithAttachmentMapperTest.java ---------------------------------------------------------------------- diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageWithAttachmentMapperTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageWithAttachmentMapperTest.java new file mode 100644 index 0000000..256298d --- /dev/null +++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageWithAttachmentMapperTest.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.cassandra.mail; + +import org.apache.james.mailbox.store.mail.model.MapperProvider; +import org.apache.james.mailbox.store.mail.model.MessageWithAttachmentMapperTest; + +public class CassandraMessageWithAttachmentMapperTest extends MessageWithAttachmentMapperTest { + @Override + protected MapperProvider createMapperProvider() { + return new CassandraMapperProvider(); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/e9a73fd1/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/JPAMappersTest.java ---------------------------------------------------------------------- diff --git a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/JPAMappersTest.java b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/JPAMappersTest.java deleted file mode 100644 index 99b6def..0000000 --- a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/JPAMappersTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************** - * 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.jpa.mail; - -import org.apache.james.mailbox.exception.MailboxException; -import org.junit.runner.RunWith; -import org.xenei.junit.contract.Contract; -import org.xenei.junit.contract.ContractImpl; -import org.xenei.junit.contract.ContractSuite; -import org.xenei.junit.contract.IProducer; - -import com.google.common.base.Throwables; - -@RunWith(ContractSuite.class) -@ContractImpl(JPAMapperProvider.class) -public class JPAMappersTest { - - private IProducer<JPAMapperProvider> producer = new IProducer<JPAMapperProvider>() { - - private final JPAMapperProvider jpaMapperProvider = new JPAMapperProvider(); - - @Override - public JPAMapperProvider newInstance() { - return jpaMapperProvider; - } - - @Override - public void cleanUp() { - try { - jpaMapperProvider.clearMapper(); - } catch (MailboxException e) { - throw Throwables.propagate(e); - } - } - }; - - @Contract.Inject - public IProducer<JPAMapperProvider> getProducer() { - return producer; - } - -} http://git-wip-us.apache.org/repos/asf/james-project/blob/e9a73fd1/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/JpaAnnotationMapperTest.java ---------------------------------------------------------------------- diff --git a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/JpaAnnotationMapperTest.java b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/JpaAnnotationMapperTest.java new file mode 100644 index 0000000..767b8c1 --- /dev/null +++ b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/JpaAnnotationMapperTest.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.jpa.mail; + +import org.apache.james.mailbox.store.mail.model.AnnotationMapperTest; +import org.apache.james.mailbox.store.mail.model.MapperProvider; + +public class JpaAnnotationMapperTest extends AnnotationMapperTest { + @Override + protected MapperProvider createMapperProvider() { + return new JPAMapperProvider(); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/e9a73fd1/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/JpaMailboxMapperTest.java ---------------------------------------------------------------------- diff --git a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/JpaMailboxMapperTest.java b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/JpaMailboxMapperTest.java new file mode 100644 index 0000000..4429d34 --- /dev/null +++ b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/JpaMailboxMapperTest.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.jpa.mail; + +import org.apache.james.mailbox.store.mail.model.MailboxMapperTest; +import org.apache.james.mailbox.store.mail.model.MapperProvider; + +public class JpaMailboxMapperTest extends MailboxMapperTest { + @Override + protected MapperProvider createMapperProvider() { + return new JPAMapperProvider(); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/e9a73fd1/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/JpaMessageMapperTest.java ---------------------------------------------------------------------- diff --git a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/JpaMessageMapperTest.java b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/JpaMessageMapperTest.java new file mode 100644 index 0000000..ce0605d --- /dev/null +++ b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/JpaMessageMapperTest.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.jpa.mail; + +import org.apache.james.mailbox.store.mail.model.MapperProvider; +import org.apache.james.mailbox.store.mail.model.MessageMapperTest; + +public class JpaMessageMapperTest extends MessageMapperTest { + @Override + protected MapperProvider createMapperProvider() { + return new JPAMapperProvider(); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/e9a73fd1/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMapperProvider.java ---------------------------------------------------------------------- diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMapperProvider.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMapperProvider.java index 1f2f65a..bcf216f 100644 --- a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMapperProvider.java +++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMapperProvider.java @@ -1,3 +1,22 @@ +/**************************************************************** + * 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.inmemory.mail; import java.util.List; http://git-wip-us.apache.org/repos/asf/james-project/blob/e9a73fd1/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryAnnotationMapperTest.java ---------------------------------------------------------------------- diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryAnnotationMapperTest.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryAnnotationMapperTest.java new file mode 100644 index 0000000..816844c --- /dev/null +++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryAnnotationMapperTest.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.inmemory.mail; + +import org.apache.james.mailbox.store.mail.model.AnnotationMapperTest; +import org.apache.james.mailbox.store.mail.model.MapperProvider; + +public class MemoryAnnotationMapperTest extends AnnotationMapperTest { + @Override + protected MapperProvider createMapperProvider() { + return new InMemoryMapperProvider(); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/e9a73fd1/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryAttachmentMapperTest.java ---------------------------------------------------------------------- diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryAttachmentMapperTest.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryAttachmentMapperTest.java new file mode 100644 index 0000000..a67688a --- /dev/null +++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryAttachmentMapperTest.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.inmemory.mail; + +import org.apache.james.mailbox.store.mail.model.AttachmentMapperTest; +import org.apache.james.mailbox.store.mail.model.MapperProvider; + +public class MemoryAttachmentMapperTest extends AttachmentMapperTest { + @Override + protected MapperProvider createMapperProvider() { + return new InMemoryMapperProvider(); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/e9a73fd1/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryMailboxMapperTest.java ---------------------------------------------------------------------- diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryMailboxMapperTest.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryMailboxMapperTest.java new file mode 100644 index 0000000..26acf6a --- /dev/null +++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryMailboxMapperTest.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.inmemory.mail; + +import org.apache.james.mailbox.store.mail.model.MailboxMapperTest; +import org.apache.james.mailbox.store.mail.model.MapperProvider; + +public class MemoryMailboxMapperTest extends MailboxMapperTest { + @Override + protected MapperProvider createMapperProvider() { + return new InMemoryMapperProvider(); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/e9a73fd1/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryMappersTest.java ---------------------------------------------------------------------- diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryMappersTest.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryMappersTest.java deleted file mode 100644 index 86c8617..0000000 --- a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryMappersTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************** - * 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.inmemory.mail; - -import org.apache.james.mailbox.exception.MailboxException; -import org.junit.runner.RunWith; -import org.xenei.junit.contract.Contract; -import org.xenei.junit.contract.ContractImpl; -import org.xenei.junit.contract.ContractSuite; -import org.xenei.junit.contract.IProducer; - -import com.google.common.base.Throwables; - -@RunWith(ContractSuite.class) -@ContractImpl(InMemoryMapperProvider.class) -public class MemoryMappersTest { - - private IProducer<InMemoryMapperProvider> producer = new IProducer<InMemoryMapperProvider>() { - - private final InMemoryMapperProvider mapperProvider = new InMemoryMapperProvider(); - - @Override - public InMemoryMapperProvider newInstance() { - return mapperProvider; - } - - @Override - public void cleanUp() { - try { - mapperProvider.clearMapper(); - } catch (MailboxException e) { - throw Throwables.propagate(e); - } - } - }; - - @Contract.Inject - public IProducer<InMemoryMapperProvider> getProducer() { - return producer; - } - -} http://git-wip-us.apache.org/repos/asf/james-project/blob/e9a73fd1/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryMessageMapperTest.java ---------------------------------------------------------------------- diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryMessageMapperTest.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryMessageMapperTest.java new file mode 100644 index 0000000..298786d --- /dev/null +++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryMessageMapperTest.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.inmemory.mail; + +import org.apache.james.mailbox.store.mail.model.MapperProvider; +import org.apache.james.mailbox.store.mail.model.MessageMapperTest; + +public class MemoryMessageMapperTest extends MessageMapperTest { + @Override + protected MapperProvider createMapperProvider() { + return new InMemoryMapperProvider(); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/e9a73fd1/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryMessageMoveTest.java ---------------------------------------------------------------------- diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryMessageMoveTest.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryMessageMoveTest.java new file mode 100644 index 0000000..0b8e2fb --- /dev/null +++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryMessageMoveTest.java @@ -0,0 +1,31 @@ +/**************************************************************** + * 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.inmemory.mail; + +import org.apache.james.mailbox.store.mail.model.MapperProvider; +import org.apache.james.mailbox.store.mail.model.MessageMoveTest; + +public class MemoryMessageMoveTest extends MessageMoveTest { + + @Override + protected MapperProvider createMapperProvider() { + return new InMemoryMapperProvider(); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/e9a73fd1/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryMessageWithAttachmentMapperTest.java ---------------------------------------------------------------------- diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryMessageWithAttachmentMapperTest.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryMessageWithAttachmentMapperTest.java new file mode 100644 index 0000000..3bab206 --- /dev/null +++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryMessageWithAttachmentMapperTest.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.inmemory.mail; + +import org.apache.james.mailbox.store.mail.model.MapperProvider; +import org.apache.james.mailbox.store.mail.model.MessageWithAttachmentMapperTest; + +public class MemoryMessageWithAttachmentMapperTest extends MessageWithAttachmentMapperTest { + @Override + protected MapperProvider createMapperProvider() { + return new InMemoryMapperProvider(); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/e9a73fd1/mailbox/store/pom.xml ---------------------------------------------------------------------- diff --git a/mailbox/store/pom.xml b/mailbox/store/pom.xml index 688f688..3dda386 100644 --- a/mailbox/store/pom.xml +++ b/mailbox/store/pom.xml @@ -119,11 +119,6 @@ <version>0.7.0-p9</version> </dependency> <dependency> - <groupId>org.xenei</groupId> - <artifactId>junit-contracts</artifactId> - <scope>test</scope> - </dependency> - <dependency> <groupId>org.apache.james</groupId> <artifactId>apache-james-mailbox-api</artifactId> <type>test-jar</type> http://git-wip-us.apache.org/repos/asf/james-project/blob/e9a73fd1/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AnnotationMapperTest.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AnnotationMapperTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AnnotationMapperTest.java index f634ac6..13fa75a 100644 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AnnotationMapperTest.java +++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AnnotationMapperTest.java @@ -28,16 +28,14 @@ import org.apache.james.mailbox.model.MailboxId; import org.apache.james.mailbox.store.mail.AnnotationMapper; import org.junit.After; import org.junit.Assume; +import org.junit.Before; import org.junit.Rule; +import org.junit.Test; import org.junit.rules.ExpectedException; -import org.xenei.junit.contract.Contract; -import org.xenei.junit.contract.ContractTest; -import org.xenei.junit.contract.IProducer; import com.google.common.collect.ImmutableSet; -@Contract(MapperProvider.class) -public class AnnotationMapperTest<T extends MapperProvider> { +public abstract class AnnotationMapperTest { private static final MailboxAnnotationKey PRIVATE_USER_KEY = new MailboxAnnotationKey("/private/commentuser"); private static final MailboxAnnotationKey PRIVATE_UPPER_CASE_KEY = new MailboxAnnotationKey("/PRIVATE/COMMENT"); private static final MailboxAnnotationKey PRIVATE_KEY = new MailboxAnnotationKey("/private/comment"); @@ -54,43 +52,44 @@ public class AnnotationMapperTest<T extends MapperProvider> { private static final MailboxAnnotation PRIVATE_GRANDCHILD_ANNOTATION = MailboxAnnotation.newInstance(PRIVATE_GRANDCHILD_KEY, "My private comment"); - - private IProducer<T> producer; private AnnotationMapper annotationMapper; + private MapperProvider mapperProvider; private MailboxId mailboxId; @Rule public ExpectedException expected = ExpectedException.none(); - @Contract.Inject - public final void setProducer(IProducer<T> producer) throws MailboxException { - T newInstance = producer.newInstance(); - Assume.assumeTrue(newInstance.getSupportedCapabilities().contains(MapperProvider.Capabilities.ANNOTATION)); + protected abstract MapperProvider createMapperProvider(); + + @Before + public final void setUp() throws MailboxException { + mapperProvider = createMapperProvider(); + mapperProvider.ensureMapperPrepared(); + Assume.assumeTrue(mapperProvider.getSupportedCapabilities().contains(MapperProvider.Capabilities.ANNOTATION)); - this.producer = producer; - this.annotationMapper = newInstance.createAnnotationMapper(); - this.mailboxId = newInstance.generateId(); + this.annotationMapper = mapperProvider.createAnnotationMapper(); + this.mailboxId = mapperProvider.generateId(); } @After - public void tearDown() { - producer.cleanUp(); + public void tearDown() throws MailboxException { + mapperProvider.clearMapper(); } - @ContractTest + @Test public void insertAnnotationShouldThrowExceptionWithNilData() { expected.expect(IllegalArgumentException.class); annotationMapper.insertAnnotation(mailboxId, MailboxAnnotation.nil(PRIVATE_KEY)); } - @ContractTest + @Test public void insertAnnotationShouldCreateNewAnnotation() throws MailboxException { annotationMapper.insertAnnotation(mailboxId, PRIVATE_ANNOTATION); assertThat(annotationMapper.getAllAnnotations(mailboxId)).containsExactly(PRIVATE_ANNOTATION); } - @ContractTest + @Test public void insertAnnotationShouldUpdateExistedAnnotation() throws MailboxException { annotationMapper.insertAnnotation(mailboxId, PRIVATE_ANNOTATION); annotationMapper.insertAnnotation(mailboxId, PRIVATE_ANNOTATION_UPDATE); @@ -98,7 +97,7 @@ public class AnnotationMapperTest<T extends MapperProvider> { assertThat(annotationMapper.getAllAnnotations(mailboxId)).containsExactly(PRIVATE_ANNOTATION_UPDATE); } - @ContractTest + @Test public void deleteAnnotationShouldDeleteStoredAnnotation() throws MailboxException { annotationMapper.insertAnnotation(mailboxId, PRIVATE_ANNOTATION); annotationMapper.deleteAnnotation(mailboxId, PRIVATE_KEY); @@ -106,12 +105,12 @@ public class AnnotationMapperTest<T extends MapperProvider> { assertThat(annotationMapper.getAllAnnotations(mailboxId)).isEmpty(); } - @ContractTest + @Test public void getEmptyAnnotationsWithNonStoredAnnotations() throws MailboxException { assertThat(annotationMapper.getAllAnnotations(mailboxId)).isEmpty(); } - @ContractTest + @Test public void getAllAnnotationsShouldRetrieveStoredAnnotations() throws MailboxException { annotationMapper.insertAnnotation(mailboxId, PRIVATE_ANNOTATION); annotationMapper.insertAnnotation(mailboxId, SHARED_ANNOTATION); @@ -119,7 +118,7 @@ public class AnnotationMapperTest<T extends MapperProvider> { assertThat(annotationMapper.getAllAnnotations(mailboxId)).containsOnly(PRIVATE_ANNOTATION, SHARED_ANNOTATION); } - @ContractTest + @Test public void getAnnotationsByKeysShouldReturnStoredAnnotationWithFilter() throws MailboxException { annotationMapper.insertAnnotation(mailboxId, PRIVATE_ANNOTATION); annotationMapper.insertAnnotation(mailboxId, PRIVATE_CHILD_ANNOTATION); @@ -128,7 +127,7 @@ public class AnnotationMapperTest<T extends MapperProvider> { .containsOnly(PRIVATE_ANNOTATION); } - @ContractTest + @Test public void getAnnotationsByKeysWithOneDepthShouldReturnThatEntryAndItsChildren() throws MailboxException { annotationMapper.insertAnnotation(mailboxId, PRIVATE_ANNOTATION); annotationMapper.insertAnnotation(mailboxId, PRIVATE_CHILD_ANNOTATION); @@ -140,7 +139,7 @@ public class AnnotationMapperTest<T extends MapperProvider> { .containsOnly(PRIVATE_ANNOTATION, PRIVATE_CHILD_ANNOTATION); } - @ContractTest + @Test public void getAnnotationsByKeysWithAllDepthShouldReturnThatEntryAndAllBelowEntries() throws MailboxException { annotationMapper.insertAnnotation(mailboxId, PRIVATE_ANNOTATION); annotationMapper.insertAnnotation(mailboxId, PRIVATE_CHILD_ANNOTATION); @@ -152,7 +151,7 @@ public class AnnotationMapperTest<T extends MapperProvider> { .containsOnly(PRIVATE_ANNOTATION, PRIVATE_CHILD_ANNOTATION, PRIVATE_GRANDCHILD_ANNOTATION); } - @ContractTest + @Test public void getAnnotationsByKeysWithOneDepthShouldReturnTheChildrenEntriesEvenItDoesNotExist() throws Exception { annotationMapper.insertAnnotation(mailboxId, PRIVATE_CHILD_ANNOTATION); annotationMapper.insertAnnotation(mailboxId, PRIVATE_GRANDCHILD_ANNOTATION); @@ -163,7 +162,7 @@ public class AnnotationMapperTest<T extends MapperProvider> { .containsOnly(PRIVATE_CHILD_ANNOTATION); } - @ContractTest + @Test public void getAnnotationsByKeysWithAllDepthShouldReturnTheChildrenEntriesEvenItDoesNotExist() throws Exception { annotationMapper.insertAnnotation(mailboxId, PRIVATE_CHILD_ANNOTATION); annotationMapper.insertAnnotation(mailboxId, PRIVATE_GRANDCHILD_ANNOTATION); @@ -174,7 +173,7 @@ public class AnnotationMapperTest<T extends MapperProvider> { .containsOnly(PRIVATE_CHILD_ANNOTATION, PRIVATE_GRANDCHILD_ANNOTATION); } - @ContractTest + @Test public void getAnnotationsByKeysWithOneDepthShouldReturnEmptyWithEmptyInputKeys() throws Exception { annotationMapper.insertAnnotation(mailboxId, PRIVATE_CHILD_ANNOTATION); annotationMapper.insertAnnotation(mailboxId, PRIVATE_GRANDCHILD_ANNOTATION); @@ -184,7 +183,7 @@ public class AnnotationMapperTest<T extends MapperProvider> { assertThat(annotationMapper.getAnnotationsByKeysWithOneDepth(mailboxId, ImmutableSet.<MailboxAnnotationKey>of())).isEmpty(); } - @ContractTest + @Test public void getAnnotationsByKeysWithOneDepthShouldReturnEmptyIfDoNotFind() throws Exception { annotationMapper.insertAnnotation(mailboxId, SHARED_ANNOTATION); annotationMapper.insertAnnotation(mailboxId, PRIVATE_USER_ANNOTATION); @@ -192,7 +191,7 @@ public class AnnotationMapperTest<T extends MapperProvider> { assertThat(annotationMapper.getAnnotationsByKeysWithOneDepth(mailboxId, ImmutableSet.of(PRIVATE_KEY))).isEmpty(); } - @ContractTest + @Test public void getAnnotationsByKeysWithAllDepthShouldReturnEmptyIfDoNotFind() throws Exception { annotationMapper.insertAnnotation(mailboxId, SHARED_ANNOTATION); annotationMapper.insertAnnotation(mailboxId, PRIVATE_USER_ANNOTATION); @@ -200,7 +199,7 @@ public class AnnotationMapperTest<T extends MapperProvider> { assertThat(annotationMapper.getAnnotationsByKeysWithAllDepth(mailboxId, ImmutableSet.of(PRIVATE_KEY))).isEmpty(); } - @ContractTest + @Test public void annotationShouldBeCaseInsentive() throws Exception { annotationMapper.insertAnnotation(mailboxId, PRIVATE_ANNOTATION); annotationMapper.insertAnnotation(mailboxId, PRIVATE_ANNOTATION_WITH_KEY_UPPER); @@ -208,24 +207,24 @@ public class AnnotationMapperTest<T extends MapperProvider> { assertThat(annotationMapper.getAllAnnotations(mailboxId)).containsOnly(PRIVATE_ANNOTATION_WITH_KEY_UPPER); } - @ContractTest + @Test public void isExistedShouldReturnTrueIfAnnotationIsStored() throws Exception { annotationMapper.insertAnnotation(mailboxId, PRIVATE_ANNOTATION); assertThat(annotationMapper.exist(mailboxId, PRIVATE_ANNOTATION)).isTrue(); } - @ContractTest + @Test public void isExistedShouldReturnFalseIfAnnotationIsNotStored() throws Exception { assertThat(annotationMapper.exist(mailboxId, PRIVATE_ANNOTATION)).isFalse(); } - @ContractTest + @Test public void countAnnotationShouldReturnZeroIfNoMoreAnnotationBelongToMailbox() throws Exception { assertThat(annotationMapper.countAnnotations(mailboxId)).isEqualTo(0); } - @ContractTest + @Test public void countAnnotationShouldReturnNumberOfAnnotationBelongToMailbox() throws Exception { annotationMapper.insertAnnotation(mailboxId, PRIVATE_ANNOTATION); annotationMapper.insertAnnotation(mailboxId, PRIVATE_ANNOTATION_UPDATE); http://git-wip-us.apache.org/repos/asf/james-project/blob/e9a73fd1/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AttachmentMapperTest.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AttachmentMapperTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AttachmentMapperTest.java index 10706f8..b0c7797 100644 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AttachmentMapperTest.java +++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AttachmentMapperTest.java @@ -30,50 +30,49 @@ import org.apache.james.mailbox.model.AttachmentId; import org.apache.james.mailbox.store.mail.AttachmentMapper; import org.junit.After; import org.junit.Assume; +import org.junit.Before; import org.junit.Rule; import org.junit.rules.ExpectedException; -import org.xenei.junit.contract.Contract; -import org.xenei.junit.contract.ContractTest; -import org.xenei.junit.contract.IProducer; +import org.junit.Test; import com.google.common.base.Charsets; import com.google.common.collect.ImmutableList; -@Contract(MapperProvider.class) -public class AttachmentMapperTest<T extends MapperProvider> { +public abstract class AttachmentMapperTest { - private IProducer<T> producer; private AttachmentMapper attachmentMapper; + private MapperProvider mapperProvider; @Rule public ExpectedException expected = ExpectedException.none(); - @Contract.Inject - public final void setProducer(IProducer<T> producer) throws MailboxException { - this.producer = producer; - T newInstance = producer.newInstance(); - Assume.assumeTrue(newInstance.getSupportedCapabilities().contains(MapperProvider.Capabilities.ATTACHMENT)); - this.attachmentMapper = newInstance.createAttachmentMapper(); + protected abstract MapperProvider createMapperProvider(); + + @Before + public final void setUp() throws MailboxException { + mapperProvider = createMapperProvider(); + Assume.assumeTrue(mapperProvider.getSupportedCapabilities().contains(MapperProvider.Capabilities.ATTACHMENT)); + this.attachmentMapper = mapperProvider.createAttachmentMapper(); } @After - public void tearDown() { - producer.cleanUp(); + public void tearDown() throws MailboxException { + mapperProvider.clearMapper(); } - @ContractTest + @Test public void getAttachmentShouldThrowWhenNullAttachmentId() throws Exception { expected.expect(IllegalArgumentException.class); attachmentMapper.getAttachment(null); } - @ContractTest + @Test public void getAttachmentShouldThrowWhenNonReferencedAttachmentId() throws Exception { expected.expect(AttachmentNotFoundException.class); attachmentMapper.getAttachment(AttachmentId.forPayload("unknown".getBytes(Charsets.UTF_8))); } - @ContractTest + @Test public void getAttachmentShouldReturnTheAttachmentWhenReferenced() throws Exception { //Given Attachment expected = Attachment.builder() @@ -88,7 +87,7 @@ public class AttachmentMapperTest<T extends MapperProvider> { assertThat(attachment).isEqualTo(expected); } - @ContractTest + @Test public void getAttachmentShouldReturnTheAttachmentsWhenMultipleStored() throws Exception { //Given Attachment expected1 = Attachment.builder() @@ -110,20 +109,20 @@ public class AttachmentMapperTest<T extends MapperProvider> { assertThat(attachment2).isEqualTo(expected2); } - @ContractTest + @Test public void getAttachmentsShouldThrowWhenNullAttachmentId() throws Exception { expected.expect(IllegalArgumentException.class); attachmentMapper.getAttachments(null); } - @ContractTest + @Test public void getAttachmentsShouldReturnEmptyListWhenNonReferencedAttachmentId() throws Exception { List<Attachment> attachments = attachmentMapper.getAttachments(ImmutableList.of(AttachmentId.forPayload("unknown".getBytes(Charsets.UTF_8)))); assertThat(attachments).isEmpty(); } - @ContractTest + @Test public void getAttachmentsShouldReturnTheAttachmentsWhenSome() throws Exception { //Given Attachment expected = Attachment.builder() http://git-wip-us.apache.org/repos/asf/james-project/blob/e9a73fd1/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperTest.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperTest.java index 36bbf79..6b0b14f 100644 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperTest.java +++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperTest.java @@ -33,19 +33,17 @@ import org.apache.james.mailbox.store.mail.MailboxMapper; import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox; import org.junit.After; import org.junit.Assume; +import org.junit.Before; import org.junit.Rule; +import org.junit.Test; import org.junit.rules.ExpectedException; -import org.xenei.junit.contract.Contract; -import org.xenei.junit.contract.ContractTest; -import org.xenei.junit.contract.IProducer; /** * Generic purpose tests for your implementation MailboxMapper. * * You then just need to instantiate your mailbox mapper and an IdGenerator. */ -@Contract(MapperProvider.class) -public class MailboxMapperTest<T extends MapperProvider> { +public abstract class MailboxMapperTest { private final static char DELIMITER = '.'; private final static char WILDCARD = '%'; @@ -82,16 +80,16 @@ public class MailboxMapperTest<T extends MapperProvider> { @Rule public ExpectedException expected = ExpectedException.none(); - private IProducer<T> producer; private MailboxMapper mailboxMapper; - private T mapperProvider; + private MapperProvider mapperProvider; - @Contract.Inject - public final void setProducer(IProducer<T> producer) throws MailboxException { - this.mapperProvider = producer.newInstance(); + protected abstract MapperProvider createMapperProvider(); + + @Before + public final void setUp() throws MailboxException { + this.mapperProvider = createMapperProvider(); Assume.assumeTrue(mapperProvider.getSupportedCapabilities().contains(MapperProvider.Capabilities.MAILBOX)); - this.producer = producer; this.mailboxMapper = mapperProvider.createMailboxMapper(); initData(); @@ -99,28 +97,28 @@ public class MailboxMapperTest<T extends MapperProvider> { @After public void tearDown() throws MailboxException { - producer.cleanUp(); + mapperProvider.clearMapper(); } - @ContractTest + @Test public void findMailboxByPathWhenAbsentShouldFail() throws MailboxException { expected.expect(MailboxNotFoundException.class); mailboxMapper.findMailboxByPath(new MailboxPath("#private", "benwa", "INBOX")); } - @ContractTest + @Test public void saveShouldPersistTheMailbox() throws MailboxException{ mailboxMapper.save(benwaInboxMailbox); MailboxAssert.assertThat(mailboxMapper.findMailboxByPath(benwaInboxPath)).isEqualTo(benwaInboxMailbox); } - @ContractTest + @Test public void saveWithNullUserShouldPersistTheMailbox() throws MailboxException{ mailboxMapper.save(esnDevGroupInboxMailbox); MailboxAssert.assertThat(mailboxMapper.findMailboxByPath(esnDevGroupInboxPath)).isEqualTo(esnDevGroupInboxMailbox); } - @ContractTest + @Test public void listShouldRetrieveAllMailbox() throws MailboxException { saveAll(); List<Mailbox> mailboxes = mailboxMapper.list(); @@ -132,37 +130,37 @@ public class MailboxMapperTest<T extends MapperProvider> { bobyMailbox, bobDifferentNamespaceMailbox, bobInboxMailbox); } - @ContractTest + @Test public void hasChildrenShouldReturnFalseWhenNoChildrenExists() throws MailboxException { saveAll(); assertThat(mailboxMapper.hasChildren(benwaWorkTodoMailbox, DELIMITER)).isFalse(); } - @ContractTest + @Test public void hasChildrenShouldReturnTrueWhenChildrenExists() throws MailboxException { saveAll(); assertThat(mailboxMapper.hasChildren(benwaInboxMailbox, DELIMITER)).isTrue(); } - @ContractTest + @Test public void hasChildrenWithNullUserShouldReturnFalseWhenNoChildrenExists() throws MailboxException { saveAll(); assertThat(mailboxMapper.hasChildren(esnDevGroupHublinMailbox, DELIMITER)).isFalse(); } - @ContractTest + @Test public void hasChildrenWithNullUserShouldReturnTrueWhenChildrenExists() throws MailboxException { saveAll(); assertThat(mailboxMapper.hasChildren(esnDevGroupInboxMailbox, DELIMITER)).isTrue(); } - @ContractTest + @Test public void hasChildrenShouldNotBeAcrossUsersAndNamespace() throws MailboxException { saveAll(); assertThat(mailboxMapper.hasChildren(bobInboxMailbox, '.')).isFalse(); } - @ContractTest + @Test public void findMailboxWithPathLikeShouldBeLimitedToUserAndNamespace() throws MailboxException { saveAll(); MailboxPath mailboxPathQuery = new MailboxPath(bobInboxMailbox.getNamespace(), bobInboxMailbox.getUser(), "IN" + WILDCARD); @@ -171,7 +169,7 @@ public class MailboxMapperTest<T extends MapperProvider> { assertMailboxes(mailboxes).containOnly(bobInboxMailbox); } - @ContractTest + @Test public void deleteShouldEraseTheGivenMailbox() throws MailboxException { expected.expect(MailboxNotFoundException.class); try { @@ -183,7 +181,7 @@ public class MailboxMapperTest<T extends MapperProvider> { mailboxMapper.findMailboxByPath(benwaInboxPath); } - @ContractTest + @Test public void deleteWithNullUserShouldEraseTheGivenMailbox() throws MailboxException { expected.expect(MailboxNotFoundException.class); try { @@ -195,7 +193,7 @@ public class MailboxMapperTest<T extends MapperProvider> { mailboxMapper.findMailboxByPath(esnDevGroupJamesPath); } - @ContractTest + @Test public void findMailboxWithPathLikeWithChildRegexShouldRetrieveChildren() throws MailboxException { saveAll(); MailboxPath regexPath = new MailboxPath(benwaWorkPath.getNamespace(), benwaWorkPath.getUser(), benwaWorkPath.getName() + WILDCARD); @@ -204,7 +202,7 @@ public class MailboxMapperTest<T extends MapperProvider> { assertMailboxes(mailboxes).containOnly(benwaWorkMailbox, benwaWorkDoneMailbox, benwaWorkTodoMailbox); } - @ContractTest + @Test public void findMailboxWithPathLikeWithNullUserWithChildRegexShouldRetrieveChildren() throws MailboxException { saveAll(); MailboxPath regexPath = new MailboxPath(obmTeamGroupInboxPath.getNamespace(), obmTeamGroupInboxPath.getUser(), obmTeamGroupInboxPath.getName() + WILDCARD); @@ -214,7 +212,7 @@ public class MailboxMapperTest<T extends MapperProvider> { assertMailboxes(mailboxes).containOnly(obmTeamGroupInboxMailbox, obmTeamGroupOPushMailbox, obmTeamGroupRoundCubeMailbox); } - @ContractTest + @Test public void findMailboxWithPathLikeWithRegexShouldRetrieveCorrespondingMailbox() throws MailboxException { saveAll(); MailboxPath regexPath = new MailboxPath(benwaInboxPath.getNamespace(), benwaInboxPath.getUser(), WILDCARD + "X"); @@ -224,7 +222,7 @@ public class MailboxMapperTest<T extends MapperProvider> { assertMailboxes(mailboxes).containOnly(benwaInboxMailbox); } - @ContractTest + @Test public void findMailboxWithPathLikeWithNullUserWithRegexShouldRetrieveCorrespondingMailbox() throws MailboxException { saveAll(); MailboxPath regexPath = new MailboxPath(esnDevGroupInboxPath.getNamespace(), esnDevGroupInboxPath.getUser(), WILDCARD + "X"); @@ -234,21 +232,21 @@ public class MailboxMapperTest<T extends MapperProvider> { assertMailboxes(mailboxes).containOnly(esnDevGroupInboxMailbox); } - @ContractTest + @Test public void findMailboxWithPathLikeShouldEscapeMailboxName() throws MailboxException { saveAll(); MailboxPath regexPath = new MailboxPath(benwaInboxPath.getNamespace(), benwaInboxPath.getUser(), "INB?X"); assertThat(mailboxMapper.findMailboxWithPathLike(regexPath)).isEmpty(); } - @ContractTest + @Test public void findMailboxByIdShouldReturnExistingMailbox() throws MailboxException { saveAll(); Mailbox actual = mailboxMapper.findMailboxById(benwaInboxMailbox.getMailboxId()); MailboxAssert.assertThat(actual).isEqualTo(benwaInboxMailbox); } - @ContractTest + @Test public void findMailboxByIdShouldFailWhenAbsent() throws MailboxException { expected.expect(MailboxNotFoundException.class); saveAll(); --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org