List of usage examples for org.springframework.integration.support PartialSuccessException getCause
public synchronized Throwable getCause()
From source file:org.springframework.integration.ftp.outbound.FtpServerOutboundTests.java
@Test public void testMgetPartial() throws Exception { Session<FTPFile> session = spyOnSession(); doAnswer(invocation -> {//from w ww . j av a 2 s.co m FTPFile[] files = (FTPFile[]) invocation.callRealMethod(); // add an extra file where the get will fail files = Arrays.copyOf(files, files.length + 1); FTPFile bogusFile = new FTPFile(); bogusFile.setName("bogus.txt"); files[files.length - 1] = bogusFile; return files; }).when(session).list("ftpSource/subFtpSource/*"); String dir = "ftpSource/subFtpSource/"; try { this.inboundMGet.send(new GenericMessage<Object>(dir + "*")); fail("expected exception"); } catch (PartialSuccessException e) { assertEquals(2, e.getDerivedInput().size()); assertEquals(1, e.getPartialResults().size()); assertThat(e.getCause().getMessage(), containsString("/ftpSource/subFtpSource/bogus.txt: No such file or directory.")); } }
From source file:org.springframework.integration.ftp.outbound.FtpServerOutboundTests.java
@Test public void testMgetRecursivePartial() throws Exception { Session<FTPFile> session = spyOnSession(); doAnswer(invocation -> {//from www . j ava2 s .c om FTPFile[] files = (FTPFile[]) invocation.callRealMethod(); // add an extra file where the get will fail files = Arrays.copyOf(files, files.length + 1); FTPFile bogusFile = new FTPFile(); bogusFile.setName("bogus.txt"); bogusFile.setTimestamp(Calendar.getInstance()); files[files.length - 1] = bogusFile; return files; }).when(session).list("ftpSource/subFtpSource/"); String dir = "ftpSource/"; try { this.inboundMGetRecursive.send(new GenericMessage<Object>(dir + "*")); fail("expected exception"); } catch (PartialSuccessException e) { assertEquals(4, e.getDerivedInput().size()); assertEquals(2, e.getPartialResults().size()); assertThat(e.getCause().getMessage(), containsString("/ftpSource/subFtpSource/bogus.txt: No such file or directory.")); } }
From source file:org.springframework.integration.ftp.outbound.FtpServerOutboundTests.java
@Test public void testMputPartial() throws Exception { Session<FTPFile> session = spyOnSession(); doAnswer(invocation -> {// www. j a v a 2s.c om throw new IOException("Failed to send localSource2"); }).when(session).write(Mockito.any(InputStream.class), Mockito.contains("localSource2")); try { this.inboundMPut.send(new GenericMessage<File>(getSourceLocalDirectory())); fail("expected exception"); } catch (PartialSuccessException e) { assertEquals(3, e.getDerivedInput().size()); assertEquals(1, e.getPartialResults().size()); assertEquals("ftpTarget/localSource1.txt", e.getPartialResults().iterator().next()); assertThat(e.getCause().getMessage(), containsString("Failed to send localSource2")); } }
From source file:org.springframework.integration.ftp.outbound.FtpServerOutboundTests.java
@Test public void testMputRecursivePartial() throws Exception { Session<FTPFile> session = spyOnSession(); File sourceLocalSubDirectory = new File(getSourceLocalDirectory(), "subLocalSource"); assertTrue(sourceLocalSubDirectory.isDirectory()); File extra = new File(sourceLocalSubDirectory, "subLocalSource2.txt"); FileOutputStream writer = new FileOutputStream(extra); writer.write("foo".getBytes()); writer.close();/*from w w w. j a v a2 s. c o m*/ doAnswer(invocation -> { throw new IOException("Failed to send subLocalSource2"); }).when(session).write(Mockito.any(InputStream.class), Mockito.contains("subLocalSource2")); try { this.inboundMPutRecursive.send(new GenericMessage<File>(getSourceLocalDirectory())); fail("expected exception"); } catch (PartialSuccessException e) { assertEquals(3, e.getDerivedInput().size()); assertEquals(2, e.getPartialResults().size()); assertThat(e.getCause(), Matchers.instanceOf(PartialSuccessException.class)); PartialSuccessException cause = (PartialSuccessException) e.getCause(); assertEquals(2, cause.getDerivedInput().size()); assertEquals(1, cause.getPartialResults().size()); assertThat(cause.getCause().getMessage(), containsString("Failed to send subLocalSource2")); } extra.delete(); }