Subversion Repositories DevTools

Rev

Blame | Last modification | View Log | RSS feed

package test;

import static org.junit.Assert.*;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

import org.junit.Before;
import org.junit.Test;

import releaseManager.TeamCity;

public class Test_TeamCity
{
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        PrintStream output = new PrintStream(buffer);

        @Before
        public void setUp()
        {
                output.flush();
                buffer.reset();
        }
        
        @Test
        public void testStartSuite()
        {
                // Arrange
                TeamCity teamCity = new TeamCity(output);
                
                // Act
                teamCity.startSuite("abcdef");
                
                // Assert
                assertEquals("Should be the same", "##teamcity[testSuiteStarted name='abcdef']\n", buffer.toString());
        }

        @Test
        public void testStartTest()
        {
                // Arrange
                TeamCity teamCity = new TeamCity(output);
                
                // Act
                teamCity.startTest("abcdef");
                
                // Assert
                assertEquals("Should be the same", "##teamcity[testStarted name='abcdef']\n", buffer.toString());
        }

        @Test
        public void testFinishTest()
        {
                // Arrange
                TeamCity teamCity = new TeamCity(output);
                
                // Act
                teamCity.finishTest("abcdef");
                
                // Assert
                assertEquals("Should be the same", "##teamcity[testFinished name='abcdef']\n", buffer.toString());
        }

        @Test
        public void testFinishSuite()
        {
                // Arrange
                TeamCity teamCity = new TeamCity(output);
                
                // Act
                teamCity.finishSuite("abcdef");
                
                // Assert
                assertEquals("Should be the same", "##teamcity[testSuiteFinished name='abcdef']\n", buffer.toString());
        }
        
        @Test
        public void testError()
        {
                // Arrange
                TeamCity teamCity = new TeamCity(output);
                
                // Act
                teamCity.error("abcdef","qwerty");
                
                // Assert
                assertEquals("Should be the same", "##teamcity[message text='abcdef' errorDetails='qwerty' status='ERROR']\n", buffer.toString());
                
        }
        
        @Test
        public void testMultilineError()
        {
                // Arrange
                TeamCity teamCity = new TeamCity(output);
                
                // Act
                teamCity.error("abcdef","qwerty\nLine2");
                
                // Assert
                assertEquals("Should be the same", "##teamcity[message text='abcdef' errorDetails='qwerty|nLine2' status='ERROR']\n", buffer.toString());               
        }
        
        
        @Test
        public void testMessageEncoding()
        {
                // Arrange
                TeamCity teamCity = new TeamCity(output);
                
                // Act
                String actual = teamCity.encode("a\nb'c\rd|e[f]");
                
                // Assert
                assertEquals("Should be the same", "a|nb|'c|rd||e|[f|]", actual);
                
        }
}