Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
simple test for the controller compares binary output of the controll…
…er to the expected png in the file system
- Loading branch information
Shawn Hartsock
committed
Mar 14, 2012
1 parent
9799317
commit ad36b23
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
test/integration/org/codehaus/groovy/grails/plugins/qrcode/QrcodeControllerTests.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.codehaus.groovy.grails.plugins.qrcode | ||
|
||
import grails.test.* | ||
import org.springframework.core.io.ClassPathResource | ||
import org.apache.commons.io.IOUtils | ||
|
||
class QrcodeControllerTests extends GrailsUnitTestCase { | ||
QrCodeRendererService qrCodeRendererService | ||
|
||
void testSimpleRender() { | ||
def qrcodeController = new QrcodeController() | ||
qrcodeController.qrCodeRendererService = qrCodeRendererService | ||
qrcodeController.request.parameters = [text:'test',size:'30'] | ||
qrcodeController.index() | ||
byte[] out = qrcodeController.response.contentAsByteArray | ||
// a 30 by 30 png image of the word "test" in a QRCode | ||
InputStream pngIn = | ||
new ClassPathResource("org/codehaus/groovy/grails/plugins/qrcode/qrcode_test.png").getInputStream() | ||
byte[] png = IOUtils.toByteArray(pngIn) | ||
|
||
assert png != null | ||
|
||
assert Arrays.equals(png,out) | ||
} | ||
} |