VariableUtilTest.java :  » XML » pirka » org » pirkaengine » core » util » Java Open Source

Java Open Source » XML » pirka 
pirka » org » pirkaengine » core » util » VariableUtilTest.java
package org.pirkaengine.core.util;

import junit.framework.Assert;

import org.junit.Test;
import org.pirkaengine.core.util.VariableUtil;

public class VariableUtilTest {

    @Test
    public void htmlEscape_() {
        String text = "";
        Assert.assertEquals(text, VariableUtil.htmlEscape(text));
    }

    @Test(expected = IllegalArgumentException.class)
    public void htmlEscape_null() {
        VariableUtil.htmlEscape(null);
    }

    @Test
    public void htmlEscape_() {
        String text = "<b></b>";
        Assert.assertEquals("&lt;b&gt;&lt;/b&gt;", VariableUtil.htmlEscape(text));
    }

    @Test
    public void htmlEscape_() {
        String text = "\"Hello\"";
        Assert.assertEquals("&quot;Hello&quot;", VariableUtil.htmlEscape(text));
    }

    @Test
    public void htmlEscape_() {
        String text = "\\1,000";
        Assert.assertEquals("&#39;1,000", VariableUtil.htmlEscape(text));
    }

    @Test
    public void htmlEscape_And() {
        String text = "D&D";
        Assert.assertEquals("D&amp;D", VariableUtil.htmlEscape(text));
    }

    @Test
    public void toNumber_int() {
        String value = "1";
        Assert.assertEquals(Integer.valueOf(1), VariableUtil.toNumber(value));
    }

    @Test
    public void toNumber_double() {
        String value = "2.8";
        Assert.assertEquals(Double.valueOf(2.8), VariableUtil.toNumber(value));
    }

    @Test
    public void toNumber_string() {
        String value = "string";
        Assert.assertNull(VariableUtil.toNumber(value));
    }

    @Test(expected = IllegalArgumentException.class)
    public void toNumber_null() {
        VariableUtil.toNumber(null);
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.