List of usage examples for org.apache.commons.net.ftp FTPCmd PWD
FTPCmd PWD
To view the source code for org.apache.commons.net.ftp FTPCmd PWD.
Click Source Link
From source file:com.consol.citrus.ftp.client.FtpClientTest.java
@Test public void testCommand() throws Exception { FtpClient ftpClient = new FtpClient(); ftpClient.setFtpClient(apacheFtpClient); reset(apacheFtpClient);/* w w w . ja v a 2s. com*/ expect(apacheFtpClient.isConnected()).andReturn(false).once(); apacheFtpClient.connect("localhost", 22222); expectLastCall().once(); expect(apacheFtpClient.getReplyString()).andReturn("OK").times(2); expect(apacheFtpClient.getReplyCode()).andReturn(200).once(); expect(apacheFtpClient.sendCommand(FTPCmd.PWD, null)).andReturn(200).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"); verify(apacheFtpClient); }
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);//from ww w. j ava2 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.consol.citrus.ftp.client.FtpClientTest.java
@Test(expectedExceptions = CitrusRuntimeException.class) public void testCommandWithUserLoginFailed() throws Exception { FtpEndpointConfiguration endpointConfiguration = new FtpEndpointConfiguration(); FtpClient ftpClient = new FtpClient(endpointConfiguration); ftpClient.setFtpClient(apacheFtpClient); endpointConfiguration.setUser("admin"); endpointConfiguration.setPassword("consol"); reset(apacheFtpClient);/*from ww w . j av a 2s .co m*/ expect(apacheFtpClient.isConnected()).andReturn(false).once(); apacheFtpClient.connect("localhost", 22222); expectLastCall().once(); expect(apacheFtpClient.getReplyString()).andReturn("OK").once(); expect(apacheFtpClient.getReplyCode()).andReturn(200).once(); expect(apacheFtpClient.login("admin", "consol")).andReturn(false).once(); replay(apacheFtpClient); ftpClient.send(new FtpMessage(FTPCmd.PWD, null), context); verify(apacheFtpClient); }
From source file:com.consol.citrus.ftp.client.FtpClientTest.java
@Test(expectedExceptions = CitrusRuntimeException.class) public void testCommandNegativeReply() throws Exception { FtpClient ftpClient = new FtpClient(); ftpClient.setFtpClient(apacheFtpClient); reset(apacheFtpClient);/*from w w w.j a va 2s .c om*/ expect(apacheFtpClient.isConnected()).andReturn(false).once(); apacheFtpClient.connect("localhost", 22222); expectLastCall().once(); expect(apacheFtpClient.getReplyString()).andReturn("OK").times(2); expect(apacheFtpClient.getReplyCode()).andReturn(200).once(); expect(apacheFtpClient.sendCommand(FTPCmd.PWD, null)).andReturn(500).once(); replay(apacheFtpClient); ftpClient.send(new FtpMessage(FTPCmd.PWD, null), context); verify(apacheFtpClient); }
From source file:com.atomicleopard.thundr.ftp.commons.FTP.java
/*** * A convenience method to send the FTP PWD command to the server, * receive the reply, and return the reply code. * <p>/*from www . j av a 2s . co m*/ * @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 pwd() throws IOException { return sendCommand(FTPCmd.PWD); }