This project has retired. For details please refer to its Attic page.
JAXR005ClassificationSchemeTest xref
View Javadoc
1   /**
2    *
3    * Copyright 2004 The Apache Software Foundation
4    *
5    *  Licensed under the Apache License, Version 2.0 (the "License");
6    *  you may not use this file except in compliance with the License.
7    *  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   *  Unless required by applicable law or agreed to in writing, software
12   *  distributed under the License is distributed on an "AS IS" BASIS,
13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   *  See the License for the specific language governing permissions and
15   *  limitations under the License.
16   */
17  package org.apache.ws.scout.registry.qa;
18  
19  import static org.junit.Assert.fail;
20  
21  import java.util.ArrayList;
22  import java.util.Collection;
23  import java.util.Iterator;
24  
25  import javax.xml.registry.BulkResponse;
26  import javax.xml.registry.BusinessQueryManager;
27  import javax.xml.registry.JAXRException;
28  import javax.xml.registry.JAXRResponse;
29  import javax.xml.registry.RegistryService;
30  import javax.xml.registry.infomodel.Classification;
31  import javax.xml.registry.infomodel.ClassificationScheme;
32  import javax.xml.registry.infomodel.Key;
33  
34  import junit.framework.JUnit4TestAdapter;
35  
36  import org.apache.ws.scout.BaseTestCase;
37  import org.apache.ws.scout.Remover;
38  import org.junit.After;
39  import org.junit.Before;
40  import org.junit.Test;
41  
42  /**
43   * Tests publish classification schemes.
44   * 
45   * Open source UDDI Browser  <http://www.uddibrowser.org>
46   * to check your results.
47   *
48   * Based on query/publish tests written by 
49   * <a href="mailto:anil@apache.org">Anil Saldhana</a>.
50   *
51   * @author <a href="mailto:dbhole@redhat.com">Deepak Bhole</a>
52   * @author <a href="mailto:anil@apache.org">Anil Saldhana</a>
53   * @author <a href="mailto:kstam@apache.org">Kurt Stam</a>
54   * 
55   * @since Sep 27, 2005
56   */
57  public class JAXR005ClassificationSchemeTest extends BaseTestCase
58  {
59      @Before
60      public void setUp()
61      {
62          super.setUp();
63      }
64  
65      @After
66      public void tearDown()
67      {
68          super.tearDown();
69      }
70  
71      @Test
72      public void testPublishClassificationScheme()
73      {
74          login();
75          try
76          {
77              RegistryService rs = connection.getRegistryService();
78              BusinessQueryManager bqm = rs.getBusinessQueryManager();
79              blm = rs.getBusinessLifeCycleManager();
80              Removerver.html#Remover">Remover remover = new Remover(blm);
81  
82              ClassificationScheme cScheme = blm.createClassificationScheme("testScheme -- APACHE SCOUT TEST", "Sample Classification Scheme");
83              Classification classification = createClassificationForUDDI(bqm);
84              cScheme.addClassification(classification);
85  
86              ArrayList<ClassificationScheme> cSchemes = new ArrayList<ClassificationScheme>();
87              cSchemes.add(cScheme);
88  
89              BulkResponse br = blm.saveClassificationSchemes(cSchemes);
90              if (br.getStatus() == JAXRResponse.STATUS_SUCCESS)
91              {
92                  System.out.println("Classification Saved");
93                  Collection coll = br.getCollection();
94                  Iterator iter = coll.iterator();
95                  while (iter.hasNext())
96                  {
97                      Key key = (Key) iter.next();
98                      System.out.println("Saved Key=" + key.getId());
99                      cScheme.setKey(key);
100                     remover.removeClassificationScheme(cScheme);
101                 }//end while
102             } else {
103                 System.err.println("JAXRExceptions " +
104                         "occurred during save:");
105                 Collection exceptions = br.getExceptions();
106                 Iterator iter = exceptions.iterator();
107                 while (iter.hasNext())
108                 {
109                     Exception e = (Exception) iter.next();
110                     System.err.println(e.toString());
111                     fail(e.toString());
112                 }
113             }
114             
115             //Classificat
116         } catch (JAXRException e)
117         {
118             e.printStackTrace();
119             fail(e.getMessage());
120         }
121     }
122 
123     private Classification createClassificationForUDDI(BusinessQueryManager bqm)
124             throws JAXRException
125     {
126         //Scheme which maps onto uddi tmodel
127         ClassificationScheme udditmodel = bqm.findClassificationSchemeByName(null, "uddi-org:types");
128 
129         Classification cl = blm.createClassification(udditmodel, "wsdl", "wsdl");
130         return cl;
131     }
132     
133     public static junit.framework.Test suite() {
134         return new JUnit4TestAdapter(JAXR005ClassificationSchemeTest.class);
135     }
136 
137 }