Russell,

I ran into this once before and I believe it happens when you have a
property descriptor with no validator.

Check your getSupportedDynamicPropertyDescriptor() method and see if
you specified a validator.

I think you at least need something like
StandardValidators.NON_EMPTY_VALIDATOR which just means that if
someone adds a dynamic property then it must have a value.

-Bryan


On Thu, May 11, 2017 at 1:51 PM, Russell Bateman <[email protected]> wrote:
> I'm having trouble feeding a dynamic property a test running a processor I'm
> writing that expects dynamic properties. I looked at other processor tests
> I've written and I see I've not done a lot of testing involving dynamic
> properties. Here's some code, followed by output as I run. I Googled, of
> course, but did not stumble upon any examples. (This isn't about newlines in
> attributes and property values--I'll figure that one out later.)
>
> @Test
> public void test() throws Exception
> {
>   final String DOCUMENT = "This is a test.";
>
>   final Map< String, String > ATTRIBUTES = new HashMap< String, String >();
>   ATTRIBUTES.put( "test-content-1", "This is a test of the Emergency
> Broadcast System." );
>   ATTRIBUTES.put( "test-content-2", "This is only a test." );
>
>   TestRunner runner = TestRunners.newTestRunner( new MyProcessor() );
>
>   runner.setProperty( MyProcessor.FLOWFILE_NAME, "fun-and-games.txt" );
>   runner.setProperty( "test-content-1", "\\n" );
>   runner.setProperty( "test-content-2",
> "-----------------------------------------------------------\n" );
>
>   runner.enqueue( DOCUMENT, ATTRIBUTES );
>   runner.run( ONE );
>   ...
> }
>
> java.lang.AssertionError: Processor has 2 validation failures:
> 'test-content-2' validated against
> '-----------------------------------------------------------
> ' is invalid because 'test-content-2' is not a supported property
> 'test-content-1' validated against '\n' is invalid because 'test-content-1'
> is not a supported property
>
>     at org.junit.Assert.fail(Assert.java:88)
>     at
> org.apache.nifi.util.MockProcessContext.assertValid(MockProcessContext.java:251)
>     at
> org.apache.nifi.util.StandardProcessorTestRunner.run(StandardProcessorTestRunner.java:161)
>     at
> org.apache.nifi.util.StandardProcessorTestRunner.run(StandardProcessorTestRunner.java:152)
>     at
> org.apache.nifi.util.StandardProcessorTestRunner.run(StandardProcessorTestRunner.java:147)
>     at
> org.apache.nifi.util.StandardProcessorTestRunner.run(StandardProcessorTestRunner.java:142)
>     at
> com.etretatlogiciels.processor.MyProcessorTest.test(MyProcessorTest.java:56)
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>     at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>     at java.lang.reflect.Method.invoke(Method.java:498)
>     at
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
>     at
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
>     at
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
>     at
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
>     at
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
>     at
> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
>     at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
>
>

Reply via email to