Examples of IAccessEvent


Examples of ch.qos.logback.access.spi.IAccessEvent

    synchronized (listAppender) {
      listAppender.wait(100);
    }

    assertTrue(listAppender.list.size() > 0);
    IAccessEvent event = listAppender.list.get(0);
    assertEquals("127.0.0.1", event.getRemoteHost());
    assertEquals("localhost", event.getServerName());
    listAppender.list.clear();
  }
View Full Code Here

Examples of ch.qos.logback.access.spi.IAccessEvent

    synchronized (listAppender) {
      listAppender.wait(100);
    }

    @SuppressWarnings("unused")
    IAccessEvent event = listAppender.list.get(0);

    // we should test the contents of the requests
    // assertEquals(msg, event.getRequestContent());
  }
View Full Code Here

Examples of ch.qos.logback.access.spi.IAccessEvent

    // first run for just in time compiler
    int resetCounter = 0;
    int pauseCounter = 0;
    for (int i = 0; i < loopNumber; i++) {
      try {
        IAccessEvent ae = DummyAccessEventBuilder.buildNewAccessEvent();
        //average time for the next method: 5000 nanos
        ae.prepareForDeferredProcessing();
        oos.writeObject(ae);
        oos.flush();
        if (++resetCounter >= resetFrequency) {
          oos.reset();
          resetCounter = 0;
        }
        if (++pauseCounter >= pauseFrequency) {
          Thread.sleep(pauseLengthInMillis);
          pauseCounter = 0;
        }

      } catch (IOException ex) {
        fail(ex.getMessage());
      }
    }
   
    // second run
    Long t1;
    Long t2;
    Long total = 0L;
    resetCounter = 0;
    pauseCounter = 0;
    // System.out.println("Beginning mesured run");
    for (int i = 0; i < loopNumber; i++) {
      try {
        IAccessEvent ae = DummyAccessEventBuilder.buildNewAccessEvent();
        t1 = System.nanoTime();
        //average length of the next method: 4000 nanos
        ae.prepareForDeferredProcessing();
        oos.writeObject(ae);
        oos.flush();
        t2 = System.nanoTime();
        total += (t2 - t1);
        if (++resetCounter >= resetFrequency) {
View Full Code Here

Examples of ch.qos.logback.access.spi.IAccessEvent

  }
 
  @Test
  public void testExpectFalse() throws EvaluationException {
    request.setRequestUri("test");
    IAccessEvent ae = new AccessEvent(request, response, serverAdapter);
    assertFalse(evaluator.evaluate(ae));
  }
View Full Code Here

Examples of ch.qos.logback.access.spi.IAccessEvent

  @Test
  public void testAppendAccessEvent() throws SQLException {
    setInsertHeadersAndStart(false);

    IAccessEvent event = createAccessEvent();
    appender.append(event);

    Statement stmt = connectionSource.getConnection().createStatement();
    ResultSet rs = null;
    rs = stmt.executeQuery("SELECT * FROM access_event where EVENT_ID = " + existingEventTableRowCount);
    if (rs.next()) {
      assertEquals(event.getTimeStamp(), rs.getLong(1));
      assertEquals(event.getRequestURI(), rs.getString(2));
      assertEquals(event.getRequestURL(), rs.getString(3));
      assertEquals(event.getRemoteHost(), rs.getString(4));
      assertEquals(event.getRemoteUser(), rs.getString(5));
      assertEquals(event.getRemoteAddr(), rs.getString(6));
      assertEquals(event.getProtocol(), rs.getString(7));
      assertEquals(event.getMethod(), rs.getString(8));
      assertEquals(event.getServerName(), rs.getString(9));
      assertEquals(event.getRequestContent(), rs.getString(10));
    } else {
      fail("No row was inserted in the database");
    }
    rs.close();
    stmt.close();
View Full Code Here

Examples of ch.qos.logback.access.spi.IAccessEvent

  }
 
  @Test
  public void testExpectTrue() throws EvaluationException {
    request.setRequestUri(expectedURL1);  
    IAccessEvent ae = new AccessEvent(request, response, serverAdapter);
    assertTrue(evaluator.evaluate(ae));   
  }
View Full Code Here

Examples of ch.qos.logback.access.spi.IAccessEvent

 
  @Test
  public void testExpectTrueMultiple() throws EvaluationException {
    evaluator.addURL(expectedURL2);
    request.setRequestUri(expectedURL2);   
    IAccessEvent ae = new AccessEvent(request, response, serverAdapter);
    assertTrue(evaluator.evaluate(ae));   
  }
View Full Code Here

Examples of ch.qos.logback.access.spi.IAccessEvent

  @Test
  public void testCheckNoHeadersAreInserted() throws Exception {
    setInsertHeadersAndStart(false);

    IAccessEvent event = createAccessEvent();
    appender.append(event);
    StatusPrinter.print(context.getStatusManager());

    //Check that no headers were inserted
    Statement stmt = connectionSource.getConnection().createStatement();
View Full Code Here

Examples of ch.qos.logback.access.spi.IAccessEvent

  @Test
  public void testAppendHeaders() throws SQLException {
    setInsertHeadersAndStart(true);

    IAccessEvent event = createAccessEvent();
    appender.append(event);

    Statement stmt = connectionSource.getConnection().createStatement();
    ResultSet rs = null;
    rs = stmt.executeQuery("SELECT * FROM access_event_header");
    String key;
    String value;
    if (!rs.next()) {
      fail("There should be results to this query");
    } else {
      key = rs.getString(2);
      value = rs.getString(3);
      assertNotNull(key);
      assertNotNull(value);
      assertEquals(event.getRequestHeader(key), value);
      rs.next();
      key = rs.getString(2);
      value = rs.getString(3);
      assertNotNull(key);
      assertNotNull(value);
      assertEquals(event.getRequestHeader(key), value);
    }
    if (rs.next()) {
      fail("There should be no more rows available");
    }

View Full Code Here

Examples of ch.qos.logback.access.spi.IAccessEvent

   
    @Test
    public void basicsAreIncluded() throws Exception {
        final long timestamp = System.currentTimeMillis();
       
        IAccessEvent event = mockBasicILoggingEvent();
        when(event.getTimeStamp()).thenReturn(timestamp);
       
        encoder.doEncode(event);
        closeQuietly(outputStream);
       
        JsonNode node = MAPPER.readTree(outputStream.toByteArray());
       
        assertThat(node.get("@timestamp").textValue(), is(FastDateFormat.getInstance("yyyy-MM-dd'T'HH:mm:ss.SSSZZ").format
                (timestamp)));
        assertThat(node.get("@version").intValue(), is(1));
        assertThat(node.get("@message").textValue(), is(String.format("%s - %s [%s] \"%s\" %s %s", event.getRemoteHost(), event.getRemoteUser(),
                FastDateFormat.getInstance("yyyy-MM-dd'T'HH:mm:ss.SSSZZ").format
                        (event.getTimeStamp()), event.getRequestURL(), event.getStatusCode(),
                event.getContentLength())));
       
        assertThat(node.get("@fields.method").textValue(), is(event.getMethod()));
        assertThat(node.get("@fields.protocol").textValue(), is(event.getProtocol()));
        assertThat(node.get("@fields.status_code").asInt(), is(event.getStatusCode()));
        assertThat(node.get("@fields.requested_url").textValue(), is(event.getRequestURL()));
        assertThat(node.get("@fields.requested_uri").textValue(), is(event.getRequestURI()));
        assertThat(node.get("@fields.remote_host").textValue(), is(event.getRemoteHost()));
        assertThat(node.get("@fields.HOSTNAME").textValue(), is(event.getRemoteHost()));
        assertThat(node.get("@fields.remote_user").textValue(), is(event.getRemoteUser()));
        assertThat(node.get("@fields.content_length").asLong(), is(event.getContentLength()));
        assertThat(node.get("@fields.elapsed_time").asLong(), is(event.getElapsedTime()));
       
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.