Source Code Cross Referenced for JAXR020ConceptTest.java in  » Web-Services » XML-Registry-JAXR » org » apache » ws » scout » registry » qa » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Services » XML Registry JAXR » org.apache.ws.scout.registry.qa 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         *
003:         * Copyright 2004 The Apache Software Foundation
004:         *
005:         *  Licensed under the Apache License, Version 2.0 (the "License");
006:         *  you may not use this file except in compliance with the License.
007:         *  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */package org.apache.ws.scout.registry.qa;
017:
018:        import static org.junit.Assert.fail;
019:
020:        import java.util.ArrayList;
021:        import java.util.Collection;
022:        import java.util.Iterator;
023:
024:        import javax.xml.registry.BulkResponse;
025:        import javax.xml.registry.BusinessQueryManager;
026:        import javax.xml.registry.FindQualifier;
027:        import javax.xml.registry.JAXRException;
028:        import javax.xml.registry.JAXRResponse;
029:        import javax.xml.registry.LifeCycleManager;
030:        import javax.xml.registry.RegistryService;
031:        import javax.xml.registry.infomodel.Classification;
032:        import javax.xml.registry.infomodel.ClassificationScheme;
033:        import javax.xml.registry.infomodel.Concept;
034:        import javax.xml.registry.infomodel.ExternalLink;
035:        import javax.xml.registry.infomodel.InternationalString;
036:        import javax.xml.registry.infomodel.Key;
037:
038:        import junit.framework.JUnit4TestAdapter;
039:
040:        import org.apache.ws.scout.BaseTestCase;
041:        import org.apache.ws.scout.Printer;
042:        import org.apache.ws.scout.Remover;
043:        import org.junit.After;
044:        import org.junit.Before;
045:        import org.junit.Test;
046:
047:        /**
048:         * Tests publish concepts.
049:         * 
050:         * Open source UDDI Browser  <http://www.uddibrowser.org>
051:         * to check your results.
052:         *
053:         * Based on query/publish tests written by 
054:         * <a href="mailto:anil@apache.org">Anil Saldhana</a>.
055:         *
056:         * @author <a href="mailto:dbhole@redhat.com">Deepak Bhole</a>
057:         * @author <a href="mailto:anil@apache.org">Anil Saldhana</a>
058:         * 
059:         * @since Sep 27, 2005
060:         */
061:        public class JAXR020ConceptTest extends BaseTestCase {
062:            private static String CONCEPT_NAME = "Apache Scout Concept -- APACHE SCOUT TEST";
063:
064:            @Before
065:            public void setUp() {
066:                super .setUp();
067:            }
068:
069:            @After
070:            public void tearDown() {
071:                super .tearDown();
072:            }
073:
074:            @Test
075:            public void testPublishConcept() {
076:                login();
077:                try {
078:                    RegistryService rs = connection.getRegistryService();
079:                    BusinessQueryManager bqm = rs.getBusinessQueryManager();
080:                    blm = rs.getBusinessLifeCycleManager();
081:
082:                    Concept concept = blm.createConcept(null, CONCEPT_NAME, "");
083:                    InternationalString is = blm
084:                            .createInternationalString("This is the concept for Apache Scout Test");
085:                    concept.setDescription(is);
086:
087:                    //Lets provide a link to juddi registry
088:                    ExternalLink wslink = blm.createExternalLink(
089:                            "http://to-rhaps4.toronto.redhat.com:9000/juddi",
090:                            "juddi");
091:                    concept.addExternalLink(wslink);
092:                    Classification cl = createClassificationForUDDI(bqm);
093:
094:                    concept.addClassification(cl);
095:
096:                    Collection<Concept> concepts = new ArrayList<Concept>();
097:                    concepts.add(concept);
098:
099:                    Key key = null;
100:                    BulkResponse br = blm.saveConcepts(concepts);
101:                    if (br.getStatus() == JAXRResponse.STATUS_SUCCESS) {
102:                        System.out.println("Concept Saved");
103:                        Collection coll = br.getCollection();
104:                        Iterator iter = coll.iterator();
105:                        while (iter.hasNext()) {
106:                            key = (Key) iter.next();
107:                            System.out.println("Saved Key=" + key.getId());
108:                        }//end while
109:                    } else {
110:                        System.err.println("JAXRExceptions "
111:                                + "occurred during save:");
112:                        Collection exceptions = br.getExceptions();
113:                        Iterator iter = exceptions.iterator();
114:                        while (iter.hasNext()) {
115:                            Exception e = (Exception) iter.next();
116:                            System.err.println(e.toString());
117:                            fail(e.toString());
118:                        }
119:                    }
120:
121:                    Concept savedConcept = (Concept) bqm.getRegistryObject(key
122:                            .getId(), LifeCycleManager.CONCEPT);
123:                    System.out.println("Save concept=" + savedConcept);
124:
125:                } catch (JAXRException e) {
126:                    e.printStackTrace();
127:                    fail(e.getMessage());
128:                }
129:            }
130:
131:            private Classification createClassificationForUDDI(
132:                    BusinessQueryManager bqm) throws JAXRException {
133:                //Scheme which maps onto uddi tmodel
134:                ClassificationScheme udditmodel = bqm
135:                        .findClassificationSchemeByName(null, "uddi-org:types");
136:
137:                Classification cl = blm.createClassification(udditmodel,
138:                        "wsdl", "wsdl");
139:                return cl;
140:            }
141:
142:            public void testDeleteConcept() {
143:                login();
144:                try {
145:                    RegistryService rs = connection.getRegistryService();
146:                    BusinessQueryManager bqm = rs.getBusinessQueryManager();
147:                    blm = rs.getBusinessLifeCycleManager();
148:                    Printer printer = new Printer();
149:                    Remover remover = new Remover(blm);
150:
151:                    Collection<String> findQualifiers = new ArrayList<String>();
152:                    findQualifiers.add(FindQualifier.SORT_BY_NAME_ASC);
153:                    Collection<String> namePatterns = new ArrayList<String>();
154:                    namePatterns.add("%" + CONCEPT_NAME + "%");
155:
156:                    BulkResponse br = bqm.findConcepts(findQualifiers,
157:                            namePatterns, null, null, null);
158:
159:                    //          check how many organisation we have matched
160:                    Collection concepts = br.getCollection();
161:
162:                    if (concepts == null) {
163:                        System.out.println("\n-- Matched 0 orgs");
164:
165:                    } else {
166:                        System.out.println("\n-- Matched " + concepts.size()
167:                                + " concepts --\n");
168:
169:                        // then step through them
170:                        for (Iterator conceptIter = concepts.iterator(); conceptIter
171:                                .hasNext();) {
172:                            Concept c = (Concept) conceptIter.next();
173:
174:                            System.out.println("Id: " + c.getKey().getId());
175:                            System.out.println("Name: "
176:                                    + c.getName().getValue());
177:
178:                            // Links are not yet implemented in scout -- so concepts 
179:                            // created via scout won't have links 
180:                            printer.printExternalLinks(c);
181:
182:                            // Print spacer between messages
183:                            System.out.println(" --- ");
184:
185:                            remover.removeConcept(c);
186:
187:                            System.out.println(" === ");
188:                        }
189:                    }//end else
190:                } catch (JAXRException e) {
191:                    e.printStackTrace();
192:                    fail(e.getMessage());
193:                }
194:            }
195:
196:            public static junit.framework.Test suite() {
197:                return new JUnit4TestAdapter(JAXR020ConceptTest.class);
198:            }
199:
200:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.