Revision 8766
Added by ben leinfelder almost 10 years ago
SolrIndexIT.java | ||
---|---|---|
4 | 4 |
import static org.junit.Assert.assertTrue; |
5 | 5 |
|
6 | 6 |
import edu.ucsb.nceas.metacat.common.SolrServerFactory; |
7 |
import java.io.File; |
|
8 |
import java.io.FileInputStream; |
|
9 |
import java.io.InputStream; |
|
10 | 7 |
import java.io.StringWriter; |
11 | 8 |
import java.io.Writer; |
12 | 9 |
import java.util.ArrayList; |
... | ... | |
74 | 71 |
|
75 | 72 |
//InputStream systemInputStream = new FileInputStream(new File(SYSTEMMETAFILEPATH)); |
76 | 73 |
SystemMetadata systemMetadata = TypeMarshaller.unmarshalTypeFromFile(SystemMetadata.class, SYSTEMMETAFILEPATH); |
77 |
InputStream emlInputStream = new FileInputStream(new File(EMLFILEPATH)); |
|
78 | 74 |
//List<String> chain = null; |
79 | 75 |
Identifier pid = new Identifier(); |
80 | 76 |
pid.setValue(id); |
81 |
solrIndex.update(pid, systemMetadata, emlInputStream);
|
|
77 |
solrIndex.update(pid, systemMetadata, EMLFILEPATH);
|
|
82 | 78 |
String result = doQuery(solrIndex.getSolrServer()); |
83 | 79 |
List<String> ids = solrIndex.getSolrIds(); |
84 | 80 |
//assertTrue(ids.size() == 1); |
... | ... | |
100 | 96 |
public void testUpdate() throws Exception { |
101 | 97 |
//InputStream systemInputStream = new FileInputStream(new File(SYSTEMMETAFILEPATH)); |
102 | 98 |
SystemMetadata systemMetadata = TypeMarshaller.unmarshalTypeFromFile(SystemMetadata.class, SYSTEMMETAUPDATEFILEPATH); |
103 |
InputStream emlInputStream = new FileInputStream(new File(EMLUPDATEFILEPATH)); |
|
104 | 99 |
/*obsoletes.add(id); |
105 | 100 |
obsoletes.add("tao");*/ |
106 | 101 |
Identifier pid = new Identifier(); |
107 | 102 |
pid.setValue(newId); |
108 |
solrIndex.update(pid, systemMetadata, emlInputStream);
|
|
103 |
solrIndex.update(pid, systemMetadata, EMLFILEPATH);
|
|
109 | 104 |
String result = doQuery(solrIndex.getSolrServer()); |
110 | 105 |
assertTrue(result.contains("version1")); |
111 | 106 |
assertTrue(result.contains("version2")); |
... | ... | |
115 | 110 |
SystemMetadata obsoletedSystemMetadata = TypeMarshaller.unmarshalTypeFromFile(SystemMetadata.class, SYSTEMMETAFILEPATH); |
116 | 111 |
assertTrue(obsoletedSystemMetadata.getIdentifier().getValue().equals(obsoletedPid.getValue())); |
117 | 112 |
obsoletedSystemMetadata.setObsoletedBy(pid); |
118 |
InputStream obsoletedEmlInputStream = new FileInputStream(new File(EMLFILEPATH)); |
|
119 |
solrIndex.update(obsoletedPid, obsoletedSystemMetadata, obsoletedEmlInputStream); |
|
113 |
solrIndex.update(obsoletedPid, obsoletedSystemMetadata, EMLFILEPATH); |
|
120 | 114 |
|
121 | 115 |
// old version should be marked as obsoleted and not returned |
122 | 116 |
result = doQuery(solrIndex.getSolrServer(), "&fq=-obsoletedBy:*"); |
... | ... | |
133 | 127 |
//InputStream systemInputStream = new FileInputStream(new File(SYSTEMMETAFILEPATH)); |
134 | 128 |
//System metadata's archive is true. |
135 | 129 |
SystemMetadata systemMetadata = TypeMarshaller.unmarshalTypeFromFile(SystemMetadata.class, SYSTEMMETAARCHIVEFILEPATH); |
136 |
InputStream emlInputStream = new FileInputStream(new File(EMLUPDATEFILEPATH)); |
|
137 | 130 |
/*ArrayList<String> obsoletes = new ArrayList<String>(); |
138 | 131 |
obsoletes.add(id); |
139 | 132 |
obsoletes.add("tao");*/ |
140 | 133 |
Identifier pid = new Identifier(); |
141 | 134 |
pid.setValue(newId); |
142 |
solrIndex.update(pid, systemMetadata, emlInputStream);
|
|
135 |
solrIndex.update(pid, systemMetadata, EMLUPDATEFILEPATH);
|
|
143 | 136 |
String result = doQuery(solrIndex.getSolrServer()); |
144 | 137 |
assertTrue(result.contains("version1")); |
145 | 138 |
assertTrue(!result.contains("version2")); |
... | ... | |
153 | 146 |
public void testDynamicFields() throws Exception { |
154 | 147 |
|
155 | 148 |
SystemMetadata systemMetadata = TypeMarshaller.unmarshalTypeFromFile(SystemMetadata.class, SYSTEMMETAFILEPATH); |
156 |
InputStream emlInputStream = new FileInputStream(new File(EMLFILEPATH)); |
|
157 | 149 |
Identifier pid = new Identifier(); |
158 | 150 |
pid.setValue(id); |
159 |
solrIndex.update(pid, systemMetadata, emlInputStream);
|
|
151 |
solrIndex.update(pid, systemMetadata, EMLFILEPATH);
|
|
160 | 152 |
String result = doQuery(solrIndex.getSolrServer()); |
161 | 153 |
List<String> ids = solrIndex.getSolrIds(); |
162 | 154 |
boolean foundId = false; |
... | ... | |
197 | 189 |
public void testOpenAnnotation() throws Exception { |
198 | 190 |
|
199 | 191 |
SystemMetadata systemMetadata = TypeMarshaller.unmarshalTypeFromFile(SystemMetadata.class, SYSTEMMETAFILEPATH); |
200 |
InputStream emlInputStream = new FileInputStream(new File(EMLFILEPATH)); |
|
201 | 192 |
Identifier pid = new Identifier(); |
202 | 193 |
pid.setValue(id); |
203 |
solrIndex.update(pid, systemMetadata, emlInputStream);
|
|
194 |
solrIndex.update(pid, systemMetadata, EMLFILEPATH);
|
|
204 | 195 |
String result = doQuery(solrIndex.getSolrServer()); |
205 | 196 |
List<String> ids = solrIndex.getSolrIds(); |
206 | 197 |
boolean foundId = false; |
... | ... | |
214 | 205 |
|
215 | 206 |
// augment with the dynamic field |
216 | 207 |
SystemMetadata annotationSystemMetadata = TypeMarshaller.unmarshalTypeFromFile(SystemMetadata.class, ANNOTATION_SYSTEM_META_FILE_PATH); |
217 |
InputStream annotationInputStream = new FileInputStream(new File(OA_FILE_PATH)); |
|
218 | 208 |
Identifier annotationPid = new Identifier(); |
219 | 209 |
annotationPid.setValue(annotation_id); |
220 |
solrIndex.update(annotationPid, annotationSystemMetadata, annotationInputStream);
|
|
210 |
solrIndex.update(annotationPid, annotationSystemMetadata, OA_FILE_PATH);
|
|
221 | 211 |
String annotationResult = doQuery(solrIndex.getSolrServer(), "&fq=standard_sm:\"http://ecoinformatics.org/oboe/oboe.1.0/oboe-standards.owl#Gram\""); |
222 | 212 |
assertTrue(annotationResult.contains(pid.getValue())); |
223 | 213 |
assertTrue(annotationResult.contains("http://ecoinformatics.org/oboe/oboe.1.0/oboe-standards.owl#Gram")); |
Also available in: Unified diff
pass around the object file path rather than the data stream so that multiple subprocessors can index the same object and not consume the stream before it gets to the next one. In preparation for extending the assertions stored in OREs. https://projects.ecoinformatics.org/ecoinfo/issues/6548