1 package org.kuali.ole.service;
2
3 import org.junit.Before;
4 import org.junit.Ignore;
5 import org.junit.Test;
6 import org.kuali.ole.RepositoryBrowser;
7 import org.kuali.ole.RepositoryManager;
8 import org.kuali.ole.base.BaseTestCase;
9 import org.kuali.ole.docstore.service.BeanLocator;
10 import org.kuali.ole.docstore.service.IngestNIndexHandlerService;
11 import org.kuali.ole.pojo.OleException;
12 import org.mockito.Mock;
13 import org.mockito.Mockito;
14 import org.mockito.MockitoAnnotations;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
17
18 import javax.jcr.Node;
19 import javax.jcr.NodeIterator;
20 import javax.jcr.RepositoryException;
21 import javax.jcr.Session;
22 import java.util.Iterator;
23
24
25
26
27
28
29
30
31
32 @Ignore
33 @Deprecated
34 public class OleDocstoreDumpService_UT extends BaseTestCase {
35
36 private static final Logger LOG = LoggerFactory.getLogger(OleDocstoreDumpService_UT.class);
37 private IngestNIndexHandlerService ingestNIndexHandlerService = BeanLocator.getIngestNIndexHandlerService();
38
39 @Mock
40 private RepositoryManager mockRepositoryManager;
41 @Mock
42 private Session mockSession;
43 @Mock
44 private Node mockRootNode;
45 @Mock
46 private NodeIterator mockNodeIterator;
47 @Mock
48 private Node mockChildNode;
49
50 @Before
51 public void setUp() throws Exception {
52 super.setUp();
53 MockitoAnnotations.initMocks(this);
54 System.getProperties().put("app.environment", "local");
55 Mockito.when(mockRepositoryManager.getSession(Mockito.anyString(), Mockito.anyString())).thenReturn(mockSession);
56 Mockito.when(mockSession.getRootNode()).thenReturn(mockRootNode);
57 Mockito.when(mockRootNode.hasProperty("nodeType")).thenReturn(true);
58 Mockito.when(mockRootNode.getNodes()).thenReturn(mockNodeIterator);
59 Mockito.when(mockNodeIterator.hasNext()).thenReturn(true);
60 Mockito.when(mockNodeIterator.next()).thenReturn(mockChildNode);
61 Mockito.when(mockChildNode.getName()).thenReturn("MockFile");
62 }
63
64 @Ignore
65 @Test
66 public void OleExportMarcRequest() throws OleException, RepositoryException {
67 cleanRepository("work","bibliographic");
68 try{
69
70
71
72
73
74
75 RepositoryBrowser repositoryBrowser = new RepositoryBrowser();
76 String dump = repositoryBrowser.getRepositoryDump();
77 LOG.info("dump" + dump);
78
79
80
81
82
83 }catch (Exception e){
84 LOG.error(e.getMessage(), e);
85 }
86 }
87
88 private void cleanRepository(String category, String type) throws OleException, RepositoryException {
89 RepositoryManager repositoryManager = mockRepositoryManager;
90 Session session = repositoryManager.getSession("mockUser", "test");
91 Node rootNode = session.getRootNode();
92 Node catNode = rootNode.getNode(category);
93
94 Node typeNode = mockRootNode;
95
96
97
98
99
100
101 session.save();
102 repositoryManager.logout(session);
103 }
104 }