Skip to content

Commit 9ccbee9

Browse files
felicijusgl-johnson
authored andcommitted
Adjust tests to use Jakarta
1 parent 7e3148f commit 9ccbee9

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

src/test/java/com/cyberark/conjur/api/ConjurTest.java

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
package com.cyberark.conjur.api;
22

33
import org.junit.Assert;
4-
import org.junit.Rule;
54
import org.junit.Test;
6-
import org.junit.rules.ExpectedException;
7-
8-
import jakarta.ws.rs.ProcessingException;
95
import jakarta.ws.rs.WebApplicationException;
6+
107
import java.util.UUID;
118

129
/**
@@ -66,26 +63,27 @@ public void testAddSecretAndRetrieveSecret() {
6663

6764
@Test
6865
public void testSetVariableWithoutVariableInPolicy() {
69-
expectedException.expect(WebApplicationException.class);
70-
expectedException.expectMessage(NOT_FOUND_STATUS_CODE);
71-
72-
Conjur conjur = new Conjur();
73-
74-
conjur.variables().addSecret(NON_EXISTING_VARIABLE_KEY, VARIABLE_VALUE);
66+
WebApplicationException thrown = Assert.assertThrows(
67+
WebApplicationException.class,
68+
() -> {
69+
Conjur conjur = new Conjur();
70+
conjur.variables().addSecret(NON_EXISTING_VARIABLE_KEY, VARIABLE_VALUE);
71+
}
72+
);
73+
Assert.assertTrue(thrown.getMessage().contains(NOT_FOUND_STATUS_CODE));
7574
}
7675

7776
@Test
7877
public void testLogonWithAlterativeAuthenticator() {
79-
expectedException.expect(ProcessingException.class);
80-
expectedException.expectMessage(UNAUTHORIZED_STATUS_CODE);
81-
8278
String authnUrl = System.getProperty(APPLIANCE_URL_PROPERTY) + ALTERNATIVE_AUTHN_ENDPOINT;
8379

84-
Conjur conjur = new Conjur(ALTERNATIVE_USERNAME, ALTERNATIVE_API_KEY, authnUrl);
85-
conjur.variables().retrieveSecret(VARIABLE_KEY);
80+
WebApplicationException thrown = Assert.assertThrows(
81+
WebApplicationException.class,
82+
() -> {
83+
Conjur conjur = new Conjur(ALTERNATIVE_USERNAME, ALTERNATIVE_API_KEY, authnUrl);
84+
conjur.variables().retrieveSecret(VARIABLE_KEY);
85+
}
86+
);
87+
Assert.assertTrue(thrown.getMessage().contains(UNAUTHORIZED_STATUS_CODE));
8688
}
87-
88-
89-
@Rule
90-
public ExpectedException expectedException = ExpectedException.none();
9189
}

0 commit comments

Comments
 (0)