Home / Class/ ApplicationPidTests Class — spring-boot Architecture

ApplicationPidTests Class — spring-boot Architecture

Architecture documentation for the ApplicationPidTests class in ApplicationPidTests.java from the spring-boot codebase.

Entity Profile

Source Code

core/spring-boot/src/test/java/org/springframework/boot/system/ApplicationPidTests.java lines 33–103

class ApplicationPidTests {

	@TempDir
	@SuppressWarnings("NullAway.Init")
	File tempDir;

	@Test
	void toStringWithPid() {
		assertThat(new ApplicationPid(123L)).hasToString("123");
	}

	@Test
	void toStringWithoutPid() {
		assertThat(new ApplicationPid(null)).hasToString("???");
	}

	@Test
	void throwIllegalStateWritingMissingPid() {
		ApplicationPid pid = new ApplicationPid(null);
		assertThatIllegalStateException().isThrownBy(() -> pid.write(new File(this.tempDir, "pid")))
			.withMessageContaining("No PID available");
	}

	@Test
	void writePid() throws Exception {
		ApplicationPid pid = new ApplicationPid(123L);
		File file = new File(this.tempDir, "pid");
		pid.write(file);
		assertThat(contentOf(file)).isEqualTo("123");
	}

	@Test
	void writeNewPid() throws Exception {
		// gh-10784
		ApplicationPid pid = new ApplicationPid(123L);
		File file = new File(this.tempDir, "pid");
		file.delete();
		pid.write(file);
		assertThat(contentOf(file)).isEqualTo("123");
	}

	@Test
	void toLong() {
		ApplicationPid pid = new ApplicationPid(123L);
		assertThat(pid.toLong()).isEqualTo(123L);
	}

	@Test
	void toLongWhenNotAvailable() {
		ApplicationPid pid = new ApplicationPid(null);
		assertThat(pid.toLong()).isNull();
	}

	@Test
	void isAvailableWhenAvailable() {
		ApplicationPid pid = new ApplicationPid(123L);
		assertThat(pid.isAvailable()).isTrue();
	}

	@Test
	void isAvailableWhenNotAvailable() {
		ApplicationPid pid = new ApplicationPid(null);
		assertThat(pid.isAvailable()).isFalse();
	}

	@Test
	void getPidFromJvm() {
		assertThat(new ApplicationPid().toString()).isNotEmpty();
	}

}

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free