-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from CJSCommonPlatform/add-jndi-value-to-diabl…
…e-reponse-validation Add new JNDI property to enable/disable rest json response validation…
- Loading branch information
Showing
23 changed files
with
268 additions
and
66 deletions.
There are no files selected for viewing
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
18 changes: 18 additions & 0 deletions
18
core/src/main/java/uk/gov/justice/services/core/dispatcher/DispatcherConfiguration.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,18 @@ | ||
package uk.gov.justice.services.core.dispatcher; | ||
|
||
import static java.lang.Boolean.parseBoolean; | ||
|
||
import uk.gov.justice.services.common.configuration.GlobalValue; | ||
|
||
import javax.inject.Inject; | ||
|
||
public class DispatcherConfiguration { | ||
|
||
@Inject | ||
@GlobalValue(key = "rest.dispatcher.response.json.validation.enabled", defaultValue = "false") | ||
private String validateRestResponseJson; | ||
|
||
public boolean shouldValidateRestResponseJson() { | ||
return parseBoolean(validateRestResponseJson); | ||
} | ||
} |
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
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
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
48 changes: 48 additions & 0 deletions
48
core/src/test/java/uk/gov/justice/services/core/dispatcher/DispatcherConfigurationTest.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,48 @@ | ||
package uk.gov.justice.services.core.dispatcher; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.junit.Assert.assertThat; | ||
import static uk.gov.justice.services.test.utils.core.reflection.ReflectionUtil.setField; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.runners.MockitoJUnitRunner; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class DispatcherConfigurationTest { | ||
|
||
@InjectMocks | ||
private DispatcherConfiguration dispatcherConfiguration; | ||
|
||
@Test | ||
public void shouldGetTheStartWaitTime() throws Exception { | ||
|
||
setField(dispatcherConfiguration, "validateRestResponseJson", "true"); | ||
assertThat(dispatcherConfiguration.shouldValidateRestResponseJson(), is(true)); | ||
|
||
setField(dispatcherConfiguration, "validateRestResponseJson", "TRUE"); | ||
assertThat(dispatcherConfiguration.shouldValidateRestResponseJson(), is(true)); | ||
|
||
setField(dispatcherConfiguration, "validateRestResponseJson", "True"); | ||
assertThat(dispatcherConfiguration.shouldValidateRestResponseJson(), is(true)); | ||
|
||
setField(dispatcherConfiguration, "validateRestResponseJson", "false"); | ||
assertThat(dispatcherConfiguration.shouldValidateRestResponseJson(), is(false)); | ||
|
||
setField(dispatcherConfiguration, "validateRestResponseJson", "FALSE"); | ||
assertThat(dispatcherConfiguration.shouldValidateRestResponseJson(), is(false)); | ||
|
||
setField(dispatcherConfiguration, "validateRestResponseJson", "False"); | ||
assertThat(dispatcherConfiguration.shouldValidateRestResponseJson(), is(false)); | ||
|
||
setField(dispatcherConfiguration, "validateRestResponseJson", null); | ||
assertThat(dispatcherConfiguration.shouldValidateRestResponseJson(), is(false)); | ||
|
||
setField(dispatcherConfiguration, "validateRestResponseJson", ""); | ||
assertThat(dispatcherConfiguration.shouldValidateRestResponseJson(), is(false)); | ||
|
||
setField(dispatcherConfiguration, "validateRestResponseJson", "something silly"); | ||
assertThat(dispatcherConfiguration.shouldValidateRestResponseJson(), is(false)); | ||
} | ||
} |
Oops, something went wrong.