/************************************************************************************** https://camel-extra.github.io This program 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 3 of the License, or (at your option) any later version. This program 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 program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. http://www.gnu.org/licenses/lgpl-3.0-standalone.html ***************************************************************************************/ package org.apacheextras.camel.component.jcifs; import org.apache.camel.Endpoint; import org.apache.camel.Exchange; import org.apache.camel.Producer; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.junit.Before; import org.junit.Test; /** * Unit test to test both consumer.moveNamePrefix and consumer.moveNamePostfix options. */ public class FromSmbMoveFileIntegrationTest extends BaseSmbIntegrationTestSupport { private String getSmbUrl() { return "smb://" + getDomain() + ";" + getUsername() + "@localhost/" + getShare() + "/camel/" + getClass().getSimpleName() + "?password=" + getPassword() + "&move=done/sub2/${file:name}.old&consumer.delay=5000"; } @Test public void testPollFileAndShouldBeMoved() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMessageCount(1); mock.expectedBodiesReceived("Hello World this file will be moved"); mock.expectedFileExists(getLocalSharePath() + "/camel/" + getClass().getSimpleName() + "/done/sub2/hello.txt.old"); mock.assertIsSatisfied(); } @Override @Before public void setUp() throws Exception { super.setUp(); // prepares the FTP Server by creating a file on the server that we want to unit // test that we can pool and store as a local file Endpoint endpoint = context.getEndpoint(getSmbUrl()); Exchange exchange = endpoint.createExchange(); exchange.getIn().setBody("Hello World this file will be moved"); exchange.getIn().setHeader(Exchange.FILE_NAME, "hello.txt"); Producer producer = endpoint.createProducer(); producer.start(); producer.process(exchange); producer.stop(); } protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() throws Exception { from(getSmbUrl()).to("mock:result"); } }; } }