Search in sources :

Example 1 with MockHttp2Server

use of org.wso2.micro.gateway.tests.common.HTTP2Server.MockHttp2Server in project product-microgateway by wso2.

the class HTTP2RequestsWithHTTP2BackEndTestCase method setup.

@BeforeClass
public void setup() throws Exception {
    String label = "http2TestLabel";
    String project = "http2TestProject";
    // get mock APIM Instance
    MockAPIPublisher pub = MockAPIPublisher.getInstance();
    API api = new API();
    api.setName("PizzaShackAPI");
    api.setContext("/pizzashack");
    api.setEndpoint("https://localhost:8443");
    api.setVersion("1.0.0");
    api.setProvider("admin");
    // Register API with label
    pub.addApi(label, api);
    API api2 = new API();
    api2.setName("PizzaShackAPINew");
    api2.setContext("/pizzashack1");
    api2.setEndpoint(getMockServiceURLHttp("/echo"));
    api2.setVersion("2.0.0");
    api2.setProvider("admin");
    // Register API with label
    pub.addApi(label, api);
    // Define application info
    ApplicationDTO application = new ApplicationDTO();
    application.setName("jwtApp");
    application.setTier("Unlimited");
    application.setId((int) (Math.random() * 1000));
    // Register a production token with key validation info
    KeyValidationInfo info = new KeyValidationInfo();
    info.setApi(api);
    info.setApplication(application);
    info.setAuthorized(true);
    info.setKeyType(TestConstant.KEY_TYPE_PRODUCTION);
    info.setSubscriptionTier("Unlimited");
    String configPath = "confs/http2-test.conf";
    super.init(label, project, configPath);
    jwtTokenProd = getJWT(api, application, "Unlimited", TestConstant.KEY_TYPE_PRODUCTION, 3600);
    boolean isOpen2 = Utils.isPortOpen(MOCK_HTTP2_SERVER_PORT);
    Assert.assertFalse(isOpen2, "Port: " + MOCK_HTTP2_SERVER_PORT + " already in use.");
    mockHttp2Server = new MockHttp2Server(MOCK_HTTP2_SERVER_PORT, true);
    mockHttp2Server.start();
}
Also used : MockHttp2Server(org.wso2.micro.gateway.tests.common.HTTP2Server.MockHttp2Server) ApplicationDTO(org.wso2.micro.gateway.tests.common.model.ApplicationDTO) API(org.wso2.micro.gateway.tests.common.model.API) MockAPIPublisher(org.wso2.micro.gateway.tests.common.MockAPIPublisher) KeyValidationInfo(org.wso2.micro.gateway.tests.common.KeyValidationInfo) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

BeforeClass (org.testng.annotations.BeforeClass)1 MockHttp2Server (org.wso2.micro.gateway.tests.common.HTTP2Server.MockHttp2Server)1 KeyValidationInfo (org.wso2.micro.gateway.tests.common.KeyValidationInfo)1 MockAPIPublisher (org.wso2.micro.gateway.tests.common.MockAPIPublisher)1 API (org.wso2.micro.gateway.tests.common.model.API)1 ApplicationDTO (org.wso2.micro.gateway.tests.common.model.ApplicationDTO)1