1 19 20 package org.netbeans.modules.websvc.wsitmodelext; 21 22 import java.io.File ; 23 import java.util.HashSet ; 24 import java.util.Set ; 25 import javax.xml.namespace.QName ; 26 import org.netbeans.junit.NbTestCase; 27 import org.netbeans.modules.websvc.wsitmodelext.addressing.Addressing10QName; 28 import org.netbeans.modules.websvc.wsitmodelext.addressing.Addressing10WsdlQName; 29 import org.netbeans.modules.websvc.wsitmodelext.addressing.AddressingQName; 30 import org.netbeans.modules.websvc.wsitmodelext.mtom.MtomQName; 31 import org.netbeans.modules.websvc.wsitmodelext.policy.PolicyQName; 32 import org.netbeans.modules.websvc.wsitmodelext.rm.RMMSQName; 33 import org.netbeans.modules.websvc.wsitmodelext.rm.RMQName; 34 import org.netbeans.modules.websvc.wsitmodelext.rm.RMSunClientQName; 35 import org.netbeans.modules.websvc.wsitmodelext.rm.RMSunQName; 36 import org.netbeans.modules.websvc.wsitmodelext.security.SecurityPolicyQName; 37 import org.netbeans.modules.websvc.wsitmodelext.security.SecurityQName; 38 import org.netbeans.modules.websvc.wsitmodelext.security.algosuite.AlgorithmSuiteQName; 39 import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.ProprietaryPolicyQName; 40 import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.ProprietarySCClientQName; 41 import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.ProprietarySecurityPolicyQName; 42 import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.ProprietaryTrustClientQName; 43 import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.service.ProprietarySCServiceQName; 44 import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.service.ProprietarySecurityPolicyServiceQName; 45 import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.service.ProprietaryTrustServiceQName; 46 import org.netbeans.modules.websvc.wsitmodelext.security.tokens.TokensQName; 47 import org.netbeans.modules.websvc.wsitmodelext.transport.FIQName; 48 import org.netbeans.modules.websvc.wsitmodelext.transport.TCPQName; 49 import org.netbeans.modules.websvc.wsitmodelext.trust.TrustQName; 50 import org.netbeans.modules.websvc.wsitmodelext.tx.TxQName; 51 import org.netbeans.modules.websvc.wsitmodelext.util.TestCatalogModel; 52 import org.netbeans.modules.websvc.wsitmodelext.util.Util; 53 import org.netbeans.modules.xml.wsdl.model.Definitions; 54 import org.netbeans.modules.xml.wsdl.model.ExtensibilityElement; 55 import org.netbeans.modules.xml.wsdl.model.WSDLComponentFactory; 56 import org.netbeans.modules.xml.wsdl.model.WSDLModel; 57 58 62 public class PolicyTest extends NbTestCase { 63 64 public PolicyTest(String testName) { 65 super(testName); 66 } 67 68 @Override 69 protected void setUp() throws Exception { 70 } 71 72 @Override 73 protected void tearDown() throws Exception { 74 TestCatalogModel.getDefault().setDocumentPooling(false); 75 } 76 77 public void testWrite() throws Exception { 78 TestCatalogModel.getDefault().setDocumentPooling(true); 79 WSDLModel model = Util.loadWSDLModel("../resources/policy.xml"); 80 WSDLComponentFactory fact = model.getFactory(); 81 82 model.startTransaction(); 83 84 Definitions d = model.getDefinitions(); 85 ExtensibilityElement e = null; 86 Set <QName > qnames = new HashSet (); 87 88 qnames.addAll(PolicyQName.getQNames()); 89 qnames.addAll(MtomQName.getQNames()); 90 qnames.addAll(FIQName.getQNames()); 91 qnames.addAll(TCPQName.getQNames()); 92 qnames.addAll(AddressingQName.getQNames()); 93 qnames.addAll(Addressing10QName.getQNames()); 94 qnames.addAll(Addressing10WsdlQName.getQNames()); 95 qnames.addAll(RMQName.getQNames()); 96 qnames.addAll(RMSunQName.getQNames()); 97 qnames.addAll(RMSunClientQName.getQNames()); 98 qnames.addAll(RMMSQName.getQNames()); 99 qnames.addAll(SecurityQName.getQNames()); 100 qnames.addAll(SecurityPolicyQName.getQNames()); 101 qnames.addAll(AlgorithmSuiteQName.getQNames()); 102 qnames.addAll(ProprietaryPolicyQName.getQNames()); 103 qnames.addAll(ProprietarySCClientQName.getQNames()); 104 qnames.addAll(ProprietarySecurityPolicyQName.getQNames()); 105 qnames.addAll(ProprietarySecurityPolicyServiceQName.getQNames()); 106 qnames.addAll(ProprietaryTrustClientQName.getQNames()); 107 qnames.addAll(ProprietaryTrustServiceQName.getQNames()); 108 qnames.addAll(ProprietarySCServiceQName.getQNames()); 109 qnames.addAll(TokensQName.getQNames()); 110 qnames.addAll(TrustQName.getQNames()); 111 qnames.addAll(TxQName.getQNames()); 112 113 for (QName qname : qnames) { 114 e = (ExtensibilityElement)fact.create(d, qname); 115 d.addExtensibilityElement(e); 116 } 117 118 model.endTransaction(); 119 120 File output = new File ("C://WSITModelTestOutput.wsdl"); 121 File golden = new File (getDataDir().getAbsolutePath() + "/goldenfiles/" + "WSITModelTestOutput.wsdl"); 122 123 Util.dumpToFile(model.getBaseDocument(), output); 124 125 System.out.println(getWorkDir().getAbsolutePath()); 126 assertFile(output, golden, getWorkDir()); 127 } 128 129 public String getTestResourcePath() { 130 return "../resources/policy.xml"; 131 } 132 133 } 134 | Popular Tags |