Skip to content

The open tool development kit provides java libraries for efficient implementation of data processing tools. Primarily the libraries have been build to close gaps within the process of test automation, but they can be helpful for implementing any application that needs to collect data from different sources, transform the data and generate outpu…

License

LK-Test-Solutions/OpenTDK

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenTDK

Property Value
Maturity moderate stable
Author LK Test Solutions GmbH
License BSD 2-Clause "Simplified"
Documentation, Tutorials, Samples GitHub Repsoitory OpenTDK_Labs
Download Binaries Releases

Maven

<dependency>
   <groupId>org.opentdk</groupId>
   <artifactId>opentdk-api</artifactId>
   <version>1.6.1</version>
</dependency> 

The Open Tool Development Kit provides packages and classes for easy implementation of java tools or applications. Developers don't need to take care about implementing code for the handling of data souces. Once a data source is required within an application it can be connected to the application by one of the concepts, provided by OpenTDK. These data sources can be configuration files, result sets of DB requests, Webservice responses (JSON, XML, YAML) and several more. There are two java projects includes in this repository, which are:

Project name Project purpose
opentdk_api Implements the functional concepts of OpenTDK to create non-GUI applications
opentdk_gui Implements concepts and base classes to create JavaFX GUI applications
opentdk_test Implements java classes, used for regression test of OpenTDK

The opentdk_api project includes the following packages:

Base Application

The package org.opentdk.api.application is used to implement base classes that can be inherited by the classes created for a new non-GUI java applications. In the current stage there is only a dispatcher class EBaseSettings that shows how to setup application settings that will be connected to a XML structure.

DataContainer

The package org.opentdk.api.datastorage implements a concept to access data from different source using unified methods for several tabular and tree formats. The methods for accessing data are defined within the class org.opentdk.api.datastorage.DataContainer which adapts container classes for specific formats. Currently available are the following container classes:

  • CSVDataContainer: Adapts the functionality to access data in tabular format that can be read from and written to column separated files
  • PropertiesDataContainer: Adapts funktionality to access data of properties files with key/value pairs per row, separated by = symbol
  • RSDataContainer: Adapts functionality to acces data from tabular result sets received by SQL requests
  • XMLDataContainer: Adapts funktionality to acces data in XML format
    Due to the adaption technique, the package can be extended for nearly any tabular or tree format by implementing format specific DataContainers. There are nearly no code changes required in case that the data source of a DataContainer object will change.

Sample usage:

A java application is using a DataContainer to load settings from a .properties file at runtime. The .properties file includes key/value pairs like Language=german. Now it is planned to change from the current .properties format to a .xml format where the same information is stored in tags like <Language>german</Language>. In case the tag Language is unique in the .xml file, then no change is required except assign the new file name AppSettings.xml to the String variable settingsFile. The following is a complete code sample for loading the content of a file into a DataContainer and getting a value of a defined field (column or node):
String settingsFile = "AppSettings.properties";
DataContainer dc = new DataContainer(settingsFile);
dc.getValue("Language");

Dispatcher

The package org.opentdk.api.dispatcher is designed to implement classes with constants that have attributes and methods, similar to the standard Java Enum type. The constants will be declared as objects of type org.opentdk.api.dispatcher.BaseDispatcherComponent and each object represents a field within a org.opentdk.api.datastorage.DataContainer. This allows to pre-define the data model of a org.opentdk.api.datastorage.DataContainer within a dispatcher class and to perform all getter, setter and other methods on the fields within the org.opentdk.api.datastorage.DataContainer.

Sample usage:

A dispatcher class is defined to setup the logger settings for an application and the values assigned to the constants are read within the application by calling their getValue method.

  • Dispatcher Class
    public class EBaseSettings extends BaseDispatcher {
    public static final BaseDispatchComponent APP_LOGFILE = new BaseDispatchComponent(EBaseSettings.class, "Logfile", "/AppSettings", "./logs/Application.log");
    public static final BaseDispatchComponent APP_LOGFILE_LIMIT = new BaseDispatchComponent(EBaseSettings.class, "LogFileLimit", "/AppSettings", "4000");
    public static final BaseDispatchComponent APP_LOGFILE_KEEP_AGE = new BaseDispatchComponent(EBaseSettings.class, "LogKeepAge", "/AppSettings", "90");
    public static final BaseDispatchComponent APP_TRACE_LEVEL = new BaseDispatchComponent(EBaseSettings.class, "TraceLevel", "/AppSettings", "1");
    }

  • Usage within application
    /* Assign XML file to the dispatcher */
    EBaseSettings.setDataContainer(EBaseSettings.class, "config/myAppSettings.xml");
    /* Get value from a constant that corresponds with a XML tag within the file */
    EBaseSettings.APP_LOGFILE.getValue(); // returns "./logs/Application.log" (the defautl value defined in declaration of the constant APP_LOGFILE)
    EBaseSettings.APP_TRACE_LEVEL.getValue(); // returns 3 (the value defined in myAppSettings.xml)

  • Content of myAppSettings.xml
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <AppSettings>
    <TraceLevel>3</TraceLevel>
    </AppSettings>

Logger

The class org.opentdk.api.logger.MLogger can be used in a static way without any further setup or initialization, to log messages at runtime of an application into a log file.
With its implemented default behaviour the MLogger will write all messages of level SEVERE into the file Application.log within a folder logs relative to the current working directory. The logfile will be automatically cleared, once a size of 10 MB has been reached and its content will be moved into an archive file with a date prefix in the file name. When an archived files has reached an age of 30 days, it will be deleted next time when the MLogger is called, in case the log file setting will not change.

Sample usage:

/* Change the behaviour */
MLogger.getInstance().setLogFile("c:/temp/logs/myJavaApp.log");
MLogger.getInstance().setTraceLevel(3); // Log all messages (Error, Warning and Information)
MLogger.getInstance().setLogKeepAge(100); // Keep archived log files for 100 days

/* Log an error message */
MLogger.getInstance().log(Level.SEVERE, "The mesh trace string has the wrong format! ", FileUtil.class.getSimpleName(), "createResultsFileName");

About

The open tool development kit provides java libraries for efficient implementation of data processing tools. Primarily the libraries have been build to close gaps within the process of test automation, but they can be helpful for implementing any application that needs to collect data from different sources, transform the data and generate outpu…

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages