Today, a colleague asked me to help him write a REST API integration test. We use Spring’s MockMvc API to test the REST API. The application uses MongoDB with Spring Data MongoDB. The application uses both MongoTemplate and Mongo based repositories for working with MongoDB. To make tests work independent of MongoDB, we mock Spring MongoDB repository interfaces.
This is a great video that explains importance of developer testing in writing robust distributed system. She talked about unit testing, integration testing, and verification language that can be used to verify a system. Unit testing is the first thing a developer can do to make sure distributed system is correct. She shared a number of anecdotes in the talk that make this talk easy to understand.
Today, I faced a requirement where I need to implement file save functionality in an Angular 4 application. In this quick post, I will show you how to implement this functionality in Angular 4 using FileSaver.js module.
Angular 4 is a good choice for building modern web applications. It comes bundled with Test utilities that makes it easy to write good quality test cases quite easily. Angular official testing guide does a good job explaining how to get started with testing Angular components. One thing that it does not cover is how to test components that use two way data binding using
ngModel directive. Last week I had to write test case for a component that uses data binding so I end up learning a lot about testing such components. In this blog, I will share my learnings with you.
Welcome to the second post of X-things-I-learnt-reading-Y’s-source-code series. This week I decided to read source code of failsafe library. Continue reading “2 Things I learnt By Reading Failsafe Source code”
I use Angular 4 at work for building a single page application. Today, I faced the problem where I had to use different base paths for router and static assets. Angular makes use of the base href to tell router how to compose navigation URLs. If your application exists at the root, then you can use
/ as the
href value as shown below.
I wanted to use
/users as my application base for router and
/public as base for my assets.
If you build the project the Angular project for the production environment using the default values you will get the following
$ ng build -prod
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>SampleNgApp</title> <base href="/"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="icon" type="image/x-icon" href="favicon.ico"> <link href="styles.xxxx.bundle.css" rel="stylesheet"/></head> <body> <app-root>Loading...</app-root> </body> </html>
This generated page will not work as it router will use
/ as base for composing navigation URLs and static assets will be looked in the current directory.
To solve my problem, I used
—-deploy-url options as shown below.
$ ng build -prod --base-href /users --deploy-url /public
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>SampleNgApp</title> <base href="/users"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="icon" type="image/x-icon" href="favicon.ico"> <link href="/public/styles.xxxx.bundle.css" rel="stylesheet"/></head> <body> <app-root>Loading...</app-root> </body> </html>
This way I solved my problem.
I am happy to announce 0.4.0 version of strman library. strman is a Java 8 library to work with String. It implements a number of helper utility functions that you makes it easy to work with String. You can refer to strman documentation to learn about all the supported functions.
In this release, we have implemented following functions
- chop: This function chops the input String into parts
- dasherize: This function converts a underscored or camelized string into an dasherized one.
- humanize: This function converts an underscored, camelized, or dasherized string into a humanized one.
- lines: This function split input to lines
- zip: This function aggregates the contents of n strings into a single list of tuples.
- underscored: This function converts a camel or dashed string into an underscored one.
- isBlank: This function returns true if a string is blank or null and false otherwise.