Refine search
@Test public void testProxyClassIsDifferent() throws Exception { assumeTrue(runTests); IJmxTestBean proxy = getProxy(); assertTrue("The proxy class should be different than the base class", (proxy.getClass() != IJmxTestBean.class)); }
@Test public void failedAssumptionShouldPrecludeImminentFailure() { assumeTrue(false); fail("A failed assumption should preclude imminent failure!"); }
@Test public void testEchoHello() throws Exception { assumeTrue(!OperatingSystem.IS_WINDOWS); String output = Shell.execCommand("echo", "hello"); assertEquals("hello\n", output); }
@Test public void zeroCopy() throws Exception { // Zero-copy only does not support servlet assumeTrue(server instanceof ReactorHttpServer || server instanceof UndertowHttpServer); URI url = new URI("http://localhost:" + port); RequestEntity<?> request = RequestEntity.get(url).build(); ResponseEntity<byte[]> response = new RestTemplate().exchange(request, byte[].class); Resource logo = new ClassPathResource("spring.png", ZeroCopyIntegrationTests.class); assertTrue(response.hasBody()); assertEquals(logo.contentLength(), response.getHeaders().getContentLength()); assertEquals(logo.contentLength(), response.getBody().length); assertEquals(MediaType.IMAGE_PNG, response.getHeaders().getContentType()); }
@Override public void run() { try { latch.await(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw Throwables.propagate(e); } if (useFifo) { Assert.assertEquals(myOrder, hasRun.getAndIncrement()); } else { Assume.assumeTrue(Integer.compare(myOrder, hasRun.getAndIncrement()) == 0); } } };
private void assertRustBuildable(final String generatedRust, final Optional<String> name) throws IOException, InterruptedException { Assume.assumeTrue(cargoExists()); final File folder = writeCargoFolderWrapper(name.orElse("test"), generatedRust, folderRule.newFolder()); assertTrue("Generated Rust should be buildable with cargo", cargoCheckInDirectory(folder)); }
@Test public void testHeadDevZero() throws Exception { assumeTrue(!OperatingSystem.IS_WINDOWS); final int length = 100000; String output = Shell.execCommand("head", "-c", Integer.toString(length), "/dev/zero"); assertEquals(length, output.length()); }
@Test public void testHandlesPaths() { // TODO fix drive letter parsing somehow assumeTrue("it will fail with schema being the drive letter (C:\\... -> C)", !Util.isWindows()); File f = RuntimeEnvironment.application.getCacheDir(); Uri expected = Uri.fromFile(f); when(uriLoader.buildLoadData(eq(expected), eq(IMAGE_SIDE), eq(IMAGE_SIDE), eq(options))) .thenReturn(new ModelLoader.LoadData<>(key, fetcher)); assertTrue(loader.handles(f.getAbsolutePath())); assertEquals( fetcher, Preconditions.checkNotNull( loader.buildLoadData(f.getAbsolutePath(), IMAGE_SIDE, IMAGE_SIDE, options)).fetcher); }
@Test public void allMacsHaveHighIO() { assumeTrue( SystemUtils.IS_OS_MAC ); assertTrue( FileUtils.highIODevice( Paths.get( "." ), false ) ); }
@Test public void noNamespacePrefixes() throws Exception { Assume.assumeTrue(wwwSpringframeworkOrgIsAccessible()); StringWriter stringWriter = new StringWriter(); AbstractStaxHandler handler = createStaxHandler(new StreamResult(stringWriter)); xmlReader.setContentHandler(handler); xmlReader.setProperty("http://xml.org/sax/properties/lexical-handler", handler); xmlReader.setFeature("http://xml.org/sax/features/namespaces", true); xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", false); xmlReader.parse(new InputSource(new StringReader(COMPLEX_XML))); assertThat(stringWriter.toString(), isSimilarTo(COMPLEX_XML).withNodeFilter(nodeFilter)); }
@Test public void testInvokeArgs() throws Exception { assumeTrue(runTests); IJmxTestBean proxy = getProxy(); int result = proxy.add(1, 2); assertEquals("The operation should return 3", 3, result); }
@Test public void testReadWithBOMUtf32Le() throws Exception { Assume.assumeTrue(Charset.isSupported("UTF_32LE")); final byte[] data = "ABC".getBytes("UTF_32LE"); final BOMInputStream in = new BOMInputStream(createUtf32LeDataStream(data, true), ByteOrderMark.UTF_32LE); assertEquals('A', in.read()); assertEquals(0, in.read()); assertEquals(0, in.read()); assertEquals(0, in.read()); assertEquals('B', in.read()); assertEquals(0, in.read()); assertEquals(0, in.read()); assertEquals(0, in.read()); assertEquals('C', in.read()); assertEquals(0, in.read()); assertEquals(0, in.read()); assertEquals(0, in.read()); assertEquals(-1, in.read()); assertTrue("hasBOM()", in.hasBOM()); assertTrue("hasBOM(UTF-32LE)", in.hasBOM(ByteOrderMark.UTF_32LE)); assertEquals("getBOM", ByteOrderMark.UTF_32LE, in.getBOM()); try { in.hasBOM(ByteOrderMark.UTF_32BE); fail("Expected IllegalArgumentException"); } catch (final IllegalArgumentException e) { // expected - not configured for UTF-32BE } in.close(); }
@Test public void testServiceLoaderFactoryBean() { assumeTrue(ServiceLoader.load(DocumentBuilderFactory.class).iterator().hasNext()); DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition bd = new RootBeanDefinition(ServiceLoaderFactoryBean.class); bd.getPropertyValues().add("serviceType", DocumentBuilderFactory.class.getName()); bf.registerBeanDefinition("service", bd); ServiceLoader<?> serviceLoader = (ServiceLoader<?>) bf.getBean("service"); assertTrue(serviceLoader.iterator().next() instanceof DocumentBuilderFactory); }
@Test public void namespacePrefixes() throws Exception { Assume.assumeTrue(wwwSpringframeworkOrgIsAccessible()); StringWriter stringWriter = new StringWriter(); AbstractStaxHandler handler = createStaxHandler(new StreamResult(stringWriter)); xmlReader.setContentHandler(handler); xmlReader.setProperty("http://xml.org/sax/properties/lexical-handler", handler); xmlReader.setFeature("http://xml.org/sax/features/namespaces", true); xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true); xmlReader.parse(new InputSource(new StringReader(COMPLEX_XML))); assertThat(stringWriter.toString(), isSimilarTo(COMPLEX_XML).withNodeFilter(nodeFilter)); }
@Test public void testGetAttributeValue() throws Exception { assumeTrue(runTests); IJmxTestBean proxy1 = getProxy(); int age = proxy1.getAge(); assertEquals("The age should be 100", 100, age); }
@Test public void testReadWithBOMUtf32Be() throws Exception { Assume.assumeTrue(Charset.isSupported("UTF_32BE")); final byte[] data = "ABC".getBytes("UTF_32BE"); final BOMInputStream in = new BOMInputStream(createUtf32BeDataStream(data, true), ByteOrderMark.UTF_32BE); assertEquals(0, in.read()); assertEquals(0, in.read()); assertEquals(0, in.read()); assertEquals('A', in.read()); assertEquals(0, in.read()); assertEquals(0, in.read()); assertEquals(0, in.read()); assertEquals('B', in.read()); assertEquals(0, in.read()); assertEquals(0, in.read()); assertEquals(0, in.read()); assertEquals('C', in.read()); assertEquals(-1, in.read()); assertTrue("hasBOM()", in.hasBOM()); assertTrue("hasBOM(UTF-32BE)", in.hasBOM(ByteOrderMark.UTF_32BE)); assertEquals("getBOM", ByteOrderMark.UTF_32BE, in.getBOM()); try { in.hasBOM(ByteOrderMark.UTF_32LE); fail("Expected IllegalArgumentException"); } catch (final IllegalArgumentException e) { // expected - not configured for UTF-32LE } in.close(); }
@Test public void onLinuxDevShmHasHighIO() { assumeTrue( SystemUtils.IS_OS_LINUX ); assertTrue( FileUtils.highIODevice( Paths.get( "/dev/shm" ), false ) ); }
@Test(expected = IOException.class) public void testSetAttributeValueWithIOException() throws Exception { assumeTrue(runTests); IJmxTestBean proxy = getProxy(); proxy.setName("Juergen IO"); }
@Test public void testInvokeNoArgs() throws Exception { assumeTrue(runTests); IJmxTestBean proxy = getProxy(); long result = proxy.myOperation(); assertEquals("The operation should return 1", 1, result); }
@Test public void testSetupAndTearDown() throws IOException { Config config = new Config(); .assumeTrue("Check if CGroups are setup", ((boolean) config.get(DaemonConfig.STORM_RESOURCE_ISOLATION_PLUGIN_ENABLE)) == true); Assert.assertTrue("Check if STORM_CGROUP_HIERARCHY_DIR exists", stormCgroupHierarchyExists(config)); Assert.assertTrue("Check if STORM_SUPERVISOR_CGROUP_ROOTDIR exists", stormCgroupSupervisorRootDirExists(config)); String correctCommand2 = config.get(DaemonConfig.STORM_CGROUP_CGEXEC_CMD) + " -g cpu,memory:/" + config.get(DaemonConfig.STORM_SUPERVISOR_CGROUP_ROOTDIR) + "/" + workerId + " "; Assert.assertTrue("Check if cgroup launch command is correct", command.toString().equals(correctCommand1) || command.toString().equals(correctCommand2)); Assert.assertTrue("Check if cpu.shares file exists", fileExists(pathToCpuShares)); Assert.assertEquals("Check if the correct value is written into cpu.shares", "200", readFileAll(pathToCpuShares)); Assert.assertTrue("Check if memory.limit_in_bytes file exists", fileExists(pathTomemoryLimitInBytes)); Assert.assertEquals("Check if the correct value is written into memory.limit_in_bytes", String.valueOf(1024 * 1024 * 1024), readFileAll(pathTomemoryLimitInBytes));