コード例 #1
0
ファイル: UnresolvedTester.java プロジェクト: kiffer580/bnd
  @SuppressWarnings("deprecation")
  public void testAllResolved() {
    assertNotNull("Expected a Bundle Context", context);
    StringBuilder sb = new StringBuilder();

    for (Bundle b : context.getBundles()) {
      if (b.getState() == Bundle.INSTALLED
          && b.getHeaders().get(aQute.bnd.osgi.Constants.FRAGMENT_HOST) == null) {
        try {
          b.start();
        } catch (BundleException e) {
          sb.append(b.getBundleId())
              .append(" ")
              .append(b.getSymbolicName())
              .append(";")
              .append(b.getVersion())
              .append("\n");
          sb.append("    ").append(e.getMessage()).append("\n\n");
          System.err.println(e.getMessage());
        }
      }
    }
    Matcher matcher = IP_P.matcher(sb);
    String out =
        matcher.replaceAll(
            "\n\n         " + aQute.bnd.osgi.Constants.IMPORT_PACKAGE + ": $1;version=[$2,$3)\n");
    assertTrue("Unresolved bundles\n" + out, sb.length() == 0);
  }
コード例 #2
0
  protected static String getMethodName(Test test) {
    String className;
    String desc = test.toString();
    Matcher matcher = methodpattern.matcher(desc);
    if (matcher.matches()) {
      className = matcher.group(1);

    } else {
      className = desc;
    }

    return className;
  }
コード例 #3
0
  public void testBaseUrl() throws Exception {
    sau1 = setupSimAu(simAuConfig(tempDirPath));
    createContent(sau1);
    crawlContent(sau1);
    CachedUrlSet cus1 = sau1.getAuCachedUrlSet();

    tempDirPath2 = getTempDir().getAbsolutePath() + File.separator;
    Configuration config2 = simAuConfig(tempDirPath2);
    config2.put("base_url", "http://anotherhost.org/");
    SimulatedArchivalUnit sau2 = setupSimAu(config2);
    createContent(sau2);
    crawlContent(sau2);
    CachedUrlSet cus2 = sau1.getAuCachedUrlSet();
    List urls1 = auUrls(sau1);
    List urls2 = auUrls(sau2);

    Pattern pat = Pattern.compile("http://([^/]+)(/.*)$");
    List<String> l1 = auUrls(sau1);
    List<String> l2 = auUrls(sau2);
    assertEquals(l1.size(), l2.size());
    for (int ix = 0; ix < l1.size(); ix++) {
      Matcher m1 = pat.matcher(l1.get(ix));
      assertTrue(m1.matches());
      Matcher m2 = pat.matcher(l2.get(ix));
      assertTrue(m2.matches());
      assertEquals("www.example.com", m1.group(1));
      assertEquals("anotherhost.org", m2.group(1));
      assertEquals(m1.group(2), m2.group(2));
    }
  }
コード例 #4
0
  public static void testParseRunProperties() throws Exception {
    Workspace ws = Workspace.getWorkspace(new File("src/test/ws"));
    Project project = ws.getProject("p1");

    ProjectLauncherImpl launcher = new ProjectLauncherImpl(project);
    launcher.prepare();

    String arg = launcher.getRunVM().iterator().next();
    String s = "-D" + LauncherConstants.LAUNCHER_PROPERTIES + "=";
    String propertiesPath = arg.substring(s.length());
    Matcher matcher = Pattern.compile("^([\"'])(.*)\\1$").matcher(propertiesPath);
    if (matcher.matches()) {
      propertiesPath = matcher.group(2);
    }

    Properties launchProps = new Properties();
    launchProps.load(new FileInputStream(new File(propertiesPath)));
    assertEquals(
        new File("src/test/ws/p1/generated/p1.jar").getAbsolutePath(),
        launchProps.get("launch.bundles"));
  }