[ColdBox-4]: Issue with mockbox and binary arguments

17 views
Skip to first unread message

jinglesthula

unread,
Dec 2, 2016, 4:58:10 PM12/2/16
to ColdBox Platform
I have a function "foo" with an argument where type="binary".  In that function, it passes the binary object on to another method "bar" on an object "baz" I'm mocking with mockbox in my "foo" unit test.  When "foo" is called in the unit test it will hit the call to the mocked "bar" method, try to pass in the binary object, and hit an exception:

Application: JSON serialization failure: Unable to serialize binary data to JSON.

It's reporting that this happens in coldbox/system/testing/MockBox.cfc: 478

I can't really alter the fact that I need to pass around binary, or that I need to mock the dependency (it sends emails, which I don't want it to do every time the test is run).

Any way around this?

br...@bradwood.com

unread,
Dec 2, 2016, 5:02:29 PM12/2/16
to col...@googlegroups.com
Can you show the stack trace of the error?  Where at in the framework is the issue?  I'm guessing it might be related to the automatic tracking of method params inside MockBox.

Thanks!

~Brad

ColdBox/CommandBox Developer Advocate
Ortus Solutions, Corp

E-mail: br...@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com 
 
 
--------- Original Message ---------
--
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org
For Bug Reports, visit https://ortussolutions.atlassian.net/browse/COLDBOX
---
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+u...@googlegroups.com.
To post to this group, send email to col...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/coldbox/daacf4e6-eb17-4baf-88e9-e8dabdd33154%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

br...@bradwood.com

unread,
Dec 2, 2016, 5:06:33 PM12/2/16
to col...@googlegroups.com
Can you show the stack trace of the error?  Where at in the framework is the issue?  I'm guessing it might be related to the automatic tracking of method params inside MockBox.

Thanks!

~Brad

ColdBox/CommandBox Developer Advocate
Ortus Solutions, Corp

E-mail: br...@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com 
 
 
--------- Original Message ---------
Subject: [coldbox:26167] [ColdBox-4]: Issue with mockbox and binary arguments
From: "jinglesthula" <mithlon...@gmail.com>
Date: 12/2/16 3:58 pm
To: "ColdBox Platform" <col...@googlegroups.com>

--

Luis Majano

unread,
Dec 4, 2016, 3:10:07 PM12/4/16
to col...@googlegroups.com
Also can you give us a test case

Luis Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com
P/F: 1-888-557-8057




jinglesthula

unread,
Dec 19, 2016, 4:42:27 PM12/19/16
to ColdBox Platform
I'm not sure how to get the full stack trace or tag context, but the component and line number are:
coldbox/system/testing/MockBox.cfc line 478
which is 
serializedArgs &= serializeJSON(argOrderedTree[arg]);
in the normalizeArguments function.


Here's a test case.

The unit test component:

component extends="coldbox.system.testing.BaseTestCase" {
public void function testFoo() {
local.myModel = variables.mockBox.createMock("model.myModel");
local.myModel.$("bar");

// file (it just expects something binary, so we'll mock away)
local.file = toBinary(toBase64("Open the pod bay doors, Hal!"));

local.myModel.foo(local.file); // here's where the wheels come off
}
}

And the actual cfc I'm writing the test for (model/myModel):

component
{
public function foo(
required binary file
) {
// do some stuff
local.result = bar(arguments.file);
// do other stuff
}

public function bar(
required binary file
) {
// do things
}
}
Reply all
Reply to author
Forward
0 new messages