From d5d82cdb8706387e2075688ee9f55f1c8e052a50 Mon Sep 17 00:00:00 2001 From: marilynel Date: Sun, 20 Jul 2025 11:31:29 -0800 Subject: [PATCH] fixing sonarcube issues --- .../java/org/json/junit/JSONObjectTest.java | 37 ++++++++++++------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/src/test/java/org/json/junit/JSONObjectTest.java b/src/test/java/org/json/junit/JSONObjectTest.java index 52a5240..3c34368 100644 --- a/src/test/java/org/json/junit/JSONObjectTest.java +++ b/src/test/java/org/json/junit/JSONObjectTest.java @@ -4000,19 +4000,24 @@ public class JSONObjectTest { @Test public void test_strictModeWithMisCasedBooleanOrNullValue(){ JSONParserConfiguration jsonParserConfiguration = new JSONParserConfiguration().withStrictMode(); - try{ - JSONObject j1 = new JSONObject("{\"a\":True}", jsonParserConfiguration); + new JSONObject("{\"a\":True}", jsonParserConfiguration); fail("Expected an exception"); - } catch (JSONException e) { } + } catch (JSONException e) { + // No action, expected outcome + } try{ - JSONObject j2 = new JSONObject("{\"a\":TRUE}", jsonParserConfiguration); + new JSONObject("{\"a\":TRUE}", jsonParserConfiguration); fail("Expected an exception"); - } catch (JSONException e) { } + } catch (JSONException e) { + // No action, expected outcome + } try{ - JSONObject j2 = new JSONObject("{\"a\":nUlL}", jsonParserConfiguration); + new JSONObject("{\"a\":nUlL}", jsonParserConfiguration); fail("Expected an exception"); - } catch (JSONException e) { } + } catch (JSONException e) { + // No action, expected outcome + } } @Test @@ -4021,17 +4026,23 @@ public class JSONObjectTest { // Parsing the following objects should fail try{ - JSONObject j3 = new JSONObject("{true : 3}", jsonParserConfiguration); + new JSONObject("{true : 3}", jsonParserConfiguration); fail("Expected an exception"); - } catch (JSONException e) { } + } catch (JSONException e) { + // No action, expected outcome + } try{ - JSONObject j4 = new JSONObject("{TRUE : 3}", jsonParserConfiguration); + new JSONObject("{TRUE : 3}", jsonParserConfiguration); fail("Expected an exception"); - } catch (JSONException e) { } + } catch (JSONException e) { + // No action, expected outcome + } try{ - JSONObject j5 = new JSONObject("{1 : 3}", jsonParserConfiguration); + new JSONObject("{1 : 3}", jsonParserConfiguration); fail("Expected an exception"); - } catch (JSONException e) { } + } catch (JSONException e) { + // No action, expected outcome + } }