EMMA Coverage Report (generated Thu May 22 12:08:10 CDT 2014)
[all classes][org.springframework.batch.item.amqp]

COVERAGE SUMMARY FOR SOURCE FILE [AmqpItemWriter.java]

nameclass, %method, %block, %line, %
AmqpItemWriter.java100% (1/1)100% (2/2)70%  (33/47)91%  (10/11)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AmqpItemWriter100% (1/1)100% (2/2)70%  (33/47)91%  (10/11)
write (List): void 100% (1/1)58%  (19/33)83%  (5/6)
AmqpItemWriter (AmqpTemplate): void 100% (1/1)100% (14/14)100% (5/5)

1/*
2 * Copyright 2012 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 
17package org.springframework.batch.item.amqp;
18 
19import org.apache.commons.logging.Log;
20import org.apache.commons.logging.LogFactory;
21import org.springframework.amqp.core.AmqpTemplate;
22import org.springframework.batch.item.ItemWriter;
23import org.springframework.util.Assert;
24 
25import java.util.List;
26 
27/**
28 * <p>
29 * AMQP {@link ItemWriter} implementation using an {@link AmqpTemplate} to
30 * send messages. Messages will be sent to the nameless exchange if not specified
31 * on the provided {@link AmqpTemplate}.
32 * </p>
33 *
34 * @author Chris Schaefer
35 */
36public class AmqpItemWriter<T> implements ItemWriter<T> {
37    private final AmqpTemplate amqpTemplate;
38    private final Log log = LogFactory.getLog(getClass());
39 
40    public AmqpItemWriter(final AmqpTemplate amqpTemplate) {
41        Assert.notNull(amqpTemplate, "AmpqTemplate must not be null");
42 
43        this.amqpTemplate = amqpTemplate;
44    }
45 
46    @Override
47    public void write(final List<? extends T> items) throws Exception {
48        if (log.isDebugEnabled()) {
49            log.debug("Writing to AMQP with " + items.size() + " items.");
50        }
51 
52        for (T item : items) {
53            amqpTemplate.convertAndSend(item);
54        }
55    }
56}

[all classes][org.springframework.batch.item.amqp]
EMMA 2.0.5312 (C) Vladimir Roubtsov