Package org.apache.ace.feedback

Examples of org.apache.ace.feedback.Descriptor.toRepresentation()


    @Test(groups = { UNIT })
    public synchronized void getRange() throws Exception {
        final Descriptor range = new Descriptor(TARGET_ID, 1, new SortedRangeSet("1-10"));
        m_task.getDescriptor(new InputStream() {
            int m_count = 0;
            byte[] m_bytes = (range.toRepresentation() + "\n").getBytes();
            @Override
            public int read() throws IOException {
                if (m_count < m_bytes.length) {
                    byte b = m_bytes[m_count];
                    m_count++;
View Full Code Here


        final Event event = new Event(TARGET_ID, 1, 1, 1, 1);
        final List<Event> events = new ArrayList<Event>();
        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];
View Full Code Here

public class LogDescriptorTest {

    @Test(groups = { UNIT })
    public void serializeDescriptor() {
        Descriptor descriptor = new Descriptor("gwid", 1, new SortedRangeSet("2-3"));
        assert descriptor.toRepresentation().equals("gwid,1,2-3") : "The representation of our descriptor is incorrect:" + descriptor.toRepresentation();
    }

    @Test(groups = { UNIT })
    public void deserializeDescriptor() {
        Descriptor descriptor = new Descriptor("gwid,1,2-3");
View Full Code Here

public class LogDescriptorTest {

    @Test(groups = { UNIT })
    public void serializeDescriptor() {
        Descriptor descriptor = new Descriptor("gwid", 1, new SortedRangeSet("2-3"));
        assert descriptor.toRepresentation().equals("gwid,1,2-3") : "The representation of our descriptor is incorrect:" + descriptor.toRepresentation();
    }

    @Test(groups = { UNIT })
    public void deserializeDescriptor() {
        Descriptor descriptor = new Descriptor("gwid,1,2-3");
View Full Code Here

    public void deserializeMultiRangeDescriptorWithFunnyGWID() {
        String line = "gw$$id,1,1-4$k6$k8$k10-20";
        Descriptor descriptor = new Descriptor(line);
        assert descriptor.getTargetID().equals("gw$id") : "Target ID not correctly parsed.";
        assert descriptor.getStoreID() == 1 : "Log ID not correctly parsed.";
        assert line.equals(descriptor.toRepresentation()) : "Converting the line back to the representation failed.";
        String representation = descriptor.getRangeSet().toRepresentation();
        assert representation.equals("1-4,6,8,10-20") : "There should be nothing in the diff between the set in the descriptor and the check-set, but we parsed: " + representation;
    }

    @Test(groups = { UNIT }, expectedExceptions = IllegalArgumentException.class)
View Full Code Here

    // Handle a call to the query 'command'
    protected boolean handleQuery(String targetID, String logID, String filter, ServletOutputStream output) throws IOException {
        if ((targetID != null) && (logID != null)) {
            // target and log id are specified, return only the range that matches these id's
            Descriptor range = m_store.getDescriptor(targetID, Long.parseLong(logID));
            output.print(range.toRepresentation());
            return true;
        }
        else if ((targetID == null) && (logID == null)) {
            // no target or log id has been specified, return all ranges
            List<Descriptor> ranges = m_store.getDescriptors();
View Full Code Here

        }
        else if ((targetID == null) && (logID == null)) {
            // no target or log id has been specified, return all ranges
            List<Descriptor> ranges = m_store.getDescriptors();
            for (Descriptor range : ranges) {
                output.print(range.toRepresentation() + "\n");
            }
            return true;
        }
        return false;
    }
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.