Forgus / spock

Automatically exported from code.google.com/p/spock
0 stars 0 forks source link

issues mocking method with byte[] as argument #283

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I cannot seem to verify method with following signature:

public void write(File file, byte[] bytes)

I'm doing:

1 * collector.cachingFileWriter.write(new File(temp.dir, "FooTest.stderr.bin"), 
"out".bytes)

it fails with:

java.lang.ClassCastException: [B cannot be cast to [Ljava.lang.Object;
    at org.spockframework.mock.constraint.PositionalArgumentListConstraint.expandVarArgs(PositionalArgumentListConstraint.java:62)
    at org.spockframework.mock.constraint.PositionalArgumentListConstraint.isSatisfiedBy(PositionalArgumentListConstraint.java:45)
    at org.spockframework.mock.runtime.MockInteraction.matches(MockInteraction.java:65)
    at org.spockframework.mock.runtime.MockInteractionDecorator.matches(MockInteractionDecorator.java:42)
    at org.spockframework.mock.runtime.InteractionScope.match(InteractionScope.java:63)
    at org.spockframework.mock.runtime.MockController.handle(MockController.java:36)
    at org.spockframework.mock.runtime.JavaMockInterceptor.intercept(JavaMockInterceptor.java:72)
    at org.spockframework.mock.runtime.CglibMockInterceptorAdapter.intercept(CglibMockInterceptorAdapter.java:30)
    at org.gradle.api.internal.tasks.testing.junit.result.TestReportDataCollector.onOutput(TestReportDataCollector.java:80)
    at org.gradle.api.internal.tasks.testing.junit.result.TestReportDataCollectorSpec.keeps track of outputs(TestReportDataCollectorSpec.groovy:130)

I worked around by changing the interface to take String instead of bytes

Original issue reported on code.google.com by szcze...@gmail.com on 19 Nov 2012 at 3:59

GoogleCodeExporter commented 8 years ago

Original comment by pnied...@gmail.com on 30 Mar 2013 at 10:44