org.wso2.carbon.logging.view.stub.LogViewerLogViewerException Java Examples

The following examples show how to use org.wso2.carbon.logging.view.stub.LogViewerLogViewerException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GRegPublisherAPILCPermissionCheck.java    From product-es with Apache License 2.0 6 votes vote down vote up
@Test(groups = {"wso2.greg", "wso2.greg.es"}, description = "PromoteLifeCycle with fault user",
      dependsOnMethods = {"testAddResources"})
public void CheckLCPermissionForAUserWithoutLCPermission() throws LogViewerLogViewerException, RemoteException, JSONException {
    authenticatePublisher("withoutLCAccessuser", "withoutLCAccessuser");
    ClientResponse response = getLifeCycleState(assetId, "restservice", lifeCycleName);

    //TODO: Following assertion fails due to bug reported at
    // https://wso2.org/jira/browse/STORE-1138
    Assert.assertTrue(response.getStatusCode() == 401, "Fault user accepted");

    JSONObject errorResponse = new JSONObject(response.getEntity(String.class));
    JSONObject dataObj = errorResponse.getJSONObject("error");
    String exception = dataObj.getString("exception");
    String message = dataObj.getString("message");

    Assert.assertTrue("Unauthorized Action - does not have permissions to view lifecycle state".equals(exception));
    Assert.assertTrue("User does not have permission to view lifecycle state".equals(message));
}
 
Example #2
Source File: GRegPublisherLifecycleHistoryTest.java    From product-es with Apache License 2.0 6 votes vote down vote up
@Test(groups = {"wso2.greg", "wso2.greg.es"}, description = "PromoteLifeCycle with fault user",
      dependsOnMethods = {"testPrepareForTestRun"})
public void CheckLCHistory() throws LogViewerLogViewerException, RemoteException,
                                                                  JSONException {
    ClientResponse response = getLifeCycleHistory(assetId, "restservice", lifeCycleName);

    Assert.assertTrue(response.getStatusCode() == 200, "Fault user accepted");

    JSONObject historyObj = new JSONObject(response.getEntity(String.class));
    JSONArray dataObj = historyObj.getJSONArray("data");

    Assert.assertEquals(((JSONObject) ((JSONObject) dataObj.get(0)).getJSONArray("action").
            get(0)).getString("name"), "Demote");
    Assert.assertEquals(((JSONObject) ((JSONObject) dataObj.get(1)).getJSONArray("action").
            get(0)).getString("name"), "Demote");
    Assert.assertEquals(((JSONObject) ((JSONObject) dataObj.get(2)).getJSONArray("action").
            get(0)).getString("name"), "Promote");
    Assert.assertEquals(((JSONObject) ((JSONObject) dataObj.get(3)).getJSONArray("action").
            get(0)).getString("name"), "Promote");

    Assert.assertEquals(dataObj.length(), 8);
}
 
Example #3
Source File: RestResourceLCWithTwoActionsPointingToSameStateWithExecutor.java    From product-es with Apache License 2.0 6 votes vote down vote up
@Test(groups = {"wso2.greg", "wso2.greg.es"}, description = "PromoteLifeCycle with fault user",
      dependsOnMethods = {"testAddResources"})
public void PerformLCActionPublish()
        throws JSONException, InterruptedException, IOException, LogViewerLogViewerException {
    queryParamMap.put("type", "restservice");
    queryParamMap.put("lifecycle", lifeCycleName);
    ClientResponse response =
            genericRestClient.geneticRestRequestPost(publisherUrl + "/asset/" + assetId + "/change-state",
                                                     MediaType.APPLICATION_FORM_URLENCODED,
                                                     MediaType.APPLICATION_JSON,
                                                     "nextState=development&comment=Published&nextAction=Publish"
                    , queryParamMap, headerMap, cookieHeader);
    JSONObject obj2 = new JSONObject(response.getEntity(String.class));
    Assert.assertTrue(response.getStatusCode() == 200, "Fault user accepted");
    LogEvent[] logEvents = logViewerClient.getLogs("INFO", "@@@@@@@@@@@@@@@@@@@@@@ " +
                                                           "PromoteNotificationExecutor ACTION executed! " +
                                                           "---------------------------", "", "");
    Assert.assertEquals(logEvents.length, 1);
}
 
Example #4
Source File: RestResourceLCWithTwoActionsPointingToSameStateWithExecutor.java    From product-es with Apache License 2.0 6 votes vote down vote up
@Test(groups = {"wso2.greg", "wso2.greg.es"}, description = "PromoteLifeCycle with fault user",
      dependsOnMethods = {"PerformLCActionPublish"})
public void PerformLCActionUnpublish() throws LogViewerLogViewerException, RemoteException, JSONException {
    queryParamMap.put("type", "restservice");
    queryParamMap.put("lifecycle", lifeCycleName);
    ClientResponse response =
            genericRestClient.geneticRestRequestPost(publisherUrl + "/asset/" + assetId + "/change-state",
                                                     MediaType.APPLICATION_FORM_URLENCODED,
                                                     MediaType.APPLICATION_JSON,
                                                     "nextState=development&comment=Unpublished" +
                                                     "&nextAction=Unpublish"
                    , queryParamMap, headerMap, cookieHeader);
    JSONObject obj2 = new JSONObject(response.getEntity(String.class));
    Assert.assertTrue(response.getStatusCode() == 200, "Fault user accepted");
    LogEvent[] logEvents = logViewerClient.getLogs("INFO", "###################### " +
                                                           "DemoteNotificationExecutor ACTION executed! " +
                                                           "---------------------------", "", "");
    //TODO: Following assertion will fail on carbon-store release 2.3.9
    //Once this test is built with carbon-store version higher than 2.3.9, it passes
    //https://wso2.org/jira/browse/REGISTRY-3086
    Assert.assertEquals(logEvents.length, 1);
}
 
Example #5
Source File: LogViewerClient.java    From product-es with Apache License 2.0 5 votes vote down vote up
public String[] getServiceNames() throws RemoteException, LogViewerLogViewerException {
    try {
        return logViewerStub.getServiceNames();
    } catch (LogViewerLogViewerException e) {
        log.error("Unable to get service name list");
        throw new LogViewerLogViewerException("Unable to get service name list");
    }
}
 
Example #6
Source File: LogViewerClient.java    From product-es with Apache License 2.0 5 votes vote down vote up
public LogEvent[] getAllSystemLogs() throws RemoteException, LogViewerLogViewerException {
    try {
        return logViewerStub.getAllSystemLogs();
    } catch (LogViewerLogViewerException e) {
        log.error("Fail to get all logs ", e);
        throw new LogViewerLogViewerException("Fail to get all system logs ", e);
    }
}
 
Example #7
Source File: LogViewerClient.java    From product-es with Apache License 2.0 3 votes vote down vote up
/**
 * Getting system logs
 *
 * @param logType   Log type (INFO,WARN,ERROR,DEBUG)
 * @param searchKey searching keyword
 * @param domain    - tenant domain
 * @param serverKey - server key defined at carbon.xml
 * @return logMessage array
 * @throws RemoteException Exception
 */
public LogEvent[] getLogs(String logType, String searchKey, String domain, String serverKey)
        throws RemoteException, LogViewerLogViewerException {
    try {
        return logViewerStub.getLogs(logType, searchKey, domain, serverKey);
    } catch (LogViewerLogViewerException e) {
        log.error("Unable to get system logs", e);
        throw new LogViewerLogViewerException("Unable to get system logs", e);
    }
}