package com.novoda.notils.string;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import junit.framework.TestCase;

public class StringUtilsTest extends TestCase {

    public void testJoinStringsWithComma() throws Exception {

        String string1 = "cool";
        String string2 = "story";
        String string3 = "bro";
        String delim = ",";

        List<String> strings = new ArrayList<String>(3);
        strings.add(string1);
        strings.add(string2);
        strings.add(string3);

        String expected = string1 + delim + string2 + delim + string3;
        assertEquals("Strings get concatenated with delimiter", expected, StringUtils.join(strings, delim));
    }

    public void testJoinStringsWith2CharDelimiter() throws Exception {

        String string1 = "a";
        String string2 = "story";
        String string3 = "about";
        String string4 = "tests";
        String delim = "--";

        ArrayList<String> strings = new ArrayList<String>(3);
        strings.add(string1);
        strings.add(string2);
        strings.add(string3);
        strings.add(string4);

        String expected = string1 + delim + string2 + delim + string3 + delim + string4;
        assertEquals("Strings get concatenated with 2-char-delimiter", expected, StringUtils.join(strings, delim));

    }

    public void testJoinWithNullCollection() throws Exception {

        Collection<?> strings = null;
        String delim = ";";

        String expected = "";
        assertEquals(expected, StringUtils.join(strings, delim));
    }

    public void testJoinEmptyCollection() throws Exception {

        ArrayList<String> strings = new ArrayList<String>(0);
        String delim = ";";

        String expected = "";
        assertEquals("Joining empty collection returns empty string", expected, StringUtils.join(strings, delim));
    }

    public void testJoinStringsWithNullDelimiter() throws Exception {

        String string1 = "a";
        String string2 = "story";
        String string3 = "about";
        String string4 = "missing delimiters";
        String delim = null;

        ArrayList<String> strings = new ArrayList<String>(3);
        strings.add(string1);
        strings.add(string2);
        strings.add(string3);
        strings.add(string4);

        String expected = string1 + string2 + string3 + string4;
        assertEquals("Delimiter=null is interpreted as empty string", expected, StringUtils.join(strings, delim));
    }

    public void testJoinIntegersWithSemicolon() throws Exception {

        Integer integer1 = 1;
        Integer integer2 = 2;
        Integer integer3 = 42;
        Integer integer4 = 1337;
        String delim = ";";

        List<Integer> integers = new ArrayList<Integer>(4);
        integers.add(integer1);
        integers.add(integer2);
        integers.add(integer3);
        integers.add(integer4);

        String expected = integer1.toString() + delim + integer2.toString() + delim + integer3.toString() + delim + integer4.toString();
        assertEquals("Collection of Integer will be joined properly using the toString-method", expected, StringUtils.join(integers, delim));
    }
}

@@ -120,32 +120,68 @@
 ort 
+org.
 junit.
-framework.TestCase
+Test;%0A%0Aimport static org.junit.Assert.assertEquals
 ;%0A%0Ap
@@ -212,27 +212,20 @@
 est 
-extends TestCase %7B%0A
+%7B%0A%0A    @Test
 %0A   
@@ -739,32 +739,42 @@
 delim));%0A    %7D%0A%0A
+    @Test%0A
     public void 
@@ -1379,32 +1379,42 @@
 elim));%0A%0A    %7D%0A%0A
+    @Test%0A
     public void 
@@ -1624,32 +1624,42 @@
 delim));%0A    %7D%0A%0A
+    @Test%0A
     public void 
@@ -1939,32 +1939,42 @@
 delim));%0A    %7D%0A%0A
+    @Test%0A
     public void 
@@ -2569,24 +2569,34 @@
 m));%0A    %7D%0A%0A
+    @Test%0A
     public v

Switch from JUnit 3 (framework) to JUnit 4 (pure Java)