01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * published by the Free Software Foundation; either version 2.1 of
10: * the License, or (at your option) any later version.
11: *
12: * This software is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this software; if not, write to the Free
19: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21: */
22: package org.jboss.test.jaxr.scout.publish.infomodel;
23:
24: import java.util.ArrayList;
25: import java.util.Collection;
26:
27: import javax.xml.registry.BulkResponse;
28: import javax.xml.registry.LifeCycleManager;
29: import javax.xml.registry.infomodel.ClassificationScheme;
30: import javax.xml.registry.infomodel.Concept;
31: import javax.xml.registry.infomodel.ExternalLink;
32: import javax.xml.registry.infomodel.Key;
33:
34: import org.jboss.test.jaxr.scout.JaxrBaseTestCase;
35:
36: //$Id: JaxrClassficationTestCase.java 57211 2006-09-26 12:39:46Z dimitris@jboss.org $
37:
38: /**
39: * Test the storage of classifications on Concepts and Services
40: * @author <a href="mailto:Anil.Saldhana@jboss.org">Anil Saldhana</a>
41: * @author <a href="mailto:Noel.Rocher@jboss.org">Noel Rocher</a>
42: * @since Apr 11, 2006
43: * @version $Revision: 57211 $
44: */
45: public class JaxrClassficationTestCase extends JaxrBaseTestCase {
46: private static final String UUID_TYPE = "uuid:C1ACF26D-9672-4404-9D70-39B756E62AB4";
47:
48: public void testClassificationOnConcepts() throws Exception {
49: login();
50: getJAXREssentials();
51: Concept concept = null;
52: Collection concepts = new ArrayList(1);
53: String portTypeName = "Test Port Type";
54: concept = blm.createConcept(null, portTypeName, "");
55: ExternalLink wsdlLink = blm.createExternalLink(
56: "http://test.org/" + portTypeName,
57: "TEST Port Type definition");
58: concept.addExternalLink(wsdlLink);
59:
60: ClassificationScheme TYPE = (ClassificationScheme) bqm
61: .getRegistryObject(UUID_TYPE,
62: LifeCycleManager.CLASSIFICATION_SCHEME);
63: assertTrue("Classifications are not empty", TYPE
64: .getClassifications().size() > 0);
65: System.out.println("TYPE.Classifications = "
66: + TYPE.getClassifications());
67: concept.addClassification(blm.createClassification(TYPE, blm
68: .createInternationalString("TEST CLASSIFICATION"),
69: "test portType"));
70:
71: concepts.add(concept);
72: BulkResponse response = blm.saveConcepts(concepts);
73: if (response != null && response.getCollection().size() > 0) {
74: concept.setKey((Key) response.getCollection().iterator()
75: .next());
76: assertNotNull("Key created != null", concept.getKey());
77: System.out.println("Concept Key = " + concept.getKey()
78: + "\".");
79: }
80:
81: //Obtain the saved concepts
82: Concept savedConcept = (Concept) bqm.getRegistryObject(concept
83: .getKey().getId(), LifeCycleManager.CONCEPT);
84: assertNotNull("savedConcept is not null", savedConcept);
85: Collection collection = savedConcept.getClassifications();
86: assertNotNull("Classifications is not null", collection);
87: assertTrue("Classifications is not empty",
88: collection.isEmpty() == false);
89: }
90: }
|