
org.kawanfw.sql.servlet.ConfiguratorMethodsTester Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aceql-server Show documentation
Show all versions of aceql-server Show documentation
AceQL combines a virtual JDBC Driver and a framework to enable remote JDBC access over HTTP. Android and Java Desktop application developers can access remote SQL databases in the cloud by simply including standard JDBC calls in their code, just like they would for a local database.
The newest version!
/*
* This file is part of AceQL.
* AceQL: Remote JDBC access over HTTP.
* Copyright (C) 2015, KawanSoft SAS
* (http://www.kawansoft.com). All rights reserved.
*
* AceQL 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.
*
* AceQL 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.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*
* Any modifications to this file must keep this entire header
* intact.
*/
package org.kawanfw.sql.servlet;
import java.io.File;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import org.kawanfw.commons.api.server.CommonsConfigurator;
import org.kawanfw.commons.server.util.ServerLogger;
import org.kawanfw.commons.util.FrameworkDebug;
import org.kawanfw.file.api.server.FileConfigurator;
import org.kawanfw.file.servlet.CommonsConfiguratorCall;
import org.kawanfw.file.servlet.ServerUserThrowable;
/**
* Tests that all configurators methods are correct. set properties if not, with
* Exception & associated message.
*
* @author Nicolas de Pomereu
*
*/
public class ConfiguratorMethodsTester {
private static boolean DEBUG = FrameworkDebug
.isSet(ConfiguratorMethodsTester.class);
private CommonsConfigurator commonsConfigurator = null;
private FileConfigurator fileConfigurator = null;
/** The Exception */
private Exception exception = null;
/** The init error message trapped */
private String initErrrorMesage = null;
/**
* Constructor
*
* @param commonsConfigurator
* @param fileConfigurator
*/
public ConfiguratorMethodsTester(CommonsConfigurator commonsConfigurator,
FileConfigurator fileConfigurator) {
this.commonsConfigurator = commonsConfigurator;
this.fileConfigurator = fileConfigurator;
}
/**
*
* @return the Exception thrown
*/
public Exception getException() {
return exception;
}
/**
*
* @return the the label of the exception thrown
*/
public String getInitErrrorMesage() {
return initErrrorMesage;
}
/**
* Test the configurators main methods to see if they throw Exceptions
*/
public void testMethods() {
// Fist thing to do: Stores in static memory the user settings for this
// transaction
// This method will also test the Connection is created, otw a
// detailed Exception is thrown
debug("initErrrorMesage: " + initErrrorMesage);
debug("Before commonsConfigurator.login.");
if (exception == null) {
// Test that the login method does not throw an Exception
@SuppressWarnings("unused")
boolean isOk = false;
try {
debug("In commonsConfigurator.login.");
isOk = commonsConfigurator
.login("dummy", "dummy".toCharArray());
debug("After new commonsConfigurator.login.");
} catch (Exception e) {
debug("Exception thrown: " + e.toString());
initErrrorMesage = ServerUserThrowable.getErrorMessage(
commonsConfigurator, "login");
exception = e;
}
}
if (exception == null) {
try {
@SuppressWarnings("unused")
File serverRootFile = fileConfigurator.getServerRoot();
} catch (Exception e) {
initErrrorMesage = ServerUserThrowable.getErrorMessage(
commonsConfigurator, "getServerRoot");
exception = e;
}
}
if (exception == null) {
try {
@SuppressWarnings("unused")
boolean oneRooPerUserName = fileConfigurator
.useOneRootPerUsername();
} catch (Exception e) {
initErrrorMesage = ServerUserThrowable.getErrorMessage(
commonsConfigurator, "useOneRootPerUsername");
exception = e;
}
}
if (exception == null) {
try {
@SuppressWarnings("unused")
String tokenRecomputed = CommonsConfiguratorCall
.computeAuthToken(commonsConfigurator, "dummy");
} catch (Exception e) {
initErrrorMesage = ServerUserThrowable.getErrorMessage(
commonsConfigurator, "getServerRoot");
exception = e;
}
}
if (exception == null) {
try {
@SuppressWarnings("unused")
boolean forceHttps = CommonsConfiguratorCall
.forceSecureHttp(commonsConfigurator);
} catch (Exception e) {
initErrrorMesage = ServerUserThrowable.getErrorMessage(
commonsConfigurator, "forceSecureHttp");
exception = e;
}
}
if (exception == null) {
try {
@SuppressWarnings("unused")
Set usernameSet = CommonsConfiguratorCall
.getBannedUsernames(commonsConfigurator);
} catch (Exception e) {
initErrrorMesage = ServerUserThrowable.getErrorMessage(
commonsConfigurator, "getBannedUsernames");
exception = e;
}
}
if (exception == null) {
try {
@SuppressWarnings("unused")
List ipsBlacklist = CommonsConfiguratorCall
.getIPsBlacklist(commonsConfigurator);
} catch (Exception e) {
initErrrorMesage = ServerUserThrowable.getErrorMessage(
commonsConfigurator, "getIPsBlacklist");
exception = e;
}
}
if (exception == null) {
try {
@SuppressWarnings("unused")
List ipsWhitelist = CommonsConfiguratorCall
.getIPsWhitelist(commonsConfigurator);
} catch (Exception e) {
initErrrorMesage = ServerUserThrowable.getErrorMessage(
commonsConfigurator, "getIPsWhitelist");
exception = e;
}
}
if (exception == null) {
try {
@SuppressWarnings("unused")
char[] encryptionPassword = CommonsConfiguratorCall
.getEncryptionPassword(commonsConfigurator);
} catch (Exception e) {
initErrrorMesage = ServerUserThrowable.getErrorMessage(
commonsConfigurator, "getEncryptionPassword");
exception = e;
}
}
}
/**
* debug
*/
public static void debug(String s) {
if (DEBUG) {
try {
ServerLogger.getLogger().log(Level.WARNING, s);
} catch (Exception e1) {
System.out.println(s);
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy