Java tutorial
/** * Copyright (C) 2012 Werner van Rensburg * * 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 3 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, see <http://www.gnu.org/licenses/>. */ package com.leverno.ysbos.item.domain; import java.io.File; import com.leverno.ysbos.item.ItemException; import com.leverno.ysbos.item.domain.Item; import junit.framework.TestCase; import org.apache.commons.io.FileUtils; public class ItemTest extends TestCase { private File fileOne; private String rootFolder; public void setUp() throws Exception { super.setUp(); rootFolder = new String("/tmp/archiverTest/"); FileUtils.forceMkdir(new File(rootFolder)); fileOne = new File(String.format("%s/one", rootFolder)); FileUtils.touch(fileOne); } public void tearDown() throws Exception { FileUtils.deleteDirectory(new File(rootFolder)); super.tearDown(); } public void testValidateFile() throws Exception { try { Item.createAndStoreItem(null); fail(); } catch (ItemException e) { } try { Item.createAndStoreItem(""); fail(); } catch (ItemException e) { } try { Item.createAndStoreItem(rootFolder); fail(); } catch (ItemException e) { } try { Item.createAndStoreItem(fileOne.getAbsolutePath()); } catch (Exception e) { fail(); } } }