Skip to content

Commit cea3503

Browse files
committed
Remove EOF
1 parent b39d1cf commit cea3503

File tree

8 files changed

+525
-561
lines changed

8 files changed

+525
-561
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
36c5a264d30c86cb3b84eb92636d8a05dcdcee1cee17d5a3bac0df4fe78fa21c
1+
988066caf62166ae458caac8dabe0fe5e2c9ad1d25d481417467a6a3a059af13
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a26b0550dd99135cd8e4e46802064d639c9e4d30c7f95005c01c82510424476c
1+
6d71e62cc841b14dcabb1dc5be4e0ac40252066d1f7890b8291693edd165dec1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/*
2+
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3+
*
4+
* WSO2 Inc. licenses this file to you under the Apache License,
5+
* Version 2.0 (the "License"); you may not use this file except
6+
* in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing,
12+
* software distributed under the License is distributed on an
13+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
* KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations
16+
* under the License.
17+
*/
18+
package org.wso2.am.integration.tests.api.lifecycle;
19+
20+
import com.google.gson.Gson;
21+
import org.apache.commons.logging.Log;
22+
import org.apache.commons.logging.LogFactory;
23+
import org.json.JSONObject;
24+
import org.testng.Assert;
25+
import org.testng.annotations.AfterClass;
26+
import org.testng.annotations.BeforeClass;
27+
import org.testng.annotations.Test;
28+
import org.wso2.am.integration.clients.store.api.v1.dto.ApplicationDTO;
29+
import org.wso2.am.integration.clients.store.api.v1.dto.SubscriptionListDTO;
30+
import org.wso2.am.integration.test.utils.APIManagerIntegrationTestException;
31+
import org.wso2.am.integration.test.utils.base.APIMIntegrationConstants;
32+
import org.wso2.am.integration.test.utils.bean.APILifeCycleAction;
33+
import org.wso2.am.integration.test.utils.bean.APIRequest;
34+
import org.wso2.carbon.automation.test.utils.http.client.HttpResponse;
35+
36+
import java.io.File;
37+
import java.net.URL;
38+
39+
40+
/**
41+
* This class checks whether the API subscriptions are retained when an API is demote to the CREATED state of
42+
* the API Lifecycle
43+
*/
44+
public class APIMANAGER5337SubscriptionRetainTestCase extends APIManagerLifecycleBaseTest {
45+
46+
private static final Log log = LogFactory.getLog(APIMANAGER5337SubscriptionRetainTestCase.class);
47+
private String apiId;
48+
private String applicationID;
49+
50+
@BeforeClass(alwaysRun = true)
51+
public void setEnvironment() throws Exception {
52+
super.init();
53+
}
54+
55+
@Test(groups = "wso2.am", description = "testing error responses")
56+
public void testAPIErrorResponse() throws Exception {
57+
58+
HttpResponse response;
59+
String apiName = "SubscriptionCheckAPI";
60+
String apiVersion = "1.0.0";
61+
String apiContext = "subscriptionCheck";
62+
String endpointUrl = getAPIInvocationURLHttp("response");
63+
64+
try {
65+
//Create the api creation request object
66+
APIRequest apiRequest;
67+
apiRequest = new APIRequest(apiName, apiContext, new URL(endpointUrl));
68+
69+
apiRequest.setVersion(apiVersion);
70+
apiRequest.setTiersCollection(APIMIntegrationConstants.API_TIER.UNLIMITED);
71+
apiRequest.setTier(APIMIntegrationConstants.API_TIER.UNLIMITED);
72+
73+
//Add the API using the API publisher.
74+
HttpResponse apiResponse = restAPIPublisher.addAPI(apiRequest);
75+
//verifyResponse(apiResponse);
76+
77+
apiId = apiResponse.getData();
78+
79+
// Create Revision and Deploy to Gateway
80+
createAPIRevisionAndDeployUsingRest(apiId, restAPIPublisher);
81+
82+
//Publish the API
83+
restAPIPublisher.changeAPILifeCycleStatus(apiId, APILifeCycleAction.PUBLISH.getAction(), null);
84+
85+
HttpResponse applicationResponse = restAPIStore.createApplication("subscriptionCheckApp1",
86+
"Test Application", APIMIntegrationConstants.APPLICATION_TIER.UNLIMITED,
87+
ApplicationDTO.TokenTypeEnum.JWT);
88+
//verifyResponse(applicationResponse);
89+
90+
applicationID = applicationResponse.getData();
91+
92+
//Subscribe the API to the Application
93+
response = restAPIStore.createSubscription(apiId, applicationID, APIMIntegrationConstants.API_TIER.UNLIMITED);
94+
//verifyResponse(response);
95+
96+
//Demote the API to the Created State
97+
restAPIPublisher.changeAPILifeCycleStatus(apiId, "Demote to Created", null);
98+
99+
Thread.sleep(1000);
100+
101+
// //Check For subscriptions
102+
SubscriptionListDTO subsDTO = restAPIStore.getAllSubscriptionsOfApplication(applicationID);
103+
// verifyResponse(response);
104+
105+
Gson g = new Gson();
106+
String subscriptionJsonString = g.toJson(subsDTO, SubscriptionListDTO.class);
107+
Assert.assertEquals(subscriptionJsonString.contains("SubscriptionCheckAPI"), true,
108+
"Subscription of the SubscriptionCheckAPI has been removed.");
109+
110+
} catch (APIManagerIntegrationTestException e) {
111+
log.error("APIManagerIntegrationTestException " + e.getMessage(), e);
112+
Assert.assertTrue(false);
113+
}
114+
}
115+
116+
@AfterClass(alwaysRun = true)
117+
public void destroy() throws Exception {
118+
restAPIStore.deleteApplication(applicationID);
119+
undeployAndDeleteAPIRevisionsUsingRest(apiId, restAPIPublisher);
120+
restAPIPublisher.deleteAPI(apiId);
121+
}
122+
}

0 commit comments

Comments
 (0)