Tuesday, October 11, 2016

Docker Cookbook



# Run this command to configure your shell: 
eval "$(docker-machine env default)"

# Delete all STOPPED docker containers
docker rm $(docker ps -aq)
 
# Delete all docker images (won't delete the images associated with running containers)
docker rmi $(docker images)
 
# Start a MySQL docker container
docker run -d -e MYSQL_ROOT_PASSWORD=password1 -e MYSQL_USER=psun -e MYSQL_PASSWORD=password1 -e MYSQL_DATABASE=psun_db --name mysql -p 3306:3306 mysql:latest
 
# Launch an interactive terminal to a running docker container
docker exec -it <container name> bash
 
# Show the container's latest 100 stdout logs 
docker logs <container name> | trail -n 100
# Follow a container's stdout
docker logs -f <container name>

Monday, October 10, 2016

Monday, August 22, 2016

Linux shell cheat sheet


ps aux
a = show processes for all users
u = display the process's user/owner
x = also show processes not attached to a terminal

Monday, December 7, 2015

How to create a MySQL docker contianer and use it in Spring Boot Data Access developement (Windows 7, Java)


This article is to document how to create MySQL docker container and use it in Java development.

Create a MySQL docker container
  1. Install docker toolbox (in this case, I use 1.9.1c)
  2. Open docker terminal
  3. Run following command
    $ docker run --detach --env MYSQL_ROOT_PASSWORD=password1 --env MYSQL_USER=psun
    --env MYSQL_PASSWORD=password1 --env MYSQL_DATABASE=netgloo_blog --name mys
    ql --publish 3306:3306 mysql:latest

Run SQL command in the existing docker container
  1. Run following command to bring up a terminal with existing docker container
    docker exec -it mysql bash
  2. Now you should enter the bash prompt. So you can run following command to log into mysql -u root -p;
  3. You should enter mysql prompt. You can use following commands to do sql query
    show databases;
    use [database_name];
    show tables;
    select ... from ...;
You need to find what the docker machine's IP is using.
docker-machine ip default
In my case, it's 192.168.99.100

Clone the spring boot sample from https://github.com/netgloo/spring-boot-samples/tree/master/spring-boot-mysql-springdatajpa-hibernate

Open the project and modify IP and MySQL user credential in application.properties file.
# Connection url for the database "netgloo_blog"
spring.datasource.url = jdbc:mysql://192.168.99.100:3306/netgloo_blog

# Username and password
spring.datasource.username = root
spring.datasource.password = password1

After that run the project by running
mvn spring-boot:run

Wednesday, November 18, 2015

Dos command notes


::check which process is using port 8080
netstat -ano | findstr 8080

::kill a process
taskkill /PID 1234 /F

Thursday, June 18, 2015

Eclipse vs Visual Studio -- Common Operation



Eclipse Visual Studio
Code Navigation
Go to declaration F3 F12
Find all references Shift+F12 There is no default shortcut in Eclipse. You can access it in context menu. Also you can define your own shortcut.
There are different scope choices when you want to find all references. They are workspace, project, hierarchy.
Debug
Step Over F3 F10




Road to Java & Eclipse as a C# & Visual Studio verteran



This article describes the road through which I learn Java & Eclipse from mostly test automation/SDET perspective as a beginner.

I have pretty good experience with C#, Visual Studio and those Microsoft testing technologies. So the natural is that I will try to find equivalents in C# and Visual Studio when I meet things in Java & Eclipse.

You are welcome to correct me if there is anything in my writing is wrong. This is my learning experience and notes. Things are supposed to change if  later I will be able to find the things I write earlier are wrong, with my knowledge growing,.

Get to Know Java and Eclipse


The ways manage projects - Eclipse vs Visual Studio

I felt very lost when I started with Java and Eclipse because most things and naming in Eclipse are so strange and different from things in Visual Studio. And the IDE layout are different. Here I would recommend to go through the first couple of sections of Java & Eclipse Beginner Tutorial to get familiar with Eclipse IDE layout and how to setup a very basic Java project in it.

Those concepts how Eclipse manages project are essentially similar to Visual Studio. Most things in one IDE can be found their equivalents in the other one. Here I would like to list those key things comparison below. I hope it can be helpful for a developer who is very familiar with Visual Studio to switch to the Eclipse world.


Eclipse Visual Studio
Wordspace Solution
Project Project
src folder N/A Java project by default creates a source folder named src under a project. It's a kind of nice because while export (build), you can choose which source folder(s) to include in the output jar. Visual Studio doesn't do this.
Package Namespace
Import
(to a workspace)
Add existing project(s) to a solution
Build Path
(to a project)
Add/delete references to a project
.project, .classpath Visual Studio project file (.csproj) Visual Studio project file takes more responsibilities than those two. e.g.

Reference

http://www.ibm.com/developerworks/library/os-eclipse-visualstudio/

https://jmonkeycoder.wordpress.com/2013/08/28/eclipse-vs-visual-studio/

Tuesday, June 3, 2014

SearchProperties for WPF


In case of WPF ignore below mentioned properties (do not use them as search)
BoundingRectangle
DisplayText
Enabled
Exists
Font
FriendlyName
HasFocus
IsTopParent
MaxDepth
NativeElement

Reference
http://social.msdn.microsoft.com/Forums/en-US/0141edee-6dcb-461e-a48d-017300525d70/which-properties-can-be-used-as-searchproperties?forum=vsautotest

Thursday, May 29, 2014

Coded UI automation with Telerik RadBusyIndicator controls




One of my project is to build a WPF windows application, I used Microsft Coded UI technology to do UI automation. The tool I use is Visual Studio 2012 Ultimate.

To our principle developer's habit, he put Telerik RadBusyIndicator WPF control on every window to show a spin when the windows/controls are in busy status. Other developers follow the habit and put the control all over the modules. Following is a sample xaml code piece which has the control.

 <telerik:RadBusyIndicator IsBusy="{Binding IsBusy, UpdateSourceTrigger=PropertyChanged}"  
              telerik:StyleManager.Theme="Expression_Dark"  
              Grid.ColumnSpan="2"  
              Grid.RowSpan="2"  
              Panel.ZIndex="1">  
   <telerik:RadBusyIndicator.BusyContent>  
     <TextBlock Text="Processing..."  
           FontSize="13"  
           Foreground="WhiteSmoke" />  
   </telerik:RadBusyIndicator.BusyContent>  
 </telerik:RadBusyIndicator>    

Normally the control's size is big, cover the whole window or a range of controls, in order to prevent unexpected user actions while the window/controls are busy.

The reason developers use the control is understandable. The application we develop is a business application. Almost every window needs to query data from backend database. During the data loading period, we do not want user interact with UI elements.

What the issue is

Coded UI generated code always has playback failure.

Reason 

The RadBusyIndicator show a spin when window/controls are in busy status. But after the window/controls busy status changes to false, it's still exist, like a transparent mask on top of other controls.

Let me use a sample to explain what the issue is...

Here is an edit box A on a windows, and a RadBusyIndicator control B on top of A. I want to use Coded UI to generate the UI automation to input text "abc" in A. Normally coded UI generated code is like following:

A.Text = "abc
And when running automation, the playback will fail at
Here is the issue, any click on the UI, if
If someone used Coded UI Test Builder to record UI actions on the windows with the RadBusyIndicator WPF control, there comes the issue -- any recorded action has playback issue (actually when I click the control to put focus on, the So it caused the PROBLEM that when I do coded UI recording, all the action it captured is against RadBusyIndicator control. the code itall the mouse click on the

     /// <summary>  
     /// input - Use 'inputParams' to pass parameters into this method.  
     /// </summary>  
     public void input()  
     {  
       #region Variable Declarations  
       UITestControl uIPatientFirstNameEdit = this.UIGlidewellOfficeWindow.UIItemCustom.UIOrderEntryDataEntryCustom.UIPatientFirstNameEdit;  
       #endregion  
       // Click 'patientFirstName' text box  
       Mouse.Click(uIPatientFirstNameEdit, new Point(13, 8));  
       // Type 'abc' in 'patientFirstName' text box  
       Keyboard.SendKeys(uIPatientFirstNameEdit, this.inputParams.UIPatientFirstNameEditSendKeys, ModifierKeys.None);  
     }