View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.hadoop.chukwa.datacollection.sender;
19  
20  import junit.framework.TestCase;
21  import org.apache.hadoop.chukwa.ChunkImpl;
22  import org.apache.hadoop.conf.*;
23  import java.util.ArrayList;
24  import java.util.List;
25  import org.apache.hadoop.chukwa.*;
26  import org.apache.hadoop.chukwa.datacollection.adaptor.filetailer.*;
27  import org.apache.hadoop.chukwa.datacollection.adaptor.Adaptor;
28  import org.apache.hadoop.chukwa.datacollection.sender.ChukwaHttpSender.CommitListEntry;
29  
30  public class TestAcksOnFailure extends TestCase {
31    public void testNoCollector() {
32      
33      Configuration conf = new Configuration();
34      conf.setInt("chukwaAgent.sender.retries", 3);
35      conf.setInt("chukwaAgent.sender.retryInterval", 1000);
36      
37      ChukwaHttpSender send = new ChukwaHttpSender(conf);
38      ArrayList<String> collectors = new ArrayList<String>();
39      collectors.add("http://somehost.invalid/chukwa");
40      send.setCollectors(new RetryListOfCollectors(collectors, conf));
41      
42      byte[] data = "sometestdata".getBytes();
43      Adaptor a = new FileTailingAdaptor();
44      ChunkImpl ci = new ChunkImpl("testtype", "sname", data.length, data, a);
45      ArrayList<Chunk> toSend = new ArrayList<Chunk>();
46      toSend.add(ci);
47      try {
48        List<CommitListEntry> resp = send.send(toSend);
49        assertTrue(resp.size() == 0);
50      } catch(Exception e) {
51        
52      }
53    }
54  
55  }