01: /******************************************************************************
02: * JBoss, a division of Red Hat *
03: * Copyright 2006, Red Hat Middleware, LLC, and individual *
04: * contributors as indicated by the @authors tag. See the *
05: * copyright.txt in the distribution for a full listing of *
06: * individual contributors. *
07: * *
08: * This is free software; you can redistribute it and/or modify it *
09: * under the terms of the GNU Lesser General Public License as *
10: * published by the Free Software Foundation; either version 2.1 of *
11: * the License, or (at your option) any later version. *
12: * *
13: * This software is distributed in the hope that it will be useful, *
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16: * Lesser General Public License for more details. *
17: * *
18: * You should have received a copy of the GNU Lesser General Public *
19: * License along with this software; if not, write to the Free *
20: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
21: * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
22: ******************************************************************************/package org.jboss.portal.test.wsrp.framework;
23:
24: import org.jboss.portal.test.wsrp.framework.support.ServiceObjectFactory;
25: import org.jboss.portal.wsrp.WSRPConstants;
26: import org.jboss.portal.wsrp.core.LocalizedString;
27: import org.jboss.portal.wsrp.core.MarkupType;
28: import org.jboss.portal.wsrp.core.PortletDescription;
29:
30: /**
31: * Provides a base class for Producer behavior used in Consumer testing.
32: *
33: * @author <a href="mailto:chris.laprun@jboss.com?subject=org.jboss.portal.test.wsrp.framework.TestProducerBehavior">Chris
34: * Laprun</a>
35: * @version $Revision: 8886 $
36: * @since 2.6
37: */
38: public abstract class TestProducerBehavior {
39: protected int callCount;
40:
41: /**
42: * Increment the number of times methods of this behavior have been called. Used when the behavior changes depending
43: * on how many times methods have been called.
44: */
45: public void incrementCallCount() {
46: callCount++;
47: }
48:
49: public int getCallCount() {
50: return callCount;
51: }
52:
53: public PortletDescription createPortletDescription(
54: String portletHandle, String suffix) {
55: PortletDescription portletDesc = new PortletDescription();
56: portletDesc.setPortletHandle(portletHandle);
57: portletDesc.setMarkupTypes(new MarkupType[] { new MarkupType(
58: "text/html", new String[] { WSRPConstants.VIEW_MODE },
59: new String[] { WSRPConstants.NORMAL_WINDOW_STATE },
60: WSRPConstants.DEFAULT_LOCALES, null) });
61:
62: String suffixString = suffix == null ? "" : suffix;
63: portletDesc
64: .setDescription(ServiceObjectFactory
65: .createLocalizedString(ServiceObjectFactory.SAMPLE_DESCRIPTION
66: + suffixString));
67: portletDesc
68: .setTitle(ServiceObjectFactory
69: .createLocalizedString(ServiceObjectFactory.SAMPLE_TITLE
70: + suffixString));
71: portletDesc
72: .setShortTitle(ServiceObjectFactory
73: .createLocalizedString(ServiceObjectFactory.SAMPLE_SHORTTITLE
74: + suffixString));
75: portletDesc
76: .setDisplayName(ServiceObjectFactory
77: .createLocalizedString(ServiceObjectFactory.SAMPLE_DISPLAYNAME
78: + suffixString));
79: portletDesc
80: .setKeywords(new LocalizedString[] { ServiceObjectFactory
81: .createLocalizedString(ServiceObjectFactory.SAMPLE_KEYWORD
82: + suffixString) });
83: return portletDesc;
84: }
85: }
|