Skip to content

Commit

Permalink
[ issue #15 ] Added JUnit, Mockito deps and FieldInjector test case
Browse files Browse the repository at this point in the history
  • Loading branch information
agazzarini committed Dec 23, 2014
1 parent 888f456 commit 996aa8f
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
7 changes: 7 additions & 0 deletions solrdf/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<slf4j.version>1.6.6</slf4j.version>
<junit.version>4.11</junit.version>
<mockito.version>1.9.5-rc1</mockito.version>
<junit.version>4.11</junit.version>
<solr.version>4.8.0</solr.version>
</properties>
<licenses>
Expand Down Expand Up @@ -75,6 +76,12 @@
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void inject(final SolrInputDocument document, final Object value) {
}
};

private final Map<String, FieldInjector> injectors = new HashMap<String, FieldInjector>();
final Map<String, FieldInjector> injectors = new HashMap<String, FieldInjector>();
{
injectors.put(XSDDatatype.XSDboolean.getURI(), booleanFieldInjector);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.gazzax.labs.solrdf.handler.update;

import static org.junit.Assert.assertSame;

import java.util.Map.Entry;

import org.gazzax.labs.solrdf.handler.update.FieldInjectorRegistry.FieldInjector;
import org.junit.Before;
import org.junit.Test;

/**
* Test case for {@link FieldInjectorRegistry}.
*
* @author Andrea Gazzarini
* @since 1.0
*/
public class FieldInjectorRegistryTestCase {
private FieldInjectorRegistry cut;

@Before
public void setUp() {
cut = new FieldInjectorRegistry();
}

/**
* If an injector has been registered for a given datatype then it must be returned.
*/
@Test
public void registeredInjector() {
for (final Entry<String, FieldInjector> entry : cut.injectors.entrySet()) {
final String dataTypeURI = entry.getKey();
final FieldInjector result = cut.get(dataTypeURI);
assertSame(entry.getValue(), result);
}

assertSame(cut.catchAllInjector(), cut.get(null));
}
}

0 comments on commit 996aa8f

Please sign in to comment.