equal
deleted
inserted
replaced
436 Socket client; |
436 Socket client; |
437 for (int i=0; i<2; i++) { |
437 for (int i=0; i<2; i++) { |
438 client = server.accept(); |
438 client = server.accept(); |
439 (new FtpServerHandler(client)).run(); |
439 (new FtpServerHandler(client)).run(); |
440 } |
440 } |
441 server.close(); |
|
442 } catch(Exception e) { |
441 } catch(Exception e) { |
|
442 } finally { |
|
443 try { server.close(); } catch (IOException unused) {} |
443 } |
444 } |
444 } |
445 } |
445 } |
446 } |
446 public static void main(String[] args) throws Exception { |
447 public static void main(String[] args) throws Exception { |
447 FtpURL test = new FtpURL(); |
448 FtpURL test = new FtpURL(); |
448 } |
449 } |
449 |
450 |
450 public FtpURL() throws Exception { |
451 public FtpURL() throws Exception { |
451 FtpServer server = null; |
452 FtpServer server = new FtpServer(0); |
452 BufferedReader in = null; |
453 BufferedReader in = null; |
453 try { |
454 try { |
454 server = new FtpServer(0); |
|
455 server.start(); |
455 server.start(); |
456 int port = server.getPort(); |
456 int port = server.getPort(); |
457 |
457 |
458 // Now let's check the URL handler |
458 // Now let's check the URL handler |
459 |
459 |
495 throw new RuntimeException("password should be null!"); |
495 throw new RuntimeException("password should be null!"); |
496 if (! "bin".equals(server.getFilename())) |
496 if (! "bin".equals(server.getFilename())) |
497 throw new RuntimeException("Incorrect filename received"); |
497 throw new RuntimeException("Incorrect filename received"); |
498 if (! "/usr".equals(server.pwd())) |
498 if (! "/usr".equals(server.pwd())) |
499 throw new RuntimeException("Incorrect pwd received"); |
499 throw new RuntimeException("Incorrect pwd received"); |
500 in.close(); |
|
501 // We're done! |
500 // We're done! |
502 |
501 |
503 } catch (Exception e) { |
502 } catch (Exception e) { |
504 try { |
|
505 in.close(); |
|
506 server.terminate(); |
|
507 server.interrupt(); |
|
508 } catch(Exception ex) { |
|
509 } |
|
510 throw new RuntimeException("FTP support error: " + e.getMessage()); |
503 throw new RuntimeException("FTP support error: " + e.getMessage()); |
|
504 } finally { |
|
505 try { in.close(); } catch (IOException unused) {} |
|
506 server.terminate(); |
|
507 server.server.close(); |
511 } |
508 } |
512 } |
509 } |
513 } |
510 } |