/** * Finds the {@code TestReport} with the given build type id ordered by build id in the descendant * order. * * @param buildTypeId the build type id. * @param limit the optional fetch limit, by default {@link * com.google.appengine.tck.site.endpoints.TestReport#DEFAULT_FETCH_LIMIT}. * @param reports the reports entry point * @return the matching test reports list or an empty one if none. */ @SuppressWarnings("unchecked") public static List<TestReport> findByBuildTypeIdOrderByBuildIdDesc( String buildTypeId, Optional<Integer> limit, Reports reports) { final MemcacheService memcacheService = reports.getMemcacheService(); List<TestReport> results = (List<TestReport>) memcacheService.get(buildTypeId); if (results == null) { final Filter buildTypeFilter = new Query.FilterPredicate("buildTypeId", FilterOperator.EQUAL, buildTypeId); final Query query = new Query(TEST_REPORT).setFilter(buildTypeFilter).addSort("buildId", DESCENDING); final DatastoreService datastoreService = reports.getDatastoreService(); final PreparedQuery preparedQuery = datastoreService.prepare(query); final List<Entity> entities = preparedQuery.asList(FetchOptions.Builder.withLimit(limit.or(DEFAULT_FETCH_LIMIT))); results = new ArrayList<>(); for (Entity oneEntity : entities) { final TestReport report = from(oneEntity); results.add(report); } memcacheService.put(buildTypeId, results); } return results; }
/** * Persists {@code this} test report to the given {@link * com.google.appengine.api.datastore.DatastoreService} and invalidate the cache. * * @param reports the reports entry point */ public void save(Reports reports) { final Entity entity = new Entity(TEST_REPORT, buildTypeId + buildId); entity.setProperty("buildTypeId", buildTypeId); entity.setProperty("buildId", buildId); entity.setProperty("buildDate", buildDate); entity.setProperty("buildDuration", buildDuration); entity.setProperty("numberOfPassedTests", numberOfPassedTests); entity.setProperty("numberOfIgnoredTests", numberOfIgnoredTests); entity.setProperty("numberOfFailedTests", numberOfFailedTests); final JSONArray jsonArrayFailedTests = new JSONArray(); for (Test oneFailingTest : failedTests) { jsonArrayFailedTests.put(oneFailingTest.asJson()); } entity.setProperty("failedTests", new Text(jsonArrayFailedTests.toString())); final JSONArray jsonArrayIgnoredTests = new JSONArray(); for (Test oneIgnoredTest : ignoredTests) { jsonArrayIgnoredTests.put(oneIgnoredTest.asJson()); } entity.setProperty("ignoredTests", new Text(jsonArrayIgnoredTests.toString())); final DatastoreService datastoreService = reports.getDatastoreService(); datastoreService.put(entity); final MemcacheService memcacheService = reports.getMemcacheService(); memcacheService.delete(buildTypeId); // invalidate cache }
@Test public void testMultistatus() { MultiStatus mst = mst(ex(), st(ex()), st(ex()), st(ex()), st(ex()), st(ex())); org.eclipse.epp.internal.logging.aeri.ui.model.Status res = Reports.newStatus(mst, configuration); assertThat(numberOfStatusObjects(res), is(6)); }
void save(Element pj_el) { // General settings saveString("rep_location", rep_location, pj_el); saveString("out_location", out_location, pj_el); saveString("rep_server", rep_server, pj_el); saveInt("rep_server_port", rep_server_port, pj_el); saveInt("max_pdf_storage", max_pdf_storage, pj_el); saveInt("min_pdf_lifetime", min_pdf_lifetime, pj_el); // Db Information saveString("db_driver", db_driver, pj_el); saveString("db_conn_str", db_conn_str, pj_el); saveString("db_user", db_user, pj_el); saveString("db_pwd", db_pwd, pj_el); // Generation Information saveString("gen_jasp_root", gen_jasp_root, pj_el); saveString("gen_class_dir", gen_class_dir, pj_el); Iterator it = reports.getIterator(); while (it.hasNext()) { ReportFacade r = (ReportFacade) it.next(); Element repf_el = new Element("ReportFacade"); r.save(repf_el); pj_el.addContent(repf_el); } }
@Test public void testFingerprintNested() { Exception root = new RuntimeException("root"); IStatus s1 = new Status(IStatus.ERROR, "org.eclipse.epp.logging.aeri", "some error message", root); IStatus s2 = new MultiStatus( "org.eclipse.epp.logging.aeri", 0, new IStatus[] {s1}, "some error message", root); org.eclipse.epp.internal.logging.aeri.ui.model.Status normal = Reports.newStatus(s1, configuration); org.eclipse.epp.internal.logging.aeri.ui.model.Status multi = Reports.newStatus(s2, configuration); Assert.assertNotEquals(normal.getFingerprint(), multi.getFingerprint()); }
@Test public void testPrettyPrintNullSafe2() { ModelFactory mf = ModelFactory.eINSTANCE; ErrorReport report = mf.createErrorReport(); report.setStatus(mf.createStatus()); Reports.prettyPrint(report); }
@Test public void testClearEventMessage() { ErrorReport event = createTestReport(); Reports.clearMessages(event); assertThat(event.getStatus().getMessage(), is(ANONYMIZED_TAG)); }
@Test public void testCausedByContainsCoreExceptionWithMultistatus() { MultiStatus mst = mst(ex(), st(ex()), st(ex()), st(ex()), st(ex()), st(ex())); Status st = st(ex(cex(mst))); org.eclipse.epp.internal.logging.aeri.ui.model.Status res = Reports.newStatus(st, configuration); assertThat(numberOfStatusObjects(res), is(7)); }
@Test public void testCreateAnonymizedSendCopyCreateNewInstance() { ModelFactory mf = ModelFactory.eINSTANCE; ErrorReport report = mf.createErrorReport(); ErrorReport copy = Reports.createAnonymizedSendCopy(report, settings, configuration); assertThat(copy, not(sameInstance(report))); }
@Test public void testPrettyPrintSkipsNullException() { ModelFactory mf = ModelFactory.eINSTANCE; ErrorReport report = mf.createErrorReport(); report.setStatus(mf.createStatus()); String prettyPrint = Reports.prettyPrint(report); assertThat(prettyPrint, not(containsString("Exception"))); }
@Test public void testPrettyPrintNullSafe3() { ModelFactory mf = ModelFactory.eINSTANCE; ErrorReport report = mf.createErrorReport(); report.setStatus(mf.createStatus()); Throwable t = mf.createThrowable(); t.setClassName("org.test"); report.getStatus().setException(t); Reports.prettyPrint(report); }
public ReportFacade createRep(String name, File jrxml) { ReportFacade rf = new ReportFacade(this); boolean b = rf.createReport(name, jrxml, facade.getDirectory()); if (!b) { Logger.addItem(new LogItem(Logger.LEVEL_ERROR, "Create Report failed")); return null; } reports.add(rf); Logger.addItem(new LogItem(Logger.LEVEL_INFO, "Report added")); return rf; }
@Test public void testCreateAnonymizedSendCopyInsertNameAndEmail() { ModelFactory mf = ModelFactory.eINSTANCE; ErrorReport report = mf.createErrorReport(); settings.setName("foobarbaz"); settings.setEmail("*****@*****.**"); ErrorReport copy = Reports.createAnonymizedSendCopy(report, settings, configuration); assertThat(copy.getName(), is("foobarbaz")); assertThat(copy.getEmail(), is("*****@*****.**")); }
@Test public void testFingerprint() { Exception cause = new RuntimeException("cause"); Exception r1 = new RuntimeException("exception message"); r1.fillInStackTrace(); Exception r2 = new RuntimeException("exception message", cause); r2.fillInStackTrace(); IStatus s1 = new Status(IStatus.ERROR, "org.eclipse.epp.logging.aeri", "some error message", r1); IStatus s2 = new Status(IStatus.ERROR, "org.eclipse.epp.logging.aeri", "some error message", r2); org.eclipse.epp.internal.logging.aeri.ui.model.Status noCause = Reports.newStatus(s1, configuration); org.eclipse.epp.internal.logging.aeri.ui.model.Status withCause = Reports.newStatus(s2, configuration); Assert.assertNotEquals(noCause.getFingerprint(), withCause.getFingerprint()); }
@Test public void testCreateAnonymizedSendCopyAnonymizes() { ModelFactory mf = ModelFactory.eINSTANCE; ErrorReport report = mf.createErrorReport(); report.setStatus(mf.createStatus()); java.lang.Throwable throwable = new RuntimeException("test exception"); throwable.fillInStackTrace(); Throwable t = Reports.newThrowable(throwable); report.getStatus().setException(t); settings.setAnonymizeMessages(true); settings.setAnonymizeStrackTraceElements(true); configuration.setAcceptedPackages(new ArrayList<String>()); ErrorReport copy = Reports.createAnonymizedSendCopy(report, settings, configuration); assertThat(copy.getStatus().getMessage(), is(Constants.HIDDEN)); StackTraceElement stackTraceElement = copy.getStatus().getException().getStackTrace().get(0); assertThat(stackTraceElement.getClassName(), is(Constants.HIDDEN)); assertThat(stackTraceElement.getMethodName(), is(Constants.HIDDEN)); assertThat(stackTraceElement.getFileName(), is(Constants.HIDDEN)); assertThat(stackTraceElement.getLineNumber(), is(-1)); }
@Test public void testDeclaringClassToNull() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { java.lang.Throwable some = new java.lang.Throwable("contains null"); java.lang.StackTraceElement ste = new java.lang.StackTraceElement("class", "method", null, 1); Field field = java.lang.StackTraceElement.class.getDeclaredField("declaringClass"); field.setAccessible(true); field.set(ste, null); some.setStackTrace(new java.lang.StackTraceElement[] {ste}); Throwable sut = Reports.newThrowable(some); Assert.assertEquals("MISSING", sut.getStackTrace().get(0).getClassName()); }
@Test public void testDetachMultistatusFromCoreException() { // #input // st4 // -ex4 // --cex // ---mst3 // ----ex1 // ----st1 // -----ex2 // ----st2 // -----ex3 Status st = st(ex(cex(mst(ex(), st(ex()), st(ex()))))); // #expected output // st4 // -ex4 // --cex(mst3) // ---ex1 // -mst3 (moved from cex to st4.children) // --ex1 // --st1 // ---ex2 // --st2 // ---ex3 org.eclipse.epp.internal.logging.aeri.ui.model.Status st4 = Reports.newStatus(st, configuration); Throwable ex4 = st4.getException(); Throwable cex = ex4.getCause(); Throwable ex1 = cex.getCause(); org.eclipse.epp.internal.logging.aeri.ui.model.Status mst3 = st4.getChildren().get(0); Throwable ex1b = mst3.getException(); org.eclipse.epp.internal.logging.aeri.ui.model.Status st1 = mst3.getChildren().get(0); Throwable ex2 = st1.getException(); org.eclipse.epp.internal.logging.aeri.ui.model.Status st2 = mst3.getChildren().get(1); Throwable ex3 = st2.getException(); assertThat(st4.getMessage(), is("st4")); assertThat(ex4.getMessage(), is("ex4")); assertThat(cex.getMessage(), is("mst3")); assertThat(ex1.getMessage(), is("ex1")); assertThat( mst3.getMessage(), is("mst3 [detached from CoreException of Status 'st4' by Error Reporting]")); assertThat(ex1b.getMessage(), is("ex1")); assertThat(st1.getMessage(), is("st1")); assertThat(ex2.getMessage(), is("ex2")); assertThat(st2.getMessage(), is("st2")); assertThat(ex3.getMessage(), is("ex3")); }
@Override public void onDestroy() { super.onDestroy(); // Toast.makeText(getApplicationContext(),"16. onDestroy()", // Toast.LENGTH_SHORT).show(); Log.e("time in mills", time + ""); long seconds = time / 1000; long minutes = seconds / 60; seconds = seconds % 60; long hours = minutes / 60; minutes = minutes % 60; String timestr = hours + ":" + minutes + ":" + seconds; Log.e("time in hh:mm:ss", timestr); reports.updateDuration(aid, timestr); }
@Test public void testMultistatusDuplicateChildFiltering() { Exception e1 = new Exception("Stack Trace"); e1.setStackTrace( createStacktraceForClasses( "java.lang.Object", "org.eclipse.core.internal.jobs.WorkerPool", "org.eclipse.core.internal.jobs.WorkerPool", "org.eclipse.core.internal.jobs.Worker")); IStatus s1 = new Status( IStatus.ERROR, "org.eclipse.ui.monitoring", "Thread 'Worker-3' tid=39 (TIMED_WAITING)\n" + "Waiting for: org.eclipse.core.internal.jobs.WorkerPool@416dc7fc", e1); Exception e2 = new Exception("Stack Trace"); e2.setStackTrace( TestReports.createStacktraceForClasses( "java.lang.Object", "org.eclipse.core.internal.jobs.WorkerPool", "org.eclipse.core.internal.jobs.WorkerPool", "org.eclipse.core.internal.jobs.Worker")); IStatus s2 = new Status( IStatus.ERROR, "org.eclipse.ui.monitoring", "Thread 'Worker-2' tid=36 (TIMED_WAITING)\n" + "Waiting for: org.eclipse.core.internal.jobs.WorkerPool@416dc7fc", e2); IStatus multi = new MultiStatus( "org.eclipse.ui.monitoring", 0, new IStatus[] {s1, s2}, "UI freeze of 10s at 08:09:02.936", new RuntimeException("stand-in-stacktrace")); org.eclipse.epp.internal.logging.aeri.ui.model.Status newStatus = Reports.newStatus(multi, configuration); assertThat(newStatus.getChildren().size(), is(1)); assertThat( newStatus.getMessage(), is( "UI freeze of 10s at 08:09:02.936 [1 child-status duplicates removed by Error Reporting]")); }
@Test public void testCoreExceptionHandling() { IStatus causingStatus = new Status(IStatus.ERROR, "the.causing.plugin", "first message"); java.lang.Throwable causingException = new CoreException(causingStatus); IStatus causedStatus = new Status(IStatus.WARNING, "some.calling.plugin", "any other message", causingException); java.lang.Throwable rootException = new CoreException(causedStatus); IStatus rootEvent = new Status( IStatus.ERROR, "org.eclipse.epp.logging.aeri", "someErrorMessage", rootException); org.eclipse.epp.internal.logging.aeri.ui.model.Status rootStatus = Reports.newStatus(rootEvent, configuration); org.eclipse.epp.internal.logging.aeri.ui.model.Status child = rootStatus.getChildren().get(0); org.eclipse.epp.internal.logging.aeri.ui.model.Status leaf = child.getChildren().get(0); assertThat(child.getPluginId(), is("some.calling.plugin")); assertThat(leaf.getPluginId(), is("the.causing.plugin")); }
@Test public void testMultistatusChildFilteringHandlesEmptyStacktrace() { Exception e1 = new Exception("Stack Trace 1"); e1.setStackTrace(new java.lang.StackTraceElement[0]); IStatus s1 = new Status( IStatus.ERROR, "org.eclipse.ui.monitoring", "Thread 'Signal Dispatcher' tid=4 (RUNNABLE)", e1); IStatus multi = new MultiStatus( "org.eclipse.ui.monitoring", 0, new IStatus[] {s1}, "UI freeze of 10s at 08:09:02.936", new RuntimeException("stand-in-stacktrace")); org.eclipse.epp.internal.logging.aeri.ui.model.Status newStatus = Reports.newStatus(multi, configuration); assertThat(newStatus.getChildren().size(), is(0)); }
public void deleteRep(ReportFacade rep) { boolean b = rep.deleteReport(); if (!b) return; reports.remove(rep); }
private ReportFacade createEmptyRep() { ReportFacade rf = new ReportFacade(this); rf.createEmptyReport(); reports.add(rf); return rf; }
@Test public void testMultistatusMainStacktracesNotFiltered() { Exception e1 = new Exception("Stack Trace"); java.lang.StackTraceElement[] stackTrace = createStacktraceForClasses( "java.lang.Thread", "org.eclipse.epp.logging.aeri.ui.actions.UiFreezeAction", "org.eclipse.ui.internal.PluginAction", "org.eclipse.ui.internal.WWinPluginAction", "org.eclipse.jface.action.ActionContributionItem", "org.eclipse.jface.action.ActionContributionItem", "org.eclipse.jface.action.ActionContributionItem", "org.eclipse.swt.widgets.EventTable", "org.eclipse.swt.widgets.Display", "org.eclipse.swt.widgets.Widget", "org.eclipse.swt.widgets.Display", "org.eclipse.swt.widgets.Display", "org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine", "org.eclipse.core.databinding.observable.Realm", "org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine", "org.eclipse.e4.ui.internal.workbench.E4Workbench", "org.eclipse.ui.internal.Workbench", "org.eclipse.core.databinding.observable.Realm", "org.eclipse.ui.internal.Workbench", "org.eclipse.ui.PlatformUI", "org.eclipse.ui.internal.ide.application.IDEApplication", "org.eclipse.equinox.internal.app.EclipseAppHandle", "org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher", "org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher", "org.eclipse.core.runtime.adaptor.EclipseStarter", "org.eclipse.core.runtime.adaptor.EclipseStarter", "sun.reflect.NativeMethodAccessorImpl", "sun.reflect.NativeMethodAccessorImpl", "sun.reflect.DelegatingMethodAccessorImpl", "java.lang.reflect.Method", "org.eclipse.equinox.launcher.Main", "org.eclipse.equinox.launcher.Main", "org.eclipse.equinox.launcher.Main", "org.eclipse.equinox.launcher.Main", "org.eclipse.equinox.launcher.Main"); e1.setStackTrace(stackTrace); IStatus s1 = new Status( IStatus.ERROR, "org.eclipse.ui.monitoring", "Sample at 11:25:04.447 (+1,331s)\n" + "Thread 'main' tid=1 (TIMED_WAITING)", e1); IStatus multi = new MultiStatus( "org.eclipse.ui.monitoring", 0, new IStatus[] {s1}, "UI freeze of 6,0s at 11:24:59.108", new RuntimeException("stand-in-stacktrace")); org.eclipse.epp.internal.logging.aeri.ui.model.Status newStatus = Reports.newStatus(multi, configuration); assertThat(newStatus.getChildren().size(), is(1)); assertThat( newStatus.getChildren().get(0).getException().getStackTrace().size(), is(stackTrace.length)); }
@Test public void testDetachMultipleMultistatusFromCoreException() { // #input // st9 // -ex6 // --cex // ---st8 // ----cex // -----mst7 // ------ex1 // ------st4 // -------cex // --------mst3 // ---------ex2 // ---------st1 // ----------ex3 // ---------st2 // ----------ex4 // ------st6 // -------cex // --------st5 // ---------ex5 Status st = st(ex(cex(st(cex(mst(ex(), st(cex(mst(ex(), st(ex()), st(ex())))), st(cex(st(ex()))))))))); // #expected output // st9 // -st8 // --mst7 // ---ex1 // ---st4 // ----mst3 // -----ex2 // ----st1 // -----ex3 // ----st2 // -----ex4 // ---st6 // ----st5 // -----ex5 org.eclipse.epp.internal.logging.aeri.ui.model.Status st9 = Reports.newStatus(st, configuration); Throwable ex6 = st9.getException(); org.eclipse.epp.internal.logging.aeri.ui.model.Status st8 = st9.getChildren().get(0); org.eclipse.epp.internal.logging.aeri.ui.model.Status mst7 = st8.getChildren().get(0); org.eclipse.epp.internal.logging.aeri.ui.model.Status st4 = mst7.getChildren().get(0); org.eclipse.epp.internal.logging.aeri.ui.model.Status mst3 = st4.getChildren().get(0); org.eclipse.epp.internal.logging.aeri.ui.model.Status st2 = mst3.getChildren().get(1); Throwable ex4 = st2.getException(); org.eclipse.epp.internal.logging.aeri.ui.model.Status st6 = mst7.getChildren().get(1); org.eclipse.epp.internal.logging.aeri.ui.model.Status st5 = st6.getChildren().get(0); Throwable ex5 = st5.getException(); assertThat(st9.getMessage(), is("st9")); assertThat(ex6.getMessage(), is("ex6")); assertThat( st8.getMessage(), is("st8 [detached from CoreException of Status 'st9' by Error Reporting]")); assertThat( mst7.getMessage(), is("mst7 [detached from CoreException of Status 'st8' by Error Reporting]")); assertThat(st4.getMessage(), is("st4")); assertThat( mst3.getMessage(), is("mst3 [detached from CoreException of Status 'st4' by Error Reporting]")); assertThat(st2.getMessage(), is("st2")); assertThat(ex4.getMessage(), is("ex4")); assertThat(st6.getMessage(), is("st6")); assertThat( st5.getMessage(), is("st5 [detached from CoreException of Status 'st6' by Error Reporting]")); assertThat(ex5.getMessage(), is("ex5")); }
@Override public void onNewIntent(Intent intent) { Dtitle = intent.getStringExtra("title"); Ddetail = intent.getStringExtra("detail"); Dfrom = intent.getStringExtra("from"); _id = intent.getStringExtra("_id"); Dsummary = intent.getStringExtra("summary"); String sharekey = intent.getStringExtra("shareKey"); if (sharekey.contains("off")) share.setVisibility(Button.GONE); name = intent.getStringExtra("name"); aid = intent.getStringExtra("id"); // String shareflag = intent.getStringExtra("shareKey"); // if(shareflag.trim().contentEquals("off")) // share.setVisibility(Button.INVISIBLE); // url = intent.getStringExtra(""); title.setText(Dtitle); detail.setText(Ddetail); from.setText(Dfrom); summary.setText(Dsummary); String root = Environment.getExternalStorageDirectory().toString(); File myDir = new File(root + Constants.APP_FOLDER_VIDEO); // myDir.mkdirs(); String fname = name; file = new File(myDir, fname); if (file.exists()) { String roo1t = Environment.getExternalStorageDirectory().toString() + Constants.APP_FOLDER_VIDEO + name; vid.setVideoPath(roo1t); vid.setZOrderOnTop(false); vid.setMediaController(new MediaController(this) {}); vid.requestFocus(); } else { if (Utilities.isInternetConnected()) { Download d = new Download(TrainingVideo.this, AnnounceDBAdapter.SQLITE_TRAINING, _id + ""); d.execute(""); d.setOnPostExecuteListener( new OnPostExecuteListener() { public void onPostExecute(String result) { String roo1t = Environment.getExternalStorageDirectory().toString() + Constants.APP_FOLDER_VIDEO + name; detail.setText(DateUtils.formatDate(Ddetail)); Bitmap thumbnail = ThumbnailUtils.createVideoThumbnail( roo1t, MediaStore.Images.Thumbnails.MINI_KIND); BitmapDrawable bitmapDrawable = new BitmapDrawable(thumbnail); // vid.setBackgroundDrawable(bitmapDrawable); btn.setImageDrawable(bitmapDrawable); vid.setVideoPath(roo1t); vid.setVideoPath(roo1t); vid.setZOrderOnTop(false); vid.setMediaController(new MediaController(TrainingVideo.this) {}); vid.requestFocus(); } }); } else { Toast.makeText( TrainingVideo.this, "Please check your internet connection", Toast.LENGTH_SHORT) .show(); } } // vid.start(); AnnounceDBAdapter announce = new AnnounceDBAdapter(getApplicationContext()); announce.open(); announce.readrow(_id + "", "Training"); announce.close(); reports.updateRead(aid); // SA VIKALP ADDED CANCEL LOLLIPOP NOTIFICATION try { Utilities.cancelLolliPopNotification(ApplicationLoader.getApplication()); } catch (Exception e) { Log.i(TAG, e.toString()); } // EA VIKALP ADDED CANCEL LOLLIPOP NOTIFICATION }