/src/test/java/com/google/ie/test/ServiceTest.java

http://thoughtsite.googlecode.com/ · Java · 38 lines · 19 code · 8 blank · 11 comment · 0 complexity · 95dccb35c7df0ba020f7da89a334b832 MD5 · raw file

  1. // Copyright 2009 Google Inc. All Rights Reserved.
  2. package com.google.ie.test;
  3. import com.google.appengine.tools.development.ApiProxyLocalImpl;
  4. import com.google.apphosting.api.ApiProxy;
  5. import org.junit.After;
  6. import org.junit.Before;
  7. import java.io.File;
  8. /**
  9. * Base class for testing all non transactional service classes. The setUp() and
  10. * tearDown() methods defined below are responsible for creating and resetting
  11. * the test environment.
  12. *
  13. * @author asirohi
  14. *
  15. */
  16. public class ServiceTest {
  17. @Before
  18. public void setUp() {
  19. // Set environment as test environment
  20. ApiProxy.setEnvironmentForCurrentThread(new TestEnvironment());
  21. ApiProxy.setDelegate(new ApiProxyLocalImpl(new File(".")) {
  22. });
  23. }
  24. @After
  25. public void tearDown() {
  26. // Setting api proxy to null. Not necessary but a good practice.
  27. ApiProxy.setDelegate(null);
  28. ApiProxy.setEnvironmentForCurrentThread(null);
  29. }
  30. }