b5889b45b9e016577215c51a453f164a0d02ef44
[aaf/authz.git] / misc / rosetta / src / test / java / org / onap / aaf / misc / rosetta / env / JU_RosettaEnv.java
1 /**
2  * ============LICENSE_START====================================================
3  * org.onap.aaf
4  * ===========================================================================
5  * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
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  * ============LICENSE_END====================================================
19  *
20  */
21
22 package org.onap.aaf.misc.rosetta.env;
23
24 import static org.junit.Assert.assertTrue;
25 import static org.mockito.MockitoAnnotations.initMocks;
26
27 import java.applet.Applet;
28 import java.util.Properties;
29
30 import javax.xml.namespace.QName;
31 import javax.xml.validation.Schema;
32
33 import org.junit.Before;
34 import org.junit.Test;
35 import org.mockito.Mock;
36 import org.mockito.Mockito;
37 import org.onap.aaf.misc.env.APIException;
38 import org.onap.aaf.misc.env.Env;
39 import org.onap.aaf.misc.env.jaxb.JAXBmar;
40 import org.onap.aaf.misc.rosetta.Saved;
41
42 public class JU_RosettaEnv {
43
44         @Before
45         public void setUp() {
46                 initMocks(this);
47         }
48         
49         @Test
50         public void testNewDataFactoryClass() {
51                 RosettaEnv rosettaObj = new RosettaEnv();
52                 try {
53                         Object retVal = rosettaObj.newDataFactory(Api.class);
54                         assertTrue(retVal instanceof RosettaDF);
55                 } catch (APIException e) {
56                         // TODO Auto-generated catch block
57                         e.printStackTrace();
58                 }
59         }
60         
61         @Test
62         public void testNewDataFactorySchema() {
63                 RosettaEnv rosettaObj = new RosettaEnv(Mockito.mock(Applet.class),"test");
64                 try {
65                         Object retVal = rosettaObj.newDataFactory(Mockito.mock(Schema.class),Api.class);
66                         assertTrue(retVal instanceof RosettaDF);
67                 } catch (APIException e) {
68                         // TODO Auto-generated catch block
69                         e.printStackTrace();
70                 }
71         }
72         
73         @Test
74         public void testNewDataFactoryQname() {
75                 RosettaEnv rosettaObj = new RosettaEnv(new String[] {"test"});
76                 rosettaObj = new RosettaEnv(Mockito.mock(Properties.class));
77                 try {
78                         Object retVal = rosettaObj.newDataFactory(Mockito.mock(QName.class),Api.class);
79                         assertTrue(retVal instanceof RosettaDF);
80                 } catch (APIException e) {
81                         // TODO Auto-generated catch block
82                         e.printStackTrace();
83                 }
84         }
85         
86         @Test
87         public void testNewDataFactoryQnameSchema() {
88                 RosettaEnv rosettaObj = new RosettaEnv("test", new String[] {"test"});
89                 rosettaObj = new RosettaEnv("test", Mockito.mock(Properties.class));
90                 try {
91                         Object retVal = rosettaObj.newDataFactory(Mockito.mock(Schema.class),Mockito.mock(QName.class),Api.class);
92                         assertTrue(retVal instanceof RosettaDF);
93                 } catch (APIException e) {
94                         // TODO Auto-generated catch block
95                         e.printStackTrace();
96                 }
97         }
98 }