Skip to content
Snippets Groups Projects
Commit acddacf7 authored by ribeaudc's avatar ribeaudc
Browse files

fix: - Integration tests.

SVN: 7547
parent 2fd7878e
No related branches found
No related tags found
No related merge requests found
...@@ -39,6 +39,8 @@ public final class LogInvocationHandler implements InvocationHandler ...@@ -39,6 +39,8 @@ public final class LogInvocationHandler implements InvocationHandler
private final Class<?> classUsedToNameLogger; private final Class<?> classUsedToNameLogger;
private final boolean onlyIfAnnotated;
/** /**
* Creates a new instance. * Creates a new instance.
* *
...@@ -49,11 +51,28 @@ public final class LogInvocationHandler implements InvocationHandler ...@@ -49,11 +51,28 @@ public final class LogInvocationHandler implements InvocationHandler
*/ */
public LogInvocationHandler(final Object object, final String name, final Level logLevel, public LogInvocationHandler(final Object object, final String name, final Level logLevel,
final Class<?> classUsedToNameLogger) final Class<?> classUsedToNameLogger)
{
this(object, name, logLevel, classUsedToNameLogger, false);
}
/**
* Creates a new instance.
*
* @param object Object whose invocations should be logged.
* @param name Meaningful name of <code>object</code>. Will be used in the log message.
* @param logLevel The log level to use for normal (successful) events.
* @param classUsedToNameLogger Class used to specify the name of the logger.
* @param onlyIfAnnotated whether the log should be activated only if method is annotated with
* {@link LogAnnotation}.
*/
public LogInvocationHandler(final Object object, final String name, final Level logLevel,
final Class<?> classUsedToNameLogger, final boolean onlyIfAnnotated)
{ {
this.object = object; this.object = object;
this.name = name; this.name = name;
this.defaultLogLevel = logLevel; this.defaultLogLevel = logLevel;
this.classUsedToNameLogger = classUsedToNameLogger; this.classUsedToNameLogger = classUsedToNameLogger;
this.onlyIfAnnotated = onlyIfAnnotated;
} }
public Object invoke(final Object proxy, final Method method, final Object[] args) public Object invoke(final Object proxy, final Method method, final Object[] args)
...@@ -78,57 +97,65 @@ public final class LogInvocationHandler implements InvocationHandler ...@@ -78,57 +97,65 @@ public final class LogInvocationHandler implements InvocationHandler
throw t; throw t;
} finally } finally
{ {
final Level logLevel = getLogLevel(method); final LogAnnotation logAnnotationOrNull = tryGetAnnotation(method);
final Logger logger = createLogger(method); if (onlyIfAnnotated == false || logAnnotationOrNull != null)
if (throwable != null || logger.isEnabledFor(logLevel))
{ {
final StringBuilder builder = final Level logLevel = getLogLevel(method, logAnnotationOrNull);
new StringBuilder(throwable == null ? "Successful" : "Failed"); final Logger logger = createLogger(method, logAnnotationOrNull);
builder.append(" invocation of "); if (throwable != null || logger.isEnabledFor(logLevel))
builder.append(name).append('.').append(method.getName()).append('(');
if (args != null)
{ {
for (int i = 0; i < args.length; i++) final StringBuilder builder =
new StringBuilder(throwable == null ? "Successful" : "Failed");
builder.append(" invocation of ");
builder.append(name).append('.').append(method.getName()).append('(');
if (args != null)
{ {
builder.append(args[i]); for (int i = 0; i < args.length; i++)
if (i < args.length - 1)
{ {
builder.append(", "); builder.append(args[i]);
if (i < args.length - 1)
{
builder.append(", ");
}
} }
} }
} builder.append(") took ").append(System.currentTimeMillis() - time).append(
builder.append(") took ").append(System.currentTimeMillis() - time).append(" msec"); " msec");
if (throwable == null) if (throwable == null)
{ {
logger.log(logLevel, builder.toString()); logger.log(logLevel, builder.toString());
} else } else
{ {
logger.error(builder.toString(), throwable); logger.error(builder.toString(), throwable);
}
} }
} }
} }
} }
private final Level getLogLevel(final Method method) private final LogAnnotation tryGetAnnotation(final Method method)
{
return method.getAnnotation(LogAnnotation.class);
}
private final Level getLogLevel(final Method method, final LogAnnotation annotationOrNull)
{ {
final LogAnnotation annotation = method.getAnnotation(LogAnnotation.class); if (annotationOrNull == null)
if (annotation == null)
{ {
return Level.DEBUG; return Level.DEBUG;
} else if (annotation.logLevel().equals(LogLevel.UNDEFINED)) } else if (annotationOrNull.logLevel().equals(LogLevel.UNDEFINED))
{ {
return defaultLogLevel; return defaultLogLevel;
} else } else
{ {
return Log4jSimpleLogger.toLog4jPriority(annotation.logLevel()); return Log4jSimpleLogger.toLog4jPriority(annotationOrNull.logLevel());
} }
} }
private final Logger createLogger(final Method method) private final Logger createLogger(final Method method, final LogAnnotation annotationOrNull)
{ {
final LogAnnotation annotation = method.getAnnotation(LogAnnotation.class);
final LogCategory logCategory = final LogCategory logCategory =
(annotation == null) ? LogCategory.OPERATION : annotation.logCategory(); (annotationOrNull == null) ? LogCategory.OPERATION : annotationOrNull.logCategory();
return LogFactory.getLogger(logCategory, classUsedToNameLogger); return LogFactory.getLogger(logCategory, classUsedToNameLogger);
} }
} }
\ No newline at end of file
...@@ -597,7 +597,7 @@ function assert_correct_content_of_processing_dir { ...@@ -597,7 +597,7 @@ function assert_correct_content_of_processing_dir {
assert_same_content $TEST_DATA/3VCP1 $data_set assert_same_content $TEST_DATA/3VCP1 $data_set
assert_same_content $TEMPLATE/openBIS-client/testdata/register-experiments/processing-parameters.txt \ assert_same_content $TEMPLATE/openBIS-client/testdata/register-experiments/processing-parameters.txt \
$DATA/processing-dir/processing-parameters-from-openbis $DATA/processing-dir/processing-parameters-from-openbis
local bds_container=$DATA/main-store/Instance_integration-test/Group_CISD/Project_NEMO/Experiment_EXP1/ObservableType_HCS_IMAGE/Sample_3VCP1/ local bds_container=$DATA/main-store/Instance_CISD/Group_CISD/Project_NEMO/Experiment_EXP1/ObservableType_HCS_IMAGE/Sample_3VCP1/
bds_container=$bds_container`ls -1 $bds_container | head -1` bds_container=$bds_container`ls -1 $bds_container | head -1`
assert_dir_exists $bds_container assert_dir_exists $bds_container
local data_set2=$bds_container/data/original/microX_200801011213_3VCP1 local data_set2=$bds_container/data/original/microX_200801011213_3VCP1
...@@ -609,7 +609,7 @@ function assert_correct_content_of_plate_3VCP1_in_store { ...@@ -609,7 +609,7 @@ function assert_correct_content_of_plate_3VCP1_in_store {
local cell_plate=3VCP1 local cell_plate=3VCP1
echo ==== assert correct content of plate 3VCP1 in store ==== echo ==== assert correct content of plate 3VCP1 in store ====
local main_dir=$DATA/main-store/Instance_integration-test/Group_CISD/Project_NEMO/Experiment_EXP1 local main_dir=$DATA/main-store/Instance_CISD/Group_CISD/Project_NEMO/Experiment_EXP1
local raw_data_dir=$main_dir/ObservableType_HCS_IMAGE/Sample_3VCP1/ local raw_data_dir=$main_dir/ObservableType_HCS_IMAGE/Sample_3VCP1/
assert_dir_exists $raw_data_dir assert_dir_exists $raw_data_dir
# Picks up the first directory found # Picks up the first directory found
...@@ -652,7 +652,7 @@ function assert_correct_content_of_plate_3VCP1_in_store { ...@@ -652,7 +652,7 @@ function assert_correct_content_of_plate_3VCP1_in_store {
assert_equals_as_in_file microX $metadata_dir/data_set/producer_code assert_equals_as_in_file microX $metadata_dir/data_set/producer_code
assert_equals_as_in_file 3VCP1 $metadata_dir/sample/code assert_equals_as_in_file 3VCP1 $metadata_dir/sample/code
assert_equals_as_in_file CELL_PLATE $metadata_dir/sample/type_code assert_equals_as_in_file CELL_PLATE $metadata_dir/sample/type_code
assert_equals_as_in_file integration-test $metadata_dir/experiment_identifier/instance_code assert_equals_as_in_file CISD $metadata_dir/experiment_identifier/instance_code
assert_equals_as_in_file CISD $metadata_dir/experiment_identifier/group_code assert_equals_as_in_file CISD $metadata_dir/experiment_identifier/group_code
assert_equals_as_in_file NEMO $metadata_dir/experiment_identifier/project_code assert_equals_as_in_file NEMO $metadata_dir/experiment_identifier/project_code
assert_equals_as_in_file EXP1 $metadata_dir/experiment_identifier/experiment_code assert_equals_as_in_file EXP1 $metadata_dir/experiment_identifier/experiment_code
...@@ -692,14 +692,14 @@ function assert_correct_content_of_invalid_plate_in_store { ...@@ -692,14 +692,14 @@ function assert_correct_content_of_invalid_plate_in_store {
local data_set=$error_dir/microX_200801011213_$cell_plate local data_set=$error_dir/microX_200801011213_$cell_plate
assert_same_content $TEST_DATA/$cell_plate $data_set assert_same_content $TEST_DATA/$cell_plate $data_set
assert_file_exists $data_set.exception assert_file_exists $data_set.exception
assert_dir_empty $DATA/main-store/Instance_integration-test/Group_CISD/Project_NEMO/Experiment_EXP1/ObservableType_HCS_IMAGE/Sample_$cell_plate assert_dir_empty $DATA/main-store/Instance_CISD/Group_CISD/Project_NEMO/Experiment_EXP1/ObservableType_HCS_IMAGE/Sample_$cell_plate
} }
function assert_correct_content_of_image_analysis_data { function assert_correct_content_of_image_analysis_data {
local cell_plate=$1 local cell_plate=$1
echo ==== check image analysis data for cell plate $cell_plate ==== echo ==== check image analysis data for cell plate $cell_plate ====
local img_analysis=$DATA/main-store/Instance_integration-test/Group_CISD/Project_NEMO/Experiment_EXP1/ObservableType_HCS_IMAGE_ANALYSIS_DATA/Sample_$cell_plate/ local img_analysis=$DATA/main-store/Instance_CISD/Group_CISD/Project_NEMO/Experiment_EXP1/ObservableType_HCS_IMAGE_ANALYSIS_DATA/Sample_$cell_plate/
assert_dir_exists $img_analysis assert_dir_exists $img_analysis
# Picks up the first directory found # Picks up the first directory found
img_analysis=$img_analysis`ls -1 $img_analysis | head -1` img_analysis=$img_analysis`ls -1 $img_analysis | head -1`
......
# Code of openBIS instance # Code of openBIS instance
instance-code = integration-test instance-code = CISD
# The root directory of the data store # The root directory of the data store
storeroot-dir = ../data/main-store storeroot-dir = ../data/main-store
...@@ -59,6 +59,7 @@ inputs=raw-data,image-analysis ...@@ -59,6 +59,7 @@ inputs=raw-data,image-analysis
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# The directory to watch for incoming data. # The directory to watch for incoming data.
raw-data.incoming-dir = ../data/out-raw raw-data.incoming-dir = ../data/out-raw
raw-data.group-code = CISD
# The extractor plugin class to use for data set information extraction # The extractor plugin class to use for data set information extraction
raw-data.data-set-info-extractor = ch.systemsx.cisd.etlserver.threev.DataSetInfoExtractorForDataAcquisition raw-data.data-set-info-extractor = ch.systemsx.cisd.etlserver.threev.DataSetInfoExtractorForDataAcquisition
...@@ -94,6 +95,7 @@ raw-data.storage-processor.file-extractor = ch.systemsx.cisd.etlserver.imsb.HCSI ...@@ -94,6 +95,7 @@ raw-data.storage-processor.file-extractor = ch.systemsx.cisd.etlserver.imsb.HCSI
# image-analysis thread # image-analysis thread
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
image-analysis.incoming-dir = ../data/out-analysis image-analysis.incoming-dir = ../data/out-analysis
image-analysis.group-code = CISD
image-analysis.data-set-info-extractor = ch.systemsx.cisd.etlserver.threev.DataSetInfoExtractorForImageAnalysis image-analysis.data-set-info-extractor = ch.systemsx.cisd.etlserver.threev.DataSetInfoExtractorForImageAnalysis
# Separator used to extract the barcode in the data set file name # Separator used to extract the barcode in the data set file name
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment