All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.picocontainer.defaults.issues.Issue0352TestCase Maven / Gradle / Ivy

There is a newer version: 2.15
Show newest version
package org.picocontainer.defaults.issues;

import org.junit.Test;import static org.junit.Assert.assertFalse;import static org.junit.Assert.assertSame;
import org.picocontainer.Startable;
import org.picocontainer.DefaultPicoContainer;
import org.picocontainer.ComponentAdapter;
import org.picocontainer.Characteristics;
import org.picocontainer.injectors.ConstructorInjector;
import org.picocontainer.injectors.SingleMemberInjector;
import org.picocontainer.behaviors.Cached;
import org.picocontainer.behaviors.Stored;

public class Issue0352TestCase {

    public static class Foo {
	}

	// This test failed before patch (see revision #5396)
	@Test
	public void testShouldFindSupertypeOfAdapterOnAbstractAdapterDerivative() {
		ConstructorInjector injector = new ConstructorInjector("key", Foo.class);
		assertSame(injector, injector.findAdapterOfType(SingleMemberInjector.class));
	}

	// This test works
	@Test
	public void testShouldFindSupertypeOfAdapterOnAbstractBehaviorDerivative() {
		ConstructorInjector injector = new ConstructorInjector("key", Foo.class);
		Cached adapter = new Cached(injector);
		assertSame(adapter, adapter.findAdapterOfType(Stored.class));
		assertSame(injector, adapter.findAdapterOfType(SingleMemberInjector.class));
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy