KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > wsitmodelext > PolicyTest


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.websvc.wsitmodelext;
21
22 import java.io.File JavaDoc;
23 import java.util.HashSet JavaDoc;
24 import java.util.Set JavaDoc;
25 import javax.xml.namespace.QName JavaDoc;
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 /**
59  *
60  * @author Martin Grebac
61  */

62 public class PolicyTest extends NbTestCase {
63     
64     public PolicyTest(String JavaDoc testName) {
65         super(testName);
66     }
67
68     @Override JavaDoc
69     protected void setUp() throws Exception JavaDoc {
70     }
71
72     @Override JavaDoc
73     protected void tearDown() throws Exception JavaDoc {
74         TestCatalogModel.getDefault().setDocumentPooling(false);
75     }
76
77     public void testWrite() throws Exception JavaDoc {
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 JavaDoc<QName JavaDoc> qnames = new HashSet JavaDoc();
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 JavaDoc qname : qnames) {
114             e = (ExtensibilityElement)fact.create(d, qname);
115             d.addExtensibilityElement(e);
116         }
117         
118         model.endTransaction();
119
120         File JavaDoc output = new File JavaDoc("C://WSITModelTestOutput.wsdl");
121         File JavaDoc golden = new File JavaDoc(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 JavaDoc getTestResourcePath() {
130         return "../resources/policy.xml";
131     }
132     
133 }
134
Popular Tags