[DMAAP-BC] Consolidate bus controller repos
[dmaap/buscontroller.git] / dmaap-bc / src / test / java / org / onap / dmaap / dbcapi / resources / DmaapResourceTest.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
22 import static org.junit.Assert.assertTrue;
23
24 import javax.ws.rs.client.Entity;
25 import javax.ws.rs.core.Application;
26 import javax.ws.rs.core.MediaType;
27 import javax.ws.rs.core.Response;
28 import org.glassfish.jersey.server.ResourceConfig;
29 import org.glassfish.jersey.test.JerseyTest;
30 import org.junit.Test;
31 import org.onap.dmaap.dbcapi.model.Dmaap;
32 import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory;
33
34
35 public class DmaapResourceTest extends JerseyTest {
36
37         static DmaapObjectFactory factory = new DmaapObjectFactory();
38
39         @Override
40         protected Application configure() {
41                 return new ResourceConfig( DmaapResource.class );
42                 //return new ResourceConfig( HelloResource.class );
43         }
44
45         private static final String  fmt = "%24s: %s%n";
46
47
48
49 /*  may conflict with test framework! 
50         @Before
51         public void setUp() throws Exception {
52         }
53
54         @After
55         public void tearDown() throws Exception {
56         }
57 */
58
59
60
61         @Test
62         public void GetTest() {
63                 Response resp = target( "dmaap").request().get( Response.class );
64                 assertTrue( resp.getStatus() == 200 );
65         }
66         @Test
67         public void PostTest() {
68
69                 Dmaap dmaap = factory.genDmaap();
70                 Entity<Dmaap> reqEntity = Entity.entity( dmaap, MediaType.APPLICATION_JSON );
71                 Response resp = target( "dmaap").request().post( reqEntity, Response.class );
72                 System.out.println( resp.getStatus() );
73                 assertTrue( resp.getStatus() == 200 );
74         }
75
76         @Test
77         public void PutTest() {
78
79                 Dmaap dmaap = factory.genDmaap();
80                 Entity<Dmaap> reqEntity = Entity.entity( dmaap, MediaType.APPLICATION_JSON );
81         
82                 dmaap.setVersion( "2" );        
83                 Response resp = target( "dmaap").request().put( reqEntity, Response.class );
84                 System.out.println( resp.getStatus() );
85                 assertTrue( resp.getStatus() == 200 );
86         }
87
88
89
90
91 }
92