Skip to content

Commit f2c8aa6

Browse files
committed
Deserialize long parameters in PerfTestMulti
Fixes #214
1 parent 3ed3ff7 commit f2c8aa6

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

src/main/java/com/rabbitmq/perf/MulticastParams.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
public class MulticastParams {
3838

39-
private int confirm = -1;
39+
private long confirm = -1;
4040
private int confirmTimeout = 30;
4141
private int consumerCount = 1;
4242
private int producerCount = 1;
@@ -181,10 +181,15 @@ public void setConsumerTxSize(int consumerTxSize) {
181181
this.consumerTxSize = consumerTxSize;
182182
}
183183

184-
public void setConfirm(int confirm) {
184+
public void setConfirm(long confirm) {
185185
this.confirm = confirm;
186186
}
187187

188+
// package protected for testing
189+
long getConfirm() {
190+
return this.confirm;
191+
}
192+
188193
public void setConfirmTimeout(int confirmTimeout) {
189194
this.confirmTimeout = confirmTimeout;
190195
}

src/main/java/com/rabbitmq/perf/PerfTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public static void main(String [] args, PerfTestOptions perfTestOptions) {
102102
int consumerChannelCount = intArg(cmd, 'Y', 1);
103103
int producerTxSize = intArg(cmd, 'm', 0);
104104
int consumerTxSize = intArg(cmd, 'n', 0);
105-
int confirm = intArg(cmd, 'c', -1);
105+
long confirm = intArg(cmd, 'c', -1);
106106
int confirmTimeout = intArg(cmd, "ct", 30);
107107
boolean autoAck = hasOption(cmd,"a");
108108
int multiAckEvery = intArg(cmd, 'A', 0);

src/main/java/com/rabbitmq/perf/PerfUtil.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ private static Object convert(Class<?> targetType, Object value) {
6161
} else {
6262
return Float.valueOf(value.toString());
6363
}
64+
} else if (isLong(targetType)) {
65+
if (value instanceof Number) {
66+
return ((Number) value).longValue();
67+
} else {
68+
return Long.valueOf(value.toString());
69+
}
6470
}
6571
}
6672
return value;
@@ -73,4 +79,8 @@ private static boolean isInt(Class<?> targetType) {
7379
private static boolean isFloat(Class<?> targetType) {
7480
return (targetType.equals(Float.class) || "float".equals(targetType.getSimpleName()));
7581
}
82+
83+
private static boolean isLong(Class<?> targetType) {
84+
return (targetType.equals(Long.class) || "long".equals(targetType.getSimpleName()));
85+
}
7686
}

src/test/java/com/rabbitmq/perf/ScenarioFactoryTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public void paramsFromJSON() {
3232
String spec = "[{'name': 'consume', 'type': 'simple', 'params':" +
3333
"[{'time-limit': 30, 'producer-count': 4, 'consumer-count': 2, " +
3434
" 'rate': 10, 'exclusive': true, " +
35+
" 'confirm': 10, " +
3536
" 'body': ['file1.json','file2.json'], 'body-content-type' : 'application/json'}]}]";
3637
List<Map> scenariosJson = new Gson().fromJson(spec, List.class);
3738
Map scenario = scenariosJson.get(0);
@@ -41,6 +42,7 @@ public void paramsFromJSON() {
4142
assertThat(params.getConsumerCount(), is(2));
4243
assertThat(params.getProducerRateLimit(), is(10.0f));
4344
assertThat(params.isExclusive(), is(true));
45+
assertThat(params.getConfirm(), is(10L));
4446
assertThat(params.getBodyFiles(), hasSize(2));
4547
assertThat(params.getBodyFiles(), contains("file1.json", "file2.json"));
4648
assertThat(params.getBodyContentType(), is("application/json"));

0 commit comments

Comments
 (0)