@Before
  @Override
  public void setUp() throws Exception {
    ServiceTestUtil.setUser(TestPropsValues.getUser());

    super.setUp();
  }
  @Before
  public void setUp() throws Exception {
    ServiceTestUtil.setUser(TestPropsValues.getUser());

    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext();

    _repository =
        RepositoryLocalServiceUtil.addRepository(
            TestPropsValues.getUserId(),
            TestPropsValues.getGroupId(),
            ClassNameLocalServiceUtil.getClassNameId(_REPOSITORY_CLASS_NAME),
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,
            StringUtil.randomString(),
            StringUtil.randomString(),
            StringUtil.randomString(),
            new UnicodeProperties(),
            true,
            serviceContext);

    _repositoryEntry =
        RepositoryEntryLocalServiceUtil.createRepositoryEntry(_repository.getDlFolderId());

    _repositoryEntry.setUuid(serviceContext.getUuid());
    _repositoryEntry.setGroupId(serviceContext.getScopeGroupId());
    _repositoryEntry.setCompanyId(serviceContext.getCompanyId());
    _repositoryEntry.setUserId(serviceContext.getUserId());
    _repositoryEntry.setUserName(StringUtil.randomString());
    _repositoryEntry.setCreateDate(serviceContext.getCreateDate(null));
    _repositoryEntry.setModifiedDate(serviceContext.getModifiedDate(null));
    _repositoryEntry.setRepositoryId(_repository.getRepositoryId());
    _repositoryEntry.setMappedId(_MAPPED_ID);

    RepositoryEntryLocalServiceUtil.addRepositoryEntry(_repositoryEntry);
  }
  @Before
  @Override
  public void setUp() throws Exception {
    _testMode = PortalRunMode.isTestMode();

    PortalRunMode.setTestMode(true);

    ServiceTestUtil.setUser(TestPropsValues.getUser());

    super.setUp();
  }
  @Override
  public Object doBeforeClass(Description description) {
    if (_mainServlet == null) {
      final MockServletContext mockServletContext =
          new AutoDeployMockServletContext(new FileSystemResourceLoader());

      PortalLifecycleUtil.register(
          new PortalLifecycle() {

            @Override
            public void portalInit() {
              ModuleFrameworkUtilAdapter.registerContext(mockServletContext);
            }

            @Override
            public void portalDestroy() {}
          });

      ServletContextPool.put(StringPool.BLANK, mockServletContext);

      MockServletConfig mockServletConfig = new MockServletConfig(mockServletContext);

      _mainServlet = new MainServlet();

      try {
        _mainServlet.init(mockServletConfig);
      } catch (ServletException se) {
        throw new RuntimeException("The main servlet could not be initialized");
      }

      ServiceTestUtil.initStaticServices();
    }

    ServiceTestUtil.initServices();

    ServiceTestUtil.initPermissions();

    return null;
  }
  @Before
  public void setUp() throws Exception {
    group = GroupTestUtil.addGroup();
    user = UserTestUtil.addUser();

    serviceContext = ServiceContextTestUtil.getServiceContext(group.getGroupId());

    doSetUp();

    ServiceTestUtil.setUser(user);

    permissionChecker = PermissionThreadLocal.getPermissionChecker();

    addPortletModelViewPermission();
  }
  @After
  public void tearDown() throws Exception {
    ServiceTestUtil.setUser(TestPropsValues.getUser());

    removePortletModelViewPermission();
  }