Skip to content

Commit 89ec4a3

Browse files
skrysmjknack
authored andcommitted
Resolved various deprecation warnings and removed unused imports
1 parent 02c53a6 commit 89ec4a3

16 files changed

Lines changed: 27 additions & 42 deletions

handlebars/src/test/java/com/github/jknack/handlebars/DecoratorTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.github.jknack.handlebars;
22

3+
import static org.junit.Assert.assertArrayEquals;
34
import static org.junit.Assert.assertEquals;
45

56
import java.io.IOException;
@@ -157,7 +158,7 @@ public void shouldFailWhenAccessingVariablesFromRoot() throws Exception {
157158
$("hash", $("foo", "fail"), "decorators", $("decorator", new Decorator() {
158159
@Override
159160
public void apply(final Template fn, final Options options) throws IOException {
160-
assertEquals(null, options.param(0));
161+
assertArrayEquals((Object[])null, options.param(0));
161162
count.incrementAndGet();
162163
}
163164
})),
@@ -173,7 +174,7 @@ public void shouldBlockFailWhenAccessingVariablesFromRoot() throws Exception {
173174
$("hash", $("foo", "fail"), "decorators", $("decorator", new Decorator() {
174175
@Override
175176
public void apply(final Template fn, final Options options) throws IOException {
176-
assertEquals(null, options.param(0));
177+
assertArrayEquals((Object[])null, options.param(0));
177178
count.incrementAndGet();
178179
}
179180
})),
@@ -189,7 +190,7 @@ public void shouldBlockFailWhenAccessingVariablesFromRoot2() throws Exception {
189190
$("hash", $("foo", "fail"), "decorators", $("decorator", new Decorator() {
190191
@Override
191192
public void apply(final Template fn, final Options options) throws IOException {
192-
assertEquals(null, options.param(0));
193+
assertArrayEquals((Object[])null, options.param(0));
193194
count.incrementAndGet();
194195
}
195196
})),

handlebars/src/test/java/com/github/jknack/handlebars/NashornTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@
44
import static org.junit.Assert.assertEquals;
55
import org.junit.Test;
66

7-
import javax.script.Bindings;
87
import javax.script.ScriptEngine;
98
import javax.script.ScriptEngineManager;
10-
import javax.script.ScriptException;
119
import javax.script.SimpleBindings;
12-
import java.io.FileNotFoundException;
1310
import java.io.FileReader;
1411
import java.nio.file.Paths;
1512
import java.util.HashMap;

handlebars/src/test/java/com/github/jknack/handlebars/cache/HighConcurrencyTemplateCacheTest.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.apache.commons.lang3.tuple.ImmutablePair;
1919
import org.apache.commons.lang3.tuple.Pair;
2020
import org.easymock.Capture;
21+
import org.easymock.EasyMock;
2122
import org.junit.Test;
2223

2324
import com.github.jknack.handlebars.HandlebarsException;
@@ -192,8 +193,8 @@ public void cancellationException() throws IOException, InterruptedException, Ex
192193
expect(future.get()).andThrow(new CancellationException());
193194
expect(future.get()).andReturn(ImmutablePair.<TemplateSource, Template> of(source, template));
194195

195-
Capture<TemplateSource> keyGet = new Capture<>();
196-
Capture<TemplateSource> keyRemove = new Capture<>();
196+
Capture<TemplateSource> keyGet = EasyMock.newCapture();
197+
Capture<TemplateSource> keyRemove = EasyMock.newCapture();
197198

198199
ConcurrentMap<TemplateSource, Future<Pair<TemplateSource, Template>>> cache = createMock(
199200
ConcurrentMap.class);
@@ -223,8 +224,8 @@ public void runtimeException() throws IOException, InterruptedException, Executi
223224
Future<Pair<TemplateSource, Template>> future = createMock(Future.class);
224225
expect(future.get()).andThrow(new ExecutionException(new IllegalArgumentException()));
225226

226-
Capture<TemplateSource> keyGet = new Capture<>();
227-
Capture<TemplateSource> keyRemove = new Capture<>();
227+
Capture<TemplateSource> keyGet = EasyMock.newCapture();
228+
Capture<TemplateSource> keyRemove = EasyMock.newCapture();
228229

229230
ConcurrentMap<TemplateSource, Future<Pair<TemplateSource, Template>>> cache = createMock(
230231
ConcurrentMap.class);
@@ -255,7 +256,7 @@ public void errorException() throws IOException, InterruptedException, Execution
255256
Future<Pair<TemplateSource, Template>> future = createMock(Future.class);
256257
expect(future.get()).andThrow(new ExecutionException(new Error()));
257258

258-
Capture<TemplateSource> keyGet = new Capture<>();
259+
Capture<TemplateSource> keyGet = EasyMock.newCapture();
259260

260261
ConcurrentMap<TemplateSource, Future<Pair<TemplateSource, Template>>> cache = createMock(
261262
ConcurrentMap.class);
@@ -285,8 +286,8 @@ public void hbsException() throws IOException, InterruptedException, ExecutionEx
285286
Future<Pair<TemplateSource, Template>> future = createMock(Future.class);
286287
expect(future.get()).andThrow(new ExecutionException(new Exception()));
287288

288-
Capture<TemplateSource> keyGet = new Capture<>();
289-
Capture<TemplateSource> keyRemove = new Capture<>();
289+
Capture<TemplateSource> keyGet = EasyMock.newCapture();
290+
Capture<TemplateSource> keyRemove = EasyMock.newCapture();
290291

291292
ConcurrentMap<TemplateSource, Future<Pair<TemplateSource, Template>>> cache = createMock(
292293
ConcurrentMap.class);

handlebars/src/test/java/com/github/jknack/handlebars/helper/StringHelpersTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import java.io.IOException;
2828
import java.util.*;
2929

30-
import org.apache.commons.lang3.SystemUtils;
3130
import org.junit.Test;
3231

3332
import com.github.jknack.handlebars.AbstractTest;
@@ -439,8 +438,8 @@ public void wordWrap() throws IOException {
439438

440439
assertEquals("wordWrap", wordWrap.name());
441440

442-
assertEquals("Joel" + SystemUtils.LINE_SEPARATOR + "is a"
443-
+ SystemUtils.LINE_SEPARATOR + "slug",
441+
assertEquals("Joel" + System.lineSeparator() + "is a"
442+
+ System.lineSeparator() + "slug",
444443
wordWrap.apply("Joel is a slug", options));
445444

446445
verify(options);

handlebars/src/test/java/com/github/jknack/handlebars/i374/Issue374.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public void test_helper__IF_EQ__with_int() throws IOException
3131
public void test_helper__IF_EQ__with_Integer() throws IOException
3232
{
3333
HashMap map = new HashMap();
34-
map.put("num1", new Integer(5)); // netbeans says: unnecessary boxing to integer
35-
map.put("num2", new Integer(5));
34+
map.put("num1", Integer.valueOf(5)); // netbeans says: unnecessary boxing to integer
35+
map.put("num2", Integer.valueOf(5));
3636
assertEquals("True", inlineTemplate().apply(map));
3737
}
3838

@@ -42,7 +42,7 @@ public void test_helper__IF_EQ__with_int_Integer() throws IOException
4242
{
4343
HashMap map = new HashMap();
4444
map.put("num1", 5);
45-
map.put("num2", new Integer(5));
45+
map.put("num2", Integer.valueOf(5));
4646
assertEquals("True", inlineTemplate().apply(map));
4747
}
4848

@@ -61,8 +61,8 @@ public void test_helper__IF_EQ__with_getValue_int() throws IOException
6161
public void test_helper__IF_EQ__with_getValue_Integer() throws IOException
6262
{
6363
HashMap map = new HashMap();
64-
map.put("val1", new Value(new Integer(5)));
65-
map.put("val2", new Value(new Integer(5)));
64+
map.put("val1", new Value(Integer.valueOf(5)));
65+
map.put("val2", new Value(Integer.valueOf(5)));
6666
assertEquals("True", inlineTemplate_getValue().apply(map));
6767
}
6868

@@ -130,22 +130,22 @@ protected Double toDouble(final Object obj)
130130
dbl = (Double) obj;
131131
}
132132
if (obj instanceof Integer) {
133-
dbl = new Double((Integer) obj);
133+
dbl = Double.valueOf((Integer) obj);
134134
}
135135
if (obj instanceof Long) {
136-
dbl = new Double((Long) obj);
136+
dbl = Double.valueOf((Long) obj);
137137
}
138138
if (obj instanceof BigDecimal) {
139139
dbl = ((BigDecimal) obj).doubleValue();
140140
}
141141
if (obj instanceof Float) {
142-
dbl = new Double((Float) obj);
142+
dbl = Double.valueOf((Float) obj);
143143
}
144144
if (obj instanceof String)
145145
{
146146
String str = (String) obj;
147147
if (str.matches("[0-9]*\\.?[0-9]+")) {
148-
dbl = new Double(str);
148+
dbl = Double.valueOf(str);
149149
}
150150
}
151151
System.out.println("Object: " + obj);

handlebars/src/test/java/com/github/jknack/handlebars/io/ServletContextTemplateLoaderTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import javax.servlet.ServletContext;
1616

1717
import org.easymock.Capture;
18+
import org.easymock.EasyMock;
1819
import org.easymock.IAnswer;
1920
import org.junit.Test;
2021

@@ -132,7 +133,7 @@ public void emotySuffix() throws IOException {
132133

133134
private void expectGetResource(final ServletContext servletContext, final String prefix)
134135
throws IOException {
135-
final Capture<String> path = new Capture<>();
136+
final Capture<String> path = EasyMock.newCapture();
136137
expect(servletContext.getResource(capture(path))).andAnswer(
137138
new IAnswer<URL>() {
138139
@Override

handlebars/src/test/java/com/github/jknack/handlebars/issues/Issue473.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ public class Issue473 extends AbstractTest {
1010

1111
@Test
1212
public void testWith() throws IOException {
13-
Hash context = $("needsPano", new Boolean(true), "group", $("title", "test"));
13+
Hash context = $("needsPano", Boolean.TRUE, "group", $("title", "test"));
1414

1515
shouldCompileTo("{{#with group}}{{needsPano}}{{/with}}", context, "true");
1616
}
1717

1818
@Test
1919
public void testBlock() throws IOException {
20-
Hash context = $("needsPano", new Boolean(true), "group", $("title", "test"));
20+
Hash context = $("needsPano", Boolean.TRUE, "group", $("title", "test"));
2121

2222
shouldCompileTo("{{#group}}{{needsPano}}{{/group}}", context, "true");
2323
}

handlebars/src/test/java/com/github/jknack/handlebars/issues/Issue479.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package com.github.jknack.handlebars.issues;
22

3-
import java.io.IOException;
4-
53
import org.junit.Test;
64

75
import com.github.jknack.handlebars.v4Test;

handlebars/src/test/java/com/github/jknack/handlebars/issues/Issue527.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.github.jknack.handlebars.issues;
22

33
import com.github.jknack.handlebars.v4Test;
4-
import static org.junit.Assert.assertEquals;
54
import org.junit.Test;
65

76
public class Issue527 extends v4Test {

handlebars/src/test/java/com/github/jknack/handlebars/issues/Issue552.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
import com.github.jknack.handlebars.v4Test;
99
import org.junit.Test;
1010

11-
import java.util.Arrays;
12-
1311
public class Issue552 extends v4Test {
1412

1513
@Override protected Object configureContext(Object context) {

0 commit comments

Comments
 (0)