try {
Connection con = DbHandler.getConnection();
con.setAutoCommit(false);
//Spara och ladda attribut
UserBean user1 = BeanFactory.getUser(Thread.currentThread().getId());
user1.setAttribute("name1", "value1");
user1.create(con);
UserBean user2 = (UserBean)UserFinderBase.findByPrimaryKey(con, new UserKey(user1.getId()));
assertEquals("Attributen skall vara lika", user1.getAttribute("name1"), user2.getAttribute("name1"));
//Radera attribut
user2.removeAttribute("name1");
assertNull("Attributet skall inte finnas", user2.getAttribute("name1"));
user2.store(con);
user1 = (UserBean)UserFinderBase.findByPrimaryKey(con, new UserKey(user2.getId()));
assertNull("Attributet skall inte finnas", user2.getAttribute("name1"));
//Uppdatera attribut
user1.setAttribute("name1", "value1");
user1.store(con);
user1.setAttribute("name1", "newvalue1");
user1.store(con);
user2 = (UserBean)UserFinderBase.findByPrimaryKey(con, new UserKey(user1.getId()));
assertEquals("Attributet skall ha nytt v�rde", "newvalue1", user2.getAttribute("name1"));
user2.removeAllAttributes();
user2.store(con);
//Skapa tre attribut, d�refter uppdatera ett och radera ett
assertTrue("Det skall inte finnas n�gra attribut", user2.getAttributes().isEmpty());
user2.setAttribute("name1", "value1");
user2.setAttribute("name2", "value2");
user2.setAttribute("name3", "value3");
user2.store(con);
user2.setAttribute("name1", "newvalue1");
user2.setAttribute("name3", "");
user2.removeAttribute("name2");
assertEquals("Det skall finnas tv� attribut", 2, user2.getAttributes().size());
user2.store(con);
user1 = (UserBean)UserFinderBase.findByPrimaryKey(con, new UserKey(user2.getId()));
assertEquals("Det skall finnas ett attribut", 1, user1.getAttributes().size());
assertEquals("Fel attributv�rde", "newvalue1", user1.getAttribute("name1"));
assertNull("Attributet skall inte finnas", user1.getAttribute("name2"));
assertNull("Attributet skall inte finnas", user1.getAttribute("name3"));