コード例 #1
0
ファイル: MeasureCacheTest.java プロジェクト: ihr/sonarqube
  @Test
  public void should_add_measure_with_big_data() {
    Project p = new Project("struts");

    assertThat(measureCache.entries()).hasSize(0);

    assertThat(measureCache.byResource(p)).hasSize(0);

    Measure m = new Measure(CoreMetrics.NCLOC, 1.0).setDate(new Date());
    m.setAlertText("foooooooooooooooooooooooooooooooooooo");
    StringBuilder data = new StringBuilder();
    for (int i = 0; i < 1_048_575; i++) {
      data.append("a");
    }

    m.setData(data.toString());

    measureCache.put(p, m);

    assertThat(measureCache.contains(p, m)).isTrue();
    assertThat(measureCache.entries()).hasSize(1);
    Iterator<Entry<Measure>> iterator = measureCache.entries().iterator();
    iterator.hasNext();
    Entry<Measure> next = iterator.next();
    assertThat(next.value()).isEqualTo(m);
    assertThat(next.key()[0]).isEqualTo("struts");

    assertThat(measureCache.byResource(p)).hasSize(1);
    assertThat(measureCache.byResource(p).iterator().next()).isEqualTo(m);
  }
コード例 #2
0
ファイル: MeasureCacheTest.java プロジェクト: ihr/sonarqube
  @Test
  public void should_add_measure() {
    Project p = new Project("struts");

    assertThat(measureCache.entries()).hasSize(0);
    assertThat(measureCache.byResource(p)).hasSize(0);

    Measure m = new Measure(CoreMetrics.NCLOC, 1.0);
    measureCache.put(p, m);

    assertThat(measureCache.contains(p, m)).isTrue();
    assertThat(measureCache.entries()).hasSize(1);
    Iterator<Entry<Measure>> iterator = measureCache.entries().iterator();
    iterator.hasNext();
    Entry<Measure> next = iterator.next();
    assertThat(next.value()).isEqualTo(m);
    assertThat(next.key()[0]).isEqualTo("struts");

    assertThat(measureCache.byResource(p)).hasSize(1);
    assertThat(measureCache.byResource(p).iterator().next()).isEqualTo(m);
  }