List of usage examples for org.apache.commons.net.ftp FTPCmd MKD
FTPCmd MKD
To view the source code for org.apache.commons.net.ftp FTPCmd MKD.
Click Source Link
From source file:com.consol.citrus.ftp.server.FtpServerLetTest.java
@Test public void testCommand() throws FtpException, IOException { reset(endpointAdapter, ftpSession, ftpRequest); expect(ftpRequest.getCommand()).andReturn(FTPCmd.MKD.getCommand()).once(); expect(ftpRequest.getArgument()).andReturn("testDir").once(); expect(endpointAdapter.handleMessage(anyObject(FtpMessage.class))).andAnswer(new IAnswer<FtpMessage>() { @Override/*from w w w.j ava 2 s .c o m*/ public FtpMessage answer() throws Throwable { FtpMessage ftpMessage = (FtpMessage) getCurrentArguments()[0]; Assert.assertEquals(ftpMessage.getPayload(String.class), FTPCmd.MKD.getCommand()); Assert.assertEquals(ftpMessage.getCommand(), FTPCmd.MKD); Assert.assertEquals(ftpMessage.getArguments(), "testDir"); Assert.assertNull(ftpMessage.getReplyCode()); Assert.assertNull(ftpMessage.getReplyString()); return new FtpMessage(FTPCmd.MKD, "testDir").replyCode(200).replyString("OK"); } }); replay(endpointAdapter, ftpSession, ftpRequest); FtpletResult result = ftpLet.beforeCommand(ftpSession, ftpRequest); Assert.assertEquals(result, FtpletResult.DEFAULT); verify(endpointAdapter, ftpSession, ftpRequest); }
From source file:com.consol.citrus.ftp.client.FtpClientTest.java
@Test public void testCommandWithArguments() throws Exception { FtpEndpointConfiguration endpointConfiguration = new FtpEndpointConfiguration(); FtpClient ftpClient = new FtpClient(endpointConfiguration); ftpClient.setFtpClient(apacheFtpClient); endpointConfiguration.setUser("admin"); endpointConfiguration.setPassword("consol"); reset(apacheFtpClient);// www. j av a 2 s . co m expect(apacheFtpClient.isConnected()).andReturn(false).once().andReturn(true).once(); apacheFtpClient.connect("localhost", 22222); expectLastCall().once(); expect(apacheFtpClient.login("admin", "consol")).andReturn(true).once(); expect(apacheFtpClient.getReplyString()).andReturn("OK").times(3); expect(apacheFtpClient.getReplyCode()).andReturn(200).once(); expect(apacheFtpClient.sendCommand(FTPCmd.PWD, null)).andReturn(200).once(); expect(apacheFtpClient.sendCommand(FTPCmd.MKD, "testDir")).andReturn(201).once(); replay(apacheFtpClient); ftpClient.send(new FtpMessage(FTPCmd.PWD, null), context); Message reply = ftpClient.receive(context); Assert.assertTrue(reply instanceof FtpMessage); FtpMessage ftpReply = (FtpMessage) reply; Assert.assertEquals(ftpReply.getCommand(), FTPCmd.PWD); Assert.assertNull(ftpReply.getArguments()); Assert.assertEquals(ftpReply.getReplyCode(), new Integer(200)); Assert.assertEquals(ftpReply.getReplyString(), "OK"); ftpClient.send(new FtpMessage(FTPCmd.MKD, "testDir"), context); reply = ftpClient.receive(context); Assert.assertTrue(reply instanceof FtpMessage); ftpReply = (FtpMessage) reply; Assert.assertEquals(ftpReply.getCommand(), FTPCmd.MKD); Assert.assertEquals(ftpReply.getArguments(), "testDir"); Assert.assertEquals(ftpReply.getReplyCode(), new Integer(201)); Assert.assertEquals(ftpReply.getReplyString(), "OK"); verify(apacheFtpClient); }
From source file:com.adaptris.ftp.ApacheFtpClientImpl.java
/** * create a directory on the server// ww w.j a va 2 s .co m * * @param dir directory name */ @Override public void mkdir(String dir) throws IOException { try { acquireLock(); log("{} {}", FTPCmd.MKD, dir); handleReturnValue(ftpClient().makeDirectory(dir)); } finally { logReply(ftpClient().getReplyStrings()); releaseLock(); } }
From source file:com.atomicleopard.thundr.ftp.commons.FTP.java
/*** * A convenience method to send the FTP MKD command to the server, * receive the reply, and return the reply code. * <p>/*from w ww .ja va 2 s.co m*/ * @param pathname The pathname of the new directory to create. * @return The reply code received from the server. * @exception FTPConnectionClosedException * If the FTP server prematurely closes the connection as a result * of the client being idle or some other reason causing the server * to send FTP reply code 421. This exception may be caught either * as an IOException or independently as itself. * @exception IOException If an I/O error occurs while either sending the * command or receiving the server reply. ***/ public int mkd(String pathname) throws IOException { return sendCommand(FTPCmd.MKD, pathname); }