You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by tv...@apache.org on 2020/04/13 11:58:03 UTC
[commons-jcs] 02/06: Remove useless test
This is an automated email from the ASF dual-hosted git repository.
tv pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jcs.git
commit e7d642140895374cd3ae4704121eb9436ab3d056
Author: Thomas Vandahl <tv...@apache.org>
AuthorDate: Mon Apr 13 13:53:38 2020 +0200
Remove useless test
---
.../block/BlockDiskElementDescriptorUnitTest.java | 89 ----------------------
1 file changed, 89 deletions(-)
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskElementDescriptorUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskElementDescriptorUnitTest.java
deleted file mode 100644
index 336b101..0000000
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskElementDescriptorUnitTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package org.apache.commons.jcs.auxiliary.disk.block;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import junit.framework.TestCase;
-
-/**
- * Simple tests for the element descriptor
- * <p>
- * @author Aaron Smuts
- */
-public class BlockDiskElementDescriptorUnitTest
- extends TestCase
-{
- /**
- * Verify that the memory used per element is reasonable.
- * <p>
- * TODO figure out a more precise expectation.
- * <p>
- * @throws Exception
- */
- public void testMemorySize()
- throws Exception
- {
- // SETUP
- long memoryBefore = measureMemoryUse();
-// System.out.println( "Before: " + memoryBefore );
-
- int numElements = 25000;
- @SuppressWarnings("unchecked")
- BlockDiskElementDescriptor<Integer>[] elements = new BlockDiskElementDescriptor[numElements];
-
- long memoryStart = measureMemoryUse();
-// System.out.println( "Start: " + memoryStart );
-
- // DO WORK
- for ( int i = 0; i < numElements; i++ )
- {
- BlockDiskElementDescriptor<Integer> descriptor = new BlockDiskElementDescriptor<>();
- descriptor.setKey( Integer.valueOf( i ) );
- descriptor.setBlocks( new int[] { 1, 2 } );
- elements[i] = descriptor;
- }
-
- // VERIFY
- long memoryEnd = measureMemoryUse();
-// System.out.println( "End: " + memoryEnd );
-
- long diff = memoryEnd - memoryStart;
-// System.out.println( "diff: " + diff );
-
- long perDiff = diff / numElements;
-// System.out.println( "per diff: " + perDiff );
-
- // about 20 bytes each
- assertTrue( "Too much was used: " + perDiff + " >= 75", perDiff < 75 );
- }
-
- /**
- * Measure memory used by the VM.
- * @return long
- * @throws InterruptedException
- */
- protected long measureMemoryUse()
- throws InterruptedException
- {
- System.gc();
- Thread.sleep( 3000 );
- System.gc();
- return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
- }
-}