### Question:
ContractCheckingIndexProxy extends DelegatingIndexProxy { @Override public void start() { if ( state.compareAndSet( State.INIT, State.STARTING ) ) { try { super.start(); } finally { this.state.set( State.STARTED ); } } else { throw new IllegalStateException( "An IndexProxy can only be started once" ); } } ContractCheckingIndexProxy( IndexProxy delegate, boolean started ); @Override void start(); @Override IndexUpdater newUpdater( IndexUpdateMode mode ); @Override void force( IOLimiter ioLimiter ); @Override void drop(); @Override void close();  }### Answer:
@Test( expected = IllegalStateException.class ) public void shouldNotCreateIndexTwice() throws IOException { IndexProxy inner = mockIndexProxy(); IndexProxy outer = newContractCheckingIndexProxy( inner ); outer.start(); outer.start(); }