Ejemplo n.º 1
0
  /** @throws java.lang.Exception */
  @Before
  public void setUp() throws Exception {
    try {

      helper = new DatabaseHelper(Config.getInstance());
      helper.createDatabaseSchema();
      connection = helper.getConnection();
      // create the dao under test
      dao = new MySQLExcpetionDAO(connection);
      mockapplication = new MockApplication();
      applicationDAO = new MySQLApplicaitonDAO(connection);

      mockanalysis = new MockAnalysis();
      mockanalysis.setApp(mockapplication);
      // make a second one so we can test update later (attach exception to different analysis)
      mockanalysis2 = new MockAnalysis();
      mockanalysis2.setApp(mockapplication);

      analysisDAO = new MySQLAnalysisDAO(connection);
      mockapplication.setId(applicationDAO.create(mockapplication));

      mockanalysis.setId(analysisDAO.create(mockanalysis));
      mockanalysis2.setId(analysisDAO.create(mockanalysis2));

    } catch (Exception e) {
      logger.error("Unable to connect to DB!", e);
    }
  }
Ejemplo n.º 2
0
 /**
  * Test method for {@link
  * de.rub.syssec.saaf.saaf.db.dao.mysql.MySQLExcpetionDAO#update(de.rub.syssec.saaf.saaf.model.SAAFException)}.
  *
  * @throws Exception
  * @throws DAOException
  */
 @Test
 public void testUpdate() throws DAOException, Exception {
   SAAFException exception = new SAAFException("Error in analysis");
   exception.setAnalysis(mockanalysis);
   exception.setId(dao.create(exception));
   assertTrue(mockanalysis.getId() != mockanalysis2.getId());
   exception.setAnalysis(mockanalysis2);
   assertTrue(dao.update(exception));
 }
Ejemplo n.º 3
0
 /* (non-Javadoc)
  * @see de.rub.syssec.saaf.analysis.steps.processing.AbstractProcessingStep#process(de.rub.syssec.saaf.model.application.ApplicationInterface)
  */
 @Override
 public boolean doProcessing(AnalysisInterface analysis) throws AnalysisException {
   ApplicationInterface app = analysis.getApp();
   if (app != null) {
     try {
       hasher.generateHash(app, false);
     } catch (IOException e) {
       logger.error("An error occured during Fuzzy Hash generation: " + e.getMessage());
     }
   } else {
     throw new AnalysisException("There was no Application in this Analysis!");
   }
   return true;
 }