Skip to content

Commit

Permalink
JAMES-2008 Move away from JUNIT contract tests in Mapper tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chibenwa authored and aduprat committed Apr 25, 2017
1 parent d8e844e commit e9a73fd
Show file tree
Hide file tree
Showing 25 changed files with 697 additions and 391 deletions.
Expand Up @@ -19,41 +19,12 @@


package org.apache.james.mailbox.cassandra.mail; package org.apache.james.mailbox.cassandra.mail;


import org.apache.james.mailbox.exception.MailboxException; import org.apache.james.mailbox.store.mail.model.AnnotationMapperTest;
import org.junit.runner.RunWith; import org.apache.james.mailbox.store.mail.model.MapperProvider;
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; public class CassandraAnnotationMapperTest extends AnnotationMapperTest {

@Override
@RunWith(ContractSuite.class) protected MapperProvider createMapperProvider() {
@ContractImpl(CassandraMapperProvider.class) return new CassandraMapperProvider();
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;
} }

} }
@@ -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();
}
}
@@ -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();
}
}
@@ -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();
}
}
@@ -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();
}
}
@@ -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();
}
}
@@ -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();
}
}
Expand Up @@ -19,41 +19,12 @@


package org.apache.james.mailbox.jpa.mail; package org.apache.james.mailbox.jpa.mail;


import org.apache.james.mailbox.exception.MailboxException; import org.apache.james.mailbox.store.mail.model.AnnotationMapperTest;
import org.junit.runner.RunWith; import org.apache.james.mailbox.store.mail.model.MapperProvider;
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; public class JpaAnnotationMapperTest extends AnnotationMapperTest {

@Override
@RunWith(ContractSuite.class) protected MapperProvider createMapperProvider() {
@ContractImpl(JPAMapperProvider.class) return new JPAMapperProvider();
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;
} }

} }
@@ -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();
}
}
@@ -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();
}
}
@@ -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; package org.apache.james.mailbox.inmemory.mail;


import java.util.List; import java.util.List;
Expand Down
@@ -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();
}
}

0 comments on commit e9a73fd

Please sign in to comment.