a b/src/test/java/org/sbaresearch/owl/TestUtils.java
1
/**
2
 * Copyright (c) 2013/2014 Verein zur Foerderung der IT-Sicherheit in Oesterreich (SBA).
3
 * The work has been developed in the TIMBUS Project and the above-mentioned are Members of the TIMBUS Consortium.
4
 * TIMBUS is supported by the European Union under the 7th Framework Programme for research and technological
5
 * development and demonstration activities (FP7/2007-2013) under grant agreement no. 269940.
6
 *
7
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
8
 * the License. You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
9
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including without
11
 * limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTIBITLY, or FITNESS FOR A PARTICULAR
12
 * PURPOSE. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise,
13
 * unless required by applicable law or agreed to in writing, shall any Contributor be liable for damages, including
14
 * any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this
15
 * License or out of the use or inability to use the Work.
16
 * See the License for the specific language governing permissions and limitation under the License.
17
 */
18
package org.sbaresearch.owl;
19
20
import org.semanticweb.owlapi.apibinding.OWLManager;
21
import org.semanticweb.owlapi.model.OWLDataFactory;
22
import org.semanticweb.owlapi.model.OWLOntologyManager;
23
24
import java.lang.reflect.Proxy;
25
import java.net.URISyntaxException;
26
27
public abstract class TestUtils {
28
    public static OwlApiFacade getOwlApiFacadeUsingProxy(OwlManagerInvocationHandler invocationHandler, OWLDataFactory owlDataFactory) {
29
        OWLOntologyManager manager = (OWLOntologyManager) Proxy.newProxyInstance(
30
                TestUtils.class.getClassLoader(),
31
                new Class[]{OWLOntologyManager.class},
32
                invocationHandler);
33
        return TestUtils.createOwlApiFacade(manager, owlDataFactory);
34
    }
35
36
    public static OwlApiFacade createDefaultOwlApiFacade() {
37
        return new OwlApiFacade(OWLManager.createOWLOntologyManager(), OWLManager.getOWLDataFactory());
38
    }
39
40
    public static OwlApiFacade createOwlApiFacade(OWLOntologyManager ontologyManager, OWLDataFactory dataFactory) {
41
        return new OwlApiFacade(ontologyManager, dataFactory);
42
    }
43
44
    public static String getUri(String path) throws URISyntaxException {
45
        return TestUtils.class.getResource(path).toURI().toASCIIString();
46
    }
47
48
    public static String getPath(String path) {
49
        return TestUtils.class.getResource(path).getPath();
50
    }
51
52
    /**
53
     * Load the Timbus truststore to avoid infinite (nearly =)) wait in integration tests that load ontologies from timbus.teco.edu...
54
     */
55
    public static void loadTimbusTrustStore() {
56
        System.setProperty("javax.net.ssl.trustStore", TestUtils.getPath("/timbus.ts"));
57
    }
58
}