forked from Qortal/qortal
eaad565765
This allows them to be excluded from final built package. pom.xml and .classpath updated Unable to test due to lack of JUnit 5 in Eclipse Neon
58 lines
1.3 KiB
Java
58 lines
1.3 KiB
Java
package test;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
import static org.junit.jupiter.api.Assertions.*;
|
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
import repository.DataException;
|
|
import repository.Repository;
|
|
import repository.RepositoryManager;
|
|
|
|
public class RepositoryTests extends Common {
|
|
|
|
private static final Logger LOGGER = LogManager.getLogger(RepositoryTests.class);
|
|
|
|
@Test
|
|
public void testGetRepository() throws DataException {
|
|
try (final Repository repository = RepositoryManager.getRepository()) {
|
|
assertNotNull(repository);
|
|
}
|
|
}
|
|
|
|
@Test
|
|
public void testMultipleInstances() throws DataException {
|
|
int n_instances = 5;
|
|
Repository[] repositories = new Repository[n_instances];
|
|
|
|
for (int i = 0; i < n_instances; ++i) {
|
|
repositories[i] = RepositoryManager.getRepository();
|
|
assertNotNull(repositories[i]);
|
|
}
|
|
|
|
for (int i = 0; i < n_instances; ++i) {
|
|
repositories[i].close();
|
|
repositories[i] = null;
|
|
}
|
|
}
|
|
|
|
@Test
|
|
public void testAccessAfterClose() throws DataException {
|
|
try (Repository repository = RepositoryManager.getRepository()) {
|
|
assertNotNull(repository);
|
|
|
|
repository.close();
|
|
|
|
try {
|
|
repository.discardChanges();
|
|
fail();
|
|
} catch (NullPointerException | DataException e) {
|
|
}
|
|
|
|
LOGGER.warn("Expect \"repository already closed\" complaint below");
|
|
}
|
|
}
|
|
|
|
}
|