/tests/com/google/appengine/datanucleus/WriteBlocker.java

http://datanucleus-appengine.googlecode.com/ · Java · 35 lines · 9 code · 4 blank · 22 comment · 2 complexity · b71b3de3508cfbdb51b67520ed759e81 MD5 · raw file

  1. /**********************************************************************
  2. Copyright (c) 2009 Google Inc.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. **********************************************************************/
  13. package com.google.appengine.datanucleus;
  14. import java.lang.reflect.Method;
  15. /**
  16. * Policy for disabling datastore writes. Useful for proving
  17. * that operations that shouldn't write to the datastore aren't
  18. * actually writing to the datastore.
  19. *
  20. * @author Max Ross <maxr@google.com>
  21. */
  22. public final class WriteBlocker implements DatastoreServiceInterceptor.Policy {
  23. public void intercept(Object o, Method method, Object[] params) {
  24. if (method.getName().equals("put") || method.getName().equals("delete")) {
  25. throw new RuntimeException("Detected a write: " + method);
  26. }
  27. }
  28. }