Search in sources :

Example 6 with FlowFileTransaction

use of org.apache.nifi.remote.protocol.FlowFileTransaction in project nifi by apache.

the class TestHttpRemoteSiteListener method testNoneExistingTransaction.

@Test
public void testNoneExistingTransaction() {
    HttpRemoteSiteListener transactionManager = HttpRemoteSiteListener.getInstance(NiFiProperties.createBasicNiFiProperties(null, null));
    String transactionId = "does-not-exist-1";
    assertFalse("Transaction should not be active.", transactionManager.isTransactionActive(transactionId));
    ProcessSession processSession = Mockito.mock(ProcessSession.class);
    FlowFileTransaction transaction = new FlowFileTransaction(processSession, null, null, 0, null, null);
    try {
        transactionManager.holdTransaction(transactionId, transaction, null);
    } catch (IllegalStateException e) {
        fail("Transaction can be held even if the transaction id is not valid anymore," + " in order to support large file or slow network.");
    }
    transactionId = "does-not-exist-2";
    try {
        transactionManager.finalizeTransaction(transactionId);
        fail("But transaction should not be finalized if it isn't active.");
    } catch (IllegalStateException e) {
    }
}
Also used : ProcessSession(org.apache.nifi.processor.ProcessSession) FlowFileTransaction(org.apache.nifi.remote.protocol.FlowFileTransaction) Test(org.junit.Test)

Aggregations

FlowFileTransaction (org.apache.nifi.remote.protocol.FlowFileTransaction)6 ProcessSession (org.apache.nifi.processor.ProcessSession)3 Test (org.junit.Test)3 HttpServerCommunicationsSession (org.apache.nifi.remote.io.http.HttpServerCommunicationsSession)2 IOException (java.io.IOException)1 HandshakeProperties (org.apache.nifi.remote.protocol.HandshakeProperties)1