Exemple #1
0
  public static void testSpecialConversions() throws URISyntaxException {
    Properties p = new Properties();
    p.put("enumv", "A");
    p.put("pattern", ".*");
    p.put("clazz", "java.lang.Object");
    p.put("constructor", "http://www.aQute.biz");

    SpecialConversions trt =
        Configurable.createConfigurable(SpecialConversions.class, (Map<Object, Object>) p);
    assertEquals(SpecialConversions.X.A, trt.enumv());
    assertEquals(".*", trt.pattern().pattern());
    assertEquals(Object.class, trt.clazz());
    assertEquals(new URI("http://www.aQute.biz"), trt.constructor());
  }
Exemple #2
0
  static <T> T set(Class<T> interf, Object value) {
    Properties p = new Properties();
    Method ms[] = interf.getMethods();

    for (Method m : ms) {
      p.put(m.getName(), value);
    }
    return Configurable.createConfigurable(interf, (Map<Object, Object>) p);
  }
Exemple #3
0
  /**
   * We create a JAR with the test.classreferenc.ClassReference class. This class contains a
   * javax.swing.Box.class reference Prior to Java 1.5, this was done in a silly way that is handled
   * specially. After 1.5 it is a normal reference.
   *
   * @throws Exception
   */
  public void testReference() throws Exception {
    Properties properties = new Properties();
    properties.put("-classpath", "compilerversions/compilerversions.jar");
    String[] packages = {
      "sun_1_1",
      "sun_1_6",
      "eclipse_1_1",
      "sun_1_2",
      "sun_1_3",
      "sun_1_4",
      "sun_1_5",
      "sun_jsr14",
      "eclipse_1_5",
      "eclipse_1_6",
      "eclipse_1_2",
      "eclipse_1_3",
      "eclipse_1_4",
      "eclipse_jsr14"
    };
    for (int i = 0; i < packages.length; i++) {
      Builder builder = new Builder();
      properties.put("Export-Package", packages[i]);
      builder.setProperties(properties);
      Jar jar = builder.build();
      System.out.println(builder.getErrors());
      System.out.println(builder.getWarnings());
      assertEquals(0, builder.getErrors().size());
      assertEquals(0, builder.getWarnings().size());

      Manifest manifest = jar.getManifest();
      String imports = manifest.getMainAttributes().getValue("Import-Package");
      assertTrue(
          "Package " + packages[i] + "contains swing ref", imports.indexOf("javax.swing") >= 0);
      assertFalse(
          "Package " + packages[i] + "should not contain ClassRef",
          imports.indexOf("ClassRef") >= 0);
    }
  }
Exemple #4
0
  public void setUp() {
    validRsls = new Properties();
    validRsls.put("rsl1", "+(&(executable=myprogram)(stdin<2.4))(&(stdin=8)   \n\n\n(stdin=0))");
    validRsls.put("rsl2", "&(executable=myprogram)(stdin<2.4)(stdin=8)(stdin=0)");
    validRsls.put("rsl3", "&(a=a)(a=b)");
    validRsls.put("rsl4", " &(a=a)");
    validRsls.put(
        "rsl5",
        "(* dont use this comment *)\n&(string=\"my name is \"\"Nick Karonis\"\" today\") (*or this one*)");
    validRsls.put("rsl6", "&(&(&(&(a=a))))");
    validRsls.put("rsl7", "&(args=\"aa ) bb\")");
    validRsls.put("rsl8", "+(&(executable=myprogram)(stdin<2.4))(|(stdin=8)   \n\n\n(stdin=0))");
    validRsls.put(
        "rsl9",
        "+(&(executable=myprogram)(stdin<2.4)(|(a=bbb)(yyy=z)))(|(stdin=8)   \n\n\n(stdin=0))");
    validRsls.put("rsl10", "&(args=hello \n\n)");
    validRsls.put("rsl11", "&(executable=\"\")");
    validRsls.put("rsl12", "&(executable=\"abc \"\" \"\" def\")");
    // validRsls.put("rsl13", "args=\"aa ) \"\"bb cc dd\"");
    validRsls.put(
        "rsl14",
        "&((*comment*)string(*comment*) \n=(*comment\ncontinue comment*)\"my (* ok *) name is \"\"Nick Karonis\"\" today\"(*comment*)) (* or this one *)");
    validRsls.put(
        "rsl15",
        "&(* dont use this comment *)\n(\n(*comment*)string(*comment*)\n=(*comment\ncontinue comment*)\"my name is \"\"Nick Karonis\"\" today\"(*comment*)) (*or this one*)");
    // validRsls.put("rsl16", "(* dont use this comment *)\n(* comment*) string  (*
    // comment*)\n=(*comment\ncontinue comment*)\"my name is \"\"Nick Karonis\"\" today\"(*comment*)
    // (*or this one*)");
    validRsls.put(
        "rsl17",
        "+(* dont use this comment *)\n((*comment*)string(*comment*)=(*comment\ncontinue comment*)\"my name is \"\"Nick Karonis\"\" today\"(*comment*)) (*or this one*)");
    validRsls.put("rsl18", "+(string='let''s try ''single quotes'' with \"double too\" ok')");

    invalidRsls = new Properties();

    invalidRsls.put("rsl1", "(my executable=a.out)");
    invalidRsls.put("rsl2", "(executable=/home /a.ou:t#22)");
    invalidRsls.put("rsl3", "&(args=dddd)(executable=)(more_args=ooo)");
    invalidRsls.put("rsl4", "(executable=^$test $$$  quotes$)");
    invalidRsls.put("rsl5", "(executable=^$my value $ \nmore \"\"\" stuff)");
    invalidRsls.put("rsl6", "(executable=)");
    invalidRsls.put("rsl7", "(args=\"\"a\"\"b\")");
    invalidRsls.put("rsl8", "(args=hello \n\nworld)");
    invalidRsls.put("rsl9", "(arguments=\"ccc ddd\"\"zzz\"\")");
    // invalidRsls.put("rsl10", "&(arguments=\"\"\"\"\")(exe=abc)");
    invalidRsls.put("rsl11", "(a=a)");
    invalidRsls.put(
        "rsl12", "+(&(executable=myprogram)(stdin<2.4))(+(stdin=8)   \n\n\n(stdin=0))+");
    invalidRsls.put("rsl13", "(=a.out)");
    invalidRsls.put("rsl14", "(executable=\")");
    invalidRsls.put("rsl15", "(executable=^\")");
    invalidRsls.put("rsl16", "(executable=^/)");
  }