/* =================================================================== * ExportRecipeTest.java * * Created Feb 24, 2005 11:23:24 AM * * Copyright (c) 2005 Matt Magoffin (spamsqr@msqr.us) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * 02111-1307 USA * =================================================================== * $Id: ExportRecipeTest.java 60 2009-05-11 09:18:28Z msqr $ * =================================================================== */ package magoffin.matt.ieat.biz.test; import java.io.ByteArrayOutputStream; import java.util.Locale; import magoffin.matt.ieat.biz.BizContext; import magoffin.matt.ieat.biz.RecipeIOBiz; import magoffin.matt.ieat.domain.Recipe; import magoffin.matt.ieat.test.AbstractSpringEnabledTest; /** * Test case for exporting a recipe. * * @author Matt Magoffin (spamsqr@msqr.us) * @version $Revision: 60 $ $Date: 2009-05-11 21:18:28 +1200 (Mon, 11 May 2009) $ */ public class ExportRecipeTest extends AbstractSpringEnabledTest { /** * Test exporting. * * @throws Exception if any error occurs */ public void testExport() throws Exception { doTestWithRecipe(new TestWithRecipe() { public void test(Recipe recipe, BizContext context) throws Exception { RecipeIOBiz rioBiz = getRecipeIOBiz(); String[] formats = rioBiz.getSupportedExportFormats(); assertNotNull("The supported formats array should not be null.", formats); for ( int i = 0; i < formats.length; i++ ) { String format = formats[i]; ByteArrayOutputStream out = new ByteArrayOutputStream(); rioBiz.exportRecipe(recipe, Locale.getDefault(), out, format); assertTrue("The recipe should export somethihng", out.size() > 0); if ( log.isDebugEnabled() ) { log.debug("Exported recipe as:\n" +out.toString()); } } } }); } /** * @return the RecipeIOBiz */ protected RecipeIOBiz getRecipeIOBiz() { return (RecipeIOBiz)getContext().getBean("recipeIOBiz"); } }