ActionsLogger { public void addAction(String MsgType, String actionName, Date startTimeaction, Date endTime) { if ((endTime == null) || (startTimeaction == null)) throw new IllegalArgumentException( "At startTime or endTime variables is null"); if (actionName == null) { Logger.getLogger(this.getClass() ).debug("Action Name is NULL MsgType:" + MsgType + " Date :" + startTimeaction); Logger.getLogger(this.getClass() ).debug(" Stop measure"); this.setStopJATK(true); } else if (actionName.equals(" null")) { Logger.getLogger(this.getClass() ).debug("Action Name is ' null' MsgType:" + MsgType + " Date :" + startTimeaction); Logger.getLogger(this.getClass() ).debug(" Stop measure"); this.setStopJATK(true); } else if (actionName.equals("")) { actionName="Empty String sent by device as std output or ERR"; Logger.getLogger(this.getClass() ) .debug("Action Name is '"+actionName+"' MsgType:" + MsgType + " Date :" + startTimeaction); } try { Action a = new Action(); a.setMsgType(MsgType); a.setActionName(actionName); a.setStartTime(startTimeaction); a.setEndTime(endTime); listaction.add(a); writetempFile(MsgType, actionName, startTimeaction, endTime); } catch (Exception e) { e.printStackTrace(); } } ActionsLogger();  ActionsLogger(String folder); Date getStartTime(); void createHopperTstfile(); void closetempfiles(); final synchronized boolean writeHopperTstFile(String MsgType); final synchronized boolean writetempFile(String MsgType, String actionName,
			Date startTimeaction, Date endTime); void addAction(String MsgType, String actionName,
			Date startTimeaction, Date endTime); void addAction(Action action); Vector<Action> getSpecificActionsVect(String cle); Vector<Action> getActions(); boolean save(OutputStream out); boolean load(File file); void setStopJATK(boolean stopJATK); boolean isStopJATK();  }
@Test(expected = IllegalArgumentException.class) public void testAddInvalidAction1() { actionLogger.addAction("MsgType","anAction",null,null); }
@Test(expected = IllegalArgumentException.class) public void testAddInvalidAction2() throws InterruptedException { Action a = new Action(); a.setEndTime(new Date()); a.setActionName("anAction"); Thread.sleep(1000); a.setStartTime(new Date()); actionLogger.addAction("MsgType","anAction",new Date(),new Date()); actionLogger.addAction(a); }
@Test(expected = IllegalArgumentException.class) public void testAddInvalidMsgType() throws InterruptedException { Action a = new Action(); a.setEndTime(new Date()); a.setActionName("anAction"); Thread.sleep(1000); a.setStartTime(new Date()); actionLogger.addAction("","anAction",new Date(),new Date()); }
@Test(expected = NullPointerException.class) public void testNullAction() { actionLogger.addAction("MsgType",null,new Date(),new Date()); }