Example usage for org.springframework.data.gemfire.snapshot ImportSnapshotException getMessage

List of usage examples for org.springframework.data.gemfire.snapshot ImportSnapshotException getMessage

Introduction

In this page you can find the example usage for org.springframework.data.gemfire.snapshot ImportSnapshotException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.springframework.data.gemfire.snapshot.SnapshotServiceFactoryBeanTest.java

@Test(expected = ImportSnapshotException.class)
public void loadCacheSnapshotWithDirectoryAndFormatHandlesExceptionAppropriately() throws Exception {
    CacheSnapshotService mockCacheSnapshotService = mock(CacheSnapshotService.class,
            "MockCacheSnapshotService");

    doThrow(new IOException("TEST")).when(mockCacheSnapshotService).load(any(File.class),
            any(SnapshotFormat.class));

    CacheSnapshotServiceAdapter adapter = new CacheSnapshotServiceAdapter(mockCacheSnapshotService);

    assertThat(adapter.getSnapshotService(), is(equalTo(mockCacheSnapshotService)));

    try {//from  w  ww .j a v a 2 s  .  com
        adapter.load(FileSystemUtils.WORKING_DIRECTORY, SnapshotFormat.GEMFIRE);
    } catch (ImportSnapshotException expected) {
        assertThat(expected.getMessage(),
                is(equalTo(String.format("Failed to load snapshots from directory (%1$s) in format (GEMFIRE)",
                        FileSystemUtils.WORKING_DIRECTORY))));
        assertThat(expected.getCause(), is(instanceOf(IOException.class)));
        assertThat(expected.getCause().getMessage(), is(equalTo("TEST")));
        throw expected;
    } finally {
        verify(mockCacheSnapshotService, times(1)).load(eq(FileSystemUtils.WORKING_DIRECTORY),
                eq(SnapshotFormat.GEMFIRE));
    }
}

From source file:org.springframework.data.gemfire.snapshot.SnapshotServiceFactoryBeanTest.java

@Test(expected = ImportSnapshotException.class)
public void loadCacheSnapshotWithFormatOptionsAndSnapshotFilesHandlesExceptionAppropriately() throws Exception {
    SnapshotOptions mockSnapshotOptions = mock(SnapshotOptions.class, "MockSnapshotOptions");

    CacheSnapshotService mockCacheSnapshotService = mock(CacheSnapshotService.class,
            "MockCacheSnapshotService");

    doThrow(new ClassCastException("TEST")).when(mockCacheSnapshotService).load(any(File[].class),
            any(SnapshotFormat.class), any(SnapshotOptions.class));

    CacheSnapshotServiceAdapter adapter = new CacheSnapshotServiceAdapter(mockCacheSnapshotService);

    assertThat(adapter.getSnapshotService(), is(equalTo(mockCacheSnapshotService)));

    try {/*from w  w w  .  j a v a2 s. com*/
        adapter.load(SnapshotFormat.GEMFIRE, mockSnapshotOptions, snapshotDat);
    } catch (ImportSnapshotException expected) {
        assertThat(expected.getMessage(),
                is(equalTo(String.format(
                        "Failed to load snapshots (%1$s) in format (GEMFIRE) using options (%2$s)",
                        Arrays.toString(new File[] { snapshotDat }), mockSnapshotOptions))));
        assertThat(expected.getCause(), is(instanceOf(ClassCastException.class)));
        assertThat(expected.getCause().getMessage(), is(equalTo("TEST")));
        throw expected;
    } finally {
        verify(mockCacheSnapshotService, times(1)).load(eq(new File[] { snapshotDat }),
                eq(SnapshotFormat.GEMFIRE), Matchers.isA(SnapshotOptions.class));
    }
}

From source file:org.springframework.data.gemfire.snapshot.SnapshotServiceFactoryBeanTest.java

@Test(expected = ImportSnapshotException.class)
public void loadRegionSnapshotWithSnapshotFileAndFormatHandlesExceptionAppropriately() throws Exception {
    RegionSnapshotService mockRegionSnapshotService = mock(RegionSnapshotService.class,
            "MockRegionSnapshotService");

    doThrow(new IOException("TEST")).when(mockRegionSnapshotService).load(any(File.class),
            any(SnapshotFormat.class));

    RegionSnapshotServiceAdapter adapter = new RegionSnapshotServiceAdapter(mockRegionSnapshotService);

    assertThat(adapter.getSnapshotService(), is(equalTo(mockRegionSnapshotService)));

    try {// w  ww .  j  ava2s .co  m
        adapter.load(snapshotDat, SnapshotFormat.GEMFIRE);
    } catch (ImportSnapshotException expected) {
        assertThat(expected.getMessage(), is(equalTo(
                String.format("Failed to load snapshot from file (%1$s) in format (GEMFIRE)", snapshotDat))));
        assertThat(expected.getCause(), is(instanceOf(IOException.class)));
        assertThat(expected.getCause().getMessage(), is(equalTo("TEST")));
        throw expected;
    } finally {
        verify(mockRegionSnapshotService, times(1)).load(eq(snapshotDat), eq(SnapshotFormat.GEMFIRE));
    }
}

From source file:org.springframework.data.gemfire.snapshot.SnapshotServiceFactoryBeanTest.java

@Test(expected = ImportSnapshotException.class)
public void loadRegionSnapshotWithFormatOptionsAndSnapshotFilesHandlesExceptionAppropriately()
        throws Exception {
    SnapshotOptions mockSnapshotOptions = mock(SnapshotOptions.class, "MockSnapshotOptions");

    RegionSnapshotService mockRegionSnapshotService = mock(RegionSnapshotService.class,
            "MockRegionSnapshotService");

    doThrow(new ClassCastException("TEST")).when(mockRegionSnapshotService).load(any(File.class),
            any(SnapshotFormat.class), any(SnapshotOptions.class));

    RegionSnapshotServiceAdapter adapter = new RegionSnapshotServiceAdapter(mockRegionSnapshotService);

    assertThat(adapter.getSnapshotService(), is(equalTo(mockRegionSnapshotService)));

    try {/*  w ww .  j av  a2s .  co  m*/
        adapter.load(SnapshotFormat.GEMFIRE, mockSnapshotOptions, snapshotDat);
    } catch (ImportSnapshotException expected) {
        assertThat(expected.getMessage(),
                is(equalTo(String.format(
                        "Failed to load snapshots (%1$s) in format (GEMFIRE) using options (%2$s)",
                        Arrays.toString(new File[] { snapshotDat }), mockSnapshotOptions))));
        assertThat(expected.getCause(), is(instanceOf(ClassCastException.class)));
        assertThat(expected.getCause().getMessage(), is(equalTo("TEST")));
        throw expected;
    } finally {
        verify(mockRegionSnapshotService, times(1)).load(eq(snapshotDat), eq(SnapshotFormat.GEMFIRE),
                eq(mockSnapshotOptions));
    }
}