65 lines
2.0 KiB
Java
65 lines
2.0 KiB
Java
package org.gcube.informationsystem.resourceregistry.dbinitialization;
|
|
|
|
import org.gcube.informationsystem.base.reference.Element;
|
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
|
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
|
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode;
|
|
import org.junit.Assert;
|
|
import org.junit.Test;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import com.arcadedb.remote.RemoteDatabase;
|
|
|
|
/**
|
|
* @author Luca Frosini (ISTI - CNR)
|
|
*/
|
|
public class DatabaseEnvironmentTest {
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(DatabaseEnvironmentTest.class);
|
|
|
|
// @Test
|
|
public void createDB() throws Exception{
|
|
logger.trace("Created DB is {}:{}/{}", DatabaseEnvironment.HOST, DatabaseEnvironment.PORT, DatabaseEnvironment.DB);
|
|
}
|
|
|
|
@Test
|
|
public void testDateTimeFormat() throws ResourceRegistryException {
|
|
RemoteDatabase database = ContextUtility.getAdminSecurityContext().getRemoteDatabase(PermissionMode.WRITER);
|
|
String dateTime = database.get(ATTRIBUTES.DATETIMEFORMAT).toString();
|
|
Assert.assertTrue(dateTime.compareTo(Element.DATETIME_PATTERN)==0);
|
|
}
|
|
|
|
|
|
/*
|
|
@Test
|
|
public void generateDBKey() throws Exception {
|
|
Properties properties = new Properties();
|
|
InputStream input = DatabaseEnvironmentTest.class.getClassLoader().getResourceAsStream("config.properties.prod");
|
|
|
|
// load a properties file
|
|
properties.load(input);
|
|
|
|
String keyFileName = properties.getProperty("DB_KEY_FILENAME");
|
|
String keyAlgorithm = properties.getProperty("DB_KEY_ALGORITHM_VARNAME");
|
|
|
|
URL url = SymmetricKey.class.getResource(keyFileName);
|
|
File keyFile = new File("src/test/resources", keyFileName);
|
|
Key key = null;
|
|
if(url!=null) {
|
|
try {
|
|
key = SymmetricKey.loadKeyFromFile(keyFile, keyAlgorithm);
|
|
} catch(Exception e) {
|
|
|
|
}
|
|
}
|
|
|
|
if(key==null){
|
|
key = KeyFactory.newAESKey();
|
|
KeySerialization.store(key, keyFile);
|
|
}
|
|
}
|
|
*/
|
|
|
|
}
|