2
* JBoss, Home of Professional Open Source
3
* Copyright 2005, JBoss Inc., and individual contributors as indicated
4
* by the @authors tag. See the copyright.txt in the distribution for a
5
* full listing of individual contributors.
7
* This is free software; you can redistribute it and/or modify it
8
* under the terms of the GNU Lesser General Public License as
9
* published by the Free Software Foundation; either version 2.1 of
10
* the License, or (at your option) any later version.
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.
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.
22
package org.jboss.test.remoting.soak;
24
import java.util.HashMap;
28
import org.apache.log4j.Logger;
29
import org.jboss.remoting.Client;
30
import org.jboss.remoting.InvokerLocator;
35
* @author <a href="ron.sigal@jboss.com">Ron Sigal</a>
36
* @version $Revision: 1.1 $
38
* Copyright Mar 13, 2008
41
public class MockEJBClient extends SoakConstants implements Runnable
43
protected static Logger log = Logger.getLogger(MockEJBClient.class);
45
protected InvokerLocator locator;
46
protected Map metadata;
47
protected String name;
48
protected boolean ok = true;
49
protected Set inUseSet;
50
protected ClientLauncher.Counter failureCounter;
52
public MockEJBClient(String locator, Map metadata) throws Exception
54
this.locator = new InvokerLocator(locator);
55
this.metadata = metadata;
56
this.name = (String) metadata.get(SoakConstants.NAME);
57
this.inUseSet = (Set) metadata.remove(IN_USE_SET);
59
failureCounter = (ClientLauncher.Counter) metadata.remove(FAILURE_COUNTER);
60
log.info("created " + name);
67
String s = (String) metadata.get(SoakConstants.NUMBER_OF_CALLS);
68
int calls = Integer.valueOf(s).intValue();
69
for (int i = 0; i < calls; i++)
80
inUseSet.remove(this);
81
log.info(name + ": " + (ok ? "PASS" : "FAIL"));
82
if (!ok) failureCounter.increment();
86
protected void makeCall(int i) throws Throwable
92
client = new Client(locator);
94
Map metadata = new HashMap();
95
metadata.put(PAYLOAD, "abc");
96
Object response = client.invoke(COPY, metadata);
97
if (!"abc".equals(response))
100
log.info(name + ": failure on call " + i);
106
log.info(name + ": failure on call " + i);
115
public String toString()