KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > wsitconf > wsdlmodelext > ProfileTest


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 2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.websvc.wsitconf.wsdlmodelext;
20
21 import java.io.File JavaDoc;
22 import java.util.Collection JavaDoc;
23 import junit.framework.*;
24 import org.netbeans.junit.NbTestCase;
25 import org.netbeans.modules.websvc.wsitconf.ui.ComboConstants;
26 import org.netbeans.modules.websvc.wsitconf.util.TestCatalogModel;
27 import org.netbeans.modules.websvc.wsitconf.util.TestUtil;
28 import org.netbeans.modules.websvc.wsitmodelext.policy.All;
29 import org.netbeans.modules.websvc.wsitmodelext.policy.PolicyReference;
30 import org.netbeans.modules.xml.wsdl.model.Binding;
31 import org.netbeans.modules.xml.wsdl.model.BindingOperation;
32 import org.netbeans.modules.xml.wsdl.model.Definitions;
33 import org.netbeans.modules.xml.wsdl.model.WSDLComponentFactory;
34 import org.netbeans.modules.xml.wsdl.model.WSDLModel;
35
36 /**
37  *
38  * @author Martin Grebac
39  */

40 public class ProfileTest extends NbTestCase {
41     
42     public ProfileTest(String JavaDoc testName) {
43         super(testName);
44     }
45
46     @Override JavaDoc
47     protected void setUp() throws Exception JavaDoc {
48         clearWorkDir();
49     }
50
51     @Override JavaDoc
52     protected void tearDown() throws Exception JavaDoc {
53         TestCatalogModel.getDefault().setDocumentPooling(false);
54     }
55
56     public void testWrite() throws Exception JavaDoc {
57         TestCatalogModel.getDefault().setDocumentPooling(true);
58         WSDLModel model = TestUtil.loadWSDLModel("../wsdlmodelext/resources/policy.xml");
59         WSDLComponentFactory fact = model.getFactory();
60         
61         Definitions d = model.getDefinitions();
62         Binding b = (Binding) d.getBindings().toArray()[0];
63
64         String JavaDoc[] profiles = new String JavaDoc[] {
65             "",
66             ComboConstants.PROF_TRANSPORT,
67             ComboConstants.PROF_MSGAUTHSSL,
68             ComboConstants.PROF_SAMLSSL,
69             ComboConstants.PROF_USERNAME,
70             ComboConstants.PROF_MUTUALCERT,
71             ComboConstants.PROF_ENDORSCERT,
72             ComboConstants.PROF_SAMLSENDER,
73             ComboConstants.PROF_SAMLHOLDER,
74             ComboConstants.PROF_KERBEROS,
75             ComboConstants.PROF_STSISSUED,
76             ComboConstants.PROF_STSISSUEDCERT,
77             ComboConstants.PROF_STSISSUEDENDORSE
78         };
79         
80         for (int i=1; i<profiles.length; i++) {
81             String JavaDoc profile = profiles[i];
82
83             //default profile set
84
ProfilesModelHelper.setSecurityProfile(b, profile);
85
86             File JavaDoc profDefaultFile = new File JavaDoc(getWorkDirPath() + File.separator + i + profile + ".wsdl");
87             TestUtil.dumpToFile(model.getBaseDocument(), profDefaultFile);
88 // assertFile(profDefaultFile, TestUtil.getGoldenFile(getDataDir(), "Profile"+ i + "Test", "testDefault"));
89

90             ProfilesModelHelper.enableSecureConversation(b, true, profile); // enable SC
91

92             File JavaDoc profSCFile = new File JavaDoc(getWorkDirPath() + File.separator + i + profile + "-SecureConversation.wsdl");
93             TestUtil.dumpToFile(model.getBaseDocument(), profSCFile);
94 // assertFile(profSCFile, TestUtil.getGoldenFile(getDataDir(), "Profile"+ i + "Test", "testSecureConversation"));
95

96             ProfilesModelHelper.enableSecureConversation(b, false, profile); // disable SC
97

98             File JavaDoc profAfterSCFile = new File JavaDoc(getWorkDirPath() + File.separator + i + profile + "-After.wsdl");
99             TestUtil.dumpToFile(model.getBaseDocument(), profAfterSCFile);
100 // assertFile(profAfterSCFile, TestUtil.getGoldenFile(getDataDir(), "Profile"+ i + "Test", "testDefault"));
101

102             readAndCheck(model, profile);
103         }
104
105     }
106
107     private void readAndCheck(WSDLModel model, String JavaDoc profile) {
108         
109         // the model operation is not enclosed in transaction inorder to catch
110
// whether the operations do not try to create non-existing elements
111

112     }
113
114     public String JavaDoc getTestResourcePath() {
115         return "../wsdlmodelext/resources/policy.xml";
116     }
117     
118 }
119
Popular Tags