home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-10-10 | 3.2 KB | 129 lines |
- // VersionTest.java
- //
- // Created 09/25/96
- //
- // (C)Copyright 1996 Microsoft Corporation, All rights reserved.
- //
-
- import java.io.*;
- import java.awt.*;
- import java.applet.*;
- import java.util.*;
- import com.ms.util.*;
-
-
- public
- class VersionTest extends TestApplet
- {
- public VersionTest ()
- {
- // Don't redirect stdout/stderr. We don't want to see the
- // FileNotFoundExceptions for missing Version classes.
- super(false);
- }
-
-
- static void DumpVersion (String compname, Properties info, PrintStream out)
- {
- if (info == null)
- {
- out.println("Not available");
- }
- else
- {
- // All version objects should have these properties.
-
- out.print("Major version = \""+info.getProperty("MajorVersion")+"\"");
- out.print(", minor version = \""+info.getProperty("MinorVersion")+"\"");
- out.print(", build = \""+info.getProperty("BuildNumber")+"\"");
- out.print(", increment = \""+info.getProperty("BuildIncrement")+"\"");
- out.println(", description = \""+info.getProperty("Description")+"\"");
- }
- }
-
-
- static void DumpSysVersion (String compname, PrintStream out)
- {
- Properties info;
-
- info = VersionManager.getSystemComponentVersion(compname);
-
- out.println("Version information for system component \""+compname+"\":");
- DumpVersion(compname, info, out);
- }
-
-
- static void DumpPkgVersion (String pkgname, PrintStream out)
- {
- Properties info;
-
- info = VersionManager.getPackageVersion(pkgname);
-
- out.println("Version information for package \""+pkgname+"\":");
- DumpVersion(pkgname, info, out);
- }
-
-
- static void dotest (PrintStream out)
- {
- Enumeration e = null;
-
- try
- {
- e = SystemVersionManager.enumerate();
- }
- catch (NoClassDefFoundError ncdf)
- {
- System.err.println("No system version manager is installed.");
- }
- catch (Throwable ex)
- {
- System.err.println("Error enumerating system components: "+e);
- }
-
- if (e != null)
- {
- while (e.hasMoreElements())
- {
- DumpSysVersion((String)e.nextElement(),out);
- out.println();
- }
- }
-
- out.println();
-
- DumpPkgVersion("TestPackage",out);
- out.println();
- DumpPkgVersion("TestPackage.Missing",out);
- out.println();
- DumpPkgVersion("Missing",out);
- out.println();
- DumpPkgVersion("Missing.Submissing",out);
- out.println();
- DumpPkgVersion("TestPackage.Subpackage",out);
- out.println();
- DumpPkgVersion("TestPackage.Subpackage.Missing",out);
- }
-
-
- public void start ()
- {
- dotest(out);
- }
-
-
- public static void main (String[] args)
- {
- try
- {
- dotest(System.out);
- }
- catch (Throwable e)
- {
- System.err.println("VersionTest error: "+e);
- e.printStackTrace();
- }
- }
- }
-
-