Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate resolver tests in o.e.osgi.tests to JUnit 4 #455

Merged
merged 1 commit into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@
public class BasePerformanceTest extends AbstractStateTest {
private Random random;

public BasePerformanceTest(String name) {
super(name);
}

protected State buildRandomState(int size) {
State state = buildEmptyState();
StateObjectFactory stateFactory = state.getFactory();
Expand Down Expand Up @@ -77,7 +73,7 @@ protected State buildRandomState(int size) {
}

@Override
protected void setUp() throws Exception {
public void setUp() throws Exception {
super.setUp();
// uses a constant seed to prevent variation on results
this.random = new Random(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import org.eclipse.core.tests.harness.CoreTest;
import org.eclipse.core.tests.harness.PerformanceTestRunner;
import org.eclipse.osgi.service.resolver.State;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;

public class StatePerformanceTest extends BasePerformanceTest {

public StatePerformanceTest(String name) {
super(name);
}
@Rule
public TestName testName = new TestName();

State storeAndRetrieve(State toStore) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Expand All @@ -33,57 +34,59 @@ State storeAndRetrieve(State toStore) throws IOException {
return toStore.getFactory().readState(bais);
}

public void testCreation() {
@Test
public void testCreation() throws Exception {
final int stateSize = 5000;
new PerformanceTestRunner() {
protected void test() {
buildRandomState(stateSize);
}
}.run(this, 10, 10);
}.run(getClass(), testName.getMethodName(), 10, 10);
}

private void testResolution(int stateSize, int repetitions, String localName, String degradation) {
private void testResolution(int stateSize, int repetitions, String degradation) throws Exception {
final State originalState = buildRandomState(stateSize);
PerformanceTestRunner runner = new PerformanceTestRunner() {
protected void test() {
originalState.resolve(false);
}
};
runner.setRegressionReason(degradation);
runner.run(this, localName, 10, repetitions);
runner.run(getClass(), testName.getMethodName(), 10, repetitions);
}

public void testResolution100() {
testResolution(100, 500, null, AllTests.DEGRADATION_RESOLUTION);
@Test
public void testResolution100() throws Exception {
testResolution(100, 500, AllTests.DEGRADATION_RESOLUTION);
}

public void testResolution1000() {
testResolution(1000, 15, "State Resolution", null);
@Test
public void testResolution1000() throws Exception {
testResolution(1000, 15, null);
}

public void testResolution500() {
testResolution(500, 50, null, AllTests.DEGRADATION_RESOLUTION);
@Test
public void testResolution500() throws Exception {
testResolution(500, 50, AllTests.DEGRADATION_RESOLUTION);
}

public void testResolution5000() {
testResolution(5000, 1, null, AllTests.DEGRADATION_RESOLUTION);
@Test
public void testResolution5000() throws Exception {
testResolution(5000, 1, AllTests.DEGRADATION_RESOLUTION);
}

private static final String DEGREDATION_STORE_RETRIEVE = "Performance decrease caused by additional fuctionality required for generic capabilities/requirements in OSGi R4.3 specification. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=324753 for details.";

public void testStoreAndRetrieve() {
@Test
public void testStoreAndRetrieve() throws Exception {
int stateSize = 5000;
final State originalState = buildRandomState(stateSize);
PerformanceTestRunner runner = new PerformanceTestRunner() {
protected void test() {
try {
storeAndRetrieve(originalState);
} catch (IOException e) {
CoreTest.fail("", e);
}
protected void test() throws IOException {
storeAndRetrieve(originalState);
}
};
runner.setRegressionReason(DEGREDATION_STORE_RETRIEVE);
runner.run(this, 10, 10);
runner.run(getClass(), testName.getMethodName(), 10, 10);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@
import java.util.Hashtable;
import org.eclipse.core.tests.harness.PerformanceTestRunner;
import org.eclipse.osgi.service.resolver.State;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;

public class StateUsesPerformanceTest extends BasePerformanceTest {

public StateUsesPerformanceTest(String name) {
super(name);
}
@Rule
public TestName testName = new TestName();

private void doUsesResolution(int stateSize, int repetitions, String localName, String degradation) throws BundleException {
private void doUsesResolution(int stateSize, int repetitions, String degradation) throws Exception {
final State originalState = buildRandomState(stateSize);
addUsesBundles(originalState);
PerformanceTestRunner runner = new PerformanceTestRunner() {
Expand All @@ -34,24 +36,28 @@ protected void test() {
}
};
runner.setRegressionReason(degradation);
runner.run(this, localName, 10, repetitions);
runner.run(getClass(), testName.getMethodName(), 10, repetitions);

}

public void testUsesResolution00100() throws BundleException {
doUsesResolution(100, 100, null, AllTests.DEGRADATION_RESOLUTION);
@Test
public void testUsesResolution00100() throws Exception {
doUsesResolution(100, 100, AllTests.DEGRADATION_RESOLUTION);
}

public void testUsesResolution00500() throws BundleException {
doUsesResolution(500, 10, null, AllTests.DEGRADATION_RESOLUTION);
@Test
public void testUsesResolution00500() throws Exception {
doUsesResolution(500, 10, AllTests.DEGRADATION_RESOLUTION);
}

public void testUsesResolution01000() throws BundleException {
doUsesResolution(1000, 10, null, AllTests.DEGRADATION_RESOLUTION);
@Test
public void testUsesResolution01000() throws Exception {
doUsesResolution(1000, 10, AllTests.DEGRADATION_RESOLUTION);
}

public void testUsesResolution05000() throws BundleException {
doUsesResolution(5000, 1, null, AllTests.DEGRADATION_RESOLUTION);
@Test
public void testUsesResolution05000() throws Exception {
doUsesResolution(5000, 1, AllTests.DEGRADATION_RESOLUTION);
}

private void addUsesBundles(State state) throws BundleException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,27 @@
*******************************************************************************/
package org.eclipse.osgi.tests.resolver;

import org.eclipse.osgi.service.resolver.*;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.ExportPackageDescription;
import org.eclipse.osgi.service.resolver.State;
import org.eclipse.osgi.service.resolver.StateObjectFactory;
import org.eclipse.osgi.tests.services.resolver.AbstractStateTest;
import org.junit.Test;
import org.osgi.framework.BundleException;

public class TestAttributes_001 extends AbstractStateTest {
public TestAttributes_001(String testName) {
super(testName);
}

BundleDescription bundle_1 = null;
BundleDescription bundle_2 = null;
BundleDescription bundle_3 = null;
BundleDescription bundle_4 = null;
BundleDescription bundle_5 = null;

@Test
public void testTest_001() {
State state = buildEmptyState();
StateObjectFactory sof = StateObjectFactory.defaultFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,25 @@
*******************************************************************************/
package org.eclipse.osgi.tests.resolver;

import org.eclipse.osgi.service.resolver.*;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.ExportPackageDescription;
import org.eclipse.osgi.service.resolver.State;
import org.eclipse.osgi.service.resolver.StateObjectFactory;
import org.eclipse.osgi.tests.services.resolver.AbstractStateTest;
import org.junit.Test;
import org.osgi.framework.BundleException;

public class TestBSN_001 extends AbstractStateTest {
public TestBSN_001(String testName) {
super(testName);
}

BundleDescription bundle_1 = null;
BundleDescription bundle_2 = null;
BundleDescription bundle_3 = null;

@Test
public void testTest_001() {
State state = buildEmptyState();
StateObjectFactory sof = StateObjectFactory.defaultFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,23 @@
*******************************************************************************/
package org.eclipse.osgi.tests.resolver;

import org.eclipse.osgi.service.resolver.*;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.State;
import org.eclipse.osgi.service.resolver.StateObjectFactory;
import org.eclipse.osgi.tests.services.resolver.AbstractStateTest;
import org.junit.Test;
import org.osgi.framework.BundleException;

public class TestCycle_001 extends AbstractStateTest {
public TestCycle_001(String testName) {
super(testName);
}

BundleDescription bundle_1 = null;
BundleDescription bundle_2 = null;

@Test
public void testTest_001() {
State state = buildEmptyState();
StateObjectFactory sof = StateObjectFactory.defaultFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,24 @@
*******************************************************************************/
package org.eclipse.osgi.tests.resolver;

import org.eclipse.osgi.service.resolver.*;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.State;
import org.eclipse.osgi.service.resolver.StateObjectFactory;
import org.eclipse.osgi.tests.services.resolver.AbstractStateTest;
import org.junit.Test;
import org.osgi.framework.BundleException;

public class TestCycle_002 extends AbstractStateTest {
public TestCycle_002(String testName) {
super(testName);
}

BundleDescription bundle_1 = null;
BundleDescription bundle_2 = null;
BundleDescription bundle_3 = null;

@Test
public void testTest_002() {
State state = buildEmptyState();
StateObjectFactory sof = StateObjectFactory.defaultFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,23 @@
*******************************************************************************/
package org.eclipse.osgi.tests.resolver;

import org.eclipse.osgi.service.resolver.*;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.State;
import org.eclipse.osgi.service.resolver.StateObjectFactory;
import org.eclipse.osgi.tests.services.resolver.AbstractStateTest;
import org.junit.Test;
import org.osgi.framework.BundleException;

public class TestCycle_003 extends AbstractStateTest {
public TestCycle_003(String testName) {
super(testName);
}

BundleDescription bundle_1 = null;
BundleDescription bundle_2 = null;
BundleDescription bundle_3 = null;

@Test
public void testTest_003() {
State state = buildEmptyState();
StateObjectFactory sof = StateObjectFactory.defaultFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,24 @@
*******************************************************************************/
package org.eclipse.osgi.tests.resolver;

import org.eclipse.osgi.service.resolver.*;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.ExportPackageDescription;
import org.eclipse.osgi.service.resolver.State;
import org.eclipse.osgi.service.resolver.StateObjectFactory;
import org.eclipse.osgi.tests.services.resolver.AbstractStateTest;
import org.junit.Test;
import org.osgi.framework.BundleException;

public class TestCycle_004 extends AbstractStateTest {
public TestCycle_004(String testName) {
super(testName);
}

BundleDescription bundle_1 = null;
BundleDescription bundle_2 = null;

@Test
public void testTest_001() {
State state = buildEmptyState();
StateObjectFactory sof = StateObjectFactory.defaultFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,25 @@
*******************************************************************************/
package org.eclipse.osgi.tests.resolver;

import org.eclipse.osgi.service.resolver.*;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.ExportPackageDescription;
import org.eclipse.osgi.service.resolver.State;
import org.eclipse.osgi.service.resolver.StateObjectFactory;
import org.eclipse.osgi.tests.services.resolver.AbstractStateTest;
import org.junit.Test;
import org.osgi.framework.BundleException;

public class TestCycle_005 extends AbstractStateTest {
public TestCycle_005(String testName) {
super(testName);
}

BundleDescription bundle_1 = null;
BundleDescription bundle_2 = null;
BundleDescription bundle_3 = null;

@Test
public void testTest_002() {
State state = buildEmptyState();
StateObjectFactory sof = StateObjectFactory.defaultFactory;
Expand Down
Loading
Loading