View Javadoc

    1   /*
    2    *  Licensed to the Apache Software Foundation (ASF) under one
    3    *  or more contributor license agreements.  See the NOTICE file
    4    *  distributed with this work for additional information
    5    *  regarding copyright ownership.  The ASF licenses this file
    6    *  to you under the Apache License, Version 2.0 (the
    7    *  "License"); you may not use this file except in compliance
    8    *  with the License.  You may obtain a copy of the License at
    9    *
    10   *    http://www.apache.org/licenses/LICENSE-2.0
    11   *
    12   *  Unless required by applicable law or agreed to in writing,
    13   *  software distributed under the License is distributed on an
    14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    15   *  KIND, either express or implied.  See the License for the
    16   *  specific language governing permissions and limitations
    17   *  under the License.
    18   *
    19   */
    20  package org.apache.mina.coap.codec;
    21
    22  import org.apache.mina.coap.CoapMessage;
    23  import org.apache.mina.coap.CoapOption;
    24  import org.apache.mina.coap.CoapOptionType;
    25  import org.apache.mina.coap.MessageType;
    26
    27  /**
    28   * Some CoAP sample messages for testing purposes.
    29   *
    30   * @author <a href="http://mina.apache.org">Apache MINA Project</a>
    31   */
    32  public interface TestMessages {
    33
    34      public static final CoapMessage NO_CONTENT_NO_OPTION = new CoapMessage(1, MessageType.ACK, 1, 1234, null, null,
    35              null);
    36
    37      public static final String NO_CONTENT_NO_OPTION_HEX = "600104D2";
    38
    39      public static final CoapMessage SOME_CONTENT_NO_OPTION = new CoapMessage(1, MessageType.CONFIRMABLE, 1, 1234,
    40              "token".getBytes(), null, "some rather large payload".getBytes());
    41
    42      public static final String SOME_CONTENT_NO_OPTION_HEX = "450104D2746F6B656EFF736F6D6520726174686572206C61726765207061796C6F6164";
    43
    44      public static final CoapMessage PAYLOAD_AND_ONE_OPTION = new CoapMessage(1, MessageType.NON_CONFIRMABLE, 1, 1234,
    45              "toto".getBytes(),
    46              new CoapOption[] { new CoapOption(CoapOptionType.URI_PATH, "coap://blabla".getBytes()) }, new byte[] {});
    47
    48      public static final String PAYLOAD_AND_ONE_OPTION_HEX = "540104D2746F746FBD00636F61703A2F2F626C61626C61";
    49
    50      public static final CoapMessage PAYLOAD_AND_MULTIPLE_OPTION = new CoapMessage(1, MessageType.NON_CONFIRMABLE, 1,
    51              1234, "toto".getBytes(), new CoapOption[] { //
    52              new CoapOption(CoapOptionType.URI_PATH, "coap://blabla".getBytes()), //
    53                                      new CoapOption(CoapOptionType.LOCATION_QUERY, "somewhere".getBytes()), //
    54                                      new CoapOption(CoapOptionType.PROXY_URI, "http://proxyuri".getBytes()), //
    55                                      new CoapOption(CoapOptionType.MAX_AGE, "bleh".getBytes()) }, new byte[] {});
    56
    57      public static final String PAYLOAD_AND_MULTIPLE_OPTION_HEX = "540104D2746F746FBD00636F61703A2F2F626C61626C6134626C656869736F6D657768657265DD0202687474703A2F2F70726F7879757269";// "540104D2746F746FBD00636F61703A2F2F626C61626C6134626C656869736F6D657768657265DD02687474703A2F2F70726F7879757269";
    58
    59      public static final CoapMessage OBSERVE = new CoapMessage(1, MessageType.CONFIRMABLE, 1, 19950, new byte[] { -28,
    60                              -91 }, new CoapOption[] { new CoapOption(CoapOptionType.OBSERVE, new byte[] {}),
    61                              new CoapOption(CoapOptionType.URI_PATH, "demo".getBytes()) }, new byte[] {});
    62      public static final String OBSERVE_HEX = "42014DEEE4A5605464656D6F";
    63  }