Package org.springframework.osgi.mock

Examples of org.springframework.osgi.mock.EntryLookupControllingMockBundle


    context.registerService((String[]) null, null, null);
    bundleContextControl.setMatcher(MockControl.ALWAYS_MATCHER);
    bundleContextControl.setReturnValue(null, MockControl.ONE_OR_MORE);

    // create task executor
    EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(null);
    aBundle.setEntryReturnOnNextCallToGetEntry(null);
    bundleContextControl.expectAndReturn(context.getBundle(), aBundle, MockControl.ONE_OR_MORE);

    // listen for bundle events
    context.addBundleListener(null);
    bundleContextControl.setMatcher(MockControl.ALWAYS_MATCHER);
View Full Code Here


  }

  public void tstTaskExecutor() throws Exception {
    Dictionary headers = new Hashtable();
    headers.put(Constants.BUNDLE_NAME, "Extender mock bundle");
    final EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
    aBundle.setEntryReturnOnNextCallToGetEntry(new ClassPathResource("META-INF/spring/moved-extender.xml").getURL());

    MockBundleContext ctx = new MockBundleContext() {

      public Bundle getBundle() {
        return aBundle;
View Full Code Here

  private static final String[] META_INF_SPRING_CONTENT = new String[] { "file://META-INF/spring/context.xml",
      "file://META-INF/spring/context-two.xml" };

  public void testBundleWithNoHeaderAndNoMetaInfSpringResourcesIsNotSpringPowered() {
    EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(null);
    aBundle.setResultsToReturnOnNextCallToFindEntries(null);
    ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
    assertFalse("bundle is not spring powered", config.isSpringPoweredBundle());
  }
View Full Code Here

    ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
    assertFalse("bundle is not spring powered", config.isSpringPoweredBundle());
  }

  public void testBundleWithSpringResourcesAndNoHeaderIsSpringPowered() {
    EntryLookupControllingMockBundle aBundle = new RepeatingEntryLookupControllingMockBundle(null);
    aBundle.setResultsToReturnOnNextCallToFindEntries(META_INF_SPRING_CONTENT);
    ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
    assertTrue("bundle is spring powered", config.isSpringPoweredBundle());
  }
View Full Code Here

  }

  public void testBundleWithHeaderAndNoMetaInfResourcesIsSpringPowered() throws Exception {
    Dictionary headers = new Hashtable();
    headers.put("Spring-Context", "META-INF/spring/context.xml");
    EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
    aBundle.setResultsToReturnOnNextCallToFindEntries(null);
    aBundle.setEntryReturnOnNextCallToGetEntry(new URL("file://META-INF/spring/context.xml"));
    ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
    assertTrue("bundle is spring powered", config.isSpringPoweredBundle());
  }
View Full Code Here

    ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
    assertTrue("bundle is spring powered", config.isSpringPoweredBundle());
  }

  public void testBundleWithNoHeaderShouldWaitFiveMinutes() {
    EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(null);
    aBundle.setResultsToReturnOnNextCallToFindEntries(META_INF_SPRING_CONTENT);
    ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
    assertEquals("bundle should timeout in five minutes", new Long(5 * 60 * 1000), new Long(config.getTimeout()));
  }
View Full Code Here

  }

  public void testBundleWithWaitFiveSecondWaitForTimeout() {
    Dictionary headers = new Hashtable();
    headers.put("Spring-Context", "*;timeout:=5");
    EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
    aBundle.setResultsToReturnOnNextCallToFindEntries(META_INF_SPRING_CONTENT);
    ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
    assertTrue("bundle should be Spring powered", config.isSpringPoweredBundle());
    assertEquals("bundle should timeout in 5 s", new Long(5 * 1000), new Long(config.getTimeout()));
  }
View Full Code Here

  public void testBundleWithWaitForEver() {
    // *;flavour
    Dictionary headers = new Hashtable();
    headers.put("Spring-Context", "*;timeout:=none");
    EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
    aBundle.setResultsToReturnOnNextCallToFindEntries(META_INF_SPRING_CONTENT);
    ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
    assertTrue("bundle should be Spring powered", config.isSpringPoweredBundle());
    assertEquals("bundle should timeout -2 (indicates forever)", new Long(-2), new Long(config.getTimeout()));
  }
View Full Code Here

    assertTrue("bundle should be Spring powered", config.isSpringPoweredBundle());
    assertEquals("bundle should timeout -2 (indicates forever)", new Long(-2), new Long(config.getTimeout()));
  }

  public void tstConfigLocationsInMetaInfNoHeader() {
    EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(null);
    aBundle.setResultsToReturnOnNextCallToFindEntries(META_INF_SPRING_CONTENT);
    ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
    String[] configFiles = config.getConfigurationLocations();
    assertEquals("0 config files", 0, configFiles.length);
    // assertEquals("bundle-url:file://META-INF/spring/context.xml",
    // configFiles[0]);
View Full Code Here

  }

  public void tstConfigLocationsInMetaInfWithHeader() throws Exception {
    Dictionary headers = new Hashtable();
    headers.put("Spring-Context", "META-INF/spring/context.xml");
    EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
    aBundle.setResultsToReturnOnNextCallToFindEntries(META_INF_SPRING_CONTENT);
    aBundle.setEntryReturnOnNextCallToGetEntry(new URL("file://META-INF/spring/context.xml"));
    ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
    String[] configFiles = config.getConfigurationLocations();
    assertTrue("bundle should be Spring powered", config.isSpringPoweredBundle());
    assertEquals("osgibundle:META-INF/spring/context.xml", configFiles[0]);
  }
View Full Code Here

TOP

Related Classes of org.springframework.osgi.mock.EntryLookupControllingMockBundle

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.