/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.repository;
import com.liferay.document.library.kernel.model.DLFolder;
import com.liferay.portal.kernel.model.Group;
import com.liferay.portal.kernel.repository.RepositoryFactoryUtil;
import com.liferay.portal.kernel.test.rule.AggregateTestRule;
import com.liferay.portal.kernel.test.rule.DeleteAfterTestRun;
import com.liferay.portal.kernel.test.util.GroupTestUtil;
import com.liferay.portal.kernel.test.util.RandomTestUtil;
import com.liferay.portal.test.rule.LiferayIntegrationTestRule;
import com.liferay.portlet.documentlibrary.util.test.DLTestUtil;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
/**
* @author Adolfo PĂ©rez
*/
public class RepositoryFactoryTest {
@ClassRule
@Rule
public static final AggregateTestRule aggregateTestRule =
new LiferayIntegrationTestRule();
@Before
public void setUp() throws Exception {
_group = GroupTestUtil.addGroup();
}
@Test
public void testCreateLocalRepositoryFromExistingRepositoryId()
throws Exception {
DLFolder dlFolder = DLTestUtil.addDLFolder(_group.getGroupId());
RepositoryFactoryUtil.createLocalRepository(dlFolder.getRepositoryId());
}
@Test
public void testCreateLocalRepositoryFromNonexistentRepositoryId()
throws Exception {
long repositoryId = RandomTestUtil.nextLong();
RepositoryFactoryUtil.createLocalRepository(repositoryId);
}
@Test
public void testCreateRepositoryFromExistingRepositoryId()
throws Exception {
DLFolder dlFolder = DLTestUtil.addDLFolder(_group.getGroupId());
RepositoryFactoryUtil.createRepository(dlFolder.getRepositoryId());
}
@Test
public void testCreateRepositoryFromNonexistentRepositoryId()
throws Exception {
long repositoryId = RandomTestUtil.randomLong();
RepositoryFactoryUtil.createRepository(repositoryId);
}
@DeleteAfterTestRun
private Group _group;
}