React Native - unit test fails because of Native Module - java

I am getting a weird anomaly when I declare a Native Java Module the new code doesn't pass unit test. Basically whatever I import from NativeModules in React Native lacks a definition: So the Unit test fails because TypeError: Cannot read property 'HelloWorld' of undefined
Steps to reproduce:
import { NativeModules } from 'react-native';
const Thing = NativeModules.SomeModule;
export const helloWorld = (addedText: string) => {
return Thing.HelloWorld(addedText);
};
export default Thing;
but the error is
TypeError: Cannot read property 'HelloWorld' of undefined
4 |
5 | export const helloWorld = (addedText: string) => {
> 6 | return Thing.HelloWorld(addedText);
| ^
7 | };
8 |
9 | export default Thing;
the actual Java is
public class SomeModule extends ReactContextBaseJavaModule {
SomeModule(ReactApplicationContext context) {
super(context);
}
#Override
public String getName() {
return "SomeModule";
}
void HelloWorld(String addedText){
try {
Log.w("HELLO_WORLD", addedText);
}
catch (Exception e) {
Log.e("DEVICE_MODULE_HELLO_WORLD_FAILED", "HelloWorld() Failed");
}
}
}
and this runs fine (when you run it) but the unit tests hate it. The issue seems to be that the React Native test lacks an awareness of the structure of const helloWorld = (addedText: string) => { return Thing.HelloWorld(addedText); }; so I dutifully made this d.ts to help
declare namespace Thing {
function helloWorld(addedText: string): void;
}
but it still fails when at unit test, it feels wrong for me to simply assume this has been overlooked, so I am assuming I must have implemented something incorrectly. Can anyone shed light on the correct way of doing this?

the answer is to mock out the function
in the test file, (the test to whatever part of your code in react-native calls helloWorld("bob chips")) (i.e not where it exports) you have to mock out the Java module as follows. Note this is global (once) at the top of the file that launched the failed test - perhaps you put helloWorld("bob chips") in Place.tsx if so perhaps the Place.test.tsx fails - because it references helloWorld("bob chips"), if so in the one that has tests that fail - inside Place.test.tsx - do this once at the top of the file:
jest.mock('react-native', () => {
const RN = jest.requireActual('react-native');
RN.NativeModules.SomeModule = {
HelloWorld: jest.fn(),
};
// mock modules created through UIManager
RN.UIManager.getViewManagerConfig = (name) => {
if (name === 'SomeModule') {
return { HelloWorld: jest.fn() };
}
return {};
};
return RN;
});
this then suppresses jest trying to test it, and allows you to write tests in java to compensate

Related

Error invoking bsh method: eval Sourced file: inline evaluation of: `import org.skyscreamer.jsonassert.Customization; Constructor error: Can't find

I use jmeter to comapre json data.use org.skyscreamer.jsonassert.
suceess in idea with jdk8, but failed in jmeter
this is error info.
i have imported jsonassert-1.5.1.jar and android-json-0.0.20131108.vaadin1.jar into %Jmeter%lib,jackson use 2.13.3 version.jmeter version is 5.5 .
Response code:500
Response message:org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ``import org.skyscreamer.jsonassert.Customization; import org.skyscreamer.jsonasse . . . '' : Constructor error: Can't find constructor: org.skyscreamer.jsonassert.comparator.CustomComparator( org.skyscreamer.jsonassert.JSONCompareMode, org.skyscreamer.jsonassert.Customization ) in class: org.skyscreamer.jsonassert.comparator.CustomComparator
this is beanshell sampler ,the code i write in the jmeter
import org.skyscreamer.jsonassert.Customization;
import org.skyscreamer.jsonassert.JSONCompare;
import org.skyscreamer.jsonassert.JSONCompareMode;
import org.skyscreamer.jsonassert.JSONCompareResult;
import org.skyscreamer.jsonassert.ValueMatcher;
import org.skyscreamer.jsonassert.comparator.CustomComparator;
import org.json.JSONException;
String newResponseMessage = vars.get("new_S{custNo}");
String oldResponseMessage = vars.get("old_S{custNo}");
log.info("oldRes"+oldResponseMessage);
log.info("newRes"+newResponseMessage);
ValueMatcher matcher = new ValueMatcher() {
public boolean equal(Object o1, Object o2) {
return true;
}
};
Customization customization = new Customization("orgSeqNo", matcher);
JSONCompareResult result;
try {
result = JSONCompare.compareJSON(newResponseMessage, oldResponseMessage, new CustomComparator(JSONCompareMode.NON_EXTENSIBLE,customization));
if (result.passed()) {
System.out.println("no different");
} else {
System.out.println(result.getMessage());
log.error(result.getMessage());
// ctx.getEngine().stopTest();
}
}catch (JSONException e){
log.error("Beanshell failure: ", e);
throw ex;
}
code in jmeter beanshell sampler
error info picture
i have imported jsonassert-1.5.1.jar and android-json-0.0.20131108.vaadin1.jar into %Jmeter%lib and %Jmeter%/lib/ext both,jackson use 2.13.3 version.jmeter version is 5.5 .
enter image description here
I use jmeter to comapre json data.use org.skyscreamer.jsonassert.
suceess in idea with jdk8, but failed in jmeter
these are codes i write with jdk8,success run,but failed in jmeter
<dependency>
<groupId>org.skyscreamer</groupId>
<artifactId>jsonassert</artifactId>
<version>1.5.1</version>
</dependency>
public class Main {
static String jsonStr1 = "{\"orgSeqNo\":\"123123\",\"code\":200,\"person\":{\"partyId\":\"10000000001\",\"partyName\":\"john\",\"partyCertType\":\"10100\",\"partyCertNo\":\"320925199612122314\",\"partyStatus\":\"1\",\"addresses\":[{\"addrId\":\"1\",\"partyId\":\"10000000001\",\"city\":\"suchou\",\"detailAddr\":\"asdfghqwe\",\"addrType\":103,\"phone\":\"13213137625\"},{\"addrId\":\"2\",\"partyId\":\"10000000001\",\"city\":\"suchou\",\"detailAddr\":\"asdfghqwe\",\"addrType\":\"101\",\"phone\":\"13213137625\"},{\"addrId\":\"3\",\"partyId\":\"10000000001\",\"city\":\"suchou\",\"detailAddr\":\"asdfghqwe\",\"addrType\":\"102\",\"phone\":\"13213137625\"}]},\"message\":\"ok\"}";
static String jsonStr2 = "{\"orgSeqNo\":\"12e9fc45c09b4a69b7aa2bbcb1313cba\",\"code\":200,\"person\":{\"partyId\":\"10000000001\",\"partyName\":\"john\",\"partyCertType\":\"10100\",\"partyCertNo\":\"320925199612122314\",\"partyStatus\":\"1\",\"addresses\":[{\"addrId\":\"1\",\"partyId\":\"10000000001\",\"city\":\"suchou\",\"detailAddr\":\"asdfghqwe\",\"addrType\":\"103\",\"phone\":\"13213137625\"},{\"addrId\":\"2\",\"partyId\":\"10000000001\",\"city\":\"suchou\",\"detailAddr\":\"asdfghqwe\",\"addrType\":\"101\",\"phone\":\"13213137625\"},{\"addrId\":\"3\",\"partyId\":\"10000000001\",\"city\":\"suchou\",\"detailAddr\":\"asdfghqwe\",\"addrType\":\"102\",\"phone\":\"13213137625\"}]},\"message\":\"ok\"}";
static String jsonStr3 = "{\"orgSeqNo\":\"12e9fc45c09b4a69b7aa2bbcb1313cba\",\"code\":200,\"person\":{\"partyId\":\"10000000001\",\"partyName\":\"john\",\"partyCertType\":\"10100\",\"partyCertNo\":\"320925199612122314\",\"partyStatus\":\"1\",\"addresses\":[{\"addrId\":\"2\",\"partyId\":\"10000000001\",\"city\":\"suchou\",\"detailAddr\":\"asdfghqwe\",\"addrType\":\"101\",\"phone\":\"13213137625\"},{\"addrId\":\"1\",\"partyId\":\"10000000001\",\"city\":\"suchou\",\"detailAddr\":\"asdfghqwe\",\"addrType\":\"103\",\"phone\":\"13213137625\"},{\"addrId\":\"3\",\"partyId\":\"10000000001\",\"city\":\"suchou\",\"detailAddr\":\"asdfghqwe\",\"addrType\":\"102\",\"phone\":\"13213137625\"}]},\"message\":\"ok\"}";
static String jsonStr4 = "{\"orgSeqNo\":\"12e9fc45c09b4a69b7aa2bbcb1313cba\",\"code\":200,\"person\":{\"partyId\":\"10000000001\",\"partyName\":\"john\",\"partyCertType\":\"10100\",\"partyCertNo\":\"320925199612122314\",\"partyStatus\":\"1\",\"addresses\":[{\"addrId\":\"1\",\"partyId\":\"10000000001\",\"city\":\"suchou\",\"detailAddr\":\"asdfghqwe\",\"addrType\":103,\"phone\":\"13213137625\"},{\"addrId\":\"2\",\"partyId\":\"10000000001\",\"city\":\"suchou\",\"detailAddr\":\"asdfghqwe\",\"addrType\":\"101\",\"phone\":\"13213137625\"},{\"addrId\":\"3\",\"partyId\":\"10000000001\",\"city\":\"suchou\",\"detailAddr\":\"asdfghqwe\",\"addrType\":\"102\",\"phone\":\"13213137625\"}]},\"message\":\"ok\"}";
public static void main(String[] args) {
// Customization customization = new Customization("orgSeqNo", (o1, o2) -> true);
ValueMatcher matcher = new ValueMatcher() {
#Override
public boolean equal(Object o1, Object o2) {
return true;
}
};
Customization customization = new Customization("orgSeqNo", matcher);
JSONCompareResult result = null;
try {
result = JSONCompare.compareJSON(jsonStr1, jsonStr3, new CustomComparator(JSONCompareMode.NON_EXTENSIBLE,customization));
if (result1.passed()) {
System.out.println("no different");
} else {
System.out.println(result.getMessage());
}
} catch (JSONException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
}
next is result,i want jmeter also like this result
person.addresses[addrId=1].addrType
Expected: 103
got: 103
Program execution result picture
i have imported jsonassert-1.5.1.jar and android-json-0.0.20131108.vaadin1.jar into %Jmeter%lib,jackson use 2.13.3 version.jmeter version is 5.5 .
run success in jvm , but error info in jmeter...
Beanshell != Java so even given your code "suceess in idea with jdk8" it doesn't necessarily mean that it will "suceess" in JMeter's Beanshell components.
Since JMeter 3.1 it's recommended to use JSR223 Test Elements and Groovy language for scripting so my expectation is that if you switch to the JSR223 Sampler and use groovy your code will "suceess" as well.
More information on Groovy scripting in JMeter: Apache Groovy: What Is Groovy Used For?

Constant path replacement for different environments using gradle

This is a Apache Storm based project. I have a Constants file which looks something like this
public class Constant {
public static final String CONTEXT_PATH ="<some path to a context.xml file>";
public static final String APP_PROPERTIES_PATH = "<path to the properties file>";
//...More static properties
}
This CONTEXT_PATH variable is different for different environments (dev, test, prod).
I have a gradle task which generates the JAR file for deployment
task stormJar(type: Jar) {
baseName = 'diagnostic'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
I was looking to dynamically change or refer the CONTEXT_PATH variable so that we can create builds for different environments without making any changes to this file.
I believe there are solutions to do so in the Android territory (BuildConfig), but not able to find a solution for a plain Java project.
The solution should be such, it should work for IDE (IntelliJ and Eclipse) as well as create environment specific build.
Doing something like below should get the work done
gradlew build -pEnvironment=prod
Not much experience with gradle. Please point me in the right direction.
Note there is a working example here.
One technique is to generate Constants.java as part of the build. Consider this template (stored as a resource, not as Java code):
public class Constants {
public static final String CONTEXT_PATH = "__CONTEXT_PATH";
public static final String APP_PROPERTIES_PATH = "__APP_PROPERTIES_PATH";
}
and the following generates Constants.java early in the compileJava task:
compileJava.doFirst {
def newConstantsFile = new File("${projectDir}/src/main/java/net/codetojoy/util/Constants.java")
def templateConstantsFile = new File("${projectDir}/resources/TemplateConstants.java")
newConstantsFile.withWriter { def writer ->
templateConstantsFile.eachLine { def line ->
def newLine = line.replace("__PACKAGE", "net.codetojoy.util")
.replace("__CONTEXT_PATH", getContextPath())
.replace("__APP_PROPERTIES_PATH", getAppPropertiesPath())
writer.write(newLine + "\n");
}
}
}
and then the crucial env-specific predicates:
def getContextPath = { ->
def result = "default"
if (project.Environment == "prod") {
result = "PROD context path here"
} else if (project.Environment == "uat") {
result = "UAT context path here"
} else if (project.Environment == "dev") {
result = "DEV context path here"
}
return result
}
def getAppPropertiesPath = { ->
def result = "default"
if (project.Environment == "prod") {
result = "PROD app properties path here"
} else if (project.Environment == "uat") {
result = "UAT app properties path here"
} else if (project.Environment == "dev") {
result = "DEV app properties path here"
}
return result
}
Note that the ENV-specific values could easily be abstracted into config files, ENV vars, etc.
Also note that the example addresses: Java package used, project version, and build timestamp as well. I write something like this for most projects.

Obfuscating Java in Gradle using yGuard ~ How to exclude methods?

I want to obfuscate Java code in Gradle using yGuard. So far, I have managed to get the obfuscation working using:
dependencies {
compile 'com.yworks:yguard:2.9.2'
}
task yGuardObfuscate {
group 'yGuard'
description 'Obfuscates existing archives.'
dependsOn "installDist"
doLast {
ant.taskdef(
name: 'yguard',
classname: 'com.yworks.yguard.YGuardTask',
classpath: sourceSets.main.runtimeClasspath.asPath
)
ant.yguard {
inoutpairs {
fileset(dir: "./build/install/module") {
include(name: "module*.jar")
exclude(name: "*_obf.jar")
}
}
rename(logFile: "./build/install/module/rename.log") {
property(name: "naming-scheme", value: "mix")
}
}
}
}
However, that has the problem that the main function gets obscured, and I can't run it anymore using java -jar module_obf.jar (which works with the unobfuscated jar).
I have tried several ways of excluding the main function from obfuscation.
First, I tried using the #Obfuscate annotation as described in the documentation (https://yworks.github.io/yGuard/task_documentation/#controlling-obfuscation-exclusion-with-annotations), like this:
#com.yworks.util.annotation.Obfuscation( exclude = true, applyToMembers = false)
public static void main(String[] args) {
try {
new Start();
} catch (SQLException e) {
LOGGER.error(e, e);
}
}
In my IDE (Eclipse 2019-14), this line was shown as valid. However, when trying to compile it with the gradle task I created, I got the following error:
...\Start.java:22: error: package com.yworks.util.annotation does not exist
#com.yworks.util.annotation.Obfuscation( exclude = true, applyToMembers = false)
^
I tried a number of things to get this to work, but could not arrive at a working solution.
So next, I tried to use a keep > method element in the yGuardObfuscate task to explicitly keep the main function of the Start class, like this:
task yGuardObfuscate {
group 'yGuard'
description 'Obfuscates existing archives.'
dependsOn "installDist"
doLast {
ant.taskdef(
name: 'yguard',
classname: 'com.yworks.yguard.YGuardTask',
classpath: sourceSets.main.runtimeClasspath.asPath
)
ant.yguard {
inoutpairs {
fileset(dir: "./build/install/module") {
include(name: "module*.jar")
exclude(name: "*_obf.jar")
}
}
rename(logFile: "./build/install/module/rename.log") {
property(name: "naming-scheme", value: "mix")
keep {
method("class": "com.company.project.module.Start", name: "public static void main(String[] args)")
}
}
}
}
}
This caused the Gradle build to fail with the following exception:
: java.lang.IllegalArgumentException: '(' expected but found void
[...]
Caused by: java.lang.IllegalArgumentException: '(' expected but found void
at com.yworks.yguard.ObfuscatorTask.toNativeMethod(ObfuscatorTask.java:188)
at com.yworks.yguard.ant.MethodSection.addEntries(MethodSection.java:35)
at com.yworks.yguard.ant.ExposeSection.createEntries(ExposeSection.java:170)
at com.yworks.yguard.ObfuscatorTask.execute(ObfuscatorTask.java:745)
at com.yworks.yguard.YGuardTask.execute(YGuardTask.java:116)
[...]
Root cause: java.lang.IllegalArgumentException: '(' expected but found void
at com.yworks.yguard.ObfuscatorTask.toNativeMethod(ObfuscatorTask.java:188)
at com.yworks.yguard.ant.MethodSection.addEntries(MethodSection.java:35)
at com.yworks.yguard.ant.ExposeSection.createEntries(ExposeSection.java:170)
at com.yworks.yguard.ObfuscatorTask.execute(ObfuscatorTask.java:745)
at com.yworks.yguard.YGuardTask.execute(YGuardTask.java:116)
Again, I tried several things here, such as writing "class" without the "", adding extra {}, but nothing helped.
So the question here is: What am I doing wrong? And how can I prevent yGuard from obfuscating the main function?
I now figured out a way to make it work, even though it sorta feels more like a workaround than a proper solution, so if anyone knows what I did wrong with the "official" solutions, please do tell me.
For this, I used the Annotation approach, and instead of using the default annotation, I created a custom annotation that is pretty much an exact copy in my project.
The annotation class looks like this:
package com.company.project.module.annotations;
public #interface Obfuscation {
boolean exclude() default true;
boolean applyToMembers() default true;
}
I use it in my Start class like this:
import com.company.project.module.annotations.*;
[...]
#Obfuscation( exclude = true, applyToMembers = false)
public static void main(String[] args) {
[...]
}
And finally, I added this custom annotation class to the rename element of my task like this:
rename(logFile: "./build/install/module/rename.log", annotationClass: "com.company.project.module.annotations.Obfuscation") {
property(name: "naming-scheme", value: "mix")
}
So the entire gradle task now looks like this:
task yGuardObfuscate {
group 'yGuard'
description 'Obfuscates existing archives.'
dependsOn "installDist"
doLast {
ant.taskdef(
name: 'yguard',
classname: 'com.yworks.yguard.YGuardTask',
classpath: sourceSets.main.runtimeClasspath.asPath
)
ant.yguard {
inoutpairs {
fileset(dir: "./build/install/module") {
include(name: "module*.jar")
exclude(name: "*_obf.jar")
}
}
rename(logFile: "./build/install/module/rename.log", annotationClass: "com.company.project.module.annotations.Obfuscation") {
property(name: "naming-scheme", value: "mix")
}
}
}
}
With that, the build now works, and I can successfully run my program using java -jar module_obf.jar.

jni4net failed to load DLLs in Java app

I'm trying to modify the jni4net sample code MyCSharpDemoCalc, and make the sample as a bridge between a .Net DLL and the Java layer. Here is the C# code:
using System;
using Dynamsoft.DotNet.TWAIN;
namespace MyCSharpDemoCalc
{
public interface ICalc
{
int MySuperSmartFunctionIDontHaveInJava(string question);
bool IsShowUI();
}
public class DemoCalc : ICalc
{
private readonly Random r = new Random();
private DynamicDotNetTwain dynamicDotNetTwain;
public DemoCalc()
{
dynamicDotNetTwain = new Dynamsoft.DotNet.TWAIN.DynamicDotNetTwain();
}
public int MySuperSmartFunctionIDontHaveInJava(string question)
{
if (question == "Answer to the Ultimate Question of Life, the Universe, and Everything")
{
return 42;
}
return r.Next();
}
public bool IsShowUI()
{
return dynamicDotNetTwain.IfShowUI;
}
}
}
In order to build it successfully, I added the following references:
System.Windows.Forms
DynamicDotNetTWAIN
Then typed in the command
proxygen.exe MyCSharpDemoCalc.dll -wd work
to generate MyCSharpDemoCalc.j4n.jarand MyCSharpDemoCalc.j4n.dll.
Now, I can import DynamicDotNetTWAIN.dll, MyCSharpDemoCalc.j4n.dll, jni4net.n.w64.v20-0.8.6.0.dll, jni4net.n-0.8.6.0.dll, jni4net.j-0.8.6.0.jar and MyCSharpDemoCalc.j4n.jar to Java project.
Java code:
import net.sf.jni4net.Bridge;
import java.io.IOException;
import mycsharpdemocalc.DemoCalc;
import mycsharpdemocalc.ICalc;
public class Program {
public static void main(String arsg[]) throws IOException {
Bridge.setClrVersion("v20");
Bridge.init();
Bridge.LoadAndRegisterAssemblyFrom(new java.io.File("DynamicDotNetTWAIN.dll"));
Bridge.LoadAndRegisterAssemblyFrom(new java.io.File("MyCSharpDemoCalc.j4n.dll")); // crashed
ICalc calc = new DemoCalc();
final int result = calc.MySuperSmartFunctionIDontHaveInJava("Answer to the Ultimate Question of Life, the Universe, and Everything");
System.out.printf("Answer to the Ultimate Question is : " + result);
System.out.printf("If show UI : " + calc.IsShowUI());
}
}
When I tried to run the application, it crashed at
Bridge.LoadAndRegisterAssemblyFrom(new
java.io.File("MyCSharpDemoCalc.j4n.dll"));
Exception in thread "main" System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.Module._GetTypesInternal(StackCrawlMark& stackMark)
at System.Reflection.Assembly.GetTypes()
at net.sf.jni4net.utils.Registry.RegisterAssembly(Assembly assembly, Boolean bindJVM, ClassLoader classLoader)
at net.sf.jni4net.Bridge.RegisterAssembly(Assembly assembly, ClassLoader classLoader)
at net.sf.jni4net.Bridge.LoadAndRegisterAssemblyFromClassLoader(File assemblyFile, ClassLoader classLoader)
at net.sf.jni4net.Bridge.LoadAndRegisterAssemblyFrom(File assemblyFile)
at net.sf.jni4net.__Bridge.LoadAndRegisterAssemblyFrom3(IntPtr __envp, JniLocalHandle __class, JniLocalHandle assemblyFile)
at net.sf.jni4net.Bridge.LoadAndRegisterAssemblyFrom(Native Method)
at com.main.Program.main(Program.java:68)
How can I fix it? Thanks!
The JNI4NET will attempt to load the image from where the JNI4NET libraries were located at, the only workaround (AFAIK) was to copy the whole libraries to your source directory, and compile your package using the copied libraries, then it will work.

What tool may i to spawn multiple threads to EJB 2.1 codes to simulate connection pool load?

i am trying to spawn multiple threads on an EJB 2.1 bean to test the load on the connection pool. Is there any way of doing so or open source tool i may look into?
Thanks if anyone has any experience in this.
Wrap your calls to your EJBs in a Servlet. There are a variety of tools in various languages to simulate load on web apps.
I use The Grinder for load testing OpenEJB. It's pretty great.
An example of a grinder.py file. This is essentially the client:
from net.grinder.script.Grinder import grinder
from net.grinder.script import Test
from javax.naming import Context,InitialContext
from java.util import Properties
# A shorter alias for the grinder.logger.output() method.
log = grinder.logger.output
tests = {
"ping" : Test(1, "ping"),
"add" : Test(2, "add"),
"sum" : Test(3, "sum"),
}
# Wrap the log() method with our Test and call the result logWrapper.
# Calls to logWrapper() will be recorded and forwarded on to the real
# log() method.
#logWrapper = test1.wrap(log)
# Initial context lookup for EJB home.
p = Properties()
p[Context.INITIAL_CONTEXT_FACTORY] = "org.apache.openejb.client.RemoteInitialContextFactory"
p[Context.PROVIDER_URL] = "ejbd://127.0.0.1:4201";
loadBean = InitialContext(p).lookup("LoadBeanRemote")
pingBean = tests["ping"].wrap(loadBean)
addBean = tests["add"].wrap(loadBean)
sumBean = tests["sum"].wrap(loadBean)
# A TestRunner instance is created for each thread. It can be used to
# store thread-specific data.
class TestRunner:
# This method is called for every run.
def __call__(self):
pingBean.ping()
addBean.add(3, 4)
sumBean.sum([3, 4, 5, 6])
Note the grinder.py file is written in jython so you can hookup any java client jars.
Here's an example grinder.properties file:
grinder.script grinder.py
grinder.processes 2
grinder.threads 20
grinder.runs 0
grinder.jvm.classpath=/Users/dblevins/work/grinder/openejb-3.1.4/lib/openejb-client-3.1.4.jar:\
/Users/dblevins/work/grinder/openejb-3.1.4/lib/javaee-api-5.0-3.jar:\
/Users/dblevins/work/grinder/openejb-3.1.4/lib/ejb31-experimental-api-3.1.4.jar:\
/Users/dblevins/work/grinder/load-beans/target/load-beans-1.0.jar
grinder.logDirectory logs
grinder.numberOfOldLogs 0
Then the LoadBean looks like so (the app you want to load test):
package org.superbiz.load;
import javax.ejb.*;
import java.lang.reflect.Method;
#Local
#Remote
#Singleton
#Lock(LockType.READ)
public class LoadBean implements Load {
public void ping() {
// do nothing
}
public int add(int a, int b) {
return a + b;
}
public int sum(int... items) {
int i = 0;
for (int item : items) {
i += item;
}
return i;
}
}

Categories

Resources