Skip to content

Commit

Permalink
Remove usage of deprecated methods in JUnit 4.13
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernard31 committed Feb 11, 2020
1 parent a201a0e commit 634060f
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,10 @@
import java.util.Collection;
import java.util.Map;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

public class AttributeSetTest {

@Rule
public ExpectedException exception = ExpectedException.none();

@Test
public void should_provide_query_params() {
AttributeSet sut = new AttributeSet(new Attribute(Attribute.OBJECT_VERSION, "1.1"),
Expand Down Expand Up @@ -89,9 +84,8 @@ public void should_to_string() {
assertEquals("ver=1.1&pmin=5&pmax=60", sut.toString());
}

@Test
@Test(expected = IllegalArgumentException.class)
public void should_throw_on_duplicates() {
exception.expect(IllegalArgumentException.class);
new AttributeSet(new Attribute(Attribute.OBJECT_VERSION, "1.1"), new Attribute(Attribute.MINIMUM_PERIOD, 5L),
new Attribute(Attribute.MINIMUM_PERIOD, 60L));
}
Expand All @@ -105,22 +99,20 @@ public void should_validate_assignation() {
sut.validate(AssignationLevel.RESOURCE);
}

@Test
@Test(expected = IllegalArgumentException.class)
public void should_throw_on_invalid_assignation_level() {
AttributeSet sut = new AttributeSet(new Attribute(Attribute.OBJECT_VERSION, "1.1"),
new Attribute(Attribute.MINIMUM_PERIOD, 5L), new Attribute(Attribute.MAXIMUM_PERIOD, 60L));

exception.expect(IllegalArgumentException.class);
// OBJECT_VERSION cannot be assigned on resource level
sut.validate(AssignationLevel.RESOURCE);
}

@Test
@Test(expected = IllegalArgumentException.class)
public void should_throw_on_invalid_pmin_pmax() {
AttributeSet sut = new AttributeSet(new Attribute(Attribute.MINIMUM_PERIOD, 50L),
new Attribute(Attribute.MAXIMUM_PERIOD, 49L));

exception.expect(IllegalArgumentException.class);
// pmin cannot be greater then pmax
sut.validate(AssignationLevel.RESOURCE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@

import static org.junit.Assert.*;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

public class AttributeTest {

@Rule
public ExpectedException exception = ExpectedException.none();

@Test
public void should_pick_correct_model() {
Attribute verAttribute = new Attribute(Attribute.OBJECT_VERSION, "1.0");
Expand All @@ -20,10 +15,8 @@ public void should_pick_correct_model() {
assertFalse(verAttribute.isWritable());
}

@Test
@Test(expected = IllegalArgumentException.class)
public void should_throw_on_invalid_value_type() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage(Attribute.OBJECT_VERSION);
new Attribute(Attribute.OBJECT_VERSION, 123);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import static org.eclipse.leshan.integration.tests.SecureIntegrationTestHelper.*;
import static org.hamcrest.CoreMatchers.hasItems;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*;

import org.eclipse.leshan.LwM2mId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import static org.eclipse.leshan.core.request.ContentFormat.*;
import static org.eclipse.leshan.integration.tests.IntegrationTestHelper.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsInstanceOf.instanceOf;
import static org.junit.Assert.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.eclipse.leshan.integration.tests;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsInstanceOf.instanceOf;
import static org.junit.Assert.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.eclipse.leshan.integration.tests;

import static org.eclipse.leshan.ResponseCode.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsInstanceOf.instanceOf;
import static org.junit.Assert.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.eclipse.leshan.integration.tests;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsInstanceOf.instanceOf;
import static org.junit.Assert.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.eclipse.leshan.integration.tests;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsInstanceOf.instanceOf;
import static org.junit.Assert.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import static org.eclipse.leshan.ResponseCode.*;
import static org.eclipse.leshan.integration.tests.IntegrationTestHelper.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsInstanceOf.instanceOf;
import static org.junit.Assert.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.eclipse.leshan.integration.tests;

import static org.eclipse.leshan.integration.tests.IntegrationTestHelper.LIFETIME;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsInstanceOf.instanceOf;
import static org.junit.Assert.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.eclipse.leshan.integration.tests;

import static org.eclipse.leshan.integration.tests.IntegrationTestHelper.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsInstanceOf.instanceOf;
import static org.junit.Assert.*;
Expand Down

0 comments on commit 634060f

Please sign in to comment.