/**
 * 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 com.sohu.jafka.producer;

import java.util.Properties;

import org.junit.Test;

import com.sohu.jafka.BaseJafkaServer;
import com.sohu.jafka.Jafka;
import com.sohu.jafka.producer.serializer.StringEncoder;

/**
 * @author adyliu (imxylz@gmail.com)
 * @since 1.0
 */
public class ProducerTest extends BaseJafkaServer {

    /**
     * Test method for
     * {@link com.sohu.jafka.producer.Producer#send(com.sohu.jafka.producer.ProducerData)}.
     */
    @Test
    public void testSend() {
        Jafka jafka = createJafka();
        Properties producerConfig = new Properties();
        producerConfig.setProperty("broker.list", "0:localhost:9092");
        producerConfig.setProperty("serializer.class", StringEncoder.class.getName());
        Producer<String, String> producer = new Producer<String, String>(new ProducerConfig(producerConfig));
        for (int i = 0; i < 1000; i++) {
            producer.send(new StringProducerData("demo").add("Hello jafka").add("https://github.com/adyliu/jafka"));
        }
        producer.close();
        close(jafka);
    }

}

@@ -1854,16 +1854,1033 @@
         
+////////////////////////////////////////////////%0A        close(jafka);%0A    %7D%0A    /**%0A     * Test method for%0A     * %7B@link com.sohu.jafka.producer.Producer#send(com.sohu.jafka.producer.ProducerData)%7D.%0A     */%0A    @Test%0A    public void testSendWithPartition() %7B%0A        Properties props = new Properties();%0A        props.setProperty(%22num.partitions%22, %225%22);%0A        Jafka jafka = createJafka(props);%0A        Properties producerConfig = new Properties();%0A        producerConfig.setProperty(%22broker.list%22, %220:localhost:9092:5%22);%0A        StringProducer producer = new StringProducer(new ProducerConfig(producerConfig));%0A        for (int i = 0; i %3C 1000; i++) %7B%0A            final String message = %22Hello jafka. #%22+i;%0A            StringProducerData data= new StringProducerData(%22demo%22);%0A            data.setKey(message);%0A            data.add(message).add(%22https://github.com/adyliu/jafka%22);%0A            producer.send(data);%0A        %7D%0A        producer.close();%0A        ////////////////////////////////////////////////%0A        
 close(ja
@@ -2890,12 +2890,11 @@
 );%0A    %7D
-%0A
 %0A%7D%0A

add num.partitions test for config brokers