text:
package org.apache.felix.ipojo.test.scenarios.service.dependency;

import java.util.Properties;

import org.apache.felix.ipojo.ComponentInstance;
import org.apache.felix.ipojo.architecture.Architecture;
import org.apache.felix.ipojo.architecture.InstanceDescription;
import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
import org.apache.felix.ipojo.test.scenarios.util.Utils;
import org.osgi.framework.ServiceReference;

public class MethodMultipleDependencies extends OSGiTestCase {

	ComponentInstance instance3, instance4, instance5, instance6, instance7;
	ComponentInstance fooProvider1, fooProvider2;

	public void setUp() {
		try {
			Properties prov = new Properties();
			prov.put("instance.name","FooProvider1");
			fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
			fooProvider1.stop();

			Properties prov2 = new Properties();
			prov2.put("instance.name","FooProvider2");
			fooProvider2 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov2);
			fooProvider2.stop();

			Properties i3 = new Properties();
			i3.put("instance.name","Object");
			instance3 = Utils.getFactoryByName(getContext(), "MObjectMultipleCheckServiceProvider").createComponentInstance(i3);

			Properties i4 = new Properties();
			i4.put("instance.name","Ref");
			instance4 = Utils.getFactoryByName(getContext(), "MRefMultipleCheckServiceProvider").createComponentInstance(i4);

			Properties i5 = new Properties();
            i5.put("instance.name","Both");
            instance5 = Utils.getFactoryByName(getContext(), "MBothMultipleCheckServiceProvider").createComponentInstance(i5);

            Properties i6 = new Properties();
            i6.put("instance.name","Map");
            instance6 = Utils.getFactoryByName(getContext(), "MMapMultipleCheckServiceProvider").createComponentInstance(i6);

            Properties i7 = new Properties();
            i7.put("instance.name","Dictionary");
            instance7 = Utils.getFactoryByName(getContext(), "MDictMultipleCheckServiceProvider").createComponentInstance(i7);
		} catch(Exception e) { fail(e.getMessage()); }

	}

	public void tearDown() {
		instance3.dispose();
		instance4.dispose();
		instance5.dispose();
		instance6.dispose();
		instance7.dispose();
		fooProvider1.dispose();
		fooProvider2.dispose();
		instance3 = null;
		instance4 = null;
		instance5 = null;
		instance6 = null;
		instance7 = null;
		fooProvider1 = null;
		fooProvider2 = null;
	}

	public void testObject() {
		ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
		assertNotNull("Check architecture availability", arch_ref);
		InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
		assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);

		fooProvider1.start();

		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
		assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);

		ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
		assertNotNull("Check CheckService availability", cs_ref);
		CheckService cs = (CheckService) getContext().getService(cs_ref);
		Properties props = cs.getProps();
		//Check properties
		assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
		assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
		assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
		assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 1);
		assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
		assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
		assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
		assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
		assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
		assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);

		fooProvider2.start();

		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
		assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

		cs = (CheckService) getContext().getService(cs_ref);
		props = cs.getProps();
		//Check properties
		assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
		assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
		assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
		assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 2);
		assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
		assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
		assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
		assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
		assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
		assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);

		fooProvider1.stop();

		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
		assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);

		cs = (CheckService) getContext().getService(cs_ref);
		props = cs.getProps();
		//Check properties
		assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
		assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
		assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
		assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 2);
		assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 1);
		assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
		assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
		assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
		assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
		assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);

		fooProvider2.stop();

		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
		assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);

		id = null;
		cs = null;
		getContext().ungetService(arch_ref);
		getContext().ungetService(cs_ref);
	}

	public void testRef() {
		ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
		assertNotNull("Check architecture availability", arch_ref);
		InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
		assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);

		fooProvider1.start();

		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
		assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);

		ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
		assertNotNull("Check CheckService availability", cs_ref);
		CheckService cs = (CheckService) getContext().getService(cs_ref);
		Properties props = cs.getProps();
		//Check properties
		assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
		assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
		assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
		assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
		assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
		assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 1);
		assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
		assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
		assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
		assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);

		fooProvider2.start();

		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
		assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

		cs = (CheckService) getContext().getService(cs_ref);
		props = cs.getProps();
		//Check properties
		assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
		assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
		assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
		assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
		assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
		assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 2);
		assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
		assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
		assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
		assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);

		fooProvider1.stop();

		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
		assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);

		cs = (CheckService) getContext().getService(cs_ref);
		props = cs.getProps();
		//Check properties
		assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
		assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
		assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
		assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
		assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
		assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 2);
		assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 1);
		assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
		assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
		assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);

		fooProvider2.stop();

		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
		assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);

		id = null;
		cs = null;
		getContext().ungetService(arch_ref);
		getContext().ungetService(cs_ref);
	}

	public void testBoth() {
        ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());
        assertNotNull("Check architecture availability", arch_ref);
        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);

        fooProvider1.start();

        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);

        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
        assertNotNull("Check CheckService availability", cs_ref);
        CheckService cs = (CheckService) getContext().getService(cs_ref);
        Properties props = cs.getProps();
        //Check properties
        assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
        assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
        assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
        assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
        assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
        assertEquals("check both bind callback invocation - 1", ((Integer)props.get("bothB")).intValue(), 1);
        assertEquals("check both unbind callback invocation - 1", ((Integer)props.get("bothU")).intValue(), 0);
        assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
        assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
        assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
        assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
        assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
        assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
        assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);

        fooProvider2.start();

        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

        cs = (CheckService) getContext().getService(cs_ref);
        props = cs.getProps();
        //Check properties
        assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
        assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
        assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
        assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
        assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
        assertEquals("check both bind callback invocation - 2", ((Integer)props.get("bothB")).intValue(), 2);
        assertEquals("check both unbind callback invocation - 2", ((Integer)props.get("bothU")).intValue(), 0);
        assertEquals("check map bind callback invocation -2", ((Integer)props.get("mapB")).intValue(), 0);
        assertEquals("check map unbind callback invocation -2", ((Integer)props.get("mapU")).intValue(), 0);
        assertEquals("check dict bind callback invocation -2", ((Integer)props.get("dictB")).intValue(), 0);
        assertEquals("check dict unbind callback invocation -2", ((Integer)props.get("dictU")).intValue(), 0);
        assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
        assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
        assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);

        fooProvider1.stop();

        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);

        cs = (CheckService) getContext().getService(cs_ref);
        props = cs.getProps();
        //Check properties
        assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
        assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
        assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
        assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
        assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
        assertEquals("check both bind callback invocation - 3", ((Integer)props.get("bothB")).intValue(), 2);
        assertEquals("check both unbind callback invocation - 3", ((Integer)props.get("bothU")).intValue(), 1);
        assertEquals("check map bind callback invocation -3", ((Integer)props.get("mapB")).intValue(), 0);
        assertEquals("check map unbind callback invocation -3", ((Integer)props.get("mapU")).intValue(), 0);
        assertEquals("check dict bind callback invocation -3", ((Integer)props.get("dictB")).intValue(), 0);
        assertEquals("check dict unbind callback invocation -3", ((Integer)props.get("dictU")).intValue(), 0);
        assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
        assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
        assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);

        fooProvider2.stop();

        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);

        id = null;
        cs = null;
        getContext().ungetService(arch_ref);
        getContext().ungetService(cs_ref);
    }

	   public void testMap() {
	        ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance6.getInstanceName());
	        assertNotNull("Check architecture availability", arch_ref);
	        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
	        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);

	        fooProvider1.start();

	        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
	        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);

	        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance6.getInstanceName());
	        assertNotNull("Check CheckService availability", cs_ref);
	        CheckService cs = (CheckService) getContext().getService(cs_ref);
	        Properties props = cs.getProps();
	        //Check properties
	        assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
	        assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
	        assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
	        assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
	        assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
	        assertEquals("check both bind callback invocation - 1", ((Integer)props.get("bothB")).intValue(), 0);
	        assertEquals("check both unbind callback invocation - 1", ((Integer)props.get("bothU")).intValue(), 0);
	        assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 1);
	        assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
	        assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
	        assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
	        assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
	        assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
	        assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);

	        fooProvider2.start();

	        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
	        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

	        cs = (CheckService) getContext().getService(cs_ref);
	        props = cs.getProps();
	        //Check properties
	        assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
	        assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
	        assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
	        assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
	        assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
	        assertEquals("check both bind callback invocation - 2", ((Integer)props.get("bothB")).intValue(), 0);
	        assertEquals("check both unbind callback invocation - 2", ((Integer)props.get("bothU")).intValue(), 0);
	        assertEquals("check map bind callback invocation -2", ((Integer)props.get("mapB")).intValue(), 2);
	        assertEquals("check map unbind callback invocation -2", ((Integer)props.get("mapU")).intValue(), 0);
	        assertEquals("check dict bind callback invocation -2", ((Integer)props.get("dictB")).intValue(), 0);
	        assertEquals("check dict unbind callback invocation -2", ((Integer)props.get("dictU")).intValue(), 0);
	        assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
	        assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
	        assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);

	        fooProvider1.stop();

	        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
	        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);

	        cs = (CheckService) getContext().getService(cs_ref);
	        props = cs.getProps();
	        //Check properties
	        assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
	        assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
	        assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
	        assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
	        assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
	        assertEquals("check both bind callback invocation - 3", ((Integer)props.get("bothB")).intValue(), 0);
	        assertEquals("check both unbind callback invocation - 3", ((Integer)props.get("bothU")).intValue(), 0);
	        assertEquals("check map bind callback invocation -3", ((Integer)props.get("mapB")).intValue(), 2);
	        assertEquals("check map unbind callback invocation -3", ((Integer)props.get("mapU")).intValue(), 1);
	        assertEquals("check dict bind callback invocation -3", ((Integer)props.get("dictB")).intValue(), 0);
	        assertEquals("check dict unbind callback invocation -3", ((Integer)props.get("dictU")).intValue(), 0);
	        assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
	        assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
	        assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);

	        fooProvider2.stop();

	        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
	        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);

	        id = null;
	        cs = null;
	        getContext().ungetService(arch_ref);
	        getContext().ungetService(cs_ref);
	    }

       public void testDict() {
           ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance7.getInstanceName());
           assertNotNull("Check architecture availability", arch_ref);
           InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
           assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);

           fooProvider1.start();

           id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
           assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);

           ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance7.getInstanceName());
           assertNotNull("Check CheckService availability", cs_ref);
           CheckService cs = (CheckService) getContext().getService(cs_ref);
           Properties props = cs.getProps();
           //Check properties
           assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
           assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
           assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
           assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
           assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
           assertEquals("check both bind callback invocation - 1", ((Integer)props.get("bothB")).intValue(), 0);
           assertEquals("check both unbind callback invocation - 1", ((Integer)props.get("bothU")).intValue(), 0);
           assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
           assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
           assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 1);
           assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
           assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
           assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
           assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);

           fooProvider2.start();

           id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
           assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

           cs = (CheckService) getContext().getService(cs_ref);
           props = cs.getProps();
           //Check properties
           assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
           assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
           assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
           assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
           assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
           assertEquals("check both bind callback invocation - 2", ((Integer)props.get("bothB")).intValue(), 0);
           assertEquals("check both unbind callback invocation - 2", ((Integer)props.get("bothU")).intValue(), 0);
           assertEquals("check map bind callback invocation -2", ((Integer)props.get("mapB")).intValue(), 0);
           assertEquals("check map unbind callback invocation -2", ((Integer)props.get("mapU")).intValue(), 0);
           assertEquals("check dict bind callback invocation -2", ((Integer)props.get("dictB")).intValue(), 2);
           assertEquals("check dict unbind callback invocation -2", ((Integer)props.get("dictU")).intValue(), 0);
           assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
           assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
           assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);

           fooProvider1.stop();

           id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
           assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);

           cs = (CheckService) getContext().getService(cs_ref);
           props = cs.getProps();
           //Check properties
           assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
           assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
           assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
           assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
           assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
           assertEquals("check both bind callback invocation - 3", ((Integer)props.get("bothB")).intValue(), 0);
           assertEquals("check both unbind callback invocation - 3", ((Integer)props.get("bothU")).intValue(), 0);
           assertEquals("check map bind callback invocation -3", ((Integer)props.get("mapB")).intValue(), 0);
           assertEquals("check map unbind callback invocation -3", ((Integer)props.get("mapU")).intValue(), 0);
           assertEquals("check dict bind callback invocation -3", ((Integer)props.get("dictB")).intValue(), 2);
           assertEquals("check dict unbind callback invocation -3", ((Integer)props.get("dictU")).intValue(), 1);
           assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
           assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
           assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);

           fooProvider2.stop();

           id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
           assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);

           id = null;
           cs = null;
           getContext().ungetService(arch_ref);
           getContext().ungetService(cs_ref);
       }

}


text:
<?php
namespace Quartz\Scheduler;

use Quartz\Core\Trigger;

interface JobRunShell
{
    /**
     * @param StdScheduler $scheduler
     */
    public function initialize(StdScheduler $scheduler);

    /**
     * @param Trigger $trigger
     */
    public function execute(Trigger $trigger);
}

redpajama_set_name: RedPajamaGithub


text:
var mongo = require("mongodb").MongoClient,
    url = "mongodb://localhost:27017/learnyoumongo",
    arg1 = process.argv[2];

function main(minAge) {
    mongo.connect(url, function (err, db) {

        var coll,
            cur,
            curDoc;

        if (err) {
            console.log(err);
            process.exit(-1);
        }

        parrotCollection = db.collection("parrots");

        cur = parrotCollection
            .find({age: {$gt: minAge}})
            .toArray(function (err, docs) {
                if (err) {
                    console.log(err);
                    process.exit(-1);
                }

                console.log(docs);
                db.close();
            });

    });
}

var minAge = parseInt(arg1, 10);
main(minAge);


text:
/*
 * Example of how to use the GL_MESA_window_pos extension.
 * Brian Paul   This file is in the public domain.
 */

#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#ifdef _WIN32
#include <windows.h>
#endif
#include "GL/glew.h"
#include "glut_wrap.h"

#include "readtex.h"

#define IMAGE_FILE DEMOS_DATA_DIR "girl.rgb"

#ifndef M_PI
#  define M_PI 3.14159265
#endif

static GLubyte *Image;
static int ImgWidth, ImgHeight;
static GLenum ImgFormat;

static PFNGLWINDOWPOS2FPROC WindowPosFunc;

static void draw( void )
{
   GLfloat angle;

   glClear( GL_COLOR_BUFFER_BIT );

   for (angle = -45.0; angle <= 135.0; angle += 10.0) {
      GLfloat x = 50.0 + 200.0 * cos( angle * M_PI / 180.0 );
      GLfloat y = 50.0 + 200.0 * sin( angle * M_PI / 180.0 );

      /* Don't need to worry about the modelview or projection matrices!!! */
      (*WindowPosFunc)( x, y );

      glDrawPixels( ImgWidth, ImgHeight, ImgFormat, GL_UNSIGNED_BYTE, Image );
   }
   glFinish();
}

static void key( unsigned char key, int x, int y )
{
   (void) x;
   (void) y;
   switch (key) {
      case 27:
         exit(0);
   }
}

/* new window size or exposure */
static void reshape( int width, int height )
{
   glViewport(0, 0, (GLint)width, (GLint)height);
}

static void init( void )
{
   if (GLEW_ARB_window_pos) {
      printf("Using GL_ARB_window_pos\n");
      WindowPosFunc = glWindowPos2fARB;
   }
   else
   if (GLEW_MESA_window_pos) {
      printf("Using GL_MESA_window_pos\n");
      WindowPosFunc = glWindowPos2fMESA;
   }
   else
   {
      printf("Sorry, GL_ARB/MESA_window_pos extension not available.\n");
      exit(1);
   }

   Image = LoadRGBImage( IMAGE_FILE, &ImgWidth, &ImgHeight, &ImgFormat );
   if (!Image) {
      printf("Couldn't read %s\n", IMAGE_FILE);
      exit(0);
   }
   glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
}

int main( int argc, char *argv[] )
{
   glutInitWindowSize(500, 500);
   glutInit(&argc, argv);
   glutInitDisplayMode( GLUT_RGB );

   if (glutCreateWindow("winpos") <= 0) {
      exit(0);
   }

   glewInit();

   init();

   glutReshapeFunc( reshape );
   glutKeyboardFunc( key );
   glutDisplayFunc( draw );
   glutMainLoop();
   return 0;
}


text:
package org.keycloak.adapters;

/**
 * @author Bill Burke
 * @version $Revision: 1 $
 */
public interface CorsHeaders {
    String ACCESS_CONTROL_ALLOW_ORIGIN = "Access-Control-Allow-Origin";
    String ACCESS_CONTROL_ALLOW_CREDENTIALS = "Access-Control-Allow-Credentials";
    String ACCESS_CONTROL_ALLOW_METHODS = "Access-Control-Allow-Methods";
    String ACCESS_CONTROL_ALLOW_HEADERS = "Access-Control-Allow-Headers";
    String ACCESS_CONTROL_MAX_AGE = "Access-Control-Max-Age";
    String ORIGIN = "Origin";
    String ACCESS_CONTROL_REQUEST_METHOD = "Access-Control-Request-Method";
    String ACCESS_CONTROL_REQUEST_HEADERS = "Access-Control-Request-Headers";
}


text:
#include <monsoon/histogram.h>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <ostream>
#include <sstream>
#include <monsoon/grammar/intf/rules.h>

namespace monsoon {

auto histogram::map() const -> std::map<range, std::double_t> {
  std::map<range, std::double_t> result;
  for (const auto& e : elems_)
    result.emplace(std::get<0>(e), std::get<1>(e));
  return result;
}

auto histogram::add(range r, std::double_t c) -> histogram& {
  const auto insert_val = elems_vector::value_type(r, c, 0);
  elems_.insert(std::upper_bound(elems_.begin(), elems_.end(),
                                 insert_val),
                insert_val);
  fixup_immed_();

  return *this;
}

auto histogram::before(const histogram& x, const histogram& y) noexcept
->  bool {
  return std::lexicographical_compare(x.elems_.begin(), x.elems_.end(),
                                      y.elems_.begin(), y.elems_.end());
}

histogram histogram::parse(std::string_view s) {
  std::string_view::iterator parse_end = s.begin();

  grammar::ast::histogram_expr result;
  bool r = grammar::x3::phrase_parse(
      parse_end, s.end(),
      grammar::parser::histogram,
      grammar::x3::space,
      result);
  if (r && parse_end == s.end())
    return result;
  throw std::invalid_argument("invalid expression");
}

auto histogram::add_immed_(range r, std::double_t c) -> void {
  elems_.emplace_back(r, c, 0);
}

auto histogram::fixup_immed_unsorted_() -> void {
  std::sort(elems_.begin(), elems_.end());
  fixup_immed_();
}

auto histogram::fixup_immed_() -> void {
  assert(std::is_sorted(elems_.begin(), elems_.end()));

  if (elems_.size() >= 2) {
    // Stage 1: split any intersecting ranges.
    for (elems_vector::iterator i = elems_.begin();
         next(i) != elems_.end();
         /* SKIP */) {
      elems_vector::iterator j = std::next(i);
      range& i_r = std::get<0>(*i);
      range& j_r = std::get<0>(*j);
      std::double_t& i_count = std::get<1>(*i);
      std::double_t& j_count = std::get<1>(*j);

      // Loop invariant.
      assert(i_r <= j_r);

      // Skip if ranges don't intersect.
      if (i_r.high() <= j_r.low()) {
        ++i;
        continue;
      }

      // If first range has partial intersection with second range,
      // split the first range.
      if (i_r.low() < j_r.low()) {
        auto left_weight = (j_r.low() - i_r.low()) / i_r.width();
        auto right_weight = 1 - left_weight;

        // Calculate right-side of the split.
        auto new_count = i_count * right_weight;
        auto new_range = range(j_r.low(), i_r.high());
        // Update i to represent the left-side of the split.
        i_r = range(i_r.low(), j_r.low());
        i_count *= left_weight;
        // Add right-side of split, make i point at the newly inserted element.
        i = elems_.emplace(j, std::move(new_range), std::move(new_count), 0);
        continue;
      }

      // If first range is a subrange of the second range,
      // split the second range and move the left-side of the split into i.
      //
      // Note that because of ordering, both start with the same range::low().
      if (i_r.high() < j_r.high()) {
        auto left_weight = i_r.width() / j_r.width();
        auto right_weight = 1 - left_weight;

        // Add left-side count to i.
        i_count += j_count * left_weight;
        j_count *= right_weight;
        j_r = range(i_r.high(), j_r.high());

        // Move j to the correct position.
        auto new_j_successor = std::upper_bound(std::next(j), elems_.end(), *j);
        if (new_j_successor != std::next(j))
          std::rotate(j, std::next(j), new_j_successor);
        else  // No re-ordering, advance iterator.
          ++i;
        continue;
      }
    }

    // Stage 2: combine ranges that are equal.
    for (elems_vector::iterator i = elems_.begin();
         next(i) != elems_.end();
         ++i) {
      elems_vector::iterator j = std::next(i);
      range& i_r = std::get<0>(*i);
      range& j_r = std::get<0>(*j);
      std::double_t& i_count = std::get<1>(*i);
      std::double_t& j_count = std::get<1>(*j);

      // Loop invariant.
      assert(i_r <= j_r);

      // Move count from first into second, so that if multiple equal
      // ranges follow eachother, they are all combined.
      // The first range is left with a zero count, that will be filtered
      // out in stage 3.
      if (i_r == j_r)
        j_count += std::exchange(i_count, 0);
    }
  }

  // Stage 3: remove empty ranges.
  fixup_immed_erase_empty_();

  // Verify invariant.
  assert(std::is_sorted(elems_.begin(), elems_.end()));

  // Update the running count.
  std::double_t running_count = 0;
  for (auto& e : elems_)
    std::get<2>(e) = (running_count += std::get<1>(e));

  // Reduce memory usage.
  elems_.shrink_to_fit();
}

auto histogram::fixup_immed_erase_empty_() -> void {
  elems_.erase(std::remove_if(elems_.begin(), elems_.end(),
                              [](elems_vector::const_reference r) {
                                return std::get<0>(r).width() == 0.0 ||
                                       std::get<0>(r).width() == -0.0;
                              }),
               elems_.end());
}

auto operator-(histogram x) noexcept -> histogram {
  for (auto& e : x.elems_) {
    std::get<1>(e) = -std::get<1>(e);
    std::get<2>(e) = -std::get<2>(e);
  }
  return x;
}

auto operator+(histogram&& x, const histogram& y) -> histogram {
  x.elems_.insert(x.elems_.end(), y.elems_.begin(), y.elems_.end());
  x.fixup_immed_unsorted_();
  return std::move(x);
}

auto operator+(const histogram& x, histogram&& y) -> histogram {
  return std::move(y) + x;
}

auto operator+(histogram&& x, histogram&& y) -> histogram {
  x.elems_.insert(x.elems_.end(), y.elems_.begin(), y.elems_.end());
  x.fixup_immed_unsorted_();
  return std::move(x);
}

auto operator+(const histogram& x, const histogram& y) -> histogram {
  histogram copy = x;
  return std::move(copy) + y;
}

auto operator-(histogram&& x, histogram&& y) -> histogram {
  for (const auto& e : y.elems_)
    x.add_immed_(std::get<0>(e), -std::get<1>(e));
  x.fixup_immed_unsorted_();
  return std::move(x);
}

auto operator-(const histogram& x, histogram&& y) -> histogram {
  for (auto& e : y.elems_)
    std::get<1>(e) = -std::get<1>(e);
  y.elems_.insert(y.elems_.end(), x.elems_.begin(), x.elems_.end());
  y.fixup_immed_unsorted_();
  return std::move(y);
}

auto operator-(histogram&& x, const histogram& y) -> histogram {
  for (const auto& e : y.elems_)
    x.add_immed_(std::get<0>(e), -std::get<1>(e));
  x.fixup_immed_unsorted_();
  return std::move(x);
}

auto operator-(const histogram& x, const histogram& y) -> histogram {
  histogram copy = y;
  return x - std::move(copy);
}

auto operator*(histogram h, std::double_t v) noexcept -> histogram {
  for (auto& e : h.elems_) {
    std::get<1>(e) *= v;
    std::get<2>(e) *= v;  // Running count scales in the same way.
  }
  h.fixup_immed_erase_empty_();
  return h;
}

auto operator/(histogram h, std::double_t v) -> histogram {
  if (v == 0.0 || v == -0.0)
    throw std::invalid_argument("division by zero");

  for (auto& e : h.elems_) {
    std::get<1>(e) /= v;
    std::get<2>(e) /= v;  // Running count scales in the same way.
  }
  h.fixup_immed_erase_empty_();
  return h;
}

auto operator*(std::double_t v, histogram h) noexcept -> histogram {
  for (auto& e : h.elems_) {
    std::get<1>(e) *= v;
    std::get<2>(e) *= v;  // Running count scales in the same way.
  }
  h.fixup_immed_erase_empty_();
  return h;
}

auto operator-=(histogram& x, const histogram& y) -> histogram& {
  for (const auto& e : y.elems_)
    x.add_immed_(std::get<0>(e), -std::get<1>(e));
  x.fixup_immed_unsorted_();
  return x;
}

auto operator+=(histogram& x, const histogram& y) -> histogram& {
  x.elems_.insert(x.elems_.end(), y.elems_.begin(), y.elems_.end());
  x.fixup_immed_unsorted_();
  return x;
}

auto operator*=(histogram& h, std::double_t v) -> histogram& {
  for (auto& e : h.elems_) {
    std::get<1>(e) *= v;
    std::get<2>(e) *= v;  // Running count scales in the same way.
  }
  h.fixup_immed_erase_empty_();
  return h;
}

auto operator/=(histogram& h, std::double_t v) -> histogram& {
  if (v == 0.0 || v == -0.0)
    throw std::invalid_argument("division by zero");

  for (auto& e : h.elems_) {
    std::get<1>(e) /= v;
    std::get<2>(e) /= v;  // Running count scales in the same way.
  }
  h.fixup_immed_erase_empty_();
  return h;
}

auto to_string(const monsoon::histogram& h) -> std::string {
  return (std::ostringstream() << h).str();
}

auto operator<<(std::ostream& out, const histogram& h) -> std::ostream& {
  if (h.empty()) return out << "[]";

  out << "[ ";
  bool first = true;
  for (const auto& e : h.data()) {
    if (!std::exchange(first, false))
      out << ", ";

    out << std::get<0>(e).low()
        << ".."
        << std::get<0>(e).high()
        << "="
        << std::get<1>(e);
  }
  out << " ]";
  return out;
}

} /* namespace monsoon */

namespace std {

auto hash<monsoon::histogram>::operator()(const monsoon::histogram& h)
    const noexcept
->  size_t {
  size_t result = 0;
  for (const auto& e : h.data()) {
    result = 23 * result +
             std::hash<monsoon::histogram::range>()(std::get<0>(e));
    result = 29 * result + std::hash<std::double_t>()(std::get<1>(e));
  }
  return result;
}

} /* namespace std */


text:
package net.jeff.api;

import org.apache.commons.lang3.RandomUtils;

import java.beans.PropertyDescriptor;

/**
 * Created by wil on 23/04/2017.
 */
public class DoublePropertyFiller<T> extends AbstractPropertyFiller<Double, T> {

    /**
     *
     * @param owner
     * @param descriptor
     */
    public DoublePropertyFiller(TypeFiller<T> owner, PropertyDescriptor descriptor) {
        super(owner, descriptor);
    }

    @Override
    public TypeFiller<T> rnd() {
        return with(RandomUtils.nextDouble(0, Double.MAX_VALUE));
    }
}


text:
using Messages.Events;
using NServiceBus;
using NServiceBus.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Rabbit.Shipping.EventHandlers
{
    public class OrderPlacedHandler : IHandleMessages<OrderPlaced>
    {
        static ILog logger = LogManager.GetLogger<OrderPlacedHandler>();

        public Task Handle(OrderPlaced message, IMessageHandlerContext context)
        {
            logger.Info($"Received OrderPlaced, OrderId = {message.OrderId} - preparing for shipment");
            return Task.CompletedTask;
        }
    }
}


text:
int main(){

  // ファクトリーの生成.
  interface_factory *first = new class_first_factory(); // class_first_factoryオブジェクトポインタをfirstに格納.
  interface_factory *second = new class_second_factory(); // class_second_factoryオブジェクトポインタをsecoundに格納.

  // first_header, first_footerを生成.
  interface_header_part *first_header = first->create_header(); // first->create_headerでヘッダを生成.
  interface_footer_part *first_footer = first->create_footer(); // first->create_footerでフッタを生成.

  // first_header, first_footerの出力.
  first_header->print(); // first_header->printで出力.
  first_footer->print(); // first_footer->printで出力.

  // first_header, first_footerの削除.
  delete first_header; // deleteでfirst_headerを削除.
  delete first_footer; // deleteでfirst_footerを削除.

  // second_header, second_footerを生成.
  interface_header_part *second_header = second->create_header(); // second->create_headerでヘッダを生成.
  interface_footer_part *second_footer = second->create_footer(); // second->create_footerでフッタを生成.

  // second_header, second_footerの出力.
  second_header->print(); // second_header->printで出力.
  second_footer->print(); // second_footer->printで出力.

  // second_header, second_footerを生成.
  delete second_header; // deleteでsecond_headerを削除.
  delete second_footer; // deleteでsecond_footerを削除.

  // ファクトリーの削除.
  delete first; // deleteでfirstを削除.
  delete second; // deleteでsecondを削除.

  // プログラムの終了.
  return 0; // 0を返して正常終了.

}


text:
require "wolfram/version"
require "wolfram/pod"
require "wolfram/parser"

require "uri"
require 'nokogiri'
require 'open-uri'

module WolframAlpha

end


text:
<?xml version="1.0" encoding="UTF-8"?>
<og-portfolio schemaVersion="1.0"
              xmlns="http://www.opengamma.com/portfolios"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://www.opengamma.com/portfolios">

  <trades>
    <otcEquityIndexOptionTrade id="t1">

      <externalSystemId><id scheme="External">IdFromExternalSystem1</id></externalSystemId>

      <tradeDate>2013-01-20</tradeDate>
      <maturityDate>2018-01-31</maturityDate>
      <counterparty><id scheme="Cpty">GOLDMAN</id></counterparty>

      <additionalCashflows>
        <additionalCashflow type="premium">
          <counterparty><id scheme="CParty">xyz</id></counterparty>
          <monetaryAmount currency="EUR">150</monetaryAmount>
          <cashflowDate>2013-01-22</cashflowDate>
        </additionalCashflow>
      </additionalCashflows>

      <optionType>Put</optionType>
      <buySell>Buy</buySell>

      <underlyingId><id scheme="BLOOMBERG_TICKER">EI09SPX</id></underlyingId>

      <notional>250000</notional>
      <!-- Validate to check matches underlying ? In future may want to allow it to differ from underlying -->
      <notionalCurrency>EUR</notionalCurrency>

      <strike>600</strike>
      <exerciseType>European</exerciseType>
      <expiryDate>2018-01-31</expiryDate>

      <expiryCalendars>
        <calendar type="bank">
          <id scheme="CountryISO2">FD</id>
        </calendar>
      </expiryCalendars>

      <settlementCalendars>
        <calendar type="bank">
          <id scheme="CountryISO2">FD</id>
        </calendar>
      </settlementCalendars>

    </otcEquityIndexOptionTrade>
  </trades>

  <portfolios>
    <portfolio name="otc_equity_index_portfolio">
      <trades>
        <trade ref="t1"/>
      </trades>
    </portfolio>
  </portfolios>

</og-portfolio>


text:
<?php

use Eliasis\Framework\View;
use Josantonius\Hook\Hook;

echo View::getOption('test');
?>
    <body>
        <?php Hook::doAction('after-body'); ?>
    </body>