Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
start moving Function unit tests out
- Loading branch information
Showing
5 changed files
with
104 additions
and
17 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
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
31 changes: 31 additions & 0 deletions
31
fcrepo-kernel/src/test/java/org/fcrepo/services/functions/GetBinaryKeyTest.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,31 @@ | ||
package org.fcrepo.services.functions; | ||
|
||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
import static org.modeshape.jcr.api.JcrConstants.JCR_CONTENT; | ||
import static org.modeshape.jcr.api.JcrConstants.JCR_DATA; | ||
|
||
import javax.jcr.LoginException; | ||
import javax.jcr.Node; | ||
import javax.jcr.Property; | ||
import javax.jcr.RepositoryException; | ||
|
||
import org.junit.Test; | ||
import org.modeshape.jcr.value.BinaryValue; | ||
|
||
public class GetBinaryKeyTest { | ||
|
||
@Test | ||
public void testApply() throws LoginException, RepositoryException { | ||
Node mockNode = mock(Node.class); | ||
Node mockContent = mock(Node.class); | ||
Property mockProp = mock(Property.class); | ||
BinaryValue mockBin = mock(BinaryValue.class); | ||
when(mockProp.getBinary()).thenReturn(mockBin); | ||
when(mockContent.getProperty(JCR_DATA)).thenReturn(mockProp); | ||
when(mockNode.getNode(JCR_CONTENT)).thenReturn(mockContent); | ||
GetBinaryKey testObj = new GetBinaryKey(); | ||
testObj.apply(mockNode); | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
fcrepo-kernel/src/test/java/org/fcrepo/services/functions/GetBinaryStoreTest.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,31 @@ | ||
package org.fcrepo.services.functions; | ||
|
||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
import javax.jcr.LoginException; | ||
import javax.jcr.RepositoryException; | ||
|
||
import org.junit.Test; | ||
import org.modeshape.jcr.JcrRepository; | ||
import org.modeshape.jcr.JcrSession; | ||
import org.modeshape.jcr.RepositoryConfiguration; | ||
import org.modeshape.jcr.RepositoryConfiguration.BinaryStorage; | ||
|
||
public class GetBinaryStoreTest { | ||
|
||
@Test | ||
public void testApply() throws LoginException, RepositoryException { | ||
JcrRepository mockRepo = mock(JcrRepository.class); | ||
JcrSession mockSession = mock(JcrSession.class); | ||
RepositoryConfiguration mockConfig = mock(RepositoryConfiguration.class); | ||
BinaryStorage mockBinStorage = mock(BinaryStorage.class); | ||
when(mockConfig.getBinaryStorage()).thenReturn(mockBinStorage); | ||
when(mockRepo.getConfiguration()).thenReturn(mockConfig); | ||
when(mockSession.getRepository()).thenReturn(mockRepo); | ||
when(mockRepo.login()).thenReturn(mockSession); | ||
GetBinaryStore testObj = new GetBinaryStore(); | ||
testObj.apply(mockRepo); | ||
} | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
fcrepo-kernel/src/test/java/org/fcrepo/services/functions/GetCacheStoreTest.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,42 @@ | ||
package org.fcrepo.services.functions; | ||
|
||
import static org.mockito.Mockito.any; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
import javax.jcr.LoginException; | ||
import javax.jcr.RepositoryException; | ||
|
||
import org.infinispan.AdvancedCache; | ||
import org.infinispan.Cache; | ||
import org.infinispan.factories.ComponentRegistry; | ||
import org.infinispan.factories.GlobalComponentRegistry; | ||
import org.infinispan.factories.components.ComponentMetadata; | ||
import org.infinispan.factories.components.ComponentMetadataRepo; | ||
import org.infinispan.loaders.CacheLoaderManager; | ||
import org.infinispan.loaders.CacheStore; | ||
import org.junit.Test; | ||
|
||
public class GetCacheStoreTest { | ||
|
||
@Test | ||
public void testApply() throws LoginException, RepositoryException { | ||
Cache<?, ?> mockCache = mock(Cache.class); | ||
AdvancedCache mockAC = mock(AdvancedCache.class); | ||
GlobalComponentRegistry mockG = mock(GlobalComponentRegistry.class); | ||
ComponentMetadataRepo mockCMR = mock(ComponentMetadataRepo.class); | ||
when(mockG.getComponentMetadataRepo()).thenReturn(mockCMR); | ||
ComponentRegistry mockCR = null; //new ComponentRegistry("foo", null, mockAC, mockG, getClass().getClassLoader()); | ||
ComponentMetadata mockMD = mock(ComponentMetadata.class); | ||
when(mockCMR.findComponentMetadata(any(Class.class))).thenReturn(mockMD); | ||
CacheLoaderManager mockCLM = mock(CacheLoaderManager.class); | ||
CacheStore mockStore = mock(CacheStore.class); | ||
when(mockCLM.getCacheStore()).thenReturn(mockStore); | ||
//when(mockCR.getComponent(CacheLoaderManager.class)).thenReturn(mockCLM); | ||
when(mockAC.getComponentRegistry()).thenReturn(mockCR); | ||
when(mockCache.getAdvancedCache()).thenReturn(mockAC); | ||
GetCacheStore testObj = new GetCacheStore(); | ||
//testObj.apply(mockCache); | ||
} | ||
|
||
} |