KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > wsrp > test > TestSomeScenarios


1 package org.exoplatform.services.wsrp.test;
2
3 /**
4  * Copyright 2001-2003 The eXo platform SARL All rights reserved.
5  * Please look at license.txt in info directory for more license detail.
6  **/

7
8
9 import java.rmi.RemoteException JavaDoc;
10 import org.exoplatform.services.wsrp.type.*;
11
12 /**
13  * Created by the Exo Development team.
14  * Author : Mestrallet Benjamin
15  * benjmestrallet@users.sourceforge.net
16  * Date: 24 janv. 2004
17  * Time: 11:43:58
18  */

19 public class TestSomeScenarios extends BaseTest {
20
21   private static final String JavaDoc PORTLET_HANDLE = "hello/HelloWorld2";
22
23   public TestSomeScenarios(String JavaDoc s) {
24     super(s);
25   }
26
27   public void testFirstConsumerScenario() throws Throwable JavaDoc, RemoteException JavaDoc {
28     //get the service description through a monitor that listen on port 8081
29
ServiceDescriptionRequest request = new ServiceDescriptionRequest();
30     request.setDesiredLocales(new String JavaDoc[]{"en"});
31     ServiceDescription serviceDescription = null;
32     serviceDescription = serviceDescriptionInterface.getServiceDescription(request);
33
34     //register or not
35
RegistrationContext rC = null;
36     if (serviceDescription.isRequiresRegistration()) {
37       System.out.println("[test] Registration required");
38       rC = registrationOperationsInterface.register(registrationData);
39       resolveRegistrationContext(rC);
40     } else {
41       System.out.println("[test] Registration non required");
42     }
43
44     //test the existence of our portlet handle
45
boolean go_on = false;
46     PortletDescription[] array = serviceDescription.getOfferedPortlets();
47     for (int i = 0; i < array.length; i++) {
48       PortletDescription portletDescription = array[i];
49       if(PORTLET_HANDLE.equals(portletDescription.getPortletHandle())){
50         go_on = true;
51         break;
52       }
53     }
54     if(!go_on)
55       fail("The portlet " + PORTLET_HANDLE + " is not deployed");
56
57     //prepare the request arguments
58
PortletContext portletContext = new PortletContext();
59     portletContext.setPortletHandle(PORTLET_HANDLE);
60     MarkupRequest getMarkup = getMarkup(rC, portletContext);
61
62     //get the markup
63
MarkupResponse response = markupOperationsInterface.getMarkup(getMarkup);
64     response.getSessionContext();
65     response.getMarkupContext();
66   }
67 }
68
Popular Tags