Test-driven development(TDD) in the Spring framework.
TDD helps me speed up my software release cycles, and ensure that I end up with a high-quality product. Spring makes Java enterprise development much easy. Spring Boot, which we will use in this blog, is a project that does this task with excellence.
Follows are the steps to configure your spring boot framework with the Junit and Maven.
Step-1)Set up Spring boot with J-Unit testing Approach
After Set your maven dependencies , for spring-boot add following dependency for testing Approach.
I was trying to setup a maven project in eclipse via GIT. I had hoped, it will auto import the project into eclipse, but for some reason that did not happen.
This is what was done as a workaround:
Step:1 Checkout your repository in your system
File->import->Git->Project from Git->Clone URI->Enter Git Repository Details
Select Destination where you wanted to store your Git Repository
Step:2 Import your Project into Eclipse
File->import->maven->install or deploy an artifact to a Maven Repository
Once these steps are done, The project is browsable in eclipse!
Some Helpful Git Commands for the commandline:
git init — Initialize your directory with git.
git add FILE and git checkout — FILE To stage/unstage a file
git commit— To save your changes. This commit will be local
git stash and git stash pop — Stashes are back
git reset HEAD –hard Revert all your local changes
git log— Access all the history in the repository
git rebase –You can squash all the commits! (one should be carefull with this one)
git branch –You can create local branches,But keep the history linear
Hope this workaround and the commands are useful to a new user.
1/Select what you need from Spring INITIALIZR :: https://start.spring.io/
2/Download/Extract the zip && cd into it.
3/Create a git repo on xp-dev.com
4/Initialize Git repo:
a)git init
b)git add .
c)create .gitignore
d)git commit .
e)git remote add origin https://xp-dev.com/git/
f)git push -u origin master
5/Open IntelliJ
a) checkout https://xp-dev.com/git/
b) Goto Maven Projects and add the pom.xml(if not picked automagically by IntelliJ
c)Do deploy, I got a failing unit test, as I added spring-tests.
With the recent sloppiness in implementation of software & hardware and synergizing them into so called the being called IoT The time is appropriate that a defacto manifesto be brought in place for the artificial species called IoT.
I assume most of us are aware of the Three Laws by Isaac Asimov.
What I propose is build for the interacting robotics with lesser-minded-human-kind!
An equipment if called IoT should abide by:
It should be considered a legal offspring of the last hand-off human entity.
It should have an IDENTU mode that should let it spill out its purpose/identity/owners.
It should have safe mode where any voice may command it to stop the current action.(something like a STATUE/RESUME mode)
I did nothing, but slept through most of the day. And then late night this next challenge of deploying the hush-hush java app over the cloud started to bother me.(afterall it was not a totally unproductive day, thinking wise!)
And then, flash back to a few days, where comparisons were made, what I am doing (javascript ehew!) and what one of the current top living inspiration in the current world Elon Musk is doing, and then I went into sad slumber!
Then yesterday happened, and then it clicked:: we Java devs(web ones, not hard core jdk ones) are orchestrating everything in lifecycle of what Elon Musk is trying to do!
Here is the analogy(it can be extended wonderfully!):
The WAR(Web ARchieve)(sorry, I am old fashioned) is like the unmanned space ship.
The dev JVM is like simulated Mars environment.
The cloud is the SPACE where the bits travel to-and-fro in form of data/packets.
The machine IP Address is like the lat/long of where you want to deploy.
So my current app is in its final integraton phase(hush-hush…) and I am trying to accomplish Slide Driven Development.(nice term!).
Slice Driven Development :: A development approach where a feature/flow is shipped to staging environment as soon as it becomes usable.
Currently I(with @explorer) are trying to integrate all features/flow of the hush-hush app, While I am totally unsure/unaware how it will behave when deployed on staging/production environment. Therefore, I had come up with this approach :: The momemt a feature becomes bug-discoverable, it ought be shipped so that:
Move to the next flow..
Bugs can be quashed..
(most imp)Our path of going from dev–>staging–>production for any feature should be seamless and smooth like skating on butter!
And then, a Eureka moment happened!! And this blog post came about!
Your Takeaway: If you are on a team working with Elon Musk(or anyone trying to transport stuff from place X to place Y, in an unsure environment), you can leverage from the experience of thousand if not millions of deployments of web java developers trying to deploy WAR file formats from local dev JVM to production JVM.
If you are being tailgated, we recommend you follow this approach to come out of that situation!
Go Absolutely Slow!
YES, surprisingly it works out just fine!
Purpose: To know who is tail-gating you AND Why?
How it works?
If the vehicle following you sees you slowing down, they will have no choice to speed up (which means they were not following you) or look-you-in-the-eye. (either ways, the problem is solved!)
Benefits of slowing down…
By slowing down, you opened an opportunity to talk.. Human Connect!
By slowing down, maybe you can have a running conversation, you are driving + talking(giving direction who knows). Saves time!
By slowing down, you saved lifes! No stats but still true!
By slowing down, You enjoy the road-side scenary. (remember enjoy the journey not just the destination!)
By slowing down, You literally look the problem in the eye than running away from it.
There goes, we have the Slow Moving Manifesto!
Credits: Smita, Rachit + (KennyG played in our neighbouring park @ 1000 hrs) 🙂
4/Listen carefully :: “You may have to use type args more with lambda’s” https://youtu.be/oGll155-vuQ?t=721 So your principle of bringing least disruptive change FAILED!
5/Freeze the screen :: Which code is still less readable? https://youtu.be/oGll155-vuQ?t=830 Come on! Stop pushing #JEP286 #DieJEP286 IT DOES NOT MAKE SENSE. Simple!
6/Sadly the current Java architects are trying to add features to reduce developers time to build a feature. There are already players to do this: Spring et al. You should be focused to create the playground, and not the rules. Why can’t they understand this simple fact? Look at the earlier Java architects… Did they focus delivering a CS concept or ease of developer writing the code? Don’t outsmart Spring, Don’t outsmart IDE’s outsmart CS concepts and implement them in Java.
7/Improved Switch design is being talked about, this is a brainstorming topic, it does not make sense to show-off it *conceptually* here!
8/Value Types — Only needed if you are pixel developer or probably a compiler writer. A lot of people writing Java are Enterprise users. We have custom wrappers, and would *not* need Value Types. But nonetheless its a welcome feature!
9/Project Valhalla — Get a basic version out, build on it later. Do not try to deliver a 5 story building in one go. Deliver one layer per version.
10/The decision for priority of a feature should have been *complexity* and if some feature is wanted and do-able, IT SHOULD BE DONE AND NOT POSTPONED.
Couple of days back, 21-October-2016 everyone connected on the web experienced sluggishness in connecting to the normal sites and saw obstruction in their regular works.
The scenario can be visually described as follows:
Incase you might be wondering why this attack happened now, the internet is way mature, why can’t it protect itself from such attacks?
Well, then do read on…
The Players
From an ideal perspective the players in the attack are listed:
Users of the web (us) (attackers and victims)
ISP’s (medium through which attack was carried out)
Device Manufacturers (Things, which got compromised — zombies)
Regulatory Organizations (They are mostly sleeping or doing other important silly stuff, lets leave them out of this discussion)
The Premise
Let us look at those questions asked earlier and more:
What is dDos?
It stands for distributed Denial of Service. Consider your regular pesky thing that you have to do and can’t live without?(siblings,kids,neighbours.. anyhuman thing). They come nagging to you, you can handle it but maybe 10 requests in a day a max! The 11th request from that pesky thing will get a denial of service response!(simply a No!)
Now,Imagine yourself at a play house. And you are already having a minor headache(it was Friday, everyone was in the mood to relax). Multiply your single pesky thing with say 10, you are bombarded with pesky request from everywhere, what will happen to you? You might handle say 20 requests at that moment, looking at the situation, but a time will come soon where you will get exhausted and simply stop responding to important requests of like : open the door, and you are standing still!
It was waiting to happen, its like too many cooks, spoil the broth kinda scenario. Lot of unpatched/sloppy devices connected to the internet working for you and they all had a common zombie entry point, that simply got activated!
The internet is way mature, why can’t it protect itself from such attacks?
I am sure there are some orgn that were actually fighting this menace! Imagine a hospital unable to get reports of a patient in critical condition!So I am pretty sure what got reported and what actually got fixed and treated is somewhat different. So the internet is not at all mature, we are still not ready to have our life depend on it, our livelihood might depend on it but not life!So some orgn might be involved (even now) preventing many such attacks to keep the internet working, and some sleeping regulations might have also protected and saved us from a much more severe attack!
The rules are pretty simple, everyone is united on this matter and no one likes a dDos attack to happen! It actually interrupts normal/perceived flow of life on a day-to-day basis.
So basically its the attackers who (misued?) a compromised device and affected the network. Its pretty clear, there is something that needs to be fixed/controlled in the wild. And its not impossible..
Onto the solution then, shall we proceed?
The Solution
Two parts solution can be proposed:
Regulation. In an ideal world, regulation is already in place and device manufacturers are supposed to follow them and hence they are able to sell their products. So something stronger needs to be put in place for regulation. Say if a device is an IoT kinda device, then as per regulation it should be allowed to use 5% of the bandwidth. If its a phone or a computer, then it will not have such a restriction, or maybe it can have!
ISP Level Quota Software. ISP’s would want to pitch in this idea, where a custom configuration software would be installed at per user site and there based on the MAC address the bandwidth quotas can be defined. Say you got a new IoT device for your home, you will get to configure and set a max bandwidth that device is allowed to consume on your home network.
WhatsApp deviated from their no-advt policy just at the start of this month. That triggered everyone to start searching for alternatives to WhatsApp’s addiction!
Here is what I could find (and wanted to try) since then:
1/ Amity : They claim themselves to be the Interactive Messaging app, and they hail from Australia. Seems very exciting!
2/Allo : This is the recently launched chatbot from Google! I think this will win the race hands-down! Their AI is very slick and you maybe even (if I say so) more human than Siri! (what am I saying?)
Although there are other non-Zuckerberg players like: Telegram,Viber,Hike,WeChat,Skype But now the segmentation has started to take its evil form in! With WhatsApp you never needed to think if the other person might or might not have the software!Kudoz to them for launching the app for Symbian S60 platform!! But ever since FB took over, just as with the deviation from no-advt policy, who knows what level of invasion might creep in! :-/ Hence my motivation to stay away from any Zuck platform!
Coming to my current phone: Jolla: Sadly only whatsapp (dislike now) and telegram seem to work via ported android apps on Sailfish OS. I wanted to try out amity app and allo on Jolla but there’s a bit of an exercise involved over there to get things working!
Further, here @RL, we had thought of creating a messaging app ourselves couple of years ago! We thought of calling it ‘Z.(shout out to deamypixel@RL) It was build around the premise of adding a ‘Z to every greeting.
say: good morning, ‘Z says: good morningz
say hi, ‘Z says: hiz!
say bye, ‘Z says: byez!
Maybe when the right opportunity comes we will give a shot at churning this one out! Any collaborators?
Until then the search for the the whatsapp alternative is still on!
The Java deployment world is plagued with infra issues! Things we need to take care of:
Apache
Tomcat
RDBMS
Firewall/Ports
Shell accesses
Security/Encryption/Keys
File System Storage
Indexes corrupting and the list goes on…
So after my failed attempt to understand/decipher CORS issues on the AWS platform, I fortunately stumbled on google-cloud! And it is one hell of a bouquet of services for us petty and dev-ops-complaining Java folks!
So churn out a bitnami tomcat instance and you get the feel of the aws thing. For over a month now my google cloud app was(still is) talking to the mysql instance on aws, before that starts to drain my mini wallet, time to configure a mysql instance on google-cloud. And here are the steps:
Have access to the SSH into your google cloud instance working
Create following script (/home/bitnami/mysql-init):
UPDATE mysql.user SET Password=PASSWORD('NEW_PASSWORD') WHERE User='root';
FLUSH PRIVILEGES;
So it turns out to get mysql talking on your bitnami instance you only need to reset the password.
Further to enable remote access do this in
/opt/bitnami/mysql/my.cnf:
#bind-address=127.0.0.1
Next to enable remote mysql access via workbench you need to enable firewall ports to allow connections for tcp 3306 for a specific ip on your google cloud instance.
And there you go, you have a lot powerful config, much like aws ready to be used, backed by google!!