Java tutorial
/* * Copyright 2011-2014 Red Hat, Inc. * * This file is part of PressGang CCMS. * * PressGang CCMS is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * PressGang CCMS 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with PressGang CCMS. If not, see <http://www.gnu.org/licenses/>. */ package org.jboss.pressgang.ccms.contentspec.client.commands; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.when; import java.io.File; import java.util.Arrays; import net.sf.ipsedixit.annotation.Arbitrary; import org.apache.commons.io.FileUtils; import org.junit.Before; import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.contrib.java.lang.system.ExpectedSystemExit; // TODO Write these tests @Ignore public class PublishCommandTest extends BaseCommandTest { @Rule public final ExpectedSystemExit exit = ExpectedSystemExit.none(); @Arbitrary Integer id; PublishCommand command; File rootTestDirectory; @Before public void setUp() { bindStdOut(); command = new PublishCommand(parser, cspConfig, clientConfig); // Only test the publish command and not the build or assemble command content. command.setNoAssemble(true); rootTestDirectory = FileUtils.toFile(ClassLoader.getSystemResource("")); when(cspConfig.getRootOutputDirectory()).thenReturn(rootTestDirectory.getAbsolutePath() + File.separator); } @Test public void shouldRequireAnExternalConnection() { // Given an already initialised command // When invoking the method boolean result = command.requiresExternalConnection(); // Then the answer should be true assertTrue(result); } @Test public void shouldNotLoadFromCsprocessorCfgWhenIdsSpecified() { // Given a command with ids specified command.setIds(Arrays.asList(id.toString())); // When invoking the method boolean result = command.loadFromCSProcessorCfg(); // Then the result should be false assertFalse(result); } @Test public void shouldReturnRightCommandName() { // Given // When getting the commands name String commandName = command.getCommandName(); // Then the name should be "publish" assertThat(commandName, is("publish")); } }