LockableList extends ArrayList<T> { @Override public T remove(int i) { if (readOnly) { throw new JTransfoException(READ_ONLY); } return super.remove(i); }  void lock(); @Override T set(int i, T t); @Override boolean add(T t); @Override void add(int i, T t); @Override T remove(int i); @Override boolean remove(Object o); @Override void clear(); @Override boolean addAll(Collection<? extends T> ts); @Override boolean addAll(int i, Collection<? extends T> ts);  }
@Test public void removeTest() throws Exception { list.remove(0); assertThat(list).hasSize(2); assertThat(list.get(0)).isEqualTo(1); exception.expect(JTransfoException.class); exception.expectMessage("Collection is read-only."); list.lock(); list.remove(0); }