From my custom processor, I'm throwing a ProcessException that never reaches my catch in the JUnit test. I already have several other JUnit tests working on this processor; this is the remaining wiggle I want to test.

I might be blind here, but I can't see what's wrong. Any comment will be useful.

Thanks,

Russ

Here's the tail-end of my processor'sonTrigger() method:

    ...

    try
    {
      X12Simple x12 = ( X12Simple ) parser.parse( is.get() );
      ...

      session.transfer( newFlowfile, resultingRelationship );
    }
catch( FormatException e ) *// this exception is caught--was thrown in X12 parser as expected!*
    {
      session.remove( newFlowfile );
* throw new ProcessException( e + " (the content is unparsable as an X12 message)" );*
    }
    catch( IOException e )
    {
      session.remove( newFlowfile );
      throw new ProcessException( e );
    }
  }
  finally
  {
    session.transfer( flowfile, ORIGINAL );
  }
}


And here's the JUnit test case for now:

@Test
public void testOnTriggerCompleteCrap()
{
  TestRunner runner = TestRunners.newTestRunner( new X12MessageRouter() );

  final int         ONE     = 1;
  final InputStream MESSAGE = new ByteArrayInputStream( _CRAP.getBytes() );

  Map< String, String > flowFileAttributes = new HashMap<>();
  flowFileAttributes.put( "testname", "X12 Message Router Unit Test" );

  runner.setValidateExpressionUsage( false );
  runner.enqueue( MESSAGE, flowFileAttributes );

  try
  {
*runner.run( ONE ); **// (exception will happen under here)*
    runner.assertQueueEmpty();
List< MockFlowFile > results = runner.getFlowFilesForRelationship( X12MessageRouter.NONE );
  }
  catch( ProcessException e )
  {
    int x = 9; *// (never caught at breakpoint set here)*
  }
}

Reply via email to