protected static String getJdkToolPathname(final Stack<String> pathnames, final GemFireException throwable) { assertNotNull(pathnames, "The JDK tool executable pathnames cannot be null!"); assertNotNull(throwable, "The GemFireException cannot be null!"); try { // assume 'java.home' JVM System property refers to the JDK installation directory. note, // however, that the // 'java.home' JVM System property usually refers to the JRE used to launch this application return IOUtils.verifyPathnameExists(pathnames.pop()); } catch (EmptyStackException ignore) { throw throwable; } catch (FileNotFoundException ignore) { return getJdkToolPathname(pathnames, throwable); } }
protected static String getJdkToolPathname(final String jdkToolExecutableName, final GemFireException throwable) { assertNotNull(jdkToolExecutableName, "The JDK tool executable name cannot be null!"); assertNotNull(throwable, "The GemFireException cannot be null!"); Stack<String> pathnames = new Stack<>(); pathnames.push(jdkToolExecutableName); pathnames .push(IOUtils.appendToPath(System.getenv("JAVA_HOME"), "..", "bin", jdkToolExecutableName)); pathnames.push(IOUtils.appendToPath(System.getenv("JAVA_HOME"), "bin", jdkToolExecutableName)); pathnames.push(IOUtils.appendToPath(JAVA_HOME, "..", "bin", jdkToolExecutableName)); pathnames.push(IOUtils.appendToPath(JAVA_HOME, "bin", jdkToolExecutableName)); return getJdkToolPathname(pathnames, throwable); }
@Test public void testAssertNotNullWithNullObject() { assertThatThrownBy(() -> { Assert.assertNotNull(null, "This is an %1$s message!", "expected"); }).isInstanceOf(NullPointerException.class).hasMessage("This is an expected message!"); }
@Test public void testAssetNotNullWithNonNullObject() { Assert.assertNotNull(new Object(), ""); }