@Before
  public void setUp() throws Exception {
    FinderCacheUtil.clearCache();

    ServiceContextThreadLocal.pushServiceContext(ServiceTestUtil.getServiceContext());

    // Group

    group = GroupTestUtil.addGroup();

    // Global scope article

    Company company = CompanyUtil.fetchByPrimaryKey(group.getCompanyId());

    globalGroupId = company.getGroupId();

    globalJournalArticle =
        JournalTestUtil.addArticle(globalGroupId, "Global Article", "Global Content");

    // Layout prototype

    layoutPrototype = LayoutTestUtil.addLayoutPrototype(ServiceTestUtil.randomString());

    layoutPrototypeLayout = layoutPrototype.getLayout();

    LayoutTestUtil.updateLayoutTemplateId(layoutPrototypeLayout, initialLayoutTemplateId);

    doSetUp();
  }
 @Override
 public void run(String[] arg0) throws ActionException {
   Properties props = new Properties();
   try {
     props.load(
         this.getClass().getClassLoader().getResourceAsStream("password.changer.properties"));
     String type = props.getProperty("type");
     String virtualHost = props.getProperty("virtualhost");
     Company c = CompanyUtil.fetchByVirtualHost(virtualHost);
     User u = null;
     String name = null;
     if ("screenname".equals(type)) {
       String screenName = props.getProperty("screenname");
       u = UserLocalServiceUtil.getUserByScreenName(c.getCompanyId(), screenName);
       name = screenName;
     } else if ("e-mail".equals(type)) {
       String emailAddress = props.getProperty("emailaddress");
       u = UserLocalServiceUtil.getUserByEmailAddress(c.getCompanyId(), emailAddress);
       name = emailAddress;
     } else {
       _log.error(
           "You should set type to screenname or e-mail if you want to use the password updater.");
     }
     String password = props.getProperty("password");
     UserLocalServiceUtil.updatePasswordManually(u.getUserId(), password, false, true, new Date());
     _log.info("Password for " + name + " was updated.");
   } catch (Exception e) {
     _log.error(e);
   }
 }
  @Test
  public void testExportImportPortletPreferences() throws Exception {

    // Check preferences after site creation

    JournalArticle journalArticle =
        JournalArticleLocalServiceUtil.getArticleByUrlTitle(
            _group.getGroupId(), _layoutSetPrototypeJournalArticle.getUrlTitle());

    Layout layout =
        LayoutLocalServiceUtil.getFriendlyURLLayout(
            _group.getGroupId(), false, _layoutSetPrototypeLayout.getFriendlyURL());

    javax.portlet.PortletPreferences jxPreferences =
        getPortletPreferences(
            layout.getCompanyId(), layout.getPlid(), _layoutSetPrototypeJournalContentPortletId);

    Assert.assertEquals(
        journalArticle.getArticleId(), jxPreferences.getValue("articleId", StringPool.BLANK));

    Assert.assertEquals(
        String.valueOf(journalArticle.getGroupId()),
        jxPreferences.getValue("groupId", StringPool.BLANK));

    Assert.assertEquals(
        String.valueOf(true), jxPreferences.getValue("showAvailableLocales", StringPool.BLANK));

    // Update site template preferences

    javax.portlet.PortletPreferences layoutSetprototypeJxPreferences =
        getPortletPreferences(
            _layoutSetPrototypeLayout.getCompanyId(),
            _layoutSetPrototypeLayout.getPlid(),
            _layoutSetPrototypeJournalContentPortletId);

    layoutSetprototypeJxPreferences.setValue("showAvailableLocales", String.valueOf(false));

    updatePortletPreferences(
        _layoutSetPrototypeLayout.getPlid(),
        _layoutSetPrototypeJournalContentPortletId,
        layoutSetprototypeJxPreferences);

    // Check preferences after layout reset

    SitesUtil.resetPrototype(layout);

    jxPreferences =
        getPortletPreferences(
            _group.getCompanyId(), layout.getPlid(), _layoutSetPrototypeJournalContentPortletId);

    Assert.assertEquals(
        journalArticle.getArticleId(), jxPreferences.getValue("articleId", StringPool.BLANK));
    Assert.assertEquals(
        String.valueOf(journalArticle.getGroupId()),
        jxPreferences.getValue("groupId", StringPool.BLANK));
    Assert.assertEquals(
        Boolean.FALSE.toString(), jxPreferences.getValue("showAvailableLocales", StringPool.BLANK));

    // Update journal content portlet with a new globally scoped journal
    // article

    Company company = CompanyUtil.fetchByPrimaryKey(_layoutSetPrototypeLayout.getCompanyId());

    Group companyGroup = company.getGroup();

    JournalArticle globalScopeJournalArticle =
        addJournalArticle(companyGroup.getGroupId(), 0, "Global Article", "Global Content");

    layoutSetprototypeJxPreferences.setValue("articleId", globalScopeJournalArticle.getArticleId());
    layoutSetprototypeJxPreferences.setValue("groupId", Long.toString(companyGroup.getGroupId()));
    layoutSetprototypeJxPreferences.setValue("lfrScopeLayoutUuid", StringPool.BLANK);
    layoutSetprototypeJxPreferences.setValue("lfrScopeType", "company");

    updatePortletPreferences(
        _layoutSetPrototypeLayout.getPlid(),
        _layoutSetPrototypeJournalContentPortletId,
        layoutSetprototypeJxPreferences);

    jxPreferences =
        getPortletPreferences(
            _group.getCompanyId(), layout.getPlid(), _layoutSetPrototypeJournalContentPortletId);

    // Check preferences when journal article is from the global scope

    Assert.assertEquals(
        globalScopeJournalArticle.getArticleId(),
        jxPreferences.getValue("articleId", StringPool.BLANK));
    Assert.assertEquals(
        String.valueOf(companyGroup.getGroupId()),
        jxPreferences.getValue("groupId", StringPool.BLANK));
    Assert.assertEquals(
        StringPool.BLANK, jxPreferences.getValue("lfrScopeLayoutUuid", StringPool.BLANK));
    Assert.assertEquals("company", jxPreferences.getValue("lfrScopeType", StringPool.BLANK));
  }