Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use AssertJ #1021

Merged
merged 3 commits into from
Jun 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions compliance/manager/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,10 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
*******************************************************************************/
package org.eclipse.rdf4j.repository.manager;

import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;

import java.io.File;
Expand Down Expand Up @@ -88,7 +86,7 @@ public void tearDown()
/**
* Test method for
* {@link org.eclipse.rdf4j.repository.manager.LocalRepositoryManager#getRepository(java.lang.String)} .
*
*
* @throws RepositoryException
* if a problem occurs accessing the repository
* @throws RepositoryConfigException
Expand Down Expand Up @@ -181,7 +179,7 @@ public void testRestartManagerWithTransaction()

/**
* Test method for {@link RepositoryManager.isSafeToRemove(String)}.
*
*
* @throws RepositoryException
* if a problem occurs during execution
* @throws RepositoryConfigException
Expand All @@ -191,11 +189,11 @@ public void testRestartManagerWithTransaction()
public void testIsSafeToRemove()
throws RepositoryException, RepositoryConfigException
{
assertThat(manager.isSafeToRemove(PROXY_ID), is(equalTo(true)));
assertThat(manager.isSafeToRemove(TEST_REPO), is(equalTo(false)));
assertThat(manager.isSafeToRemove(PROXY_ID)).isTrue();
assertThat(manager.isSafeToRemove(TEST_REPO)).isFalse();
manager.removeRepository(PROXY_ID);
assertThat(manager.hasRepositoryConfig(PROXY_ID), is(equalTo(false)));
assertThat(manager.isSafeToRemove(TEST_REPO), is(equalTo(true)));
assertThat(manager.hasRepositoryConfig(PROXY_ID)).isFalse();;
assertThat(manager.isSafeToRemove(TEST_REPO)).isTrue();;
}

@Test
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -508,9 +508,9 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>1.3</version>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.9.1</version>
<scope>test</scope>
</dependency>

Expand Down
4 changes: 2 additions & 2 deletions rio/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,18 @@
*******************************************************************************/
package org.eclipse.rdf4j.rio.helpers;

import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.isA;
import static org.junit.Assert.assertThat;
import static org.assertj.core.api.Assertions.assertThat;

import java.nio.file.spi.FileTypeDetector;
import java.util.ServiceLoader;

import org.junit.Test;

public class RioFileTypeDetectorTest {
public class RioFileTypeDetectorTest
{
@Test
public void correctClassIsRegisteredInServices()
{
assertThat(ServiceLoader.load(FileTypeDetector.class),
hasItem(isA(RioFileTypeDetector.class)));
assertThat(ServiceLoader.load(FileTypeDetector.class)).anyMatch(ftd -> ftd instanceof RioFileTypeDetector);
}
}
4 changes: 2 additions & 2 deletions rio/rdfxml/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
*******************************************************************************/
package org.eclipse.rdf4j.rio.rdfxml;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;

import java.io.ByteArrayOutputStream;
Expand All @@ -30,8 +30,6 @@
import org.eclipse.rdf4j.rio.RDFParser;
import org.eclipse.rdf4j.rio.helpers.ParseErrorCollector;
import org.eclipse.rdf4j.rio.helpers.StatementCollector;
import org.hamcrest.CoreMatchers;
import org.hamcrest.Matchers;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -53,7 +51,7 @@ public void setUp()
throws Exception
{
platformLocale = Locale.getDefault();

Locale.setDefault(Locale.ENGLISH);
vf = SimpleValueFactory.getInstance();
parser = new RDFXMLParser();
Expand Down Expand Up @@ -87,7 +85,7 @@ public void rdfXmlLoadedFromInsideAJarResolvesRelativeUris()

Collection<Statement> stmts = sc.getStatements();

assertThat(stmts, Matchers.<Statement> iterableWithSize(3));
assertThat(stmts).hasSize(3);

Iterator<Statement> iter = stmts.iterator();

Expand All @@ -102,7 +100,7 @@ public void rdfXmlLoadedFromInsideAJarResolvesRelativeUris()

String resourceUrl = res.stringValue();

assertThat(resourceUrl, CoreMatchers.startsWith("jar:" + zipfileUrl + "!"));
assertThat(resourceUrl).startsWith("jar:" + zipfileUrl + "!");

URL javaUrl = new URL(resourceUrl);
assertEquals("jar", javaUrl.getProtocol());
Expand Down
5 changes: 0 additions & 5 deletions rio/trix/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,5 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
4 changes: 2 additions & 2 deletions rio/turtle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@
*******************************************************************************/
package org.eclipse.rdf4j.rio.turtle;

import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.hasSize;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

Expand All @@ -35,8 +32,6 @@
import org.eclipse.rdf4j.rio.helpers.ParseErrorCollector;
import org.eclipse.rdf4j.rio.helpers.SimpleParseLocationListener;
import org.eclipse.rdf4j.rio.helpers.StatementCollector;
import org.hamcrest.CoreMatchers;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;

Expand Down Expand Up @@ -116,11 +111,11 @@ public void testParseIllegalURINonFatal()

parser.getParserConfig().addNonFatalError(BasicParserSettings.VERIFY_URI_SYNTAX);
parser.parse(new StringReader(data), baseURI);
assertThat(errorCollector.getErrors(), hasSize(1));
assertThat(errorCollector.getFatalErrors(), empty());
assertThat(statementCollector.getStatements(), not(empty()));
assertThat("only syntactically legal triples should have been reported",
statementCollector.getStatements(), hasSize(1));
assertThat(errorCollector.getErrors()).hasSize(1);
assertThat(errorCollector.getFatalErrors()).isEmpty();
assertThat(statementCollector.getStatements()).isNotEmpty();
assertThat(statementCollector.getStatements()).hasSize(1)
.overridingErrorMessage("only syntactically legal triples should have been reported");
}

@Test
Expand All @@ -132,10 +127,11 @@ public void testParseIllegalURINoVerify()
parser.getParserConfig().set(BasicParserSettings.VERIFY_URI_SYNTAX, false);

parser.parse(new StringReader(data), baseURI);
assertThat(errorCollector.getErrors(), empty());
assertThat(errorCollector.getFatalErrors(), empty());
assertThat(statementCollector.getStatements(), not(empty()));
assertThat("all triples should have been reported", statementCollector.getStatements(), hasSize(3));
assertThat(errorCollector.getErrors()).isEmpty();
assertThat(errorCollector.getFatalErrors()).isEmpty();
assertThat(statementCollector.getStatements()).isNotEmpty();
assertThat(statementCollector.getStatements()).hasSize(3)
.overridingErrorMessage("all triples should have been reported");
}

@Test
Expand Down Expand Up @@ -360,7 +356,7 @@ public void rdfXmlLoadedFromInsideAJarResolvesRelativeUris()

Collection<Statement> stmts = sc.getStatements();

assertThat(stmts, Matchers.<Statement> iterableWithSize(2));
assertThat(stmts).hasSize(2);

Iterator<Statement> iter = stmts.iterator();

Expand All @@ -373,7 +369,7 @@ public void rdfXmlLoadedFromInsideAJarResolvesRelativeUris()

String resourceUrl = res.stringValue();

assertThat(resourceUrl, CoreMatchers.startsWith("jar:" + zipfileUrl + "!"));
assertThat(resourceUrl).startsWith("jar:" + zipfileUrl + "!");

URL javaUrl = new URL(resourceUrl);
assertEquals("jar", javaUrl.getProtocol());
Expand Down