@@ -78,6 +78,7 @@ public void testAdaptJsonScalars(JavaxJsonAdaptation adaptation) {
78
78
assertNull (adaptation .adapt (JsonValue .NULL ));
79
79
assertEquals (true , adaptation .adapt (JsonValue .TRUE ));
80
80
assertEquals (false , adaptation .adapt (JsonValue .FALSE ));
81
+ assertEquals ("value" , adaptation .adapt (Json .createValue ("value" )));
81
82
assertEquals (BigInteger .ONE , adaptation .adapt (Json .createValue (1 )));
82
83
assertEquals (BigInteger .ONE , adaptation .adapt (Json .createValue (1L )));
83
84
assertEquals (BigInteger .ONE , adaptation .adapt (Json .createValue (BigInteger .ONE )));
@@ -112,6 +113,7 @@ public void testInvertIntrinsics(JavaxJsonAdaptation adaptation) {
112
113
assertEquals (Json .createValue ("value" ), adaptation .invert ("value" ));
113
114
assertEquals (Json .createValue (1 ), adaptation .invert (1 ));
114
115
assertEquals (Json .createValue (1L ), adaptation .invert (1L ));
116
+ assertEquals (Json .createValue (1.0 ), adaptation .invert (1.0 ));
115
117
assertEquals (Json .createValue (BigInteger .ONE ), adaptation .invert (BigInteger .ONE ));
116
118
assertEquals (Json .createValue (BigDecimal .ONE ), adaptation .invert (BigDecimal .ONE ));
117
119
}
@@ -130,4 +132,39 @@ public void testInvertArrayAdapter(JavaxJsonAdaptation adaptation) {
130
132
assertSame (array , adaptation .invert (new JavaxJsonArrayAdapter (array )));
131
133
}
132
134
135
+ @ Test
136
+ public void testNewInstanceDefaultClassLoader () {
137
+ final ClassLoader tccl = Thread .currentThread ().getContextClassLoader ();
138
+ Thread .currentThread ().setContextClassLoader (null );
139
+ assertTrue (JavaxJsonAdaptation .newInstance () instanceof Jsr374Adaptation );
140
+ Thread .currentThread ().setContextClassLoader (tccl );
141
+ }
142
+
143
+ @ Test
144
+ public void testNewInstanceThreadContextClassLoader () {
145
+ final ClassLoader tccl = Thread .currentThread ().getContextClassLoader ();
146
+ Thread .currentThread ().setContextClassLoader (getClass ().getClassLoader ());
147
+ assertTrue (JavaxJsonAdaptation .newInstance () instanceof Jsr374Adaptation );
148
+ Thread .currentThread ().setContextClassLoader (tccl );
149
+ }
150
+
151
+ @ Test
152
+ public void testNewInstanceWithClassLoader () {
153
+ assertTrue (JavaxJsonAdaptation .newInstance (getClass ().getClassLoader ())
154
+ instanceof Jsr374Adaptation );
155
+ }
156
+
157
+ @ Test
158
+ public void testDetermineProvider () {
159
+ assertEquals (JavaxJsonAdaptation .JSR_374_ADAPTATION ,
160
+ JavaxJsonAdaptation .determineProvider ("createValue" , String .class ));
161
+ assertEquals (JavaxJsonAdaptation .JSR_353_ADAPTATION ,
162
+ JavaxJsonAdaptation .determineProvider (".noSuchMethod" ));
163
+ }
164
+
165
+ @ Test (expected = RuntimeException .class )
166
+ public void testInstanceWhenCannotInstantiate () {
167
+ JavaxJsonAdaptation .newInstance (getClass ().getClassLoader (), ".noSuchProviderName" );
168
+ }
169
+
133
170
}
0 commit comments