ThreadLocalStack { public void set(T item) { Preconditions.checkNotNull(item); Deque<T> stack = new ArrayDeque<T>(); stack.addFirst(item); stackLocal.set(stack); }  T push(T item); T peek(); T pop(); T popOrError(); T get(); T getOrError(); void set(T item); void remove(); void with(T item, WithProcedure procedure);  }
@Test public void set() { String item = UUID.randomUUID().toString(); stack.set(item); assertThat(stack.pop(), equalTo(item)); assertThat(stack.pop(), nullValue()); }
@Test(expected = NullPointerException.class) public void setNull() { stack.set(null); }