Package org.springframework.osgi.mock

Examples of org.springframework.osgi.mock.MockBundle


  private static String PKG = "com.acme.facade";


  public void testGetNoBundleClassPathDefined() {
    Properties props = new Properties();
    Bundle bundle = new MockBundle(props);
    String[] cp = OsgiHeaderUtils.getBundleClassPath(bundle);
    assertEquals(0, cp.length);
  }
View Full Code Here


  public void testGetBundleClassPath() {
    Properties props = new Properties();
    String path1 = ".";
    String path2 = "WEB-INF/";
    props.setProperty(Constants.BUNDLE_CLASSPATH, path1 + "," + path2);
    Bundle bundle = new MockBundle(props);
    String[] cp = OsgiHeaderUtils.getBundleClassPath(bundle);
    assertEquals(2, cp.length);
    assertEquals(path1, cp[0]);
    assertEquals(path2, cp[1]);
  }
View Full Code Here

  public void testGetBundleClassPathWithWhiteSpaces() {
    Properties props = new Properties();
    String path1 = ".";
    String path2 = "WEB-INF/";
    props.setProperty(Constants.BUNDLE_CLASSPATH, " " + path1 + " ,  " + path2 + "   ");
    Bundle bundle = new MockBundle(props);
    String[] cp = OsgiHeaderUtils.getBundleClassPath(bundle);

    // check for spaces
    assertSame(cp[0], cp[0].trim());
    assertSame(cp[1], cp[1].trim());
View Full Code Here

    assertEquals(path2, cp[1]);
  }

  public void testGetRequireBundleUndeclared() throws Exception {
    Properties props = new Properties();
    Bundle bundle = new MockBundle(props);
    String[] rb = OsgiHeaderUtils.getRequireBundle(bundle);
    assertEquals(0, rb.length);
  }
View Full Code Here

  public void testGetRequireBundleWithMultipleBundlesAttributesAndWhitespaces() throws Exception {
    Properties props = new Properties();
    String pkg2 = "foo.bar";
    props.setProperty(Constants.REQUIRE_BUNDLE, "  " + PKG + ";visibility:=reexport;bundle-version=\"1.0\" ,\t  "
        + pkg2 + "\n  ");
    Bundle bundle = new MockBundle(props);
    String[] rb = OsgiHeaderUtils.getRequireBundle(bundle);

    assertSame(rb[0], rb[0].trim());
    assertSame(rb[1], rb[1].trim());
  }
View Full Code Here

  public void testGetRequireBundleWMultipleUnversionedEntries() throws Exception {
    Properties props = new Properties();
    String b1 = "foo";
    String b2 = "bar";
    props.setProperty(Constants.REQUIRE_BUNDLE, b1 + "," + b2);
    Bundle bundle = new MockBundle(props);
    String[] rb = OsgiHeaderUtils.getRequireBundle(bundle);
    assertEquals(2, rb.length);
    assertEquals(b1, rb[0]);
    assertEquals(b2, rb[1]);
  }
View Full Code Here

  public void testRequireBundleWithSimpleVersions() throws Exception {
    Properties props = new Properties();
    String b1 = "foo;bundle-version=1.1.0";
    String b2 = "bar;bundle-version=2";
    props.setProperty(Constants.REQUIRE_BUNDLE, b1 + "," + b2);
    Bundle bundle = new MockBundle(props);
    String[] rb = OsgiHeaderUtils.getRequireBundle(bundle);
    assertEquals(2, rb.length);
    assertEquals(b1, rb[0]);
    assertEquals(b2, rb[1]);
  }
View Full Code Here

  public void testRequireBundleWithRangeVersions() throws Exception {
    Properties props = new Properties();
    String b1 = "foo;bundle-version=\"[1.0,2.0)\"";
    String b2 = "bar;bundle-version=1.0.0";
    props.setProperty(Constants.REQUIRE_BUNDLE, b1 + "," + b2);
    Bundle bundle = new MockBundle(props);
    String[] rb = OsgiHeaderUtils.getRequireBundle(bundle);
    assertEquals(2, rb.length);
    assertEquals(b1, rb[0]);
    assertEquals(b2, rb[1]);
  }
View Full Code Here

  public void testRequireBundleWithQuotes() throws Exception {
    Properties props = new Properties();
    String b1 = "foo;bundle-version=\"[1.0,2.0)\"";
    String b2 = "bar;bundle-version=\"1.0.0\"";
    props.setProperty(Constants.REQUIRE_BUNDLE, b1 + "," + b2);
    Bundle bundle = new MockBundle(props);
    String[] rb = OsgiHeaderUtils.getRequireBundle(bundle);
    assertEquals(2, rb.length);
    assertEquals(b1, rb[0]);
    assertEquals(b2, rb[1]);
  }
View Full Code Here

  public void testRequireBundleWithVersionAndExtraAttributes() throws Exception {
    Properties props = new Properties();
    String b1 = "foo;bundle-version=\"[1.0,2.0)\";visibility:=reexport";
    String b2 = "bar;resolution:=optional;bundle-version=\"1.0.0\"";
    props.setProperty(Constants.REQUIRE_BUNDLE, b1 + "," + b2);
    Bundle bundle = new MockBundle(props);
    String[] rb = OsgiHeaderUtils.getRequireBundle(bundle);
    assertEquals(2, rb.length);
    assertEquals(b1, rb[0]);
    assertEquals(b2, rb[1]);
  }
View Full Code Here

TOP

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

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.