Java, NoSQL, SQL, REST API and other scary words

Angular JS – implement Emoji

Today I’ll show you how to implement custom emoji (in fact – how to replace any text with any image) with AngularJS. In fact, that will kill you browser, cause this is a pretty heaven operation and for the chat application, which refreshes every 3 seconds, such kind of solution is a real disaster.

So, the first step is to implement custom binding for your text, you could easily do it this way:

2017-03-27_12-02-15

As you can see – I’m using emoji function here, and here is my code listing:

var emoticons = {
 ':)' : getUrlToMessages +'img_smile.png',
 ':(' : getUrlToMessages +'img_sad.png',
 ':D' : getUrlToMessages +'img_haha.png',
 ':o' : getUrlToMessages +'img_omg.png'
 }, patterns = [], metachars = /[[\]{}()*+?.\\|^$\-,&#\s]/g;

$scope.emoji = function(message){
   if (message != null){
   // build a regex pattern for each defined property
   for (var i in emoticons) {
     if (emoticons.hasOwnProperty(i)){ // escape metacharacters
     patterns.push('('+i.replace(metachars, "\\$&")+')');
     }
   }
   // build the regular expression and replace
   return message.replace(new RegExp(patterns.join('|'), 'g'), function (match) {
     var escape = typeof emoticons[match] != 'undefined' ? '<img src="' + emoticons[match] + '" />' : match;
     return $sce.trustAsHtml(escape);
   });
 }
}

As far as I don’t want to use any custom images,  I’ll just use decimal code emoji. This is not so straightforward cause Angular’s $sanitize service attempts to convert the characters to their HTML-entity equivalent.  To avoid that HTML going through $sanitize – pass your string through $sce.trustAsHtml:

$scope.emoji = function(message){
 return $sce.trustAsHtml(message);
 }

 

Standard
Java, NoSQL, SQL, REST API and other scary words

Cassandra Datastax and Java – best way to set up connection

I’ll research the best way to make a connection from my Java to Cassandra here. There are a lot of examples how to do that, but the main thing, but I’m developing some kind of chat application on my localhost (will do single insert/update statements, etc.) when all this Spark examples are perfect for analytical workflows.

The first one example is Spark 1.6:

public static JavaSparkContext getCassandraConnector(){
         SparkConf conf = new SparkConf();
         conf.setAppName("Chat");
         conf.set("spark.driver.allowMultipleContexts", "true");
         conf.set("spark.cassandra.connection.host", "127.0.0.1");
         conf.set("spark.rpc.netty.dispatcher.numThreads","2");
         conf.setMaster("local[2]");

         JavaSparkContext sc = new JavaSparkContext(conf);
         return sc;
    }

So, I also got an example for Spark 2.x where the builder will automatically reuse an existing SparkContext if one exists and create a SparkContext if it does not exist. Configuration options set in the builder are automatically propagated over to Spark and Hadoop during I/O. Continue reading

Standard
QA (eng)

QA terms and questions

What are different types of software testing?

Note: Except the Shakeout testing and Unit testing which are respectively done by the CMT and Coder/Developer, all other testing are done by the QA Engineer (Tester).

1) Unit testing: It is a test to check the code whether it is properly working or not as per the requirement.  It is done by the developers (Not testers).

2) Shakeout testing: This test is basically carried out to check the networking facility, database connectivity and the integration of modules. (It is done by the Configuration Team)

3) Smoke testing: It is an initial set of test to check whether the major functionalities are working or not and also to check the major breakdowns in the application. It is the preliminary test carried out by the SQA tester.

4) Functional testingal It is a test to check whether each and every functionality of that application is working as per the requirement. It is major test where 80% of the tests are done. In this test, the Test Cases are ‘executed’.

5) Integration testing: It is a test to check whether all the modules are combined together or not and working successfully as specified in the requirement

6) Regression testing: When a functionality is added to an application, we need to make sure that the newly added functionality does not break the application.  In order to make it sure, we perform a repeated testing which is called Regression Testing.  We also do regression testing after the developers fix the bugs.  See the video below for more understanding. (Courtesy of guru99.com).

7) System testing: Testing which is based on overall requirements specification and it covers all combined parts of a system. It is also a black box type of testing. System testing is black box testing, performed by the Test Team, and at the start of the system testing the complete system is configured in a controlled environment. System testing simulates real life scenarios that occur in a “simulated real life” test environment and test all functions of the system that are required in real life. Upon completion of integration testing, system testing is started. Before system testing, all unit and integration test results are reviewed by Software QA to ensure all problems have been resolved.

8) Load testing: It is a test to check the user’s response time of number of users using any one scenario (single business process) of the same application at the same time.

9) Stress testing: In this type of testing the application is tested against heavy load such as complex numerical values, large number of inputs, large number of queries etc. which checks for the stress/load the applications can withstand.

10) Performance testing: It is a test to check the user’s response time of number of users using multiple scenarios (multiple business process) of the same application at the same time.

11) User acceptance testing: In this type of testing, the software is handed over to the user in order to find out if the software meets the user expectations and works as it is expected to.

12) Black box testing: It is test where a tester performs testing without looking into the code. OR A testing method where the application under test is viewed as a black box and the internal behavior of the program is completely ignored. Testing occurs based upon the external specifications. Also known as behavioral testing, since only the external behavior of the program is evaluated and analyzed.

13) White box testing: It is a test where a tester looks into the code and performs the testing.

14) Alpha testing: In this type of testing, the users are invited at the development center where they use the application and the developers note every particular input or action carried out by the user. Any type of abnormal behavior of the system is noted and rectified by the developers.

15) Beta testing: In this type of testing, the software is distributed as a beta version to the users and users test the application at their sites. As the users explore the software, in case if any exception/defect occurs that is reported to the developers.

16) Acceptance testing: Is black box testing that gives the client/customer/project manager the opportunity to verify the system functionality and usability prior to the system being released to production. The acceptance test is the responsibility of the client/customer or project manager, however, it is conducted with the full support of the project team. The test team also works with the client/customer/project manager to develop the acceptance criteria.

17) Recovery/error testing: Is testing how well a system recovers from crashes, hardware failures, or other catastrophic problems.

18) Security/penetration testing: Is testing how well the system is protected against unauthorized internal or external access, or willful damage. This type of testing usually requires sophisticated testing techniques.

19) Compatibility testing: Is testing how well software performs in a particular hardware, software, operating system, or network environment.

20) Comparison testing:  Is testing that compares software weaknesses and strengths to those of competitors’ products.

21) Incremental testing: After unit testing is completed, developer performs integration testing. It is the process of verifying the interfaces and interaction between modules. While integrating, there are lots of techniques used by developers and one of them is the incremental approach. In Incremental integration testing, the developers integrate the modules one by one using stubs or drivers to uncover the defects. This approach is known as incremental integration testing. To the contrary, big bang is one other integration testing technique, where all the modules are integrated in one shot.

22) End-to-end testing: End-to-end testing is a technique used to test whether the flow of an application right from start to finish is behaving as expected. The purpose of performing end-to-end testing is to identify system dependencies and to ensure that the data integrity is maintained between various system components and systems. The entire application is tested for critical functionalities such as communicating with the other systems, interfaces, database, network, and other applications.

23) Sanity testing: Sanity testing, a software testing technique performed by the test team for some basic tests. The aim of basic test is to be conducted whenever a new build is received for testing. The terminologies such as Smoke Test or Build Verification Test or Basic Acceptance Test or Sanity Test are interchangeably used, however, each one of them is used under a slightly different scenario. Sanity test is usually unscripted, helps to identify the dependent missing functionalities. It is used to determine if the section of the application is still working after a minor change. Sanity testing can be narrow and deep. Sanity test is a narrow regression test that focuses on one or a few areas of functionality.

24) Usability testing: Usability testing is a way to see how easy to use something is by testing it with real users. Users are asked to complete tasks, typically while they are being observed by a researcher, to see where they encounter problems and experience confusion.

25) Install/uninstall testing: Installation Testing: It is performed to verify if the software has been installed with all the necessary components and the application is working as expected. This is very important as installation would be the first user interaction with the end users. Companies launch Beta Version just to ensure smoother transition to the actual product. Uninstallation Testing: Uninstallation testing is performed to verify if all the components of the application is removed during the process or NOT. All the files related to the application along with its folder structure have to be removed upon successful uninstallation. Post Uninstallation System should be able to go back to the stable state.

26) Exploratory testing, ad-hoc testing: Exploratory testing is a hands-on approach in which testers are involved in minimum planning and maximum test execution. The planning involves the creation of a test charter, a short declaration of the scope of a short (1 to 2 hour) time-boxed test effort, the objectives and possible approaches to be used.

27) Mutation testing: Mutation Testing is a type of software testing where we mutate (change) certain statements in the source code and check if the test cases are able to find the errors. It is a type of white box testing which is mainly used for unit testing. The changes in mutant program are kept extremely small, so it does not affect the overall objective of the program. The goal of Mutation Testing is to assess the quality of the test cases which should be robust enough to fail mutant code. This method is also called as Fault based testing strategy as it involves creating fault in the program

What is Negative Testing?

Testing the system or application using negative data is called negative testing, for example, testing password entering 6 characters where it should be 8 characters should display a message.

When we test an application by putting negative values (instead of actual values), then the system should not allow the other values rather than the actual value.  The system should give an message that the value is not correct.  This is called negative testing.
Another example is, if a user tries to type a letter in a numeric field, the correct behavior in this case would be to display the “Incorrect data type, please enter a number” message. The purpose of negative testing is to detect such situations and prevent applications from crashing. Also, negative testing helps you improve the quality of your application and find its weak points. (source: Jerry Ruban)

What is a Test Plan?

A Test Plan is a document describing the scope, approach, resources, and schedule of intended testing activities. It identifies test items, the features to be tested, the testing tasks and who will do each task (roles and responsibilities) and any risks and its solutions.

A Test Plan includes Heading, Revision History, Table of Contents, Introduction, Scope, Approach, Overview, different types of testing that will be carried out, what software and hardware will be required, issues, risks, assumptions and sign off section. Continue reading

Standard
QA (eng)

Test Framework build 1.0

So, my latest and greatest framework build is ready (available at BickBucket, I could share the access, but it will be no core test methods, cause they came from my work and I can’t share them). This is a link to the overall description of the very first version of it. Framework available for every QA in my company and instructions, manuals, key method descriptions and examples provided, for example:

  • Which method validates that alerts and warnings exists (with expected message) and how to close them.
  • Which one method hides/shows grid columns
  • Which one method checks special characters/too long value/empty value input into the text fields
  • Which method and how add/validates date or number fields input
  • Which one method opens row menu
  • Which one validates that value exists in the grid
  • And tens of others

I successfully made TeamCity project to run test suites for some of our components and every QA could create test and upload them to the test library:

12.png Continue reading

Standard
QA (eng)

Test Suite Report Builder Comparison

Here is a short comparison of for most popular ways to build test report for TestNG + Java framework (with comparison table in the end of the post).

Log4J

This is a pretty simple logger which throws test suite execution to the Windows Console, Eclipse Console and text file.

There is no screenshot capturing or easy navigation between multiple suites, so, this is just a huge text file.

1 Continue reading

Standard
QA (eng)

Test Framework (Java, TestNG, ANT, etc)

Introduction to Automation testing:

Testing is an essential part of a software development process. While testing intermediate versions of products/projects being developed, testing team needs to execute a number of test cases. In addition, prior to release every new version, it is mandatory that the version passed through a set of “regression” and “smoke” tests. Most of all such tests are standard for every new version of product/project, and therefore can be automated in order to save human resources and time for executing them.

Benefits of using automated testing are the following:

  • Reduction of tests’ time execution and human resources required
  • Complete control over the tests’ results (“actual results” vs “expected results”)
  • Possibility to quickly change test’s preconditions and input data, and re-run the tests dynamically with multiple sets of data

Automation workflow for the application can be presented as follows:

  • First of all it is required to identify tasks that an application has to accomplish.
  • Second, a set of necessary input data has to be created.
  • Third, expected results have to be defined in order one can judge that an application (a requested feature) works correspondingly.
  • Fourth, Executes a test.
  • Finally, Compares expected results with actual results, and decides whether the test has been passed successfully.

Goal:

The goal of this framework is to create a flexible and extendable automated testing framework, which should expand test coverage for as many solutions as possible. Framework must have input and output channels and library of methods to work with UI.

Environment Specifications:

  • Selenium Webdriver. Selenium is a suite of tools for cross-platform automated testing of web applications. It runs on many browsers and operating systems and can be controlled by many programming languages and testing frameworks. Selenium WebDriver is a functional automation tool to automate the applications. It makes direct calls to the browser using each native support for automation.
  • Eclipse IDE. Eclipse is an integrated development environment (IDE) used in computer programming, and is the most widely used Java IDE. It contains a base workspace and an extensible plug-in system for customizing the environment. Eclipse is written mostly in Java and its primary use is for developing Java applications.
  • Java.
  • TestNG. Is a testing framework inspired from JUnit and NUnit. It has extended new functionalities, which made it more powerful and easier than the other testing frameworks. It supports ReportNG (simple HTML reporting plug-in) and XLST (Graphical / Pictorial reports) plug-ins to customize or extend the default TestNG reporting style. TestNG also provides ability to implement ‘IReporter’ an interface which can be implemented to generate a Customized TestNG report by users. It has ‘generateReport()’ method which will be invoked after all the suite has completed its execution and gives the report into the specified output directory.
  • Apache Ant is a Java library and command-line tool whose mission is to drive processes described in build files as targets and extension points dependent upon each other. The main known usage of Ant is the build of Java applications.
  • AutoIT Tool used to handle Windows popups for Document Uploads and Downloads.
  • Apache POI to perform operations with excel like read, write and update the excel sheet
  • Webdriver is a driver that contains programming interface for controlling all kinds of possible actions in browser.
  • Selenium TakesScreenshot to take screenshot in case of error.
  • Log4j is a reliable, fast and flexible logging framework (APIs) written in Java, which is distributed under the Apache Software License.
  • JDBC. Java Database Connectivity (JDBC) is an application programming interface (API) for the programming language Java, which defines how a client may access a database. It is part of the Java Standard Edition platform, from Oracle Corporation.

Continue reading

Standard
Java, NoSQL, SQL, REST API and other scary words

Spark Dataset API implementation

Dataframes

Spark introduced Dataframes in Spark 1.3 release. Dataframe overcomes the key challenges that RDDs had.

A DataFrame is a distributed collection of data organized into named columns. It is conceptually equivalent to a table in a relational database or a R/Python Dataframe. Along with Dataframe, Spark also introduced catalyst optimizer, which leverages advanced programming features to build an extensible query optimizer.

Dataframe Features

  • Distributed collection of Row Object: A DataFrame is a distributed collection of data organized into named columns. It is conceptually equivalent to a table in a relational database, but with richer optimizations under the hood.
  • Data Processing: Processing structured and unstructured data formats (Avro, CSV, elastic search, and Cassandra) and storage systems (HDFS, HIVE tables, MySQL, etc). It can read and write from all these various datasources.
  • Optimization using catalyst optimizer: It powers both SQL queries and the DataFrame API. Dataframe use catalyst tree transformation framework in four phases,
  • 1.Analyzing a logical plan to resolve references 2.Logical plan optimization 3.Physical planning 4.Code generation to compile parts of the query to Java bytecode.
  • Hive Compatibility: Using Spark SQL, you can run unmodified Hive queries on your existing Hive warehouses. It reuses Hive frontend and MetaStore and gives you full compatibility with existing Hive data, queries, and UDFs.
  • Tungsten: Tungsten provides a physical execution backend whichexplicitly manages memory and dynamically generates bytecode for expression evaluation.
  • Programming Languages supported:
  • Dataframe API is available in Java, Scala, Python, and R.

Continue reading

Standard