-
Notifications
You must be signed in to change notification settings - Fork 408
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests about mandatory or optional content format.
- Loading branch information
1 parent
bab1cfb
commit f15debb
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
leshan-core/src/test/java/org/eclipse/leshan/core/request/ContentFormatTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 Sierra Wireless and others. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* and Eclipse Distribution License v1.0 which accompany this distribution. | ||
* | ||
* The Eclipse Public License is available at | ||
* http://www.eclipse.org/legal/epl-v20.html | ||
* and the Eclipse Distribution License is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.html. | ||
* | ||
* Contributors: | ||
* Sierra Wireless - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.leshan.core.request; | ||
|
||
import static org.eclipse.leshan.core.request.ContentFormat.*; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.eclipse.leshan.core.LwM2m.Version; | ||
import org.eclipse.leshan.core.node.codec.CodecException; | ||
import org.junit.Test; | ||
|
||
public class ContentFormatTest { | ||
|
||
@Test | ||
public void get_optional_content_format_for_v1_0() throws CodecException { | ||
|
||
List<ContentFormat> optionalContentFormat = ContentFormat | ||
.getOptionalContentFormatForClient(Arrays.asList(TLV, JSON, TEXT, OPAQUE), Version.V1_0); | ||
|
||
assertEquals(Arrays.asList(JSON, TEXT, OPAQUE), optionalContentFormat); | ||
} | ||
|
||
@Test | ||
public void get_optional_content_format_for_v1_1() throws CodecException { | ||
List<ContentFormat> optionalContentFormat = ContentFormat.getOptionalContentFormatForClient( | ||
Arrays.asList(TLV, JSON, SENML_JSON, SENML_CBOR, TEXT, OPAQUE, CBOR, LINK), Version.V1_1); | ||
|
||
assertEquals(Arrays.asList(TLV, JSON, SENML_JSON, SENML_CBOR, CBOR), optionalContentFormat); | ||
|
||
} | ||
} |