Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Saturday, May 12, 2012

Cassandra Explorer - GUI for Cassandra

Please go to following url for the newest version.
http://blog.shelan.org/2012/06/cassandra-gui-20-making-things-little.html


WSO2 products can manage a Cassandra Cluster using Cassandra feature.[1]  (No need to follow the instructions to setup cassandra I have added a pre installed version [2])
If you have a Cassandra cluster i am sure you have the problem of viewing the data instantly. Cassandra CLI is one of the tools but it would be easier if it has a nice UI and would more convenient for administrators. Cassandra Explore has been developed to make the things easier for Cassandra users.

Download the Cassandra Feature pre installed WSO2 Carbon Server. [2] . (Until we officially release Cassandra Explorer with Cassandra feature lets use this.)

Extract the downloaded product and lets refer extracted folder as CARBON_HOME.

You have two different options with Cassandra feature.

1. Use internal Cassandra Server .

In this it will start internal Cassandra Server and you can use it to store data.

2. User External Cassandra Cluster.

This option if you already have setup your Cassandra Cluster and you need to view data. You need to
add your Cassandra Clusters details in CARBON_HOME/repository/conf/etc/cassandra-component.xml

Starting Carbon Server

1) If you need to use internal server. go to CARBON_HOME/bin and run sh wso2server.sh (linux) or
wso2server.bat

 If you need to connect to an external cassandra cluster you need to run same wso2server.sh with following parameter

sh wso2server.sh -Ddisable.cassandra.server.startup=true

and log in with default username and password (admin, admin)

List Key Spaces.

Click Cassandra Keyspaces ---> List to list down keyspaces.




Select a Key Space

Select a keyspace from available keyspaces.


Select a Column Family to Explore Data.

Click on Explore icon to view data in a Column Family.


View Data on Column Family.

This will display rows and columns in the Column Family. In a Row you can paginate through Columns. If you need to retrieve a key quickly enter your row ID and click explore row.



View data on a Row

Click on a row link to view data.

You can search  a Name or Value through search Box and will update the results as you type.


[1] http://wso2.org/library/knowledge-base/2012/04/deploy-cassandra-feature-wso2-carbon-product

[2] https://www.dropbox.com/s/m00uodj1ymkpdzb/wso2carbon-4.0.0-SNAPSHOT.zip

Friday, December 23, 2011

Better testing with Testng


Most of the programmers busy with writing code and forget the importance of having tested the implementations then and there.When you start writing tests you should select the best suitable framework for your job or else you will make things worse. There are few different tests such as
  • Unit test : You have a clear narrow and well defined scope to check a single point of large story/ contract
  • Integration test : In this you will be checking inter operation with more than one sub systems and may expand across system boundaries.
  • Smoke test/ sanity tests: This is a basic integration test for a product to verify system perform its basic functionality as expected
  • Regression test : Test to verify a fixed bug is actually fixed and it will not encounter again
  • Acceptance test : This is also a form of integration test which carried out to verify a use case or a user story
Out of these tests JUnit is adequate to perform Unit tests but for integration tests it has some limitations. If you have some complex dependencies between modules or states such as a sever needed to be started with deployed artiface before all the tests execute or establish a database connection with some preconditions you will find hard time if you choose JUnit .One key important thing you need to keep in mind is “JUnit instantiate class before it runs each and every test method”.
There are lots of comparisons between JUnit and Testng [1][2].When you go through them you will realize how Testng becomes your trusted companion for tests such as integration tests.Testng provides you annotations to control things better and a very cleaner way.Not only that you have custom testng.xml file which enables to customize things to accomplish lots of things as desirable.
If you wish to migrate to Testng there are lots of resources available to learn about Testng.But i advice do not try to convert JUnit tests directly but rather modify them to inherit elegance of Testng :) .
  • Add Testng as a maven dependency
<dependency>
  <groupId>org.testng</groupId>
  <artifactId>testng</artifactId>
  <version>6.1.1</version>
  <scope>test</scope>
</dependency>

  • Annotations available [3]
@BeforeSuite: The annotated method will be run before all tests in this suite have run.
@AfterSuite: The annotated method will be run after all tests in this suite have run.
@BeforeTest: The annotated method will be run before any test method belonging to the classes inside the <test> tag is run.
@AfterTest: The annotated method will be run after all the test methods belonging to the classes inside the <test> tag have run.
@BeforeGroups: The list of groups that this configuration method will run before. This method is guaranteed to run shortly before the first test method that belongs to any of these groups is invoked.
@AfterGroups: The list of groups that this configuration method will run after. This method is guaranteed to run shortly after the last test method that belongs to any of these groups is invoked.
@BeforeClass: The annotated method will be run before the first test method in the current class is invoked.
@AfterClass: The annotated method will be run after all the test methods in the current class have been run.
@BeforeMethod: The annotated method will be run before each test method.
@AfterMethod: The annotated method will be run after each test method.
  • How to handle Expected exceptions

@Test(expectedExceptions = ExpectedException.class)
  public void expectedExceptionTester() {
    throwAnException();
  }
The above method should throw the expected exception otherwise it should fail.