Commons/src/test/java/eu/univento/commons/CommonsTest.java

65 lines
1.5 KiB
Java
Raw Normal View History

/*
2018-01-15 12:23:58 +01:00
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.commons;
import eu.univento.commons.database.DatabaseManager;
2017-08-14 12:06:33 +02:00
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
2017-08-14 12:06:33 +02:00
import java.util.concurrent.atomic.AtomicReference;
import static org.awaitility.Awaitility.await;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
* @author joethei
2017-08-14 12:06:33 +02:00
* @version 1.0
*/
public class CommonsTest {
2017-08-14 12:06:33 +02:00
private Commons commons;
@Before
public void init() {
commons = new Commons();
}
@After
public void close() {
commons.shutdown();
}
@Test
public void testCommons() {
assertNotNull(commons);
assertNotNull(commons.getDatabaseManager());
assertNotNull(commons.getConfigurationHandler());
}
@Test
public void testDatabaseManager() {
DatabaseManager db = commons.getDatabaseManager();
assertNotNull(db.getMongoDB());
assertNotNull(db.getMySQL());
2017-08-14 12:06:33 +02:00
assertNotNull(db.getRedis());
}
@Test
2017-08-14 12:06:33 +02:00
public void testRedis() {
AtomicReference<String> result = new AtomicReference<>();
2017-08-14 12:06:33 +02:00
commons.getDatabaseManager().getRedis().getClient().get("test", event -> {
if(event.failed()) event.cause().printStackTrace();
result.set(event.result());
});
2017-08-14 12:06:33 +02:00
await().until(() -> result.get() != null);
assertTrue(result.get().equals("nope"));
}
}