### Question:
X509SourceManager { public static synchronized X509Source getX509Source() throws X509SourceException, SocketEndpointAddressException { if (x509Source == null) { x509Source = DefaultX509Source.newSource(); } return x509Source; } private  X509SourceManager(); static synchronized X509Source getX509Source();  }### Answer:
@Test void getX509Source_returnTheX509SourceInstance() throws Exception { Field field = X509SourceManager.class.getDeclaredField("x509Source"); field.setAccessible(true); X509Source source = new X509SourceStub(); field.set(null, source); X509Source x509Source = X509SourceManager.getX509Source(); assertEquals(source, x509Source); }
@Test void getX509Source_defaultAddressNotSet() throws Exception { TestUtils.setEnvironmentVariable(Address.SOCKET_ENV_VARIABLE, "" ); try { X509SourceManager.getX509Source(); } catch (IllegalStateException e) { assertEquals("Endpoint Socket Address Environment Variable is not set: SPIFFE_ENDPOINT_SOCKET", e.getMessage()); } }