Java

Java related posts

Subcomponents

Subcomponents is one of the most requested feature of JIRA. As of today there are nearly 800 votes for the issue JRA-846. Also there are duplicate issues which are closed as being duplicate. Component Specific Versions plugin now supports subcomponents.

 

Subcomponents Selection

 

Plugin allows you to group components under a component tree. Nodes of this tree could be Virtual Components, or Real Components(Which are usual JIRA Components). You can nest components in any level you like.

Virtual Components: These are a new type of components normally not available in JIRA. You can create them inside “Subcomponents” tab of project’s administration page. Using them is optional. They allow you to better represent type of work/module kind of components. Since they are not real JIRA components, you can’t create issues for them. If you select them for issue creation, issue is associated with all of the real components grouped under the virtual component.

Real Components: These are normal JIRA components created from “Components” tab of your project’s administrative screen. You can also create them inside “Subcomponents” tab. Both actions do the same thing. Like Virtual Components, Real Components also allows other components (Virtual or Real) to be grouped under them. In addition to virtual components, you can also create issues for Real Components. They stay as they are even if you decide to uninstall the plugin someday.

Subcomponent Hierarchy

 

Above example shows one grouping of subcomponents for a hypothetical ERP project. In addition to modules developed by the team, it also shows different databases supported by the platform under “Databases” virtual component. Since “Databases” isn’t a real component any issue opened to it is automatically assigned to 3 databases (Oracle, Postgres, MySQL) under the virtual component.

Of course component selection tree is available inside quick edit menu of issue page. It is opened with the same icon. Using subcomponents doesn’t hide usual way of selecting components, autocomplete text field. It just complements it with another way of selecting components.

Subcomponents on Quick Edit

 

Selecting a parent component (whether it is virtual or not) will automatically select all of it’s visible children of it. The same way unselecting a parent component will select all of it’s visible children. With respect to selection the difference between a virtual parent component and a real parent component is real parent components are also added to components field of the issue whereas virtual components are not.

plugin also contains subcomponentsof function to allow you to query all issues opened to a component hierarchy. It returns all subcomponents of a component in a recursive way. This returns parent component itself, if you do not want it to be included you can pass a 2nd argument to JQL function, which should be false to exclude parent component itself or it should be true to include parent component itself. Default value is true.

project = ERP and component in subcomponentsof(“Client”)

You can pass virtual or real components to this method.

VN:F [1.9.22_1171]
Rating: 8.7/10 (7 votes cast)

Hosting a Static Site on Amazon S3

Amazon S3 has very cheap pricing model and a huge bandwidth that makes it perfect for serving static web sites. I will try to summarize what I have done here because it is the 4th time I have doing the same thing and I still need to go over a few different tutorials. I will also show how to change name servers for your domain for Bluehost and Godaddy.
Here a brief overview of what will do:

  • Jekyll: For generating our static web site. 
  • Feeling Responsive: Jekyll theme we will be using. You can choose a different theme from here.
  • Forklif: We will create a MacOS X app to upload changed files to S3. You can use any program you like but you will definitely need one. 
  • Markdown PRO: Markdown editor we will be using to edit our pages and blog posts. Any text editor is ok but Markdown PRO has live preview capability. 

Creating S3 Buckets

Login to your Amazon Management Console for bucket creation. Select S3 service and create two buckets for you website. For example if your web site name will be www.mywebsite.com, create buckets as mywebsite.com and www.mywebsite.com. You can leave Region option as default but if you can guess you can select a location closer to your potential customers for slightly more faster response time.
Open properties of mywebsite.com, we need to change 2 settings there.

First, expand “Static Website Hosting” and select “Enable Website Hosting”. Enter “index.html” for “Index Document”. You can leave “Error Document” option as empty but you can use any page as error page just be sure that you actually create that page. Do not forget to save

Redirect all requests to another host name

Redirect all requests to another host name

Seconds, expand “Permissions” tab and click on “Add Bucket Policyand enter the following, do not forget to change mywebsite.com to your own bucket name.

{
	"Version": "2012-10-17",
	"Statement": [
		{
			"Sid": "AddPerm",
			"Effect": "Allow",
			"Principal": "*",
			"Action": "s3:GetObject",
			“Resource": "arn:aws:s3:::mywebsite.com/*"
		}
	]
}

Save bucket policy.

Open properties of www.mywebsite.com, we will just forward this bucket to our mywebsite.com.
Expand “Static Website Hosting” and select “Redirect all requests to another host name” and save. Thats all for this bucket.

Redirect all requests to another host name

Redirect all requests to another host name

We have done with S3 settings. Now we need to setup name server side of things in both Route 53 and our domain name registerer.

Creating Route 53 Records

Open Route 53 Management Console and select “Hosted Zones” and than “Create Hosted Zone”. Do not enter www part, just enter mywebsite.com. You can leave comment section empty. Press “Create” button to create the zone record.

Create Hosted Zone

Create Hosted Zone

It will create two record sets, one for name servers with type “NS” and a “SOA” record. You will need name server names while you are changing name servers for your domain later, so write them down or better leave the tab open.
Press “Create Record Set” button to create a new record. Select Type A and Alias. Click on Alias Target and select your S3 Endpoint from the combobox. Leave others as default and press “Create”.

Add one more record. This time, write “www” to Name field and select Alias Target that points to www.mywebsite.com. After that you should have 4 record sets as shown in following screenshot. Of course name servers for your domain may be different.

Changing Bluehost Name Servers

Login to your Bluehost account and open “Domains” tab. Select the domain name you like to manage and select “Name Servers” tab from right. Enter the Amazon Route 53 name servers you have noted above.

It may take several hours for new settings to be applicable.

Changing GoDaddy Name Servers

Login to your Godaddy account. Under “Products” expand “Domains” and click on “Manage” next to domain name you like to manage.

Under Settings, Nameservers click on “manage” link. This will open a page where your can enter name servers from Route 53. Select “Custom” and enter 4 name servers displayed in Route 53 panel.

After that refresh the page and new name servers should be displayed in the page. It may take several hours for new settings to be applicable.

Synchronizing Files with Amazon S3

Open Forklif application and add a new connection for your S3 account:

Forklift S3 Connection

Forklift S3 Connection

Open your local “_site” folder and Amazon S3 remote folder side by side.

Click inside the tab showing your local files and select File->Sync to…. This will open synchronization window:

 

Synclet

Synclet

For the first synchronization you can exclude filter. In later synchronizations you can exclude .css, js files because they are a part of theme and will not change. There is an option that allows you to exclude non-changed files but in my case it did not worked reliably. Jekyll may be modifying the update date of files at every run. Unless you have a huge site non of these are actually an issue.

Chose “Save as Synclet” option because you will need to run it every time you add a new post or make a change on your site. Give it any name you want and save it under “Applications” folder. You can open it like any other MacOS X application. It will automatically detect files to be synched and upload all of them to S3 bucket.

VN:F [1.9.22_1171]
Rating: 10.0/10 (1 vote cast)

Using Selenium Chrome Driver on Mac OS X

Update (26/06/2015)
Previously I have written a function which waits until a specific element is available on the page, doWhenAvailable. I have find out Selenium has already a similar feature build-in. Its element search functions could wait until an element is available on the page. It can be activated in @BeforeClass method:

driver. manage( .timeouts( ). implicitlyWait(TIMEOUT_TIME,  TimeUnit.SECONDS) ;
//doWhenAvailable(driver, By.id( “view_profile”), WebElement::click); 
driver.findElement(By.id(“view_profile”)).click() ;

 

It took several attempts for me able to use Chrome Driver by using the instructions from its website and I have decided to publish a step by step tutorial.

Selenium allows you to run your tests using several different browsers Chrome, Firefox, InternetExplorer and HTMLUnit. HTMLUnit is not a real browser it is just a browser simulator written in Java, it can execute JavaScript too. Some settings you have to use for each one is different but for all of them you have to start by adding main Selenium dependency to you project. This is the common part.

Creating Maven Project

I have created a new maven project using following pom.xml but you can just add selenium dependency to your own pom.xml if you want. Here is the pom.xml file I have used for my test project:

 

<!--?xml version="1.0" encoding="UTF-8"?-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelversion>4.0.0</modelversion>
    <groupid>com.deniz.jira</groupid>
    <artifactid>JIRASeleniumTests</artifactid>
    <version>1.0</version>
    <name>JIRASeleniumTests</name>
    <dependencies>
        <!-- This is only required dependency. -->
        <dependency>
            <groupid>org.seleniumhq.selenium</groupid>
            <artifactid>selenium-java</artifactid>
            <version>2.46.0</version>
        </dependency>
        <!-- Selenium does not enforce any unit testing framework and
        it does not have any unit testing features, like asserts so
        we are using JUnit for this. But this is optional and
        you do not need to use any unit testing library if you want. -->
        <dependency>
            <groupid>junit</groupid>
            <artifactid>junit</artifactid>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupid>org.hamcrest</groupid>
            <artifactid>hamcrest-all</artifactid>
            <version>1.3</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <!-- Using Java 8's Lambda expressions makes code simple.
        Because you will be using a lot of handler to asynchronous methods.
        But this is not required. -->
        <plugins>
            <plugin>
                <groupid>org.apache.maven.plugins</groupid>
                <artifactid>maven-compiler-plugin</artifactid>
                <version>3.3</version>
                <configuration>
                    <source>1.8
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

WebDriver Specific Initialization

For newcomers it is best to stick with Firefox. It is easier to setup. After installing Firefox browser to you system just create a new FirefoxDriver and start running your project. There are no extra step required.

For Chrome in addition to Chrome Browser you have to install Chrome Driver too. You can download Chrome Driver from Chromium web site and put it in a suitable place in your system. Location is not important because we will be providing location of it through a system property to our test execution.

In my case I have put chromedriver executable to Applications folder. So for my JUnit test I have use following setting:

System.setProperty("webdriver.chrome.driver" ,  "/Applications/chromedriver");

Writing Actual Test Codes

We have to initialize our WebDriver instance, since I am using JUnit I have done it in @BeforeClass so it is automatically run before my test cases. You can also do this before every test case using @BeforeTest but it will be a lot slower because you will most probably do extra initialization than shown below. For example logging-in to web site.

@BeforeClass
public static void init() {
    driver = new ChromeDriver(); //init chrome driver
    //driver = new FirefoxDriver(); //uncomment to use Firefox
    driver.get("http://localhost:8080”); //url of website we like to test
    driver.manage().window().setSize(new Dimension(1600, 900)); //resize browser window
    //login to web site
}

You will most probably want browser to automatically closed after your tests are completed. Add driver.quit() to your JUnit teardown method. If you do not each execution will left a new browser window open.

@AfterClass
public static void teardown() {
    driver.quit();
}

Nowadays nearly all web applications will be loaded asynchronously. That mean when page is loaded the element you like to test will not be on the page, it will be generated by a JavaScript code. This makes writing test a little more difficult, you have to wait until related element is created by JavaScript code. I have writing a small helper function and reused it in my test code. It waits until given element (Specified using By) is available on the page and execute the given code block (Consumer) when the element is available:

public   static   void   doWhenAvailable( WebDriver driver ,  By by ,  Consumer consumer )   { 
     ( new   WebDriverWait (driver,  TIMEOUT_TIME ) ).until( ( WebDriver drv )   -&gt;  driver.findElement( by )  !=  null ) ; 
    consumer.accept( driver.findElement( by ) ) ; 
 }

 

Using this method with Java 8 is very readable. For example below code waits until an element with id=“view_profile” is available on the page and when it is available just clicks on it.

doWhenAvailable(driver, By.id("view_profile"), WebElement::click);

Following code performs more complex operation when requested element is available. It wails until <select id=“ts_month_picker_selector” …..> select element is available on the page and select option element which has a value of “Jan”:

doWhenAvailable(driver, By.id("ts_month_picker_selector"), (element) -&gt; {
    Select select = new Select(element);
    select.selectByValue(String.valueOf(“Jan"));
});

You will mostly need to perform other asynchronous operations inside the callback and this will result into callback hell. I am still looking a way to promise style of chaining asynchronous operations.

Tips and Tricks

  • Give every HTML element a unique id field. This will allow you to specify elements easily in your test code.
  • Create a reusable small test library specific to your application. For example you should encapsulate logging-in to test system in a method and reuse that method from every test case.
  • Try to avoid time based waits with Thread.sleep() or any other sleep as much as possible. Because they will increate time to run your tests. But you will probably need this for some AJAX based code. In my case I need it for dynamically filled comboboxes which fills its content as you type. Otherwise you may get StaleElementReferenceException because your driver will be using a previous instance of the same visual element not the one on the page. Instead of sleep you may allow StaleElementReferenceException to occur and re-fetch the element automatically. You can check details from here.
  • At the end of the test if test fails take a screenshot automatically. I will explain it in another post. 
VN:F [1.9.22_1171]
Rating: 7.7/10 (3 votes cast)

Automate Native to Ascii Conversion with Gulp

All of my recent projects use Javascript and Java together. Increasing I’m switching from Maven to Gulp for automation. I have now perform native to ascii conversion with gulp instead of maven and native2ascii tool of JDK.

var gulp = require("gulp");
var n2a = require("gulp-native2ascii");
var shell = require("gulp-shell");

gulp.task("n2a", function () {
    gulp.src("src/main/resources/i18n/reminders*.properties")
        .pipe(n2a({reverse: false}))
        .pipe(gulp.dest("src/main/resources/i18n/"));
});

gulp.task("proguard", shell.task([
    '../../proguard4.11/bin/proguard.sh @proguard.conf'
]));
VN:F [1.9.22_1171]
Rating: 9.0/10 (2 votes cast)

Component Versions JIRA Plugin

Component Specific Vesions is a JIRA plugin that allows you to define which versions are valid for which versions, and enforce this during issue operations. For more information please visit http://jiraplugins.com

VN:F [1.9.22_1171]
Rating: 10.0/10 (1 vote cast)

ShopaHolic

ShopaHolic iPhone uygulaması ile Limango, Markafoni ve Trendyol kampanya sitelerindeki kampanyaları yakından takip edebilirsiniz. Tek bir arayüz üzerinden kampanyaları takip edip fiyat karşılaştırması yapabilirsiniz. İsterseniz anahtar kelimeler tanımlayıp uygulamanın size haber vermesini sağlayabilirsiniz. Kampanya’dan ürün sayfasına kadar ulaşabilir isterseniz “Satın Al” fonksiyonu ile ürünü ilgili sitenin kendi arayüzü üzerinden satın alabilirsiniz.

 

VN:F [1.9.22_1171]
Rating: 10.0/10 (2 votes cast)

Worklog PRO-A More Effective Way for Entering Worklogs in JIRA

 

Keeping track of time spent on anything is a requirement in a lot of organizations. Unfortunately most of the time this is a manual process and correctness of entered work logs are low. Worklog PRO is a JIRA plugin that aims to increase correctness of work logs by making entering work logs a lot easier. How this is possible?

Periodic Worklog

Periodic Work Logs

Sometimes our tasks spans more than one day. But JIRA’s build in work log mechanism requires you to enter work logs day by day. Worklog PRO allows you to enter a specific amount of time to all the days within a given range.

Periodic Worklog

In addition to allowing you to enter worklog for current issue, this dialog allows you to log work to any issue in JIRA. At top of the dialog a predefined list of filters is displayed that makes locating issues easier. Any keyword you have search in the issue box will be searched within the selected filter.

  • Recent: Shows latest issues you have viewed
  • No Worklog: Shows latest issues you have viewed but you haven’t logged any work yet
  • Assigned: Shows latest issues assigned to you
  • Reported: Shows latest issues you have reported
  • Watched: Shows latest issues you have added to you watch list
  • Voted: Shows latest issues you have voted
  • Filters: You can search a filter from you favorite or owned filters. Latest issues from this filter will be displayed also any keyword you have written in issue search box will be searched in that filter.

Worklog Timer

It is sometimes difficult to estimate how much time you have spent on an issue. Also in some type of issues you may need very accurate timing, for you are charging your customers according to time you spent. Worklog PRO includes a timer that is attach to bottom of JIRA’s screen. Just start it before starting to work on an issue and it will interactively count how much you have spent. When you stopped the counter it will display the work log entry screen.
One additional usage of this counter is motivation, seeing time passing will motivate you to work harder. As said, “You may be delayed, but time will not”.

Timer

Worklog by User Panel

A lot of people forget to enter work logs to issues, especially if they are not the one who is resolving the issue. Most of the time, in addition to person resolving the issue, a lot of people is involved during the lifecycle of an issue. Person reporting the issue or people involved in the discussion all spent time on the issue. Plugin makes it a lot easier to find out the issues you involved somehow, list the issues, search for a keyword. Even it could show you only the issues you have involved but not entered any work log yet.

Worklog by User

 

VN:F [1.9.22_1171]
Rating: 5.5/10 (2 votes cast)

Android Kargo Takip Uygulaması

Günümüzde bir çoğumuz Internet üzerinden alış veriş yapıyoruz. Özellikle yurt dışından yapılan alış verişlerde kargonun nerede olduğunu takip etmek zor oluyor. PTT’nin takip sayfası oldukca kullanışsız ve yurt dışından yapılan bir gönderinin PTT takip sayfasında çıkması biraz vakit alıyor. Bazı alış veriş siteleri de kargo takip numarasını mail ile göndermeyip kendi siteleri üzerinden hesabınıza girip kendi sağladıkları arayüz üzerinden bu bilgiyi veriyorlar. Ben de kargom nerede diye kontrol etmeyi kolaylaştıracak bir Android uygulaması geliştirdim. Bu uygulama Türkiye’de hizmet veren bütün kargo şirketlerini kapsadığı gibi, UPS, Fedex, DHL ve China Post (Çin’den gelen postalar/kargolar için) gibi uluslar arası gönderi yapan kargo şirketlerini destekliyor. Uygulamayı Android Market’den indirebilirsiniz, ismi “Kargo Takibi”.

Uygulama en son girdiğiniz takip numaralarını da saklıyor ve tekrar sorgulama yapmak için sadece listeden takip numarasını seçmeniz yeterli oluyor. Kargo şirketini kendisi tamamlıyor.

Uygulama siz takip numarasını yazdığınız zaman girdiğiniz formattan hangi kargo şirketine ait olduğunu çoğu zaman anlayabiliyor ve otomatik olarak şirket seçeneğini dolduruyor. Bu uygulamayı yaparken tabiki farklı kargo şirketlerinin farklı farklı takip numarası kullandıklarını farkettim ve bu formatları da sizler ile paylaşmak istedim. Uygulama dışında da işe yarar olduğunu düşünüyorum çünku takip bu numara fatura no vb. diğer bilgiler ile karıştırılabiliyor.

ARAS Kargo: Aras Kargo takip numarası 13 tane rakamdan oluşur. Örnek:4208993503499

China Post(Çin’den yapılan posta gönderileri için): China Post takip numarası R ile başlar ve CN ile biter. R’den sonra bir harf daha vardır ve 9 tane rakam içerir. Örnek:RA697576059CN

DHL: DHL takip numarası 10 tane rakamdan oluşur. Örnek:2217900993

Fedex: FEDEX takip numarası 12 tane rakamdan oluşur. Örnek:802416569979

MNG Kargo: MNG Kargo takip numarası iki adet harf ile başlar ve ardından genellikle 6 tane rakam gelir. Tamamen rakamlardan oluştuğu veya 2 harften sonra 4 rakam gelen takip numaraları da olabilir. Örnek:DB501983

PTT Kargo: PTT Kargo takip numarası genellikle 13 adet rakamdan oluşur. 2 adet harfin ardından 11 adet rakam gelecek şekilde de olabilir. Örnek:AP00869174550 veya 2789339611984

PTT Kargo Yurt Dışı: PTT Yurt Dışı takip numarası R ile başlar ardından 1 tane harf gelir ve bunu 9 adet rakam izler. İki adet harf ile biter. Bu harf gönderinin yapıldığı ülkeye göre değişir. Mesela Çin’den yapılan gönderilerin takip kodu CH ile biter. Örnek:RS915119275CH

Sürat Kargo: Sürat Kargo takip numarası 12 adet rakam ve harfden oluşur. Örnek:2aca211a3b5b

UPS Türkiye: UPS takip numarası H veya U ile başlar. Harf ve ramaklardan oluşur. Toplamda 16 karakter uzunluktadır. Örnek:U34B519G2533391

Yurtiçi Kargo: Yurtiçi Karg takip numarası 12 tane rakamdan oluşur. Örnek:608993503499

VN:F [1.9.22_1171]
Rating: 10.0/10 (4 votes cast)

Component Level Versioning and Bundle of Components in JIRA

Each project in JIRA has its own set of components and versions. Versions are defined at project level so any version is valid for any component of the project. For a very long time ability to use component specific version numbers within the JIRA is one of the most requested feature. There are various feature requests opened just for this feature, like JRA-3501. If your project contains components that have different version numbers you have two choices:

You may make your each component a different project

Advantage of this approach is you may have finer level of detail in managing the project. You may assign different issue schemas, workflows or assign different persons to different roles. Disadvantage is your project administration may become more complex. Also you have to define special filters to see all issues of higher level project.

You may use “Component and Bundle Versions for JIRA” plugin

This plugin allows you to assign different versions to different components within your JIRA project. This component specific version is enforced on every issue operation like create, edit, inline edit, workflow screens. Possibility of selecting incorrect component and version pair for an issue is greatly reduced. This plugin also allows you to group different version of different components into a bundle. Bundles has different versions than components. In any issue screen if no component is selected, plug-in only allows versions that are assigned to a bundle. You can also filter issues using two new JQL functions; affectsBundle and fixedInBundle. affectsBundle function takes a list of bundle names and returns all issues that are affecting the components in the bundle or directly entered for bundle without specifying any component. fixedInBundle JQL function works similar to affectsBundle but works for “fix version” field.
You may have more detailed explanation of plug-in at its home page and help pages. You can also visit the plug-in’s page at Atlassian Marketplace.

Use following links to take advantage of a limited time promotions:

Component and Bundle Versions for JIRA

VN:F [1.9.22_1171]
Rating: 10.0/10 (1 vote cast)

CMMI, Scrum, Kanban

I have just checked trend of 3 popular process. As you can see, CMMI goes down for a long time. The interesting part is CMMI is very popular in India, China, Pakistan, Taiwan then it is in the other parts of the world. On the other hand scrum is more popular in Europe.

Google Trends for Scrum, Kanban, CMMI

Google Trends for Scrum, Kanban, CMMI

Popularity of CMMI by Country

Popularity of CMMI by Country

Popularity of Scrum by Country

Popularity of Scrum by Country

VN:F [1.9.22_1171]
Rating: 8.7/10 (3 votes cast)