1
1
/*
2
- * Copyright 2002-2014 the original author or authors.
2
+ * Copyright 2002-2017 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -140,15 +140,15 @@ public void testGetObjectType() throws Exception {
140
140
mcfb .setTargetMethod ("voidRetvalMethod" );
141
141
mcfb .afterPropertiesSet ();
142
142
Class <?> objType = mcfb .getObjectType ();
143
- assertTrue (objType . equals ( void .class ) );
143
+ assertSame (objType , void .class );
144
144
145
145
// verify that we can call a method with args that are subtypes of the
146
146
// target method arg types
147
147
TestClass1 ._staticField1 = 0 ;
148
148
mcfb = new MethodInvokingFactoryBean ();
149
149
mcfb .setTargetClass (TestClass1 .class );
150
150
mcfb .setTargetMethod ("supertypes" );
151
- mcfb .setArguments (new Object [] { new ArrayList <Object >(), new ArrayList <Object >(), "hello" } );
151
+ mcfb .setArguments (new ArrayList <>(), new ArrayList <Object >(), "hello" );
152
152
mcfb .afterPropertiesSet ();
153
153
mcfb .getObjectType ();
154
154
@@ -157,7 +157,7 @@ public void testGetObjectType() throws Exception {
157
157
mcfb .registerCustomEditor (String .class , new StringTrimmerEditor (false ));
158
158
mcfb .setTargetClass (TestClass1 .class );
159
159
mcfb .setTargetMethod ("supertypes" );
160
- mcfb .setArguments (new Object [] { "1" , new Object ()} );
160
+ mcfb .setArguments ("1" , new Object ());
161
161
try {
162
162
mcfb .afterPropertiesSet ();
163
163
fail ("Should have thrown NoSuchMethodException" );
@@ -225,7 +225,7 @@ public void testGetObject() throws Exception {
225
225
mcfb = new MethodInvokingFactoryBean ();
226
226
mcfb .setTargetClass (TestClass1 .class );
227
227
mcfb .setTargetMethod ("supertypes" );
228
- mcfb .setArguments (new Object [] { new ArrayList <Object >(), new ArrayList <Object >(), "hello" } );
228
+ mcfb .setArguments (new ArrayList <>(), new ArrayList <Object >(), "hello" );
229
229
// should pass
230
230
mcfb .afterPropertiesSet ();
231
231
}
@@ -235,7 +235,7 @@ public void testArgumentConversion() throws Exception {
235
235
MethodInvokingFactoryBean mcfb = new MethodInvokingFactoryBean ();
236
236
mcfb .setTargetClass (TestClass1 .class );
237
237
mcfb .setTargetMethod ("supertypes" );
238
- mcfb .setArguments (new Object [] { new ArrayList <Object >(), new ArrayList <Object >(), "hello" , "bogus" } );
238
+ mcfb .setArguments (new ArrayList <>(), new ArrayList <Object >(), "hello" , "bogus" );
239
239
try {
240
240
mcfb .afterPropertiesSet ();
241
241
fail ("Matched method with wrong number of args" );
@@ -247,7 +247,7 @@ public void testArgumentConversion() throws Exception {
247
247
mcfb = new MethodInvokingFactoryBean ();
248
248
mcfb .setTargetClass (TestClass1 .class );
249
249
mcfb .setTargetMethod ("supertypes" );
250
- mcfb .setArguments (new Object [] { 1 , new Object ()} );
250
+ mcfb .setArguments (1 , new Object ());
251
251
try {
252
252
mcfb .afterPropertiesSet ();
253
253
mcfb .getObject ();
@@ -260,14 +260,14 @@ public void testArgumentConversion() throws Exception {
260
260
mcfb = new MethodInvokingFactoryBean ();
261
261
mcfb .setTargetClass (TestClass1 .class );
262
262
mcfb .setTargetMethod ("supertypes2" );
263
- mcfb .setArguments (new Object [] { new ArrayList <Object >(), new ArrayList <Object >(), "hello" , "bogus" } );
263
+ mcfb .setArguments (new ArrayList <>(), new ArrayList <Object >(), "hello" , "bogus" );
264
264
mcfb .afterPropertiesSet ();
265
265
assertEquals ("hello" , mcfb .getObject ());
266
266
267
267
mcfb = new MethodInvokingFactoryBean ();
268
268
mcfb .setTargetClass (TestClass1 .class );
269
269
mcfb .setTargetMethod ("supertypes2" );
270
- mcfb .setArguments (new Object [] { new ArrayList <Object >(), new ArrayList <Object >(), new Object ()} );
270
+ mcfb .setArguments (new ArrayList <>(), new ArrayList <Object >(), new Object ());
271
271
try {
272
272
mcfb .afterPropertiesSet ();
273
273
fail ("Matched method when shouldn't have matched" );
@@ -292,14 +292,14 @@ public void testInvokeWithIntArgument() throws Exception {
292
292
ArgumentConvertingMethodInvoker methodInvoker = new ArgumentConvertingMethodInvoker ();
293
293
methodInvoker .setTargetClass (TestClass1 .class );
294
294
methodInvoker .setTargetMethod ("intArgument" );
295
- methodInvoker .setArguments (new Object [] { 5 } );
295
+ methodInvoker .setArguments (5 );
296
296
methodInvoker .prepare ();
297
297
methodInvoker .invoke ();
298
298
299
299
methodInvoker = new ArgumentConvertingMethodInvoker ();
300
300
methodInvoker .setTargetClass (TestClass1 .class );
301
301
methodInvoker .setTargetMethod ("intArgument" );
302
- methodInvoker .setArguments (new Object [] { "5" } );
302
+ methodInvoker .setArguments (5 );
303
303
methodInvoker .prepare ();
304
304
methodInvoker .invoke ();
305
305
}
@@ -309,37 +309,37 @@ public void testInvokeWithIntArguments() throws Exception {
309
309
MethodInvokingBean methodInvoker = new MethodInvokingBean ();
310
310
methodInvoker .setTargetClass (TestClass1 .class );
311
311
methodInvoker .setTargetMethod ("intArguments" );
312
- methodInvoker .setArguments (new Object []{new Integer [] {5 , 10 }});
312
+ methodInvoker .setArguments (new Object [] {new Integer [] {5 , 10 }});
313
313
methodInvoker .afterPropertiesSet ();
314
314
315
315
methodInvoker = new MethodInvokingBean ();
316
316
methodInvoker .setTargetClass (TestClass1 .class );
317
317
methodInvoker .setTargetMethod ("intArguments" );
318
- methodInvoker .setArguments (new Object []{new String []{"5" , "10" }});
318
+ methodInvoker .setArguments (new Object [] {new String [] {"5" , "10" }});
319
319
methodInvoker .afterPropertiesSet ();
320
320
321
321
methodInvoker = new MethodInvokingBean ();
322
322
methodInvoker .setTargetClass (TestClass1 .class );
323
323
methodInvoker .setTargetMethod ("intArguments" );
324
- methodInvoker .setArguments (new Object []{new Integer [] {5 , 10 }});
324
+ methodInvoker .setArguments (new Object [] {new Integer [] {5 , 10 }});
325
325
methodInvoker .afterPropertiesSet ();
326
326
327
327
methodInvoker = new MethodInvokingBean ();
328
328
methodInvoker .setTargetClass (TestClass1 .class );
329
329
methodInvoker .setTargetMethod ("intArguments" );
330
- methodInvoker .setArguments (new String []{ "5" , "10" } );
330
+ methodInvoker .setArguments ("5" , "10" );
331
331
methodInvoker .afterPropertiesSet ();
332
332
333
333
methodInvoker = new MethodInvokingBean ();
334
334
methodInvoker .setTargetClass (TestClass1 .class );
335
335
methodInvoker .setTargetMethod ("intArguments" );
336
- methodInvoker .setArguments (new Object []{new Integer [] {5 , 10 }});
336
+ methodInvoker .setArguments (new Object [] {new Integer [] {5 , 10 }});
337
337
methodInvoker .afterPropertiesSet ();
338
338
339
339
methodInvoker = new MethodInvokingBean ();
340
340
methodInvoker .setTargetClass (TestClass1 .class );
341
341
methodInvoker .setTargetMethod ("intArguments" );
342
- methodInvoker .setArguments (new Object []{ "5" , "10" } );
342
+ methodInvoker .setArguments ("5" , "10" );
343
343
methodInvoker .afterPropertiesSet ();
344
344
}
345
345
0 commit comments