SDN-R update common
[ccsdk/features.git] / sdnr / wt / common / src / test / java / org / onap / ccsdk / features / sdnr / wt / common / test / TestPomfile.java
1 /*******************************************************************************
2  * ============LICENSE_START========================================================================
3  * ONAP : ccsdk feature sdnr wt
4  * =================================================================================================
5  * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6  * =================================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software distributed under the License
13  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14  * or implied. See the License for the specific language governing permissions and limitations under
15  * the License.
16  * ============LICENSE_END==========================================================================
17  ******************************************************************************/
18 package org.onap.ccsdk.features.sdnr.wt.common.test;
19
20 import static org.junit.Assert.assertEquals;
21 import static org.junit.Assert.assertNotNull;
22 import static org.junit.Assert.fail;
23
24 import java.io.ByteArrayInputStream;
25 import java.io.FileInputStream;
26 import java.io.IOException;
27 import javax.xml.parsers.ParserConfigurationException;
28
29 import org.junit.Test;
30 import org.onap.ccsdk.features.sdnr.wt.common.file.PomFile;
31 import org.onap.ccsdk.features.sdnr.wt.common.file.PomPropertiesFile;
32 import org.xml.sax.SAXException;
33
34 public class TestPomfile {
35
36     private static final String TESTPROPERTY_KEY="elasticsearch-rest-client.version";
37     private static final String TESTPROPERTY_VALUE = "6.4.3";
38     private static final String POMFILENAME = "pom.xml";
39     private static final String POM_PROPERTY = "#Generated by org.apache.felix.bundleplugin\n" +
40             "#Tue Nov 19 11:20:33 CET 2019\n" +
41             "version=0.7.0-SNAPSHOT\n" +
42             "groupId=org.onap.ccsdk.features.sdnr.wt\n" +
43             "artifactId=sdnr-wt-data-provider-provider\n";
44     //private static final Date DATE_EXPECTED = new Date(119, 10, 19, 11, 20, 33);
45
46     @Test
47     public void test() {
48         PomFile pom=null;
49         try {
50             pom = new PomFile(new FileInputStream(POMFILENAME));
51         } catch (ParserConfigurationException | SAXException | IOException e) {
52             fail(e.getMessage());
53         }
54         assertNotNull(pom);
55         assertEquals(TESTPROPERTY_VALUE, pom.getProperty(TESTPROPERTY_KEY));
56
57     }
58     @Test
59     public void testProp() {
60         PomPropertiesFile file = null;
61         try {
62             file = new PomPropertiesFile(new ByteArrayInputStream(POM_PROPERTY.getBytes()));
63         } catch (IOException e) {
64             // TODO Auto-generated catch block
65             e.printStackTrace();
66         }
67         assertNotNull(file);
68         assertNotNull(file.getBuildDate());
69     }
70 }