2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
20 package org.onap.dmaap.dbcapi.resources;
22 import static org.junit.Assert.assertTrue;
24 import jakarta.ws.rs.client.Entity;
25 import jakarta.ws.rs.core.Application;
26 import jakarta.ws.rs.core.MediaType;
27 import jakarta.ws.rs.core.Response;
28 import org.glassfish.jersey.server.ResourceConfig;
29 import org.glassfish.jersey.test.JerseyTest;
30 import org.junit.BeforeClass;
31 import org.junit.Test;
32 import org.onap.dmaap.dbcapi.model.Dmaap;
33 import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory;
36 public class DmaapResourceTest extends JerseyTest {
38 static DmaapObjectFactory factory = new DmaapObjectFactory();
41 public static void setUpClass(){
42 System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
46 protected Application configure() {
47 return new ResourceConfig( DmaapResource.class );
51 public void GetTest() {
52 Response resp = target( "dmaap").request().get( Response.class );
53 assertTrue( resp.getStatus() == 200 );
56 public void PostTest() {
58 Dmaap dmaap = factory.genDmaap();
59 Entity<Dmaap> reqEntity = Entity.entity( dmaap, MediaType.APPLICATION_JSON );
60 Response resp = target( "dmaap").request().post( reqEntity, Response.class );
61 System.out.println( resp.getStatus() );
62 assertTrue( resp.getStatus() == 200 );
66 public void PutTest() {
68 Dmaap dmaap = factory.genDmaap();
69 Entity<Dmaap> reqEntity = Entity.entity( dmaap, MediaType.APPLICATION_JSON );
71 dmaap.setVersion( "2" );
72 Response resp = target( "dmaap").request().put( reqEntity, Response.class );
73 System.out.println( resp.getStatus() );
74 assertTrue( resp.getStatus() == 200 );