|
45 | 45 | @RunWith(Parameterized.class) |
46 | 46 | public class JsonLdProcessorTest { |
47 | 47 |
|
48 | | - private static final String TEST_DIR = "json-ld.org"; |
| 48 | + private static final String TEST_DIR = "json-ld-api-tests"; |
| 49 | + // option: run the old 1.0 test suite: |
| 50 | + // private static final String TEST_DIR = "json-ld.org-tests"; |
| 51 | + |
49 | 52 | private static final String MANIFEST_FILE = "manifest.jsonld"; |
50 | 53 |
|
51 | 54 | private static Map<String, Object> REPORT; |
@@ -186,36 +189,8 @@ public static Collection<Object[]> data() throws URISyntaxException, IOException |
186 | 189 |
|
187 | 190 | final ClassLoader cl = Thread.currentThread().getContextClassLoader(); |
188 | 191 | final File testDir = new File(cl.getResource(TEST_DIR).toURI()); |
189 | | - final File mainManifestFile = new File(testDir, MANIFEST_FILE); |
190 | | - |
191 | | - final Map<String, Object> mainManifest = (Map<String, Object>) JsonUtils |
192 | | - .fromInputStream(new FileInputStream(mainManifestFile)); |
193 | 192 |
|
194 | | - final List<String> manifestFileNames = (List<String>) mainManifest |
195 | | - .get("sequence"); |
196 | | - |
197 | | - final List<File> manifestfiles = new ArrayList<File>(); |
198 | | - |
199 | | - for (final String manifestFileName : manifestFileNames) { |
200 | | - System.out.println("Using manifest: " + testDir + " " + manifestFileName); |
201 | | - manifestfiles.add(new File(testDir, manifestFileName)); |
202 | | - } |
203 | | - |
204 | | - // final List<File> manifestfiles = Arrays.asList(f.listFiles(new FilenameFilter() { |
205 | | - // @Override |
206 | | - // public boolean accept(File dir, String name) { |
207 | | - // if (name.contains("manifest") && name.endsWith(".jsonld") && !name.equals("manifest.jsonld")) { |
208 | | - // System.out.println("Using manifest: " + dir + " " |
209 | | - // + name); |
210 | | - // // Remote-doc tests are not currently supported |
211 | | - // if (name.contains("remote-doc")) { |
212 | | - // return false; |
213 | | - // } |
214 | | - // return true; |
215 | | - // } |
216 | | - // return false; |
217 | | - // } |
218 | | - // })); |
| 193 | + final List<File> manifestfiles = loadManifestFiles(testDir); |
219 | 194 |
|
220 | 195 | final Collection<Object[]> rdata = new ArrayList<Object[]>(); |
221 | 196 | for (final File in : manifestfiles) { |
@@ -246,6 +221,40 @@ public static Collection<Object[]> data() throws URISyntaxException, IOException |
246 | 221 | return rdata; |
247 | 222 | } |
248 | 223 |
|
| 224 | + private static List<File> loadManifestFiles(final File testDir) { |
| 225 | + List<File> manifestfiles = new ArrayList<File>(); |
| 226 | + if (testDir.getName().equals("json-ld-api-tests")) { |
| 227 | + final File mainManifestFile = new File(testDir, MANIFEST_FILE); |
| 228 | + Map<String, Object> mainManifest; |
| 229 | + try { |
| 230 | + mainManifest = (Map<String, Object>) JsonUtils.fromInputStream(new FileInputStream(mainManifestFile)); |
| 231 | + final List<String> manifestFileNames = (List<String>) mainManifest.get("sequence"); |
| 232 | + for (final String manifestFileName : manifestFileNames) { |
| 233 | + System.out.println("Using manifest: " + testDir + " " + manifestFileName); |
| 234 | + manifestfiles.add(new File(testDir, manifestFileName)); |
| 235 | + } |
| 236 | + } catch (IOException e) { |
| 237 | + e.printStackTrace(); |
| 238 | + } |
| 239 | + } else { |
| 240 | + manifestfiles = Arrays.asList(testDir.listFiles(new FilenameFilter() { |
| 241 | + @Override |
| 242 | + public boolean accept(File dir, String name) { |
| 243 | + if (name.contains("manifest") && name.endsWith(".jsonld") && !name.equals("manifest.jsonld")) { |
| 244 | + System.out.println("Using manifest: " + dir + " " + name); |
| 245 | + // Remote-doc tests are not currently supported |
| 246 | + if (name.contains("remote-doc")) { |
| 247 | + return false; |
| 248 | + } |
| 249 | + return true; |
| 250 | + } |
| 251 | + return false; |
| 252 | + } |
| 253 | + })); |
| 254 | + } |
| 255 | + return manifestfiles; |
| 256 | + } |
| 257 | + |
249 | 258 | private class TestDocumentLoader extends DocumentLoader { |
250 | 259 |
|
251 | 260 | private final String base; |
|
0 commit comments