[DMAAP-BC] Fix failing jenkins
[dmaap/buscontroller.git] / dmaap-bc / src / test / java / org / onap / dmaap / dbcapi / resources / FeedResourceTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * org.onap.dmaap
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 package org.onap.dmaap.dbcapi.resources;
21 import static org.junit.Assert.assertTrue;
22
23 import javax.ws.rs.client.Entity;
24 import javax.ws.rs.core.Application;
25 import javax.ws.rs.core.MediaType;
26 import javax.ws.rs.core.Response;
27 import org.glassfish.jersey.server.ResourceConfig;
28 import org.glassfish.jersey.test.JerseyTest;
29 import org.junit.BeforeClass;
30 import org.junit.Test;
31 import org.onap.dmaap.dbcapi.model.Feed;
32
33
34 public class FeedResourceTest extends JerseyTest {
35
36         @BeforeClass
37         public static void setUpClass(){
38                 System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
39         }
40         @Override
41         protected Application configure() {
42                 return new ResourceConfig( FeedResource.class );
43         }
44
45         @Test
46         public void GetTest() {
47                 Response resp = target( "feeds").request().get( Response.class );
48                 System.out.println( "GET feed resp=" + resp.getStatus() );
49
50                 assertTrue( resp.getStatus() == 200 );
51         }
52         @Test
53         public void PostTest() {
54                 Feed feed = new Feed( "aPostTest", "1.0", "a unit test", "dgl", "unrestricted" );
55                 Entity<Feed> reqEntity = Entity.entity( feed, MediaType.APPLICATION_JSON );
56                 Response resp = target( "feeds").request().post( reqEntity, Response.class );
57                 System.out.println( "POST feed resp=" + resp.getStatus() );
58                 assertTrue( resp.getStatus() == 200 );
59         }
60
61 }
62