2017-02-18 18:08:45 +01:00
|
|
|
/*
|
2018-01-15 12:23:58 +01:00
|
|
|
* Copyright (c) 2018 univento.eu - All rights reserved
|
2017-02-18 18:08:45 +01:00
|
|
|
* 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;
|
2017-02-18 18:08:45 +01:00
|
|
|
import org.junit.Test;
|
|
|
|
|
2017-08-14 12:06:33 +02:00
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
|
|
|
import static org.awaitility.Awaitility.await;
|
2017-02-18 18:08:45 +01:00
|
|
|
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
|
2017-02-18 18:08:45 +01:00
|
|
|
*/
|
|
|
|
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() {
|
2017-02-18 18:08:45 +01:00
|
|
|
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());
|
2017-02-18 18:08:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2017-08-14 12:06:33 +02:00
|
|
|
public void testRedis() {
|
|
|
|
AtomicReference<String> result = new AtomicReference<>();
|
2017-02-18 18:08:45 +01:00
|
|
|
|
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-02-18 18:08:45 +01:00
|
|
|
|
2017-08-14 12:06:33 +02:00
|
|
|
await().until(() -> result.get() != null);
|
|
|
|
assertTrue(result.get().equals("nope"));
|
2017-02-18 18:08:45 +01:00
|
|
|
}
|
|
|
|
}
|