Ejemplo n.º 1
0
 private void logVersionInfo(Class<?> clazz, String title, Log log) {
   Package pack = clazz.getPackage();
   String version = null;
   if (pack != null) {
     if (pack.getImplementationTitle() != null) {
       title = pack.getImplementationTitle();
     }
     version = pack.getImplementationVersion();
   }
   if (version == null) {
     try {
       String classname = clazz.getName();
       Class<?> packinf =
           Class.forName(classname.substring(0, classname.lastIndexOf('.')) + ".PackageInfo");
       java.lang.reflect.Method mo = packinf.getMethod("getProductVersion");
       version = mo.invoke(null).toString();
     } catch (Exception pie) {
       log.info("PackageInfo not found");
     }
     if (version == null) {
       version = "<unknown>";
     }
   }
   log.info(title + " version " + version);
 }
Ejemplo n.º 2
0
  /** Starts the Error Checker Service thread */
  @Override
  public void run() {
    lastTab = editor.getSketch().getCodeIndex(editor.getSketch().getCurrentCode());
    initializeErrorWindow();
    xqpreproc = new XQPreprocessor();
    // Run check code just once before entering into loop.
    // Makes sure everything is initialized and set.
    checkCode();
    editor.getTextArea().repaint();
    stopThread = false;

    while (!stopThread) {
      try {
        // Take a nap.
        Thread.sleep(sleepTime);
      } catch (Exception e) {
        System.out.println("Oops! [ErrorCheckerThreaded]: " + e);
        // e.printStackTrace();
      }

      if (pauseThread) continue;

      // Check every x seconds
      checkCode();
      if (runCount < 5) {
        runCount++;
      }

      if (runCount == 3) {
        Package p = XQMode.class.getPackage();
        System.out.println(p.getImplementationTitle() + " v" + p.getImplementationVersion());
      }
    }
  }
Ejemplo n.º 3
0
 public static void main(String[] args) {
   Package pckgs[];
   pckgs = Package.getPackages();
   for (Package pckg : pckgs) {
     System.out.println(
         pckg.getName()
             + " "
             + pckg.getImplementationTitle()
             + " "
             + pckg.getImplementationVendor()
             + " "
             + pckg.getImplementationVersion());
   }
 }
 private void ensureDroolsRuntimeMatches(
     String expectedRuntimeVersion, VersionCheckStrategy versionCheckStrategy) {
   final Package droolsCorePackage = KnowledgePackageImp.class.getPackage();
   final String implementationTitle = droolsCorePackage.getImplementationTitle();
   final String implementationVersion = droolsCorePackage.getImplementationVersion();
   switch (versionCheckStrategy) {
     case VERSIONS_MUST_MATCH:
       ensureVersionsMatch(expectedRuntimeVersion, implementationTitle, implementationVersion);
       break;
     case IGNORE_UNKNOWN_RUNTIME_VERSION:
       ensureVersionsMatchIgnoringUnknown(
           expectedRuntimeVersion, implementationTitle, implementationVersion);
       break;
   }
 }
Ejemplo n.º 5
0
 static String productVersion(Class<?> clazz) {
   String title = null;
   String version = null;
   String vendor = null;
   Package pkg = clazz.getPackage();
   if (pkg != null) {
     title = pkg.getImplementationTitle();
     version = pkg.getImplementationVersion();
     vendor = pkg.getImplementationVendor();
   }
   StringBuilder builder = new StringBuilder("Product Version: ");
   builder.append((title != null) ? title : clazz.getSimpleName());
   builder.append("  ");
   builder.append((version != null) ? version : "(unknown version)");
   if (vendor != null) {
     builder.append(",  ").append(vendor);
   }
   return builder.toString();
 }
Ejemplo n.º 6
0
  /**
   * @tests java.lang.Package#getImplementationVendor()
   * @tests java.lang.Package#getImplementationVersion()
   * @tests java.lang.Package#getSpecificationTitle()
   * @tests java.lang.Package#getSpecificationVendor()
   * @tests java.lang.Package#getSpecificationVersion()
   * @tests java.lang.Package#getImplementationTitle()
   */
  public void test_helper_Attributes() throws Exception {

    Package p = getTestPackage("hyts_all_attributes.jar", "p.C");
    assertEquals(
        "Package getImplementationTitle returns a wrong string (1)",
        "p Implementation-Title",
        p.getImplementationTitle());
    assertEquals(
        "Package getImplementationVendor returns a wrong string (1)",
        "p Implementation-Vendor",
        p.getImplementationVendor());
    assertEquals(
        "Package getImplementationVersion returns a wrong string (1)",
        "2.2.2",
        p.getImplementationVersion());
    assertEquals(
        "Package getSpecificationTitle returns a wrong string (1)",
        "p Specification-Title",
        p.getSpecificationTitle());
    assertEquals(
        "Package getSpecificationVendor returns a wrong string (1)",
        "p Specification-Vendor",
        p.getSpecificationVendor());
    assertEquals(
        "Package getSpecificationVersion returns a wrong string (1)",
        "2.2.2",
        p.getSpecificationVersion());

    // No entry for the package
    Package p2 = getTestPackage("hyts_no_entry.jar", "p.C");
    assertEquals(
        "Package getImplementationTitle returns a wrong string (2)",
        "MF Implementation-Title",
        p2.getImplementationTitle());
    assertEquals(
        "Package getImplementationVendor returns a wrong string (2)",
        "MF Implementation-Vendor",
        p2.getImplementationVendor());
    assertEquals(
        "Package getImplementationVersion returns a wrong string (2)",
        "5.3.b1",
        p2.getImplementationVersion());
    assertEquals(
        "Package getSpecificationTitle returns a wrong string (2)",
        "MF Specification-Title",
        p2.getSpecificationTitle());
    assertEquals(
        "Package getSpecificationVendor returns a wrong string (2)",
        "MF Specification-Vendor",
        p2.getSpecificationVendor());
    assertEquals(
        "Package getSpecificationVersion returns a wrong string (2)",
        "1.2.3",
        p2.getSpecificationVersion());

    // No attributes in the package entry
    Package p3 = getTestPackage("hyts_no_attributes.jar", "p.C");
    assertEquals(
        "Package getImplementationTitle returns a wrong string (3)",
        "MF Implementation-Title",
        p3.getImplementationTitle());
    assertEquals(
        "Package getImplementationVendor returns a wrong string (3)",
        "MF Implementation-Vendor",
        p3.getImplementationVendor());
    assertEquals(
        "Package getImplementationVersion returns a wrong string (3)",
        "5.3.b1",
        p3.getImplementationVersion());
    assertEquals(
        "Package getSpecificationTitle returns a wrong string (3)",
        "MF Specification-Title",
        p3.getSpecificationTitle());
    assertEquals(
        "Package getSpecificationVendor returns a wrong string (3)",
        "MF Specification-Vendor",
        p3.getSpecificationVendor());
    assertEquals(
        "Package getSpecificationVersion returns a wrong string (3)",
        "1.2.3",
        p3.getSpecificationVersion());

    // Some attributes in the package entry
    Package p4 = getTestPackage("hyts_some_attributes.jar", "p.C");
    assertEquals(
        "Package getImplementationTitle returns a wrong string (4)",
        "p Implementation-Title",
        p4.getImplementationTitle());
    assertEquals(
        "Package getImplementationVendor returns a wrong string (4)",
        "MF Implementation-Vendor",
        p4.getImplementationVendor());
    assertEquals(
        "Package getImplementationVersion returns a wrong string (4)",
        "2.2.2",
        p4.getImplementationVersion());
    assertEquals(
        "Package getSpecificationTitle returns a wrong string (4)",
        "MF Specification-Title",
        p4.getSpecificationTitle());
    assertEquals(
        "Package getSpecificationVendor returns a wrong string (4)",
        "p Specification-Vendor",
        p4.getSpecificationVendor());
    assertEquals(
        "Package getSpecificationVersion returns a wrong string (4)",
        "2.2.2",
        p4.getSpecificationVersion());

    // subdirectory Package
    Package p5 = getTestPackage("hyts_pq.jar", "p.q.C");
    assertEquals(
        "Package getImplementationTitle returns a wrong string (5)",
        "p Implementation-Title",
        p5.getImplementationTitle());
    assertEquals(
        "Package getImplementationVendor returns a wrong string (5)",
        "p Implementation-Vendor",
        p5.getImplementationVendor());
    assertEquals(
        "Package getImplementationVersion returns a wrong string (5)",
        "1.1.3",
        p5.getImplementationVersion());
    assertEquals(
        "Package getSpecificationTitle returns a wrong string (5)",
        "p Specification-Title",
        p5.getSpecificationTitle());
    assertEquals(
        "Package getSpecificationVendor returns a wrong string (5)",
        "p Specification-Vendor",
        p5.getSpecificationVendor());
    assertEquals(
        "Package getSpecificationVersion returns a wrong string (5)",
        "2.2.0.0.0.0.0.0.0.0.0",
        p5.getSpecificationVersion());
  }
  @TestTargetNew(
      level = TestLevel.COMPLETE,
      notes = "",
      method = "definePackage",
      args = {
        java.lang.String.class, java.lang.String.class,
        java.lang.String.class, java.lang.String.class,
        java.lang.String.class, java.lang.String.class,
        java.lang.String.class, java.net.URL.class
      })
  public void test_definePackage() {

    PackageClassLoader pcl = new PackageClassLoader(getClass().getClassLoader());

    String[] packageProperties = {
      "test.package", "title", "1.0", "Vendor", "Title", "1.1", "implementation vendor"
    };

    URL url = null;
    try {
      url = new URL("file:");
    } catch (MalformedURLException e) {
      fail("MalformedURLException was thrown.");
    }
    pcl.definePackage(
        packageProperties[0],
        packageProperties[1],
        packageProperties[2],
        packageProperties[3],
        packageProperties[4],
        packageProperties[5],
        packageProperties[6],
        url);

    Package pack = pcl.getPackage(packageProperties[0]);
    assertEquals(packageProperties[1], pack.getSpecificationTitle());
    assertEquals(packageProperties[2], pack.getSpecificationVersion());
    assertEquals(packageProperties[3], pack.getSpecificationVendor());
    assertEquals(packageProperties[4], pack.getImplementationTitle());
    assertEquals(packageProperties[5], pack.getImplementationVersion());
    assertEquals(packageProperties[6], pack.getImplementationVendor());
    assertTrue(pack.isSealed(url));
    assertTrue(pack.isSealed());

    try {
      pcl.definePackage(
          packageProperties[0],
          packageProperties[1],
          packageProperties[2],
          packageProperties[3],
          packageProperties[4],
          packageProperties[5],
          packageProperties[6],
          null);
      fail("IllegalArgumentException was not thrown.");
    } catch (IllegalArgumentException iae) {
      // expected
    }

    pcl.definePackage("test.package.test", null, null, null, null, null, null, null);
    pack = pcl.getPackage("test.package.test");
    assertNull(pack.getSpecificationTitle());
    assertNull(pack.getSpecificationVersion());
    assertNull(pack.getSpecificationVendor());
    assertNull(pack.getImplementationTitle());
    assertNull(pack.getImplementationVersion());
    assertNull(pack.getImplementationVendor());
    assertFalse(pack.isSealed());
  }
 /** @return the implementation title from Hazelast */
 public String getAdapterName() {
   return HZ_PACKAGE.getImplementationTitle();
 }