Coverage Report - org.apache.camel.component.file.remote.FtpEndpoint
 
Classes in this File Line Coverage Branch Coverage Complexity
FtpEndpoint
100% 
100% 
0
 
 1  
 /**
 2  
  *
 3  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 4  
  * contributor license agreements.  See the NOTICE file distributed with
 5  
  * this work for additional information regarding copyright ownership.
 6  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 7  
  * (the "License"); you may not use this file except in compliance with
 8  
  * 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.camel.component.file.remote;
 19  
 
 20  
 import org.apache.camel.Processor;
 21  
 import org.apache.commons.logging.Log;
 22  
 import org.apache.commons.logging.LogFactory;
 23  
 import org.apache.commons.net.ftp.FTPClient;
 24  
 
 25  
 import java.io.IOException;
 26  
 
 27  2
 public class FtpEndpoint extends RemoteFileEndpoint<RemoteFileExchange> {
 28  1
     private static final transient Log log = LogFactory.getLog(FtpEndpoint.class);
 29  
 
 30  
     public FtpEndpoint(String uri, RemoteFileComponent remoteFileComponent, RemoteFileConfiguration configuration) {
 31  4
         super(uri, remoteFileComponent, configuration);
 32  4
     }
 33  
 
 34  
     public FtpProducer createProducer() throws Exception {
 35  1
         return new FtpProducer(this, createFtpClient());
 36  
     }
 37  
 
 38  
     public FtpConsumer createConsumer(Processor processor) throws Exception {
 39  1
         final FtpConsumer consumer = new FtpConsumer(this, processor, createFtpClient());
 40  1
         configureConsumer(consumer);
 41  1
         return consumer;
 42  
     }
 43  
 
 44  
     protected FTPClient createFtpClient() throws IOException {
 45  2
         final FTPClient client = new FTPClient();
 46  2
         String host = getConfiguration().getHost();
 47  2
         int port = getConfiguration().getPort();
 48  2
         log.debug("Connecting to host: " + host + " port: " + port);
 49  
 
 50  2
         client.connect(host, port);
 51  2
         client.login(getConfiguration().getUsername(), getConfiguration().getPassword());
 52  2
         client.setFileType(getConfiguration().isBinary() ? FTPClient.BINARY_FILE_TYPE : FTPClient.ASCII_FILE_TYPE);
 53  2
         return client;
 54  
     }
 55  
 }