Source Code Cross Referenced for JAXR060RegistryTest.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:         * JBoss, Home of Professional Open Source
003:         * Copyright 2006, JBoss Inc., and individual contributors as indicated
004:         * by the @authors tag. See the copyright.txt in the distribution for a
005:         * full listing of individual contributors.
006:         *
007:         * This is free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU Lesser General Public License as
009:         * published by the Free Software Foundation; either version 2.1 of
010:         * the License, or (at your option) any later version.
011:         *
012:         * This software is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this software; if not, write to the Free
019:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021:         */
022:        package org.apache.ws.scout.registry.qa;
023:
024:        import static org.junit.Assert.assertEquals;
025:        import static org.junit.Assert.assertTrue;
026:        import static org.junit.Assert.fail;
027:
028:        import java.util.ArrayList;
029:        import java.util.Collection;
030:        import java.util.Iterator;
031:
032:        import javax.xml.registry.BulkResponse;
033:        import javax.xml.registry.FindQualifier;
034:        import javax.xml.registry.JAXRException;
035:        import javax.xml.registry.JAXRResponse;
036:        import javax.xml.registry.RegistryService;
037:        import javax.xml.registry.infomodel.Classification;
038:        import javax.xml.registry.infomodel.ClassificationScheme;
039:        import javax.xml.registry.infomodel.Organization;
040:        import javax.xml.registry.infomodel.Service;
041:        import javax.xml.registry.infomodel.ServiceBinding;
042:        import javax.xml.registry.infomodel.User;
043:
044:        import junit.framework.JUnit4TestAdapter;
045:
046:        import org.apache.ws.scout.BaseTestCase;
047:        import org.apache.ws.scout.Creator;
048:        import org.apache.ws.scout.Finder;
049:        import org.apache.ws.scout.Remover;
050:        import org.junit.After;
051:        import org.junit.Before;
052:        import org.junit.Test;
053:
054:        /**
055:         * Testing the registry.
056:         * 
057:         * @author kstam
058:         *
059:         */
060:        public class JAXR060RegistryTest extends BaseTestCase {
061:            @Before
062:            public void setUp() {
063:                super .setUp();
064:                login();
065:                try {
066:                    RegistryService rs = connection.getRegistryService();
067:                    bqm = rs.getBusinessQueryManager();
068:                    blm = rs.getBusinessLifeCycleManager();
069:                    ClassificationScheme cScheme = blm
070:                            .createClassificationScheme(
071:                                    "org.jboss.soa.esb.:testcategory",
072:                                    "JBossESB Classification Scheme");
073:                    ArrayList<ClassificationScheme> cSchemes = new ArrayList<ClassificationScheme>();
074:                    cSchemes.add(cScheme);
075:                    BulkResponse br = blm.saveClassificationSchemes(cSchemes);
076:                    assertEquals(JAXRResponse.STATUS_SUCCESS, br.getStatus());
077:                } catch (JAXRException je) {
078:                    fail(je.getMessage());
079:                }
080:            }
081:
082:            @After
083:            public void tearDown() {
084:                super .tearDown();
085:                login();
086:                try {
087:                    RegistryService rs = connection.getRegistryService();
088:                    bqm = rs.getBusinessQueryManager();
089:                    blm = rs.getBusinessLifeCycleManager();
090:                    Collection<String> findQualifiers = new ArrayList<String>();
091:                    findQualifiers.add(FindQualifier.AND_ALL_KEYS);
092:                    findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
093:                    ClassificationScheme cScheme = bqm
094:                            .findClassificationSchemeByName(findQualifiers,
095:                                    "org.jboss.soa.esb.:testcategory");
096:                    Remover remover = new Remover(blm);
097:                    remover.removeClassificationScheme(cScheme);
098:                } catch (JAXRException je) {
099:                    fail(je.getMessage());
100:                }
101:            }
102:
103:            /**
104:             * Tests the successful creation of the RED HAT/JBossESB Organization.
105:             */
106:            @SuppressWarnings("unchecked")
107:            @Test
108:            public void publishCheckAndDelete() {
109:                login();
110:                try {
111:                    RegistryService rs = connection.getRegistryService();
112:                    blm = rs.getBusinessLifeCycleManager();
113:                    Creator creator = new Creator(blm);
114:
115:                    Collection<Organization> organizations = new ArrayList<Organization>();
116:                    Organization organization = creator
117:                            .createOrganization("Red Hat/JBossESB");
118:                    organizations.add(organization);
119:                    BulkResponse br = blm.saveOrganizations(organizations);
120:                    assertEquals(BulkResponse.STATUS_SUCCESS, br.getStatus());
121:                } catch (JAXRException je) {
122:                    je.printStackTrace();
123:                    assertTrue(false);
124:                }
125:                //find organization
126:                try {
127:                    RegistryService rs = connection.getRegistryService();
128:                    bqm = rs.getBusinessQueryManager();
129:                    Finder finder = new Finder(bqm);
130:                    Collection<Organization> orgs = finder
131:                            .findOrganizationsByName("Red Hat/JBossESB");
132:                    Organization org = orgs.iterator().next();
133:                    assertEquals("Red Hat/JBossESB", org.getName().getValue());
134:                } catch (JAXRException je) {
135:                    fail(je.getMessage());
136:                }
137:                try {
138:                    RegistryService rs = connection.getRegistryService();
139:                    bqm = rs.getBusinessQueryManager();
140:                    Finder finder = new Finder(bqm);
141:                    Collection<Organization> orgs = finder
142:                            .findOrganizationsByName("Not Existing Org");
143:                    assertEquals(0, orgs.size());
144:                } catch (JAXRException je) {
145:                    fail(je.getMessage());
146:                }
147:                //Publish a service
148:                try {
149:                    RegistryService rs = connection.getRegistryService();
150:                    bqm = rs.getBusinessQueryManager();
151:                    Finder finder = new Finder(bqm);
152:                    Collection<Organization> orgs = finder
153:                            .findOrganizationsByName("Red Hat/JBossESB");
154:                    Organization organization = orgs.iterator().next();
155:
156:                    blm = rs.getBusinessLifeCycleManager();
157:                    //Adding the category as prefix for the name
158:                    Service service = blm
159:                            .createService(blm
160:                                    .createInternationalString("Registry Test ServiceName"));
161:                    service
162:                            .setDescription(blm
163:                                    .createInternationalString("Registry Test Service Description"));
164:                    Collection<String> findQualifiers = new ArrayList<String>();
165:                    findQualifiers.add(FindQualifier.AND_ALL_KEYS);
166:                    findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
167:                    ClassificationScheme cScheme = bqm
168:                            .findClassificationSchemeByName(findQualifiers,
169:                                    "org.jboss.soa.esb.:testcategory");
170:                    Classification classification = blm.createClassification(
171:                            cScheme, "category", "registry");
172:                    service.addClassification(classification);
173:                    organization.addService(service);
174:                    Collection<Service> services = new ArrayList<Service>();
175:                    services.add(service);
176:                    BulkResponse br = blm.saveServices(services);
177:                    assertEquals(BulkResponse.STATUS_SUCCESS, br.getStatus());
178:                } catch (JAXRException je) {
179:                    fail(je.getMessage());
180:                }
181:                //find Service
182:                try {
183:                    RegistryService rs = connection.getRegistryService();
184:                    bqm = rs.getBusinessQueryManager();
185:                    blm = rs.getBusinessLifeCycleManager();
186:                    Finder finder = new Finder(bqm);
187:                    //Find the service
188:                    Service service = finder.findService("registry",
189:                            "Registry Test ServiceName", blm);
190:                    assertEquals("Registry Test ServiceName", service.getName()
191:                            .getValue());
192:                } catch (JAXRException je) {
193:                    fail(je.getMessage());
194:                }
195:                //publish serviceBinding
196:                try {
197:                    RegistryService rs = connection.getRegistryService();
198:                    bqm = rs.getBusinessQueryManager();
199:                    blm = rs.getBusinessLifeCycleManager();
200:                    Finder finder = new Finder(bqm);
201:                    //Find the service
202:                    Service service = finder.findService("registry",
203:                            "Registry Test ServiceName", blm);
204:
205:                    ServiceBinding serviceBinding = blm.createServiceBinding();
206:                    serviceBinding.setDescription(blm
207:                            .createInternationalString("eprDescription"));
208:                    String xml = "<epr>epr uri</epr>";
209:                    serviceBinding.setAccessURI(xml);
210:
211:                    ArrayList<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>();
212:                    serviceBindings.add(serviceBinding);
213:                    service.addServiceBindings(serviceBindings);
214:                    Collection<String> findQualifiers = new ArrayList<String>();
215:                    findQualifiers.add(FindQualifier.AND_ALL_KEYS);
216:                    findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
217:                    ClassificationScheme cScheme = bqm
218:                            .findClassificationSchemeByName(findQualifiers,
219:                                    "org.jboss.soa.esb.:testcategory");
220:                    Classification classification = blm.createClassification(
221:                            cScheme, "category", "registry");
222:                    service.addClassification(classification);
223:
224:                    BulkResponse br = blm.saveServiceBindings(serviceBindings);
225:                    assertEquals(BulkResponse.STATUS_SUCCESS, br.getStatus());
226:                    BulkResponse br2 = blm.saveServiceBindings(serviceBindings); //Save one more
227:                    assertEquals(BulkResponse.STATUS_SUCCESS, br2.getStatus());
228:
229:                    //Delete one binding
230:                    Collection<ServiceBinding> serviceBindings2 = finder
231:                            .findServiceBindings(service.getKey());
232:                    ServiceBinding serviceBinding2 = serviceBindings2
233:                            .iterator().next();
234:                    Remover remover = new Remover(blm);
235:                    remover.removeServiceBinding(serviceBinding2);
236:
237:                } catch (JAXRException re) {
238:                    fail(re.getMessage());
239:                }
240:                //find all services for this organization
241:                try {
242:                    RegistryService rs = connection.getRegistryService();
243:                    bqm = rs.getBusinessQueryManager();
244:                    Finder finder = new Finder(bqm);
245:                    Collection<Organization> orgs = finder
246:                            .findOrganizationsByName("Red Hat/JBossESB");
247:                    Organization org = orgs.iterator().next();
248:                    //Listing out the services and their Bindings
249:                    System.out
250:                            .println("-------------------------------------------------");
251:                    System.out.println("Organization name: "
252:                            + org.getName().getValue());
253:                    System.out.println("Description: "
254:                            + org.getDescription().getValue());
255:                    System.out.println("Key id: " + org.getKey().getId());
256:                    User primaryContact = org.getPrimaryContact();
257:                    System.out.println("Primary Contact: "
258:                            + primaryContact.getPersonName().getFullName());
259:                    Collection services = org.getServices();
260:                    for (Iterator serviceIter = services.iterator(); serviceIter
261:                            .hasNext();) {
262:                        Service service = (Service) serviceIter.next();
263:                        System.out.println("- Service Name: "
264:                                + service.getName().getValue());
265:                        System.out.println("  Service Key : "
266:                                + service.getKey().getId());
267:                        Collection serviceBindings = service
268:                                .getServiceBindings();
269:                        for (Iterator serviceBindingIter = serviceBindings
270:                                .iterator(); serviceBindingIter.hasNext();) {
271:                            ServiceBinding serviceBinding = (ServiceBinding) serviceBindingIter
272:                                    .next();
273:                            System.out.println("  ServiceBinding Description: "
274:                                    + serviceBinding.getDescription()
275:                                            .getValue());
276:                            String xml = serviceBinding.getAccessURI();
277:                            System.out.println("  ServiceBinding URI: " + xml);
278:                            assertEquals("<epr>epr uri</epr>", xml);
279:                        }
280:                    }
281:                    System.out
282:                            .println("-------------------------------------------------");
283:                } catch (Exception je) {
284:                    fail(je.getMessage());
285:                }
286:                //delete the service
287:                try {
288:                    RegistryService rs = connection.getRegistryService();
289:                    bqm = rs.getBusinessQueryManager();
290:                    blm = rs.getBusinessLifeCycleManager();
291:                    Finder finder = new Finder(bqm);
292:                    //Find the service
293:                    Service service = finder.findService("registry",
294:                            "Registry Test ServiceName", blm);
295:                    Remover remover = new Remover(blm);
296:                    remover.removeService(service);
297:                } catch (JAXRException je) {
298:                    fail(je.getMessage());
299:                }
300:                //delete the organization
301:                try {
302:                    RegistryService rs = connection.getRegistryService();
303:                    bqm = rs.getBusinessQueryManager();
304:                    blm = rs.getBusinessLifeCycleManager();
305:                    Finder finder = new Finder(bqm);
306:                    Collection<Organization> orgs = finder
307:                            .findOrganizationsByName("Red Hat/JBossESB");
308:                    Organization org = orgs.iterator().next();
309:                    Remover remover = new Remover(blm);
310:                    remover.removeOrganization(org);
311:                } catch (JAXRException je) {
312:                    fail(je.getMessage());
313:                }
314:            }
315:
316:            public static junit.framework.Test suite() {
317:                return new JUnit4TestAdapter(JAXR060RegistryTest.class);
318:            }
319:
320:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.