### Question:
SMAdaptor extends QBeanSupport implements SMAdaptorMBean { protected void initService () throws Exception { Element e = getPersist (); QFactory factory = getServer().getFactory(); sm = (SMAdapter) factory.newInstance (getImpl ()); factory.setLogger (sm, e); factory.setConfiguration (sm, e); } SMAdaptor(); void setImpl(String clazz); String getImpl();  }### Answer:
@Test public void testInitServiceThrowsNullPointerException() throws Throwable { SMAdaptor sMAdaptor = new SMAdaptor(); String[] args = new String[1]; args[0] = "testString"; sMAdaptor.setServer(q2); try { sMAdaptor.initService(); 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.QFactory.newInstance(String)\" because \"factory\" is null", ex.getMessage(), "ex.getMessage()"); } assertNull(sMAdaptor.sm, "sMAdaptor.sm"); assertFalse(sMAdaptor.isModified(), "sMAdaptor.isModified()"); } }
@Test public void testInitServiceThrowsNullPointerException1() throws Throwable { SMAdaptor sMAdaptor = new SMAdaptor(); try { sMAdaptor.initService(); 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.getFactory()\" because the return value of \"org.jpos.q2.security.SMAdaptor.getServer()\" is null", ex.getMessage(), "ex.getMessage()"); } assertNull(sMAdaptor.sm, "sMAdaptor.sm"); assertFalse(sMAdaptor.isModified(), "sMAdaptor.isModified()"); } }