View Javadoc

1   /*
2    * #%L
3    * Native ARchive plugin for Maven
4    * %%
5    * Copyright (C) 2002 - 2014 NAR Maven Plugin developers.
6    * %%
7    * Licensed under the Apache License, Version 2.0 (the "License");
8    * you may not use this file except in compliance with the License.
9    * You may obtain a copy of the License at
10   * 
11   * http://www.apache.org/licenses/LICENSE-2.0
12   * 
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   * #L%
19   */
20  package com.github.maven_nar.cpptasks;
21  
22  import java.io.File;
23  import java.io.IOException;
24  
25  import javax.xml.parsers.ParserConfigurationException;
26  
27  import org.xml.sax.SAXException;
28  
29  /**
30   * DependencyTable tests
31   *
32   * @author curta
33   */
34  public class TestDependencyTable extends TestXMLConsumer {
35    /**
36     * Constructor
37     * 
38     * @param testName
39     *          test name
40     */
41    public TestDependencyTable(final String testName) {
42      super(testName);
43    }
44  
45    /**
46     * Loads a dependency file from OpenSHORE (http://www.openshore.org)
47     * 
48     * @throws IOException
49     */
50    public void testLoadOpenshore() throws IOException, ParserConfigurationException, SAXException {
51      final String tmpDir = System.getProperty("java.io.tmpdir");
52      try {
53        copyResourceToTmpDir("openshore/dependencies.xml", "dependencies.xml");
54        final DependencyTable dependencies = new DependencyTable(new File(tmpDir));
55        dependencies.load();
56      } finally {
57        deleteTmpFile("dependencies.xml");
58      }
59    }
60  
61    /**
62     * Loads a dependency file from Xerces-C (http://xml.apache.org)
63     * 
64     * @throws IOException
65     */
66    public void testLoadXerces() throws IOException, ParserConfigurationException, SAXException {
67      final String tmpDir = System.getProperty("java.io.tmpdir");
68      try {
69        copyResourceToTmpDir("xerces-c/dependencies.xml", "dependencies.xml");
70        final DependencyTable dependencies = new DependencyTable(new File(tmpDir));
71        dependencies.load();
72      } finally {
73        deleteTmpFile("dependencies.xml");
74      }
75    }
76  }