Search in sources :

Example 1 with StateStoreException

use of com.mesosphere.sdk.state.StateStoreException in project dcos-commons by mesosphere.

the class StateQueriesTest method testFailedUpload.

@Test
public void testFailedUpload() throws IOException {
    InputStream inputStream = new ByteArrayInputStream(FILE_CONTENT.getBytes(StateQueries.FILE_ENCODING));
    when(formDataContentDisposition.getFileName()).thenReturn(FILE_NAME);
    when(formDataContentDisposition.getSize()).thenReturn((long) FILE_CONTENT.getBytes(StateQueries.FILE_ENCODING).length);
    doThrow(new StateStoreException(new PersisterException(Reason.STORAGE_ERROR, "Failed to store"))).when(mockStateStore).storeProperty(StateQueries.FILE_NAME_PREFIX + FILE_NAME, FILE_CONTENT.getBytes(StateQueries.FILE_ENCODING));
    Response response = StateQueries.putFile(mockStateStore, inputStream, formDataContentDisposition);
    assertEquals(500, response.getStatus());
}
Also used : StateStoreException(com.mesosphere.sdk.state.StateStoreException) Response(javax.ws.rs.core.Response) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) StateStoreUtilsTest(com.mesosphere.sdk.state.StateStoreUtilsTest) Test(org.junit.Test)

Example 2 with StateStoreException

use of com.mesosphere.sdk.state.StateStoreException in project dcos-commons by mesosphere.

the class StateQueriesTest method testGetPropertyFails.

@Test
public void testGetPropertyFails() {
    when(mockStateStore.fetchProperty("foo")).thenThrow(new StateStoreException(Reason.UNKNOWN, "hi"));
    Response response = StateQueries.getProperty(mockStateStore, new StringPropertyDeserializer(), "foo");
    assertEquals(500, response.getStatus());
}
Also used : StateStoreException(com.mesosphere.sdk.state.StateStoreException) Response(javax.ws.rs.core.Response) StringPropertyDeserializer(com.mesosphere.sdk.http.types.StringPropertyDeserializer) StateStoreUtilsTest(com.mesosphere.sdk.state.StateStoreUtilsTest) Test(org.junit.Test)

Example 3 with StateStoreException

use of com.mesosphere.sdk.state.StateStoreException in project dcos-commons by mesosphere.

the class StateQueriesTest method testGetPropertyMissing.

@Test
public void testGetPropertyMissing() {
    when(mockStateStore.fetchProperty("foo")).thenThrow(new StateStoreException(Reason.NOT_FOUND, "hi"));
    Response response = StateQueries.getProperty(mockStateStore, new StringPropertyDeserializer(), "foo");
    assertEquals(404, response.getStatus());
}
Also used : StateStoreException(com.mesosphere.sdk.state.StateStoreException) Response(javax.ws.rs.core.Response) StringPropertyDeserializer(com.mesosphere.sdk.http.types.StringPropertyDeserializer) StateStoreUtilsTest(com.mesosphere.sdk.state.StateStoreUtilsTest) Test(org.junit.Test)

Example 4 with StateStoreException

use of com.mesosphere.sdk.state.StateStoreException in project dcos-commons by mesosphere.

the class StateQueriesTest method testGetFrameworkIdFails.

@Test
public void testGetFrameworkIdFails() {
    when(mockFrameworkStore.fetchFrameworkId()).thenThrow(new StateStoreException(Reason.UNKNOWN, "hi"));
    Response response = StateQueries.getFrameworkId(mockFrameworkStore);
    assertEquals(500, response.getStatus());
}
Also used : StateStoreException(com.mesosphere.sdk.state.StateStoreException) Response(javax.ws.rs.core.Response) StateStoreUtilsTest(com.mesosphere.sdk.state.StateStoreUtilsTest) Test(org.junit.Test)

Example 5 with StateStoreException

use of com.mesosphere.sdk.state.StateStoreException in project dcos-commons by mesosphere.

the class StateQueriesTest method testGetPropertyKeysFails.

@Test
public void testGetPropertyKeysFails() {
    when(mockStateStore.fetchPropertyKeys()).thenThrow(new StateStoreException(Reason.UNKNOWN, "hi"));
    Response response = StateQueries.getPropertyKeys(mockStateStore);
    assertEquals(500, response.getStatus());
}
Also used : StateStoreException(com.mesosphere.sdk.state.StateStoreException) Response(javax.ws.rs.core.Response) StateStoreUtilsTest(com.mesosphere.sdk.state.StateStoreUtilsTest) Test(org.junit.Test)

Aggregations

StateStoreException (com.mesosphere.sdk.state.StateStoreException)5 StateStoreUtilsTest (com.mesosphere.sdk.state.StateStoreUtilsTest)5 Response (javax.ws.rs.core.Response)5 Test (org.junit.Test)5 StringPropertyDeserializer (com.mesosphere.sdk.http.types.StringPropertyDeserializer)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1