### Question:
ScriptContextImplementation implements InternalScriptContext { public void stopThisWorkerThread() throws InvalidContextException { if (m_threadContextLocator.get() != null) { throw new ShutdownException("Thread has been shut down"); } else { throw new InvalidContextException( "stopThisWorkerThread() must be called from a worker thread"); } } ScriptContextImplementation(
     WorkerIdentity workerIdentity,
     WorkerIdentity firstWorkerIdentity,
     ThreadContextLocator threadContextLocator,
     GrinderProperties properties,
     Logger logger,
     Sleeper sleeper,
     SSLControl sslControl,
     Statistics scriptStatistics,
     TestRegistry testRegistry,
     ThreadStarter threadStarter,
     ThreadStopper threadStopper,
     BarrierGroups barrierGroups,
     BarrierIdentity.Factory barrierIdentityFactory); int getAgentNumber(); String getProcessName(); int getProcessNumber(); int getFirstProcessNumber(); int getThreadNumber(); int getRunNumber(); Logger getLogger(); void sleep(long meanTime); void sleep(long meanTime, long sigma); int startWorkerThread(); int startWorkerThread(Object testRunner); void stopThisWorkerThread(); boolean stopWorkerThread(int threadNumber); GrinderProperties getProperties(); Statistics getStatistics(); SSLControl getSSLControl(); TestRegistry getTestRegistry(); Barrier barrier(String name);  }### Answer:
@Test public void testStopThisWorkerThread() throws Exception { final StubThreadContextLocator threadContextLocator = new StubThreadContextLocator(); final ScriptContextImplementation scriptContext = new ScriptContextImplementation( null, null, threadContextLocator, null, null, null, null, null, null, null, null, null, null); try { scriptContext.stopThisWorkerThread(); fail("Expected InvalidContextException"); } catch (InvalidContextException e) { } threadContextLocator.set(m_threadContext); try { scriptContext.stopThisWorkerThread(); fail("Expected ShutdownException"); } catch (ShutdownException e) { } }