Skip to content

Commit cf50555

Browse files
Fix bugs and suppress noise in core-unittests (SQLMap, SideMenuBar, Login1)
- SQLMap: Fixed a NullPointerException in `SelectBuilder` constructor when `parent` is null, and updated `SQLMapTest` to assert success instead of expecting failure. - SideMenuBar: Added a null check for `parent` in `installMenuBar` to prevent NPEs during initialization or restoration. - Login1Test: Wrapped expected exception generation in `TestLogger` to prevent pollution of the test output console.
1 parent e60fe06 commit cf50555

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

CodenameOne/src/com/codename1/properties/SQLMap.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,9 @@ private SelectBuilder(PropertyBase property, String operator, String prefix, Str
726726
this.prefix = prefix;
727727
this.suffix = suffix;
728728
this.parent = parent;
729-
parent.child = this;
729+
if (parent != null) {
730+
parent.child = this;
731+
}
730732
}
731733

732734
/**

CodenameOne/src/com/codename1/ui/SideMenuBar.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ protected Button createOpenButton() {
243243
* {@inheritDoc}
244244
*/
245245
protected void installMenuBar() {
246+
if (parent == null) {
247+
return;
248+
}
246249
if (parent.getClientProperty("Menu") != null) {
247250
return;
248251
}

maven/core-unittests/src/test/java/com/codename1/properties/SQLMapTest.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,9 @@ public void testSelectBuild() throws Exception {
131131
Database db = com.codename1.ui.Display.getInstance().openOrCreate("test.db");
132132
SQLMap sqlMap = SQLMap.create(db);
133133

134-
// This is expected to throw NPE because of broken constructor logic in SelectBuilder
135-
try {
136-
sqlMap.selectBuild();
137-
Assertions.fail("Expected NullPointerException from selectBuild()");
138-
} catch (NullPointerException e) {
139-
// Expected
140-
}
134+
// This was expected to throw NPE because of broken constructor logic in SelectBuilder
135+
// But we fixed it, so now it should work.
136+
SQLMap.SelectBuilder builder = sqlMap.selectBuild();
137+
Assertions.assertNotNull(builder);
141138
}
142139
}

maven/core-unittests/src/test/java/com/codename1/social/Login1Test.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ public void showAuthentication(ActionListener al) {
4646
login.setOauth2URL("url");
4747
login.setRedirectURI("uri");
4848

49-
login.doLogin();
49+
com.codename1.junit.TestLogger.install();
50+
try {
51+
login.doLogin();
52+
} finally {
53+
com.codename1.junit.TestLogger.remove();
54+
}
5055
}
5156
}

0 commit comments

Comments
 (0)