List of usage examples for org.apache.commons.httpclient HttpStatus SC_CREATED
int SC_CREATED
To view the source code for org.apache.commons.httpclient HttpStatus SC_CREATED.
Click Source Link
From source file:org.wso2.iot.integration.device.operation.AndroidOperation.java
@Test(groups = { Constants.AndroidOperations.OPERATIONS_GROUP }, description = "Test Android web clip operation.") public void testWebClip() throws Exception { HttpResponse response = client.post( Constants.AndroidOperations.OPERATION_ENDPOINT + Constants.AndroidOperations.WEB_CLIP_ENDPOINT, Constants.AndroidOperations.WEB_CLIP_PAYLOAD); Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode()); }
From source file:org.wso2.iot.integration.operation.OperationManagement.java
@Test(dependsOnMethods = { "testEnrollment" }, description = "Test Android install apps operation.") public void testInstallApps() throws Exception { JsonObject operationData = PayloadGenerator.getJsonPayload( Constants.AndroidOperations.OPERATION_PAYLOAD_FILE_NAME, Constants.AndroidOperations.INSTALL_APPS_OPERATION); JsonArray deviceIds = new JsonArray(); JsonPrimitive deviceID = new JsonPrimitive(Constants.DEVICE_ID); deviceIds.add(deviceID);//from w w w . j av a2 s. co m operationData.add(Constants.DEVICE_IDENTIFIERS_KEY, deviceIds); HttpResponse response = rclient.post(Constants.AndroidOperations.INSTALL_APPS_ENDPOINT, operationData.toString()); Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode()); }
From source file:org.wso2.iot.integration.role.RoleManagement.java
@Test(description = "Test add role.") public void testAddRole() throws FileNotFoundException { IOTResponse response = client.post(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT, PayloadGenerator// w w w .j a v a2 s.c o m .getJsonPayload(Constants.RoleManagement.ROLE_PAYLOAD_FILE_NAME, Constants.HTTP_METHOD_POST) .toString()); Assert.assertEquals(HttpStatus.SC_CREATED, response.getStatus()); }
From source file:org.wso2.iot.integration.samples.VirtualFireAlarmTestCase.java
@BeforeClass(alwaysRun = true) public void initTest() throws Exception { super.init(userMode); restClient = new RestClient(backendHTTPSURL, Constants.APPLICATION_JSON, accessTokenString); if (userMode == TestUserMode.TENANT_ADMIN) { HttpResponse response = restClient .post(Constants.VirtualFireAlarmConstants.ANALYTICS_ARTIFACTS_DEPLOYMENT_ENDPOINT, ""); Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode()); }/*w w w . j a v a 2 s . co m*/ }
From source file:org.wso2.iot.integration.samples.VirtualFireAlarmTestCase.java
@Test(description = "Test whether the policy publishing from the server to device works", dependsOnMethods = { "testEventPublishing" }) public void testPolicyPublishing() throws Exception { String deviceId2 = userMode == TestUserMode.TENANT_ADMIN ? tenantDeviceId2 : VirtualFireAlarmTestCase.deviceId2; String topic = automationContext.getContextTenant().getDomain() + "/" + DEVICE_TYPE + "/" + deviceId2 + "/operation/#"; String clientId = deviceId2 + ":" + DEVICE_TYPE; HttpResponse response = restClient.post("/api/device-mgt/v1.0/policies", PayloadGenerator.getJsonPayload(Constants.VirtualFireAlarmConstants.PAYLOAD_FILE, Constants.VirtualFireAlarmConstants.POLICY_DATA).toString()); Assert.assertEquals("Policy creation for virtual fire alarm failed", HttpStatus.SC_CREATED, response.getResponseCode()); JsonObject jsonObject = new JsonParser().parse(response.getData()).getAsJsonObject(); String policyId = jsonObject.getAsJsonPrimitive("id").getAsString(); JsonArray jsonArray = new JsonArray(); jsonArray.add(new JsonPrimitive(policyId)); response = restClient.post(Constants.VirtualFireAlarmConstants.ACTIVATE_POLICY_ENDPOINT, jsonArray.toString());/* w w w . ja va 2 s . com*/ Assert.assertEquals("Policy activation for virtual fire alarm failed", HttpStatus.SC_OK, response.getResponseCode()); MqttSubscriberClient mqttSubscriberClient = new MqttSubscriberClient(broker, clientId, topic, accessToken); response = restClient.put(Constants.VirtualFireAlarmConstants.APPLY_CHANGES_ENDPOINT, ""); Assert.assertEquals("Applying changes to policy for virtual fire alarm failed", HttpStatus.SC_OK, response.getResponseCode()); // Allow some time for message delivery Thread.sleep(20000); ArrayList<MqttMessage> mqttMessages = mqttSubscriberClient.getMqttMessages(); Assert.assertEquals("Policy published message is not received by the mqtt listener. ", 2, mqttMessages.size()); }
From source file:org.wso2.iot.integration.user.UserManagement.java
@Test(description = "Test add user.") public void testAddUser() throws Exception { // Add a user with the details and check whether that user is added correctly. HttpResponse response = client.post(Constants.UserManagement.USER_ENDPOINT, PayloadGenerator/* w ww. j av a2s. c o m*/ .getJsonPayload(Constants.UserManagement.USER_PAYLOAD_FILE_NAME, Constants.HTTP_METHOD_POST) .toString()); Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode()); AssertUtil.jsonPayloadCompare( PayloadGenerator.getJsonPayload(Constants.UserManagement.USER_RESPONSE_PAYLOAD_FILE_NAME, Constants.HTTP_METHOD_POST).toString(), response.getData(), true); }
From source file:org.wso2.mdm.integration.certificate.CertificateManagement.java
@Test(description = "Test certificate adding.") public void testAddCertificate() throws Exception { MDMResponse response = client.post(Constants.CertificateManagement.CERTIFICATE_ADD_ENDPOINT, Constants.CertificateManagement.CERTIFICATE_ADD_PAYLOAD); Assert.assertEquals(HttpStatus.SC_CREATED, response.getStatus()); }
From source file:org.wso2.mdm.integration.device.operation.AndroidOperation.java
@Test(groups = Constants.AndroidOperations.OPERATIONS_GROUP, description = "Test Android device lock operation.") public void testLock() throws Exception { HttpResponse response = client.post(Constants.AndroidOperations.LOCK_ENDPOINT, Constants.AndroidOperations.COMMAND_OPERATION_PAYLOAD); Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode()); }
From source file:org.wso2.mdm.integration.device.operation.AndroidOperation.java
@Test(groups = Constants.AndroidOperations.OPERATIONS_GROUP, description = "Test Android device location operation.") public void testLocation() throws Exception { HttpResponse response = client.post(Constants.AndroidOperations.LOCATION_ENDPOINT, Constants.AndroidOperations.COMMAND_OPERATION_PAYLOAD); Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode()); }
From source file:org.wso2.mdm.integration.device.operation.AndroidOperation.java
@Test(groups = Constants.AndroidOperations.OPERATIONS_GROUP, description = "Test Android device clear password " + "operation.") public void testClearPassword() throws Exception { HttpResponse response = client.post(Constants.AndroidOperations.CLEAR_PASSWORD_ENDPOINT, Constants.AndroidOperations.COMMAND_OPERATION_PAYLOAD); Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode()); }