Skip to content

Commit

Permalink
#61 update mockito
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-conway committed Dec 1, 2020
1 parent 8ebbb19 commit 8ce61ad
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 24 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

#### Have test setup utilities honor jargon.properties ssl negotiation setting #366

Enable unit tests to respect jargon properties defaults for ssl negotiation

#### Update maven deps for Mockito and ByteBuddy (to allow running under JDK 11)

### Changed
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
import java.util.Properties;
import java.util.Random;

import org.irods.jargon.core.connection.ClientServerNegotiationPolicy.SslNegotiationPolicy;
import org.irods.jargon.core.connection.IRODSAccount;
import org.irods.jargon.core.connection.SettableJargonProperties;
import org.irods.jargon.core.connection.SettableJargonPropertiesMBean;
import org.irods.jargon.core.exception.JargonException;
import org.irods.jargon.core.exception.JargonRuntimeException;
import org.irods.jargon.core.exception.UnixFileRenameException;
Expand Down Expand Up @@ -46,6 +49,20 @@ public IRODSTestSetupUtilities() throws TestConfigurationException {

try {
irodsFileSystem = IRODSFileSystem.instance();
SettableJargonPropertiesMBean settableJargonProperties = new SettableJargonProperties(
irodsFileSystem.getJargonProperties());
String negPropsValue = testingPropertiesHelper.getTestProperties()
.getProperty(TestingPropertiesHelper.IRODS_SSL_NEGOTIATION_PROPERTY);

// If prop not set default to neg refuse
if (negPropsValue == null) {
settableJargonProperties.setNegotiationPolicy(SslNegotiationPolicy.CS_NEG_REFUSE);
} else {
settableJargonProperties.setNegotiationPolicy(SslNegotiationPolicy.valueOf(negPropsValue));

}
irodsFileSystem.getIrodsSession().setJargonProperties(settableJargonProperties);

dataObjectAO = irodsFileSystem.getIRODSAccessObjectFactory().getDataObjectAO(irodsAccount);
collectionAO = irodsFileSystem.getIRODSAccessObjectFactory().getCollectionAO(irodsAccount);

Expand All @@ -57,8 +74,7 @@ public IRODSTestSetupUtilities() throws TestConfigurationException {
/**
* Remove the scratch directory from irods based on the testing.properties file
*
* @throws TestConfigurationException
* {@link TestConfigurationException}
* @throws TestConfigurationException {@link TestConfigurationException}
*/
@Overheaded
// [#1628] intermittent -528036 errors on delete of collections
Expand Down Expand Up @@ -100,8 +116,7 @@ public void clearIrodsScratchDirectory() throws TestConfigurationException {
* Clear and then create a fresh scratch directory in irods based on the
* testing.properties file
*
* @throws TestConfigurationException
* {@link TestConfigurationException}
* @throws TestConfigurationException {@link TestConfigurationException}
*/
public void initializeIrodsScratchDirectory() throws TestConfigurationException {
clearIrodsScratchDirectory();
Expand All @@ -128,11 +143,9 @@ public void initializeIrodsScratchDirectory() throws TestConfigurationException
* Create a directory under scratch with the given name, which is typically a
* name assigned per Junit test class
*
* @param testingDirectory
* {@code String} with a directory to go underneath scratch, do not
* supply leading '/'
* @throws TestConfigurationException
* {@link TestConfigurationException}
* @param testingDirectory {@code String} with a directory to go underneath
* scratch, do not supply leading '/'
* @throws TestConfigurationException {@link TestConfigurationException}
*/
public void initializeDirectoryForTest(final String testingDirectory) throws TestConfigurationException {
StringBuilder scratchDir = new StringBuilder();
Expand Down Expand Up @@ -164,19 +177,17 @@ public void initializeDirectoryForTest(final String testingDirectory) throws Tes
* folders. Each list of candidates is tested with a random number and added at
* that point based on a threshold value
*
* @param irodsAbsolutePath
* {@code String} with a parent path
* @param candidateAvusForData
* {@link AvuData} in a {@code List} that will be added to data
* objects if a random number is above a threshold
* @param candidateAvusForCollections
* {@link AvuData} in a {@code List} that will be added to
* collections if a random number is above a threshold
* @param thresholdToAdd
* {@code int} to compare to a random number to indicate that the
* given avu should be added at the given node or leaf (0-99)
* @throws Exception
* for any error
* @param irodsAbsolutePath {@code String} with a parent path
* @param candidateAvusForData {@link AvuData} in a {@code List} that
* will be added to data objects if a random
* number is above a threshold
* @param candidateAvusForCollections {@link AvuData} in a {@code List} that
* will be added to collections if a random
* number is above a threshold
* @param thresholdToAdd {@code int} to compare to a random number
* to indicate that the given avu should be
* added at the given node or leaf (0-99)
* @throws Exception for any error
*/
public void decorateDirWithMetadata(final String irodsAbsolutePath, final List<AvuData> candidateAvusForData,
final List<AvuData> candidateAvusForCollections, final int thresholdToAdd) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public class TestingPropertiesHelper {
public static String IRODS_CONFIRM_TESTING_FALSE = "false";
public static String IRODS_TEST_OPTION_EIRODS = "test.option.eirods";
public static String IRODS_TEST_OPTION_PYTHON = "test.option.python";
public static String IRODS_SSL_NEGOTIATION_PROPERTY = "ssl.negotiation.policy";

/**
* Return the given property (by key) as an int
Expand Down
2 changes: 1 addition & 1 deletion jargon-mdquery/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down

0 comments on commit 8ce61ad

Please sign in to comment.