FileDocCategorySizeDatePackage
PolicyModelTranslatorTest.javaAPI DocExample5964Tue May 29 16:57:40 BST 2007com.sun.xml.ws.policy.sourcemodel

PolicyModelTranslatorTest

public class PolicyModelTranslatorTest extends TestCase
author
Marek Potociar

Fields Summary
private static final String
COMPACT_MODEL_SUFFIX
private static final String
NORMALIZED_MODEL_SUFFIX
private static final Map
COMPLEX_POLICIES
private PolicyModelTranslator
translator
Constructors Summary
public PolicyModelTranslatorTest(String testName)

        super(testName);
    
Methods Summary
protected voidsetUp()

        translator = PolicyModelTranslator.getTranslator();
    
protected voidtearDown()

    
public voidtestGetTranslator()
Test of getTranslator method, of class com.sun.xml.ws.policy.PolicyModelTranslator.

        PolicyModelTranslator result = PolicyModelTranslator.getTranslator();
        assertNotNull(result);
    
public voidtestTranslateComplexPoliciesWithMultipleNestedPolicyAlternatives()
Test of translate method, of class com.sun.xml.ws.policy.PolicyModelTranslator.

        int index = 0;
        for (Map.Entry<String, Integer> entry : COMPLEX_POLICIES.entrySet()) {
            String compactResourceName = entry.getKey() + COMPACT_MODEL_SUFFIX;
            String normalizedResouceName = entry.getKey() + NORMALIZED_MODEL_SUFFIX;
            int expectedNumberOfAlternatives = entry.getValue();
            
            PolicySourceModel compactModel = PolicyResourceLoader.unmarshallModel(compactResourceName);
            PolicySourceModel normalizedModel = PolicyResourceLoader.unmarshallModel(normalizedResouceName);

//            System.out.println(index + ". compact model: " + compactModel);
//            System.out.println("===========================================================");
//            System.out.println(index + ". normalized model: " + normalizedModel);
//            System.out.println("===========================================================");
            
            Policy compactModelPolicy = translator.translate(compactModel);
            Policy normalizedModelPolicy = translator.translate(normalizedModel);
            
            assertEquals("Normalized and compact model policy instances should contain equal number of alternatives", normalizedModelPolicy.getNumberOfAssertionSets(), compactModelPolicy.getNumberOfAssertionSets());
            assertEquals("This policy should contain '" + expectedNumberOfAlternatives + "' alternatives", expectedNumberOfAlternatives, compactModelPolicy.getNumberOfAssertionSets());
            assertEquals("Normalized and compact policy expression should form equal Policy instances", normalizedModelPolicy, compactModelPolicy);
            
//            System.out.println(index + ". compact model policy: " + compactModelPolicy);
//            System.out.println("===========================================================");
//            System.out.println(index + ". normalized model policy: " + normalizedModelPolicy);
            
            index++;
        }