### Question:
SpaceAdaptor extends QBeanSupport implements SpaceAdaptorMBean { protected void stopService () throws Exception { getServer().getMBeanServer().unregisterMBean (objectName); } SpaceAdaptor(); synchronized void setSpaceName(String spaceName); String getSpaceName(); Set getKeys();  }### Answer:
@Test public void testStopServiceThrowsNullPointerException() throws Throwable { SpaceAdaptor spaceAdaptor = new SpaceAdaptor(); try { spaceAdaptor.stopService(); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"org.jpos.q2.Q2.getMBeanServer()\" because the return value of \"org.jpos.q2.qbean.SpaceAdaptor.getServer()\" is null", ex.getMessage(), "ex.getMessage()"); } } }