/** * Returns a {@link Processor} object of the current JVM. * * <p> * Important: The os.arch System Property returns the architecture used by the JVM * not of the operating system. * </p> * * @return A {@link Processor} when supported, else <code>null</code>. */ public static Processor getProcessor() { return getProcessor(SystemUtils.OS_ARCH); }
@Test public void testGetProcessor() { assertNotNull(ArchUtils.getProcessor(X86)); assertNull(ArchUtils.getProcessor("NA")); }
@Test public void testIs32BitJVM() { Processor processor = ArchUtils.getProcessor(X86); assertEqualsArchNotNull(Processor.Arch.BIT_32, processor); assertTrue(processor.is32Bit()); processor = ArchUtils.getProcessor(IA64_32); assertEqualsArchNotNull(Processor.Arch.BIT_32, processor); assertTrue(processor.is32Bit()); processor = ArchUtils.getProcessor(PPC); assertEqualsArchNotNull(Processor.Arch.BIT_32, processor); processor.is32Bit(); processor = ArchUtils.getProcessor(X86_64); assertNotEqualsArchNotNull(Processor.Arch.BIT_32, processor); assertFalse(processor.is32Bit()); processor = ArchUtils.getProcessor(PPC64); assertNotEqualsArchNotNull(Processor.Arch.BIT_32, processor); assertFalse(processor.is32Bit()); processor = ArchUtils.getProcessor(IA64); assertNotEqualsArchNotNull(Processor.Arch.BIT_32, processor); assertFalse(processor.is32Bit()); }
@Test public void testIs64BitJVM() { Processor processor = ArchUtils.getProcessor(X86_64); assertEqualsArchNotNull(Processor.Arch.BIT_64, processor); assertTrue(processor.is64Bit()); processor = ArchUtils.getProcessor(PPC64); assertEqualsArchNotNull(Processor.Arch.BIT_64, processor); assertTrue(processor.is64Bit()); processor = ArchUtils.getProcessor(IA64); assertEqualsArchNotNull(Processor.Arch.BIT_64, processor); assertTrue(processor.is64Bit()); processor = ArchUtils.getProcessor(X86); assertNotEqualsArchNotNull(Processor.Arch.BIT_64, processor); assertFalse(processor.is64Bit()); processor = ArchUtils.getProcessor(PPC); assertNotEqualsArchNotNull(Processor.Arch.BIT_64, processor); assertFalse(processor.is64Bit()); processor = ArchUtils.getProcessor(IA64_32); assertNotEqualsArchNotNull(Processor.Arch.BIT_64, processor); assertFalse(processor.is64Bit()); }
@Test public void testArch() { Processor processor = ArchUtils.getProcessor(X86); assertEqualsTypeNotNull(Processor.Type.X86, processor); assertTrue(processor.isX86()); assertNotEqualsTypeNotNull(Processor.Type.PPC, processor); assertFalse(processor.isPPC()); processor = ArchUtils.getProcessor(X86_64); assertEqualsTypeNotNull(Processor.Type.X86, processor); assertTrue(processor.isX86()); processor = ArchUtils.getProcessor(IA64_32); assertEqualsTypeNotNull(Processor.Type.IA_64, processor); assertTrue(processor.isIA64()); processor = ArchUtils.getProcessor(IA64); assertEqualsTypeNotNull(Processor.Type.IA_64, processor); assertTrue(processor.isIA64()); assertNotEqualsTypeNotNull(Processor.Type.X86, processor); assertFalse(processor.isX86()); processor = ArchUtils.getProcessor(PPC); assertEqualsTypeNotNull(Processor.Type.PPC, processor); assertTrue(processor.isPPC()); assertNotEqualsTypeNotNull(Processor.Type.IA_64, processor); assertFalse(processor.isIA64()); processor = ArchUtils.getProcessor(PPC64); assertEqualsTypeNotNull(Processor.Type.PPC, processor); assertTrue(processor.isPPC()); }
/** * Returns a {@link Processor} object of the current JVM. * * <p> * Important: The os.arch System Property returns the architecture used by the JVM * not of the operating system. * </p> * * @return A {@link Processor} when supported, else <code>null</code>. */ public static Processor getProcessor() { return getProcessor(SystemUtils.OS_ARCH); }
/** * Returns a {@link Processor} object of the current JVM. * * <p> * Important: The os.arch System Property returns the architecture used by the JVM * not of the operating system. * </p> * * @return A {@link Processor} when supported, else <code>null</code>. */ public static Processor getProcessor() { return getProcessor(SystemUtils.OS_ARCH); }
/** * Returns a {@link Processor} object of the current JVM. * * <p> * Important: The os.arch System Property returns the architecture used by the JVM * not of the operating system. * </p> * * @return A {@link Processor} when supported, else <code>null</code>. */ public static Processor getProcessor() { return getProcessor(SystemUtils.OS_ARCH); }
private static URL getURL(String version) { StringBuilder url = new StringBuilder(); url.append("https://releases.hashicorp.com/vault/").append(version).append("/vault_").append(version).append("_"); if (SystemUtils.IS_OS_MAC) { url.append("darwin_"); } else if (SystemUtils.IS_OS_LINUX) { url.append("linux_"); } else if (SystemUtils.IS_OS_WINDOWS) { url.append("windows_"); } else { throw new IllegalStateException("Unsupported operating system"); } if (ArchUtils.getProcessor().is64Bit()) { url.append("amd64.zip"); } else { url.append("386.zip"); } System.out.println("Downloading " + url.toString()); try { return new URL(url.toString()); } catch (Exception e) { throw new RuntimeException(e); } }
private static URL getURL(String version) { StringBuilder url = new StringBuilder(); url.append("https://releases.hashicorp.com/vault/").append(version).append("/vault_").append(version).append("_"); if (SystemUtils.IS_OS_MAC) { url.append("darwin_"); } else if (SystemUtils.IS_OS_LINUX) { url.append("linux_"); } else if (SystemUtils.IS_OS_WINDOWS) { url.append("windows_"); } else { throw new IllegalStateException("Unsupported operating system"); } if (ArchUtils.getProcessor().is64Bit()) { url.append("amd64.zip"); } else { url.append("386.zip"); } System.out.println("Downloading " + url.toString()); try { return new URL(url.toString()); } catch (Exception e) { throw new RuntimeException(e); } }