// Path: wasync/src/main/java/org/atmosphere/wasync/Decoder.java
// public final static class Decoded<T> {
//     /**
//      * Use this object to prevent the delivering of messages to {@link Function}
//      */
//     public final static Decoded ABORT = new Decoded(null, ACTION.ABORT);
// 
//     public enum ACTION {
//         /**
//          * Continue the decoding/dispatching process.
//          */
//         CONTINUE,
//         /**
//          * Do not dispatch the message to {@link Function}
//          */
//         ABORT}
// 
//     private final T decodedMessage;
//     private final ACTION action;
// 
//     /**
//      * Create a decoded object
//      * @param decodedMessage the decoded message
//      * @param action the action
//      */
//     public Decoded(T decodedMessage, ACTION action) {
//         this.decodedMessage = decodedMessage;
//         this.action = action;
//     }
// 
//     /**
//      * Create a decoded object with action set to {@link ACTION#CONTINUE}
//      * @param decodedMessage the decoded Message
//      */
//     public Decoded(T decodedMessage) {
//         this.decodedMessage = decodedMessage;
//         this.action = ACTION.CONTINUE;
//     }
// 
//     /**
//      * Return the decoded message.
//      * @return the decoded message.
//      */
//     public T decoded() {
//         return decodedMessage;
//     }
// 
//     /**
//      * Return the action.
//      * @return the action.
//      */
//     public ACTION action() {
//         return action;
//     }
// }
// 
// Path: wasync/src/main/java/org/atmosphere/wasync/Event.java
// public enum Event {
// 
//     /**
//      * This event is fired when the connection is open. This event is only fired once.
//      */
//     OPEN,
// 
//     /**
//      * This event is fired when the connection gets closed. This event is only fired once.
//      */
//     CLOSE,
// 
//     /**
//      * This event is fired every time a new message is received.
//      */
//     MESSAGE,
// 
//     /**
//      * This event is fired every time the connection re-opened
//      */
//     REOPENED,
// 
//     /**
//      * This event is fired when unexpected error happens. This event is only fired once.
//      */
//     ERROR,
// 
//     /**
//      * This event is fire when the response's status is received. This event is only fired once.
//      */
//     STATUS,
// 
//     /**
//      * This event is fire when the response's headers is received. This event is only fired once.
//      */
//     HEADERS,
// 
//     /**
//      * This event is fire when the response's bytes are received.
//      */
//     MESSAGE_BYTES,
// 
//     /**
//      * This event is fire when the connection has been established. The Transport propagated is the one that worked.
//      * This event is only fired once.
//      */
//     TRANSPORT
// 
// }


import static org.testng.Assert.assertEquals;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.atmosphere.wasync.Decoder.Decoded;
import org.atmosphere.wasync.Event;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
/*
 * Copyright 2008-2022 Async-IO.org
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package org.atmosphere.wasync.decoder;




/**
 *
 * @author Sebastian Lövdahl <slovdahl@hibox.fi>
 */
public class TrackMessageSizeDecoderTest {

    private final String DELIMITER = "|";
    private TrackMessageSizeDecoder decoder;

    @AfterMethod
    public void tearDownMethod() throws Exception {
        decoder = null;
    }

    @Test
    public void testWithProtocol() {
        decoder = new TrackMessageSizeDecoder(DELIMITER, true);
        String message = "37|{\"message\":\"ab\",\"time\":1373900488808}";

// Path: wasync/src/main/java/org/atmosphere/wasync/Decoder.java
// public final static class Decoded<T> {
//     /**
//      * Use this object to prevent the delivering of messages to {@link Function}
//      */
//     public final static Decoded ABORT = new Decoded(null, ACTION.ABORT);
// 
//     public enum ACTION {
//         /**
//          * Continue the decoding/dispatching process.
//          */
//         CONTINUE,
//         /**
//          * Do not dispatch the message to {@link Function}
//          */
//         ABORT}
// 
//     private final T decodedMessage;
//     private final ACTION action;
// 
//     /**
//      * Create a decoded object
//      * @param decodedMessage the decoded message
//      * @param action the action
//      */
//     public Decoded(T decodedMessage, ACTION action) {
//         this.decodedMessage = decodedMessage;
//         this.action = action;
//     }
// 
//     /**
//      * Create a decoded object with action set to {@link ACTION#CONTINUE}
//      * @param decodedMessage the decoded Message
//      */
//     public Decoded(T decodedMessage) {
//         this.decodedMessage = decodedMessage;
//         this.action = ACTION.CONTINUE;
//     }
// 
//     /**
//      * Return the decoded message.
//      * @return the decoded message.
//      */
//     public T decoded() {
//         return decodedMessage;
//     }
// 
//     /**
//      * Return the action.
//      * @return the action.
//      */
//     public ACTION action() {
//         return action;
//     }
// }
// 
// Path: wasync/src/main/java/org/atmosphere/wasync/Event.java
// public enum Event {
// 
//     /**
//      * This event is fired when the connection is open. This event is only fired once.
//      */
//     OPEN,
// 
//     /**
//      * This event is fired when the connection gets closed. This event is only fired once.
//      */
//     CLOSE,
// 
//     /**
//      * This event is fired every time a new message is received.
//      */
//     MESSAGE,
// 
//     /**
//      * This event is fired every time the connection re-opened
//      */
//     REOPENED,
// 
//     /**
//      * This event is fired when unexpected error happens. This event is only fired once.
//      */
//     ERROR,
// 
//     /**
//      * This event is fire when the response's status is received. This event is only fired once.
//      */
//     STATUS,
// 
//     /**
//      * This event is fire when the response's headers is received. This event is only fired once.
//      */
//     HEADERS,
// 
//     /**
//      * This event is fire when the response's bytes are received.
//      */
//     MESSAGE_BYTES,
// 
//     /**
//      * This event is fire when the connection has been established. The Transport propagated is the one that worked.
//      * This event is only fired once.
//      */
//     TRANSPORT
// 
// }


// Path: wasync/src/test/java/org/atmosphere/wasync/decoder/TrackMessageSizeDecoderTest.java
import static org.testng.Assert.assertEquals;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.atmosphere.wasync.Decoder.Decoded;
import org.atmosphere.wasync.Event;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;

/*
 * Copyright 2008-2022 Async-IO.org
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package org.atmosphere.wasync.decoder;




/**
 *
 * @author Sebastian Lövdahl <slovdahl@hibox.fi>
 */
public class TrackMessageSizeDecoderTest {

    private final String DELIMITER = "|";
    private TrackMessageSizeDecoder decoder;

    @AfterMethod
    public void tearDownMethod() throws Exception {
        decoder = null;
    }

    @Test
    public void testWithProtocol() {
        decoder = new TrackMessageSizeDecoder(DELIMITER, true);
        String message = "37|{\"message\":\"ab\",\"time\":1373900488808}";

        Decoded<List<String>> result = decoder.decode(Event.MESSAGE, message);