<commit_before>/*
 * jETeL/CloverETL - Java based ETL application framework.
 * Copyright (c) Javlin, a.s. (<EMAIL>)
 *  
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */
package org.jetel.component.fileoperation;


public class PooledFTPOperationHandlerTest extends FTPOperationHandlerTest {
	
	protected PooledFTPOperationHandler handler = null;
	
	@Override
	protected IOperationHandler createOperationHandler() {
		return handler = new PooledFTPOperationHandler();
	}
	
	@Override
	protected void tearDown() throws Exception {
		super.tearDown();
		handler = null;
	}

	@Override
	public void testGetPriority() {
//		assertEquals(IOperationHandler.TOP_PRIORITY, handler.getPriority(Operation.copy(PooledFTPOperationHandler.FTP_SCHEME, PooledFTPOperationHandler.FTP_SCHEME)));
		assertEquals(IOperationHandler.TOP_PRIORITY, handler.getPriority(Operation.move(PooledFTPOperationHandler.FTP_SCHEME, PooledFTPOperationHandler.FTP_SCHEME)));
		assertEquals(IOperationHandler.TOP_PRIORITY, handler.getPriority(Operation.delete(PooledFTPOperationHandler.FTP_SCHEME)));
		assertEquals(IOperationHandler.TOP_PRIORITY, handler.getPriority(Operation.create(PooledFTPOperationHandler.FTP_SCHEME)));
		assertEquals(IOperationHandler.TOP_PRIORITY, handler.getPriority(Operation.resolve(PooledFTPOperationHandler.FTP_SCHEME)));
		assertEquals(IOperationHandler.TOP_PRIORITY, handler.getPriority(Operation.info(PooledFTPOperationHandler.FTP_SCHEME)));
		assertEquals(IOperationHandler.TOP_PRIORITY, handler.getPriority(Operation.list(PooledFTPOperationHandler.FTP_SCHEME)));
		assertEquals(IOperationHandler.TOP_PRIORITY, handler.getPriority(Operation.read(PooledFTPOperationHandler.FTP_SCHEME)));
		assertEquals(IOperationHandler.TOP_PRIORITY, handler.getPriority(Operation.write(PooledFTPOperationHandler.FTP_SCHEME)));
	}

	@Override
	public void testCanPerform() {
//		assertTrue(handler.canPerform(Operation.copy(PooledFTPOperationHandler.FTP_SCHEME, PooledFTPOperationHandler.FTP_SCHEME)));
		assertTrue(handler.canPerform(Operation.move(PooledFTPOperationHandler.FTP_SCHEME, PooledFTPOperationHandler.FTP_SCHEME)));
		assertTrue(handler.canPerform(Operation.delete(PooledFTPOperationHandler.FTP_SCHEME)));
		assertTrue(handler.canPerform(Operation.create(PooledFTPOperationHandler.FTP_SCHEME)));
		assertTrue(handler.canPerform(Operation.resolve(PooledFTPOperationHandler.FTP_SCHEME)));
		assertTrue(handler.canPerform(Operation.info(PooledFTPOperationHandler.FTP_SCHEME)));
		assertTrue(handler.canPerform(Operation.list(PooledFTPOperationHandler.FTP_SCHEME)));
		assertTrue(handler.canPerform(Operation.read(PooledFTPOperationHandler.FTP_SCHEME)));
		assertTrue(handler.canPerform(Operation.write(PooledFTPOperationHandler.FTP_SCHEME)));
	}

}<commit_msg>FIX: CLO-4404 - Improve FTP connection error reporting<commit_after>/*
 * jETeL/CloverETL - Java based ETL application framework.
 * Copyright (c) Javlin, a.s. (<EMAIL>)
 *  
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */
package org.jetel.component.fileoperation;

import java.io.IOException;
import java.net.URI;

import org.apache.commons.net.ftp.FTPConnectionClosedException;


public class PooledFTPOperationHandlerTest extends FTPOperationHandlerTest {
	
	protected PooledFTPOperationHandler handler = null;
	
	@Override
	protected IOperationHandler createOperationHandler() {
		return handler = new PooledFTPOperationHandler();
	}
	
	@Override
	protected void tearDown() throws Exception {
		super.tearDown();
		handler = null;
	}

	@Override
	public void testGetPriority() {
//		assertEquals(IOperationHandler.TOP_PRIORITY, handler.getPriority(Operation.copy(PooledFTPOperationHandler.FTP_SCHEME, PooledFTPOperationHandler.FTP_SCHEME)));
		assertEquals(IOperationHandler.TOP_PRIORITY, handler.getPriority(Operation.move(PooledFTPOperationHandler.FTP_SCHEME, PooledFTPOperationHandler.FTP_SCHEME)));
		assertEquals(IOperationHandler.TOP_PRIORITY, handler.getPriority(Operation.delete(PooledFTPOperationHandler.FTP_SCHEME)));
		assertEquals(IOperationHandler.TOP_PRIORITY, handler.getPriority(Operation.create(PooledFTPOperationHandler.FTP_SCHEME)));
		assertEquals(IOperationHandler.TOP_PRIORITY, handler.getPriority(Operation.resolve(PooledFTPOperationHandler.FTP_SCHEME)));
		assertEquals(IOperationHandler.TOP_PRIORITY, handler.getPriority(Operation.info(PooledFTPOperationHandler.FTP_SCHEME)));
		assertEquals(IOperationHandler.TOP_PRIORITY, handler.getPriority(Operation.list(PooledFTPOperationHandler.FTP_SCHEME)));
		assertEquals(IOperationHandler.TOP_PRIORITY, handler.getPriority(Operation.read(PooledFTPOperationHandler.FTP_SCHEME)));
		assertEquals(IOperationHandler.TOP_PRIORITY, handler.getPriority(Operation.write(PooledFTPOperationHandler.FTP_SCHEME)));
	}

	@Override
	public void testCanPerform() {
//		assertTrue(handler.canPerform(Operation.copy(PooledFTPOperationHandler.FTP_SCHEME, PooledFTPOperationHandler.FTP_SCHEME)));
		assertTrue(handler.canPerform(Operation.move(PooledFTPOperationHandler.FTP_SCHEME, PooledFTPOperationHandler.FTP_SCHEME)));
		assertTrue(handler.canPerform(Operation.delete(PooledFTPOperationHandler.FTP_SCHEME)));
		assertTrue(handler.canPerform(Operation.create(PooledFTPOperationHandler.FTP_SCHEME)));
		assertTrue(handler.canPerform(Operation.resolve(PooledFTPOperationHandler.FTP_SCHEME)));
		assertTrue(handler.canPerform(Operation.info(PooledFTPOperationHandler.FTP_SCHEME)));
		assertTrue(handler.canPerform(Operation.list(PooledFTPOperationHandler.FTP_SCHEME)));
		assertTrue(handler.canPerform(Operation.read(PooledFTPOperationHandler.FTP_SCHEME)));
		assertTrue(handler.canPerform(Operation.write(PooledFTPOperationHandler.FTP_SCHEME)));
	}
	
	/**
	 * test for CLO-4404
	 */
	public void testErrorReporting() {
		URI uri = URI.create("ftp://invalid_user:invalid_pass@koule/");
		try {
			handler.connect(uri);
			fail();
		} catch (IOException e) {
			if (e.getSuppressed().length == 0 || !(e.getSuppressed()[0] instanceof FTPConnectionClosedException)) {
				fail();
			}
		} catch (Exception e) {
			fail();
		}
	}

}
{'fraction_non_alphanumeric': 0.09306717021850552, 'fraction_numerical': 0.00566495818721338, 'mean_word_length': 7.0773420479302835, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6965637', 'n_tokens_mistral': 2358, 'n_tokens_neox': 2277, 'n_words': 428}