FileDocCategorySizeDatePackage
PolicyUtilsTest.javaAPI DocExample10513Tue May 29 16:57:40 BST 2007com.sun.xml.ws.policy.privateutil

PolicyUtilsTest

public class PolicyUtilsTest extends TestCase
author
Marek Potociar (marek.potociar at sun.com)

Fields Summary
private static final PolicyLogger
LOGGER
Constructors Summary
public PolicyUtilsTest(String testName)

    
       
        super(testName);
    
Methods Summary
protected voidsetUp()

    
protected voidtearDown()

    
public voidtestCollectionsCombine()
Test of combine method, of class com.sun.xml.ws.policy.privateutil.PolicyUtils.Collections.

        // TODO review the generated test code and remove the default call to fail.
        // fail("The test case is a prototype.");
    
public voidtestCommonsGetStackMethodName()
Test of getStackMethodName method, of class com.sun.xml.ws.policy.privateutil.PolicyUtils.Commons.

        int index;
        String expResult, result;
        
        index = 0;
        expResult = "dumpThreads";
        result = PolicyUtils.Commons.getStackMethodName(index);
        assertEquals(expResult, result);
        
        index = 1;
        expResult = "getStackTrace";
        result = PolicyUtils.Commons.getStackMethodName(index);
        assertEquals(expResult, result);
        
        index = 2;
        expResult = "getStackMethodName";
        result = PolicyUtils.Commons.getStackMethodName(index);
        assertEquals(expResult, result);
        
        index = 3;
        expResult = "testCommonsGetStackMethodName";
        result = PolicyUtils.Commons.getStackMethodName(index);
        assertEquals(expResult, result);
    
public voidtestComparisonCompareBoolean()
Test of compareBoolean method, of class com.sun.xml.ws.policy.privateutil.PolicyUtils.Comparison.

        boolean b1, b2;
        int expResult, result;
        
        b1 = true;
        b2 = true;
        expResult = 0;
        result = PolicyUtils.Comparison.compareBoolean(b1, b2);
        assertEquals(expResult, result);
        
        b1 = false;
        b2 = false;
        expResult = 0;
        result = PolicyUtils.Comparison.compareBoolean(b1, b2);
        assertEquals(expResult, result);
        
        b1 = false;
        b2 = true;
        expResult = -1;
        result = PolicyUtils.Comparison.compareBoolean(b1, b2);
        assertEquals(expResult, result);
        
        b1 = true;
        b2 = false;
        expResult = 1;
        result = PolicyUtils.Comparison.compareBoolean(b1, b2);
        assertEquals(expResult, result);
    
public voidtestComparisonCompareNullableStrings()
Test of compareNullableStrings method, of class com.sun.xml.ws.policy.privateutil.PolicyUtils.Comparison.

        String s1, s2;
        int expResult, result;
        
        s1 = null;
        s2 = null;
        expResult = 0;
        result = PolicyUtils.Comparison.compareNullableStrings(s1, s2);
        assertEquals(expResult, result);
        
        s1 = "";
        s2 = "";
        expResult = 0;
        result = PolicyUtils.Comparison.compareNullableStrings(s1, s2);
        assertEquals(expResult, result);
        
        s1 = "abc";
        s2 = "abc";
        expResult = 0;
        result = PolicyUtils.Comparison.compareNullableStrings(s1, s2);
        assertEquals(expResult, result);
        
        s1 = null;
        s2 = "";
        expResult = -1;
        result = PolicyUtils.Comparison.compareNullableStrings(s1, s2);
        assertEquals(expResult, result);
        
        s1 = null;
        s2 = "abc";
        expResult = -1;
        result = PolicyUtils.Comparison.compareNullableStrings(s1, s2);
        assertEquals(expResult, result);
        
        s1 = "abc";
        s2 = "abd";
        expResult = -1;
        result = PolicyUtils.Comparison.compareNullableStrings(s1, s2);
        assertEquals(expResult, result);
        
        s1 = "";
        s2 = null;
        expResult = 1;
        result = PolicyUtils.Comparison.compareNullableStrings(s1, s2);
        assertEquals(expResult, result);
        
        s1 = "abc";
        s2 = null;
        expResult = 1;
        result = PolicyUtils.Comparison.compareNullableStrings(s1, s2);
        assertEquals(expResult, result);
        
        s1 = "abd";
        s2 = "abc";
        expResult = 1;
        result = PolicyUtils.Comparison.compareNullableStrings(s1, s2);
        assertEquals(expResult, result);
    
public voidtestConfigFileGenerateFullName()
Test of generateFullName method, of class com.sun.xml.ws.policy.privateutil.PolicyUtils.ConfigFile.

        System.out.println("generateFullName");
        
        String configFileIdentifier = "test";
        
        String expResult = "wsit-test.xml";
        String result = PolicyUtils.ConfigFile.generateFullName(configFileIdentifier);
        assertEquals(expResult, result);
    
public voidtestConfigFileLoadFromClasspath()
Test of loadFromClasspath method, of class com.sun.xml.ws.policy.privateutil.PolicyUtils.ConfigFile.

        // TODO review the generated test code and remove the default call to fail.
        // fail("The test case is a prototype.");
    
public voidtestConfigFileLoadFromContext()
Test of loadFromContext method, of class com.sun.xml.ws.policy.privateutil.PolicyUtils.ConfigFile.

        // TODO review the generated test code and remove the default call to fail.
        // fail("The test case is a prototype.");
    
public voidtestGetCallerMethodName()

        class TestCall {
            public void testCall() {
                String expResult, result;
                
                expResult = "testGetCallerMethodName";
                result = PolicyUtils.Commons.getCallerMethodName();
                assertEquals(expResult, result);                
            }
        };
        
        TestCall tc = new TestCall();
        tc.testCall();
    
public voidtestIOCloseResource()
Test of closeResource method, of class com.sun.xml.ws.policy.privateutil.PolicyUtils.IO.

        PolicyUtils.IO.closeResource((Closeable) null);
        PolicyUtils.IO.closeResource((XMLStreamReader) null);
        
        // TODO: add more testing code 
    
public voidtestReflectionInvoke()
Test of invoke method, of class com.sun.xml.ws.policy.privateutil.PolicyUtils.Reflection.

        
        // TODO review the generated test code and remove the default call to fail.
        // fail("The test case is a prototype.");
    
public voidtestRtf2396Unquote()

        assertEquals("hello Vasku", PolicyUtils.Rfc2396.unquote("hello%20Vasku"));
    
public voidtestServiceProviderLoad()
Test of load method, of class com.sun.xml.ws.policy.privateutil.PolicyUtils.ServiceProvider.

        System.out.println("load");
        
        PolicyAssertionCreator[] result = PolicyUtils.ServiceProvider.load(PolicyAssertionCreator.class, this.getClass().getClassLoader());
        assertEquals(9, result.length);
    
public voidtestTextCreateIndent()
Test of createIndent method, of class com.sun.xml.ws.policy.privateutil.PolicyUtils.Text.

        int indentLevel;
        String expResult, result;
        
        indentLevel = 0;
        expResult = "";
        result = PolicyUtils.Text.createIndent(indentLevel);
        assertEquals(expResult, result);
        
        
        indentLevel = 1;
        expResult = "    ";
        result = PolicyUtils.Text.createIndent(indentLevel);
        assertEquals(expResult, result);
        
        indentLevel = 2;
        expResult = "        ";
        result = PolicyUtils.Text.createIndent(indentLevel);
        assertEquals(expResult, result);