1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.docstore.process;
17
18 import org.apache.camel.CamelContext;
19 import org.apache.camel.Exchange;
20 import org.apache.camel.ExchangePattern;
21 import org.apache.camel.impl.DefaultCamelContext;
22 import org.apache.camel.impl.DefaultExchange;
23 import org.junit.After;
24 import org.junit.Before;
25 import org.junit.Test;
26 import org.kuali.ole.docstore.model.enums.DocCategory;
27 import org.kuali.ole.docstore.model.enums.DocFormat;
28 import org.kuali.ole.docstore.model.enums.DocType;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
31
32 import static org.junit.Assert.fail;
33
34
35
36
37
38
39
40
41 public class BulkIngestDocStoreRequestBuilder_UT {
42
43 private static final Logger LOG = LoggerFactory.getLogger(BulkIngestDocStoreRequestBuilder_UT.class);
44 Exchange exchange = new DefaultExchange(new DefaultCamelContext(), ExchangePattern.InOut);
45
46
47
48
49
50
51 @Before
52 public void setUp() throws Exception {
53 }
54
55
56
57
58
59
60 @After
61 public void tearDown() throws Exception {
62 }
63
64 @Test
65 public void testForMarc() {
66 System.out.println("Start: ");
67 CamelContext camelContext = DocStoreCamelContext.getInstance().getCamelContext();
68 BulkIngestDocStoreRequestBuilder builder = new BulkIngestDocStoreRequestBuilder(
69 "/opt/docstore/upload/ole-batchUpload/mrc", "rck", "batchIngest", camelContext,
70 DocCategory.WORK.getCode(), DocType.BIB.getDescription(), DocFormat.MARC.getCode(),
71 "/opt/docstore/upload/ole-batchUpload");
72 System.out.println("Starting Context: ");
73 try {
74 camelContext.addRoutes(builder);
75 camelContext.start();
76 Thread.currentThread().sleep(2000);
77 System.out.println("Ended: ");
78 camelContext.stop();
79 } catch (Exception e) {
80 LOG.info("Exception :" + e);
81 fail("Error in processing.." + e.getMessage());
82 }
83 }
84
85 @Test
86 public void testForDublinQ() {
87 System.out.println("Start: ");
88
89 CamelContext camelContext = DocStoreCamelContext.getInstance().getCamelContext();
90 BulkIngestDocStoreRequestBuilder builder = new BulkIngestDocStoreRequestBuilder(
91 "/opt/docstore/upload/ole-batchUpload/dublin-q", "rck", "batchIngest", camelContext,
92 DocCategory.WORK.getCode(), DocType.BIB.getDescription(), DocFormat.DUBLIN_CORE.getCode(),
93 "/opt/docstore/upload/ole-batchUpload");
94 System.out.println("Starting Context: ");
95 try {
96 camelContext.addRoutes(builder);
97 camelContext.start();
98 Thread.currentThread().sleep(2000);
99 System.out.println("Ended: ");
100 camelContext.stop();
101 } catch (Exception e) {
102 LOG.info("Exception :" + e);
103 fail("Error in processing.." + e.getMessage());
104 }
105 }
106
107 @Test
108 public void testForDublinUnq() {
109 System.out.println("Start: ");
110
111 CamelContext camelContext = DocStoreCamelContext.getInstance().getCamelContext();
112 BulkIngestDocStoreRequestBuilder builder = new BulkIngestDocStoreRequestBuilder(
113 "/opt/docstore/upload/ole-batchUpload/dublin-unq", "rck", "batchIngest", camelContext,
114 DocCategory.WORK.getCode(), DocType.BIB.getDescription(), DocFormat.DUBLIN_UNQUALIFIED.getCode(),
115 "/opt/docstore/upload/ole-batchUpload");
116 System.out.println("Starting Context: ");
117 try {
118 camelContext.addRoutes(builder);
119 camelContext.start();
120 Thread.currentThread().sleep(2000);
121 System.out.println("Ended: ");
122 camelContext.stop();
123 } catch (Exception e) {
124 LOG.info("Exception :" + e);
125 fail("Error in processing.." + e.getMessage());
126 }
127 }
128
129 @Test
130 public void testDocStoreCamelContext() throws Exception {
131 DocStoreCamelContext docStoreCamelContext = DocStoreCamelContext.getInstance();
132 docStoreCamelContext.isRunning();
133 docStoreCamelContext.suspend();
134 docStoreCamelContext.resume();
135 docStoreCamelContext.stop();
136 }
137 }