@Test void usedNonHeapMemorySizeIsCalculated() { this.mockCollectorWithDefaults(); MemoryUsage nonHeapMemoryUsage = this.memoryBean.getNonHeapMemoryUsage(); when(nonHeapMemoryUsage.getUsed()).thenReturn(10L).thenReturn(9L).thenReturn(11L).thenReturn(10L); this.cut.gather(); this.cut.gather(); this.cut.gather(); this.cut.gather(); MemoryInformationData collector = (MemoryInformationData) this.cut.get(); assertThat(collector.getMinUsedNonHeapMemorySize(), is(9L)); assertThat(collector.getMaxUsedNonHeapMemorySize(), is(11L)); assertThat(collector.getTotalUsedNonHeapMemorySize(), is(40L)); }
@Test void comittedHeapMemorySizeIsCalculated() { this.mockCollectorWithDefaults(); MemoryUsage heapMemoryUsage = this.memoryBean.getHeapMemoryUsage(); when(heapMemoryUsage.getCommitted()).thenReturn(10L).thenReturn(9L).thenReturn(11L).thenReturn(10L); this.cut.gather(); this.cut.gather(); this.cut.gather(); this.cut.gather(); MemoryInformationData collector = (MemoryInformationData) this.cut.get(); assertThat(collector.getMinComittedHeapMemorySize(), is(9L)); assertThat(collector.getMaxComittedHeapMemorySize(), is(11L)); assertThat(collector.getTotalComittedHeapMemorySize(), is(40L)); }
@Test void comittedNonHeapMemorySizeIsCalculated() { this.mockCollectorWithDefaults(); MemoryUsage nonHeapMemoryUsage = this.memoryBean.getNonHeapMemoryUsage(); when(nonHeapMemoryUsage.getCommitted()).thenReturn(10L).thenReturn(9L).thenReturn(11L).thenReturn(10L); this.cut.gather(); this.cut.gather(); this.cut.gather(); this.cut.gather(); MemoryInformationData collector = (MemoryInformationData) this.cut.get(); assertThat(collector.getMinComittedNonHeapMemorySize(), is(9L)); assertThat(collector.getMaxComittedNonHeapMemorySize(), is(11L)); assertThat(collector.getTotalComittedNonHeapMemorySize(), is(40L)); }
@Test void comittedVirtualMemSizeIsCalculated() { this.mockCollectorWithDefaults(); when(this.osBean.getCommittedVirtualMemorySize()).thenReturn(10L).thenReturn(9L).thenReturn(11L).thenReturn(10L); this.cut.gather(); this.cut.gather(); this.cut.gather(); this.cut.gather(); MemoryInformationData collector = (MemoryInformationData) this.cut.get(); assertThat(collector.getMinComittedVirtualMemSize(), is(9L)); assertThat(collector.getMaxComittedVirtualMemSize(), is(11L)); assertThat(collector.getTotalComittedVirtualMemSize(), is(40L)); }
@Test void freeSwapSpaceIsCalculated() { this.mockCollectorWithDefaults(); when(this.osBean.getFreeSwapSpaceSize()).thenReturn(10L).thenReturn(9L).thenReturn(11L).thenReturn(10L); this.cut.gather(); this.cut.gather(); this.cut.gather(); this.cut.gather(); MemoryInformationData collector = (MemoryInformationData) this.cut.get(); assertThat(collector.getMinFreeSwapSpace(), is(9L)); assertThat(collector.getMaxFreeSwapSpace(), is(11L)); assertThat(collector.getTotalFreeSwapSpace(), is(40L)); }
@Test void freeMemoryIsCalculated() { this.mockCollectorWithDefaults(); when(this.osBean.getFreePhysicalMemorySize()).thenReturn(10L).thenReturn(9L).thenReturn(11L).thenReturn(10L); this.cut.gather(); this.cut.gather(); this.cut.gather(); this.cut.gather(); MemoryInformationData collector = (MemoryInformationData) this.cut.get(); assertThat(collector.getMinFreePhysMemory(), is(9L)); assertThat(collector.getMaxFreePhysMemory(), is(11L)); assertThat(collector.getTotalFreePhysMemory(), is(40L)); }
@Test void usedHeapMemorySizeIsCalculated() { this.mockCollectorWithDefaults(); MemoryUsage heapMemoryUsage = this.memoryBean.getHeapMemoryUsage(); when(heapMemoryUsage.getUsed()).thenReturn(10L).thenReturn(9L).thenReturn(11L).thenReturn(10L); this.cut.gather(); this.cut.gather(); this.cut.gather(); this.cut.gather(); MemoryInformationData collector = (MemoryInformationData) this.cut.get(); assertThat(collector.getMinUsedHeapMemorySize(), is(9L)); assertThat(collector.getMaxUsedHeapMemorySize(), is(11L)); assertThat(collector.getTotalUsedHeapMemorySize(), is(40L)); }
@Test void countIsIncremented() { this.mockCollectorWithDefaults(); this.cut.gather(); this.cut.gather(); MemoryInformationData collector = (MemoryInformationData) this.cut.get(); assertThat(collector.getCount(), is(2)); } }