我有以下测试代码:
org.apache.kafka.connect.runtime.distributed.DistributedHerderTest > testInconsistentConfigs FAILED
java.lang.NullPointerException
at org.apache.kafka.connect.runtime.AbstractHerder.getConnector(AbstractHerder.java:342)
at org.apache.kafka.connect.runtime.distributed.DistributedHerder$$EnhancerByCGLIB$$af0dd240.CGLIB$getConnector$39(<generated>)
at org.apache.kafka.connect.runtime.distributed.DistributedHerder$$EnhancerByCGLIB$$af0dd240$$FastClassByCGLIB$$8c31132d.invoke(<generated>)
at org.easymock.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.easymock.internal.ClassProxyFactory$MockMethodInterceptor.intercept(ClassProxyFactory.java:92)
at org.apache.kafka.connect.runtime.distributed.DistributedHerder$$EnhancerByCGLIB$$af0dd240.getConnector(<generated>)
at org.apache.kafka.connect.runtime.AbstractHerder.connectorType(AbstractHerder.java:349)
at org.apache.kafka.connect.runtime.distributed.DistributedHerder$$EnhancerByCGLIB$$af0dd240.CGLIB$connectorType$23(<generated>)
at org.apache.kafka.connect.runtime.distributed.DistributedHerder$$EnhancerByCGLIB$$af0dd240$$FastClassByCGLIB$$8c31132d.invoke(<generated>)
at org.easymock.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.easymock.internal.ClassProxyFactory$MockMethodInterceptor.intercept(ClassProxyFactory.java:92)
at org.apache.kafka.connect.runtime.distributed.DistributedHerder$$EnhancerByCGLIB$$af0dd240.connectorType(<generated>)
at org.apache.kafka.connect.runtime.distributed.DistributedHerderTest.setUp(DistributedHerderTest.java:179)
其中connectorType()方法在AbstractHerder中定义,是DistributedHerder的基类。 由于牧人是使用DistributedHerder创建的,因此easy mock无法找到AbstractHerder类的模拟,导致NPE:
Parent
欢迎任何提示。
答案 0 :(得分:0)
我在这里有点失落,但仍会尝试用苏格拉底问题提供一些提示。
DistributedHerder
的PowerMock?它看起来像是正常的部分嘲弄Plugins
而不是简单的EasyMock?herder.new ConfigUpdateListener()
?那是哪种语言?worker
?replay()
。我们可以提供完整的代码吗?backoff
和updateDeletedConnectorStatus
没有记录任何内容。这是正常的吗?plugins()
方法返回null。这个没有被嘲笑所以它可能只是返回null确实没有?