Package org.netbeans.server.uihandler.DbInsertionTest

Examples of org.netbeans.server.uihandler.DbInsertionTest.TestLogFileTask


        EntityManager em = perUtils.createEntityManager();
        em.getTransaction().begin();
        String userId = "file";
        int session = 1;
        Logfile log = new Logfile(userId, session);
        TestLogFileTask task = new TestLogFileTask(em, log);
        DbInsertion insertion = new DbInsertion(rec, thrown, task);
        ExceptionsData excData = new ExceptionsData();
        insertion.start(excData);
        task.markFinished();

        Integer issueId = (Integer) excData.getSubmitId();
        int issuezillaId = 110;
        org.netbeans.modules.exceptions.entity.Exceptions exc =
                em.find(org.netbeans.modules.exceptions.entity.Exceptions.class, issueId);
        Report report = exc.getReportId();
        report.setIssueId(issuezillaId);
        em.merge(report);
        Issue issue = BugReporterFactory.getDefaultReporter().getIssue(issuezillaId);
        issue.setIssueStatus("NEW");
        issue.setLastResolutionChange(new Date());
        for (int i = 1; i < 3; i++) {
            em.getTransaction().commit();
            em.getTransaction().begin();

            task = new TestLogFileTask(em, log);
            insertion = new DbInsertion(rec, thrown, task);
            insertion.start(excData);
            task.markFinished();
            waitIssuezillaInsertionFinished();
            changeUserName(em, excData.getSubmitId());
        }
        handler.flush();
        for (int i = 3; i <= 9; i++) {
            em.getTransaction().commit();
            em.getTransaction().begin();

            task = new TestLogFileTask(em, log);
            insertion = new DbInsertion(rec, thrown, task);
            insertion.start(excData);
            task.markFinished();
            waitIssuezillaInsertionFinished();
            changeUserName(em, excData.getSubmitId());

            LogRecord result = handler.getResult();
            if (i == 3 || i == 9) {//priorityLog
View Full Code Here


        EntityManager em = perUtils.createEntityManager();
        em.getTransaction().begin();
        String userId = "file";
        int session = 1;
        Logfile log = new Logfile(userId, session);
        TestLogFileTask task = new TestLogFileTask(em, log);
        DbInsertion insertion = new DbInsertion(rec, thrown, task);
        ExceptionsData excData = new ExceptionsData();
        insertion.start(excData);
        task.markFinished();

        Integer issueId = (Integer) excData.getSubmitId();
        int issuezillaId = 11;
        org.netbeans.modules.exceptions.entity.Exceptions exc =
                em.find(org.netbeans.modules.exceptions.entity.Exceptions.class, issueId);
        Report report = exc.getReportId();
        report.setIssueId(issuezillaId);
        em.merge(report);
        Issue issue = BugReporterFactory.getDefaultReporter().getIssue(issuezillaId);
        issue.setIssueStatus("NEW");
        issue.setLastResolutionChange(new Date());
        for (int i = 1; i < 3; i++) {
            em.getTransaction().commit();
            em.getTransaction().begin();

            task = new TestLogFileTask(em, log);
            insertion = new DbInsertion(rec, thrown, task);
            insertion.start(excData);
            task.markFinished();
            waitIssuezillaInsertionFinished();
            changeUserName(em, excData.getSubmitId());
        }
        issue.setIssueStatus("RESOLVED");
        issue.setResolution("FIXED");
        handler.flush();
        for (int i = 3; i <= 9; i++) {
            em.getTransaction().commit();
            em.getTransaction().begin();

            task = new TestLogFileTask(em, log);
            insertion = new DbInsertion(rec, thrown, task);
            insertion.start(excData);
            task.markFinished();
            waitIssuezillaInsertionFinished();
            changeUserName(em, excData.getSubmitId());

            LogRecord result = handler.getResult();
            assertNull("ISSUE IS FIXED", result);
View Full Code Here

        Throwable thrown = new NullPointerException("TESTING NULL POINTER");
        String userId = "file";

        ExceptionsData eData = new ExceptionsData();
        Logfile log = new Logfile(userId, session);
        TestLogFileTask task = new TestLogFileTask(em, log);
        DbInsertion dbInsertion = new DbInsertion(rec, thrown, task);
        dbInsertion.start(eData);
        task.markFinished();
        waitIssuezillaInsertionFinished();
        if ((Boolean) eData.isDuplicateReport()) {
            if (!isReopen){
                assertAreDuplicates(rootId, eData.getSubmitId());
            }
View Full Code Here

        EntityManager em = perUtils.createEntityManager();
        em.getTransaction().begin();
        String userId = "file";
        int session = 1;
        Logfile log = new Logfile(userId, session);
        DbInsertion insertion = new DbInsertion(rec, null, null, new TestLogFileTask(em, log), 100L, null, "method");
        insertion.start(new ExceptionsData());

        LogRecord result = handler.getResult();
        assertNull("NOT A DIRECT USER", result);

        em.persist(new Directuser(directUserName));
        em.getTransaction().commit();
        em.getTransaction().begin();

        insertion = new DbInsertion(rec, null, null, new TestLogFileTask(em, log), 100L, null, "method");
        insertion.start(new ExceptionsData());

        waitIssuezillaInsertionFinished();
        result = handler.getResult();
        assertNull("DIRECT USER IGNORED FOR SLOWNESS", result);
View Full Code Here

        EntityManager em = perUtils.createEntityManager();
        em.getTransaction().begin();
        String userId = "file";
        int session = 1;
        Logfile log = new Logfile(userId, session);
        DbInsertion insertion = new DbInsertion(rec, null, null, new TestLogFileTask(em, log), 100L, null, "method");
        insertion.start(new ExceptionsData());
        //waitLogsParsed();
        List<Slowness> all =
                PersistenceUtils.getAll(em, Slowness.class);
        Slowness rootSlowness = all.get(all.size() - 1);
        rootId = rootSlowness.getId();
        List<Nbuser> users = PersistenceUtils.getAll(em, Nbuser.class);
        Nbuser user = null;
        for (Nbuser us : users) {
            if (userName.equals(us.getName())) {
                user = us;
            }
        }
        all = PersistenceUtils.getAll(em, Slowness.class);
        rootSlowness = all.get(all.size() - 1);
        assertNotNull(rootSlowness);
        assertEquals(1, rootSlowness.getReportId().getDuplicates(em));
        assertEquals(1, rootSlowness.getReportId().getDuplicatesFromDistinctUsers(em));
        assertEquals(1, rootSlowness.getReportId().getDuplicatesFromOneUser(em, user));

        session = 2;
        log = new Logfile(userId, session);

        // -- refresh persistence context ---//
        em.getTransaction().commit();
        em.close();
        em = perUtils.createEntityManager();
        em.getTransaction().begin();
        all = PersistenceUtils.getAll(em, Slowness.class);
        rootSlowness = all.get(all.size() - 1);

        rootSlowness = insert(em, new DbInsertion(rec, null, null, new TestLogFileTask(em, log), 100L, null, "method"));
        assertEquals(2, rootSlowness.getReportId().getDuplicates(em));
        assertEquals(1, rootSlowness.getReportId().getDuplicatesFromDistinctUsers(em));
        assertEquals(2, rootSlowness.getReportId().getDuplicatesFromOneUser(em, user));


        session = 3;
        log = new Logfile(userId, session);

        // -- refresh persistence context ---//
        em.getTransaction().commit();
        em.close();
        em = perUtils.createEntityManager();
        em.getTransaction().begin();
        all = PersistenceUtils.getAll(em, Slowness.class);
        rootSlowness = all.get(all.size() - 1);

        rootSlowness = insert(em, new DbInsertion(rec, null, null, new TestLogFileTask(em, log), 100L, null, "method"));
        assertEquals(3, rootSlowness.getReportId().getDuplicates(em));
        assertEquals(1, rootSlowness.getReportId().getDuplicatesFromDistinctUsers(em));
        assertEquals(3, rootSlowness.getReportId().getDuplicatesFromOneUser(em, user));
        userName = "exceptions";
        params.set(3, userName);
        params.set(6, "petrzajac");
        rec.setParameters(params.toArray());

        session = 4;
        log = new Logfile(userId, session);

        // -- refresh persistence context ---//
        em.getTransaction().commit();
        em.close();
        em = perUtils.createEntityManager();
        em.getTransaction().begin();
        all = PersistenceUtils.getAll(em, Slowness.class);
        rootSlowness = all.get(all.size() - 1);

        rootSlowness = insert(em, new DbInsertion(rec, null, null, new TestLogFileTask(em, log), 100L, null, "method"));
        users = PersistenceUtils.getAll(em, Nbuser.class);
        Iterator<Nbuser> userIt = users.iterator();
        Nbuser user2 = null;
        while (userIt.hasNext()) {
            user2 = userIt.next();
            if (user2.getName().equals(userName)) {
                break;
            }
        }
        assertEquals(4, rootSlowness.getReportId().getDuplicates(em));
        assertEquals(2, rootSlowness.getReportId().getDuplicatesFromDistinctUsers(em));
        assertEquals(3, rootSlowness.getReportId().getDuplicatesFromOneUser(em, user));
        assertEquals(1, rootSlowness.getReportId().getDuplicatesFromOneUser(em, user2));

        session = 5;
        log = new Logfile(userId, session);
        rootSlowness = insert(em, new DbInsertion(rec, null, null, new TestLogFileTask(em, log), 100L, null, "method"));

        // -- refresh persistence context ---//
        em.getTransaction().commit();
        em.close();
        em = perUtils.createEntityManager();
View Full Code Here

        TestHandler handler = new TestHandler();
        BugReporter.LOG.addHandler(handler);
        EntityManager em = perUtils.createEntityManager();
        em.getTransaction().begin();
        Logfile log = new Logfile("testDir", 1);
        TestLogFileTask task = new TestLogFileTask(em, log);
        ProductVersion pv = new ProductVersion(1);
        pv.setProductVersion("NetBeans IDE 6.0 (Build 081204)");
        Nbversion nbv = new Nbversion(1);
        nbv.setVersion("6.0");
        pv.setNbversionId(nbv);
        log.setProductVersionId(pv);
        Nbuser user = new Nbuser(1);
        user.setName("HALLO");
        Slowness slown = new Slowness(100);
        slown.setActionTime(1000L);
        Method m = new Method(30);
        m.setName("unknown");
        Report report = new Report(100);
        slown.setSuspiciousMethod(m);
        slown.setReportId(report);
        slown.setLogfileId(log);
        report.setComponent("user.dir");
        report.setSubcomponent("some.jar");
        slown.setNbuserId(user);
        em.persist(nbv);
        em.persist(pv);
        em.persist(report);
        em.persist(user);
        em.persist(m);
        em.persist(slown);

        new IZInsertion(slown, null).start();
        task.markFinished();
        IZInsertion.waitIZInsertionFinished();
        LogRecord result = handler.getResult();
        assertNull(result);

        em.getTransaction().commit();
View Full Code Here

        rec.setParameters(params.toArray());
        String userId = "file";

        ExceptionsData eData = new ExceptionsData();
        Logfile log = new Logfile(userId, session);
        TestLogFileTask task = new TestLogFileTask(em, log);
        DbInsertion dbInsertion = new DbInsertion(rec, null, null, task, 10000L, null, "somethingFailed()");
        dbInsertion.start(eData);
        task.markFinished();
        waitIssuezillaInsertionFinished();
        if ((Boolean) eData.isDuplicateReport()) {
            if (!isReopen){
                assertAreDuplicates(rootId, eData.getSubmitId());
            }
View Full Code Here

        EntityManager em = perUtils.createEntityManager();
        em.getTransaction().begin();
        String userId = "file";
        int session = 1;
        Logfile log = new Logfile(userId, session);
        TestLogFileTask task = new TestLogFileTask(em, log);
        DbInsertion insertion = new DbInsertion(rec, thrown, task);
        insertion.start(new ExceptionsData());
        task.markFinished();

        LogRecord result = handler.getResult();
        assertNull("NOT A DIRECT USER", result);

        em.persist(new Directuser(directUserName));
        em.getTransaction().commit();
        em.getTransaction().begin();

        task = new TestLogFileTask(em, log);
        ExceptionsData excData = new ExceptionsData();
        insertion = new DbInsertion(rec, thrown, task);
        insertion.start(excData);
        task.markFinished();

        waitIssuezillaInsertionFinished();
        result = handler.getResult();
        assertNotNull("DIRECT USER", result);
        Object[] parameters = result.getParameters();
        assertEquals(summary, parameters[0]);
        assertEquals("exceptions", parameters[1]);
        assertEquals("petrzajac", parameters[2]);
        handler.flush();

        int issuezillaId = 10;
        org.netbeans.modules.exceptions.entity.Exceptions exc =
                em.find(org.netbeans.modules.exceptions.entity.Exceptions.class, excData.getSubmitId());
        Report report = exc.getReportId();
        report.setIssueId(issuezillaId);
        em.merge(report);
        Issue issue = BugReporterFactory.getDefaultReporter().getIssue(issuezillaId);
        issue.setLastResolutionChange(new Date());

        String undirectUser = "tester";
        params.set(3, undirectUser);
        params.set(6, undirectUser);
        rec.setParameters(params.toArray());
        task = new TestLogFileTask(em, log);
        insertion = new DbInsertion(rec, thrown, task);
        insertion.start(new ExceptionsData());
        task.markFinished();
        waitIssuezillaInsertionFinished();

        result = handler.getResult();
        assertNotNull("MANY DUPLICATES FILTER - ADD COMMENT", result);
        parameters = result.getParameters();
        assertEquals(Integer.toString(issuezillaId), parameters[0].toString());
        assertEquals("default comment reporter", null, parameters[1]);
        String str = (String) parameters[3];
        assertNotNull("GENERATED MESSAGE", str);
        assertTrue(str.contains("already"));
        handler.flush();

        issue.setIssueStatus("RESOLVED");
        issue.setResolution("FIXED");
        em.getTransaction().commit();

        em.getTransaction().begin();
        assertTrue(PersistenceUtils.issueIsFixed(issuezillaId));
        assertFalse(PersistenceUtils.issueIsOpen(issuezillaId));

        task = new TestLogFileTask(em, log);
        insertion = new DbInsertion(rec, thrown, task);
        insertion.start(new ExceptionsData());
        task.markFinished();
        waitIssuezillaInsertionFinished();

        assertNull("CLOSED ISSUE", handler.getResult());
        em.getTransaction().commit();
        em.close();
View Full Code Here

        EntityManager em = perUtils.createEntityManager();
        em.getTransaction().begin();
        String userId = "file";
        int session = 1;
        Logfile log = new Logfile(userId, session);
        DbInsertion insertion = new DbInsertion(rec, thrown, new TestLogFileTask(em, log));
        insertion.start(new ExceptionsData());
        //waitLogsParsed();
        List<org.netbeans.modules.exceptions.entity.Exceptions> all =
                PersistenceUtils.getAll(em, org.netbeans.modules.exceptions.entity.Exceptions.class);
        org.netbeans.modules.exceptions.entity.Exceptions rootException = all.get(all.size() - 1);
        rootId = rootException.getId();
        List<Nbuser> users = PersistenceUtils.getAll(em, Nbuser.class);
        Nbuser user = null;
        for (Nbuser us : users) {
            if (userName.equals(us.getName())) {
                user = us;
            }
        }
        all = PersistenceUtils.getAll(em, org.netbeans.modules.exceptions.entity.Exceptions.class);
        rootException = all.get(all.size() - 1);
        assertNotNull(rootException);
        assertEquals(1, rootException.getReportId().getDuplicates(em));
        assertEquals(1, rootException.getReportId().getDuplicatesFromDistinctUsers(em));
        assertEquals(1, rootException.getReportId().getDuplicatesFromOneUser(em, user));

        session = 2;
        log = new Logfile(userId, session);

        // -- refresh persistence context ---//
        em.getTransaction().commit();
        em.close();
        em = perUtils.createEntityManager();
        em.getTransaction().begin();
        all = PersistenceUtils.getAll(em, org.netbeans.modules.exceptions.entity.Exceptions.class);
        rootException = all.get(all.size() - 1);

        rootException = insert(em, new DbInsertion(rec, thrown, new TestLogFileTask(em, log)));
        assertEquals(2, rootException.getReportId().getDuplicates(em));
        assertEquals(1, rootException.getReportId().getDuplicatesFromDistinctUsers(em));
        assertEquals(2, rootException.getReportId().getDuplicatesFromOneUser(em, user));


        session = 3;
        log = new Logfile(userId, session);

        // -- refresh persistence context ---//
        em.getTransaction().commit();
        em.close();
        em = perUtils.createEntityManager();
        em.getTransaction().begin();
        all = PersistenceUtils.getAll(em, org.netbeans.modules.exceptions.entity.Exceptions.class);
        rootException = all.get(all.size() - 1);

        rootException = insert(em, new DbInsertion(rec, thrown, new TestLogFileTask(em, log)));
        assertEquals(3, rootException.getReportId().getDuplicates(em));
        assertEquals(1, rootException.getReportId().getDuplicatesFromDistinctUsers(em));
        assertEquals(3, rootException.getReportId().getDuplicatesFromOneUser(em, user));
        userName = "exceptions";
        params.set(3, userName);
        params.set(6, "petrzajac");
        rec.setParameters(params.toArray());

        session = 4;
        log = new Logfile(userId, session);

        // -- refresh persistence context ---//
        em.getTransaction().commit();
        em.close();
        em = perUtils.createEntityManager();
        em.getTransaction().begin();
        all = PersistenceUtils.getAll(em, org.netbeans.modules.exceptions.entity.Exceptions.class);
        rootException = all.get(all.size() - 1);

        rootException = insert(em, new DbInsertion(rec, thrown, new TestLogFileTask(em, log)));
        users = PersistenceUtils.getAll(em, Nbuser.class);
        Iterator<Nbuser> userIt = users.iterator();
        Nbuser user2 = null;
        while (userIt.hasNext()) {
            user2 = userIt.next();
            if (user2.getName().equals(userName)) {
                break;
            }
        }
        assertEquals(4, rootException.getReportId().getDuplicates(em));
        assertEquals(2, rootException.getReportId().getDuplicatesFromDistinctUsers(em));
        assertEquals(3, rootException.getReportId().getDuplicatesFromOneUser(em, user));
        assertEquals(1, rootException.getReportId().getDuplicatesFromOneUser(em, user2));

        session = 5;
        log = new Logfile(userId, session);
        rootException = insert(em, new DbInsertion(rec, thrown, new TestLogFileTask(em, log)));

        // -- refresh persistence context ---//
        em.getTransaction().commit();
        em.close();
        em = perUtils.createEntityManager();
View Full Code Here

        pv.setProductVersion("NetBeans IDE 6.0 (Build 081204)");
        Nbversion nbv = new Nbversion(1);
        nbv.setVersion("6.0");
        pv.setNbversionId(nbv);
        log.setProductVersionId(pv);
        TestLogFileTask task = new TestLogFileTask(em, log);
        Nbuser user = new Nbuser(1);
        user.setName("HALLO");
        org.netbeans.modules.exceptions.entity.Exceptions exc = new org.netbeans.modules.exceptions.entity.Exceptions(100);
        Report report = new Report(100);
        Stacktrace stacktrace = new Stacktrace(100);
        stacktrace.setLineCollection(Collections.<Line>emptyList());
        stacktrace.setClass1("NullPointerException");
        exc.setReportId(report);
        exc.setLogfileId(log);
        exc.setStacktrace(stacktrace);
        report.setComponent("user.dir");
        report.setSubcomponent("some.jar");
        exc.setNbuserId(user);
        em.persist(nbv);
        em.persist(pv);
        em.persist(report);
        em.persist(stacktrace);
        em.persist(user);
        em.persist(exc);

        new IZInsertion(exc, null).start();
        task.markFinished();
        IZInsertion.waitIZInsertionFinished();
        LogRecord result = handler.getResult();
        assertNull(result);

        em.getTransaction().commit();
View Full Code Here

TOP

Related Classes of org.netbeans.server.uihandler.DbInsertionTest.TestLogFileTask

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.