Package org.apache.ace.log

Examples of org.apache.ace.log.LogEvent


    }

    @Test(groups = { UNIT })
    public synchronized void synchronizeLog() throws Exception {
        final LogDescriptor range = new LogDescriptor("gwID", 1, new SortedRangeSet(new long[] {0}));
        final LogEvent event = new LogEvent("gwID", 1, 1, 1, 1, new Properties());
        final List<LogEvent> events = new ArrayList<LogEvent>();
        events.add(event);

        InputStream input = new InputStream() {
            byte[] bytes = range.toRepresentation().getBytes();
            int count = 0;
            @Override
            public int read() throws IOException {
                if (count < bytes.length) {
                    byte b = bytes[count];
                    count++;
                    return b;
                } else {
                    return -1;
                }
            }
        };
        TestUtils.configureObject(m_task, LogStore.class, new LogStore() {
            public List<?> get(long logID, long from, long to) throws IOException {
                return events;
            }
            public long getHighestID(long logID) throws IOException {
                return event.getID();
            }
            public List<?> get(long logID) throws IOException { return null; }
            public long[] getLogIDs() throws IOException { return null; }
            @SuppressWarnings("unchecked")
            public LogEvent put(int type, Dictionary props) throws IOException { return null; }
        });
        MockConnection connection = new MockConnection(new URL("http://mock"));
        m_task.synchronizeLog(1, input, connection);
        String expectedString = event.toRepresentation() + "\n";
        String actualString = connection.getString();

        assert actualString.equals(expectedString) : "We expected " + expectedString + " but received " + actualString;
    }
View Full Code Here


            List<LogEvent> events = new ArrayList<LogEvent>();

            String eventString = null;
            while ((eventString = reader.readLine()) != null) {
                try {
                    LogEvent event = new LogEvent(eventString);
                    events.add(event);
                }
                catch (IllegalArgumentException e) {
                    // Just skip this one.
                }
View Full Code Here

            String eventString;
            while ((eventString = reader.readLine()) != null) {
                try {
                    m_log.log(LogService.LOG_DEBUG, "Log event received: '" + eventString +"'");
                    LogEvent event = new LogEvent(eventString);
                    events.add(event);
                }
                catch (IllegalArgumentException iae) {
                    success = false;
                    m_log.log(LogService.LOG_WARNING, "Could not construct LogEvent from string: '" + eventString + "'");
View Full Code Here

        input.setBytes(expected.getBytes());
        m_logServlet.handleSend(input);

        String actual = "";
        for (Iterator<LogEvent> i = m_mockStore.m_events.iterator(); i.hasNext();) {
            LogEvent event = i.next();
            actual = actual + event.toRepresentation() + "\n";
        }
        assert expected.equals(actual);
    }
View Full Code Here

        assert ranges.isEmpty() : "New store should have no ranges.";
        List<LogEvent> events = new ArrayList<LogEvent>();
        for (String gateway : new String[] { "g1", "g2", "g3" }) {
            for (long log : new long[] { 1, 2, 3, 5 }) {
                for (long id : new long[] { 1, 2, 3, 20 }) {
                    events.add(new LogEvent(gateway, log, id, System.currentTimeMillis(), AuditEvent.FRAMEWORK_STARTED, new Properties() {
                        {
                            put("test", "bar");
                        }
                    }));
                }
View Full Code Here

    }

    @Test( groups = { TestUtils.UNIT } )
    public void testLogWithSpecialCharacters() throws IOException {
        String gatewayID = "myga\0teway";
        LogEvent event = new LogEvent(gatewayID, 1, 1, System.currentTimeMillis(), AuditEvent.FRAMEWORK_STARTED, new Properties());
        List<LogEvent> events = new ArrayList<LogEvent>();
        events.add(event);
        m_logStore.put(events);
        assert m_logStore.getDescriptors().size() == 1 : "Incorrect amount of ranges returned from store: expected 1, found " + m_logStore.getDescriptors().size();
        assert m_logStore.getDescriptors(gatewayID).size() == 1 : "We expect to find a single event: expected 1, found " + m_logStore.getDescriptors(gatewayID).size();
View Full Code Here

            in = new BufferedReader(new FileReader(log));
            String file = log.getAbsolutePath();
            long counter = 0;
            for (String line = in.readLine(); line != null; line = in
                    .readLine()) {
                LogEvent event = new LogEvent(line);
                long id = event.getID();
                if ((counter != -1) && ++counter == id) {

                } else {
                    counter = -1;
                }
View Full Code Here

            }

            while (store.hasNext()) {
                long eventID = store.readCurrentID();
                if ((eventID >= from) && (eventID <= to)) {
                    result.add(new LogEvent(new String(store.read())));
                } else {
                    store.skip();
                }
            }
        }
View Full Code Here

     *             in case of any IO error.
     */
    public synchronized LogEvent put(int type, Dictionary props)
            throws IOException {
        try {
            LogEvent result = new LogEvent(m_identification.getID(),
                    m_store.getId(), getNextID(), System.currentTimeMillis(),
                    type, props);
            m_store.append(result.getID(), result.toRepresentation().getBytes());
            return result;
        }
        catch (IOException ex) {
            handleException(m_store, ex);
        }
View Full Code Here

TOP

Related Classes of org.apache.ace.log.LogEvent

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.