Package jfun.yan.containers

Examples of jfun.yan.containers.DefaultContainer


     *               is not necessary.
     */
    protected abstract Component prepDEF_verifyDoesNotInstantiate(Container yan);

    final public void testDEF_verifyDoesNotInstantiate() {
        final Container yan = new DefaultContainer();
        final Component component = prepDEF_verifyDoesNotInstantiate(yan);
        //assertSame(getComponentAdapterType(), component.getClass());
        final Component notInstantiatablecomponentAdapter =
          new NotInstantiatableComponentAdapter(component);
        final Container wrappedPicoContainer = wrapComponentInstances(
View Full Code Here


            assertEquals(component.getType(), serializedComponentAdapter.getType());
            final Object instanceAfterSerialization = create(serializedComponentAdapter, yan);
            assertNotNull(instanceAfterSerialization);
            assertSame(instance.getClass(), instanceAfterSerialization.getClass());
        }*/
      final Container yan = new DefaultContainer();
      testSerializable(prepSER_isSerializable(yan), yan);
      testSerializable(Components.value("hello"), yan);
      testSerializable(Components.ctor(ArrayList.class, null), yan);
      testSerializable(Components.ctor(ArrayList.class, null), yan);
      testSerializable(Components.method(this, "greet").withArgument(0, Components.value("Tom")).singleton().proxy(), yan);
View Full Code Here

        throw new AssertionFailedError("You have to overwrite this method for a useful test");
    }

    final public void testVER_verificationFails() {
        if ((getComponentAdapterNature() & VERIFYING) > 0) {
            final Container yan = new DefaultContainer();
            final Component component = prepVER_verificationFails(yan);
            //assertSame(getComponentAdapterType(), component.getClass());
            try {
                yan.verifyComponent(component);
                fail("YanException expected");
            } catch (YanException e) {
            } catch (Exception e) {
                fail("YanException expected");
            }
View Full Code Here

    private static Class verify(Component cc, ComponentMap c){
      return cc.verify(c.getDependencyOfType(cc.getType(),c));
    }
    final public void testINS_createsNewInstances() {
        if ((getComponentAdapterNature() & INSTANTIATING) > 0) {
            final Container yan = new DefaultContainer();
            final Component component = prepINS_createsNewInstances(yan);
            //assertSame(getComponentAdapterType(), component.getClass());
            final Object instance = create(component, yan);
            assertNotNull(instance);
            assertNotSame(instance, create(component, yan));
View Full Code Here

     */
    protected abstract Component prepINS_errorIsRethrown(Container yan);

    final public void testINS_errorIsRethrown() {
        if ((getComponentAdapterNature() & INSTANTIATING) > 0) {
            final Container yan = new DefaultContainer();
           
            //assertSame(getComponentAdapterType(), component.getClass());

              final Component component = prepINS_errorIsRethrown(yan);
             
View Full Code Here

        throw new AssertionFailedError("You have to overwrite this method for a useful test");
    }

    final public void testINS_runtimeExceptionIsRethrown() {
        if ((getComponentAdapterNature() & INSTANTIATING) > 0) {
            final Container yan = new DefaultContainer();
            final Component component = prepINS_runtimeExceptionIsRethrown(yan);
            //assertSame(getComponentAdapterType(), component.getClass());
            try {
                create(component, yan);
                fail("Thrown RuntimeException excpected");
View Full Code Here

        throw new AssertionFailedError("You have to overwrite this method for a useful test");
    }

    final public void testINS_normalExceptionIsRethrownInsidePicoInvocationTargetInitializationException() {
        if ((getComponentAdapterNature() & INSTANTIATING) > 0) {
            final Container yan = new DefaultContainer();
            final Component component = prepINS_normalExceptionIsRethrownInsidePicoInvocationTargetInitializationException(yan);
            //assertSame(getComponentAdapterType(), component.getClass());
            try {
                create(component, yan);
                fail("Thrown PicoInvocationTargetInitializationException excpected");
View Full Code Here

    final public void testRES_dependenciesAreResolved() {
        if ((getComponentAdapterNature() & RESOLVING) > 0) {
            final List dependencies = new LinkedList();
            final Object[] wrapperDependencies = new Object[]{dependencies};
            final Container yan = new DefaultContainer();
            final Component component = prepRES_dependenciesAreResolved(yan);
            //assertSame(getComponentAdapterType(), component.getClass());
            assertFalse(yan.getComponents().contains(component));
            final Container wrappedPicoContainer = wrapComponentInstances(
                    CollectingComponentAdapter.class, yan, wrapperDependencies);
            final Object instance = create(component,wrappedPicoContainer);
            assertNotNull(instance);
            assertTrue(dependencies.size() > 0);
View Full Code Here

    }
*/
    final protected Container wrapComponentInstances(
            final Class decoratingComponentAdapterClass, final Container yan, final Object[] wrapperDependencies) {
        assertTrue(DelegatingComponent.class.isAssignableFrom(decoratingComponentAdapterClass));
        final Container mutablePicoContainer = new DefaultContainer();
        final int size = (wrapperDependencies != null ? wrapperDependencies.length : 0) + 1;
        final Collection allComponentAdapters = yan.getComponents();
        for (final Iterator iter = allComponentAdapters.iterator(); iter.hasNext();) {
            //final Parameter[] parameters = new Parameter[size];
            final Creator[] params = new Creator[size];
            params[0] = Components.value(iter.next()).guard().singleton();
            for (int i = 1; i < params.length; i++) {
              Component tmp = Components.value(wrapperDependencies[i - 1]);
              switch(i%3){//to test all singleton methods.
                case 0:
                 tmp = tmp.singleton(new GlobalScope());
                 break;
                case 1:
                  tmp = tmp.singleton(new ThreadLocalScope());
                case 2:
                  tmp = tmp.singleton();
              }
              params[i] = tmp.guard();
            }
            Component cc = Components.ctor(decoratingComponentAdapterClass)
            .withArguments(params);
            final Container instantiatingPicoContainer = new DefaultContainer();
            instantiatingPicoContainer.registerComponent("decorator",
                cc);
            mutablePicoContainer.registerComponent(
                (Component) instantiatingPicoContainer.getInstance("decorator"));
        }
        return mutablePicoContainer;
    }
View Full Code Here

      
       JS
       */
     
      public void TodotestUnambiguouSelfDependency() {
          Container pico = new DefaultContainer();
          pico.registerConstructor(SimpleTouchable.class);
          pico.registerConstructor(DecoratedTouchable.class);
          Touchable t = (Touchable) pico.getInstance(DecoratedTouchable.class);
          assertNotNull(t);
      }
View Full Code Here

TOP

Related Classes of jfun.yan.containers.DefaultContainer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.