/** * Returns a new fresh file with the given name under the temporary folder. */ public File newFile(String fileName) throws IOException { File file = new File(getRoot(), fileName); if (!file.createNewFile()) { throw new IOException( "a file with the name \'" + fileName + "\' already exists in the test folder"); } return file; }
@Test public void export_package_as_string() { exporter.setTargetFolder(folder.getRoot()); exporter.export(getClass().getPackage().getName()); assertTrue(new File(folder.getRoot(), "com/querydsl/codegen/QExampleEmbeddable.java").exists()); assertTrue(new File(folder.getRoot(), "com/querydsl/codegen/QExampleEmbedded.java").exists()); assertTrue(new File(folder.getRoot(), "com/querydsl/codegen/QExampleEntity.java").exists()); assertTrue(new File(folder.getRoot(), "com/querydsl/codegen/QExampleEntityInterface.java").exists()); assertTrue(new File(folder.getRoot(), "com/querydsl/codegen/QExampleSupertype.java").exists()); assertTrue(new File(folder.getRoot(), "com/querydsl/codegen/sub/QExampleEntity2.java").exists()); }
@Test public void shouldStartStopNeoServerWithoutAnyConfigFiles() throws Throwable { // When int resultCode = ServerBootstrapper.start( bootstrapper, withConnectorsOnRandomPortsConfig( "--home-dir", tempDir.newFolder( "home-dir" ).getAbsolutePath(), "-c", configOption( data_directory, tempDir.getRoot().getAbsolutePath() ), "-c", configOption( logs_directory, tempDir.getRoot().getAbsolutePath() ), "-c", "dbms.backup.enabled=false" ) ); // Then assertEquals( ServerBootstrapper.OK, resultCode ); assertEventually( "Server was not started", bootstrapper::isRunning, is( true ), 1, TimeUnit.MINUTES ); }
@Test public void whenRelativePathIsProvidedInProperties_shouldReturnFileUrl() throws Exception { DependencyResolver resolver = new PropertiesDependencyResolver( propsFile("com.group:example:1.3", new File("path", "1")), mock); URL url = resolver.getLocalArtifactUrl(exampleDep); assertThat(url).isEqualTo( temporaryFolder.getRoot().toPath().resolve("path").resolve("1").toUri().toURL()); }
@Test(expected = IllegalConfigurationException.class) public void testInvalidConfiguration() throws IOException { GlobalConfiguration.loadConfiguration(tempFolder.getRoot().getAbsolutePath()); }
@Before public void setup() throws Exception { outputFile = new File(temporaryFolder.getRoot(), "dependency.txt").getAbsoluteFile(); showDeadlockCommand = "show dead-locks --file=" + outputFile.getAbsolutePath(); outputFile.delete(); locator = lsRule.startLocatorVM(0, l -> l.withHttpService()); Properties props = new Properties(); props.setProperty(ConfigurationProperties.SERIALIZABLE_OBJECT_FILTER, "org.apache.geode.management.internal.cli.commands.ShowDeadlock*"); server1 = lsRule.startServerVM(1, props, locator.getPort()); server2 = lsRule.startServerVM(2, props, locator.getPort()); connect(); }
@Test public void shouldUseSpecifiedHomeDir() { // given File configFile = ConfigFileBuilder.builder( folder.getRoot() ).build(); // when Config testConf = Config.fromFile( configFile ).withHome( folder.getRoot() ).build(); // then assertEquals( folder.getRoot(), testConf.get( GraphDatabaseSettings.neo4j_home ) ); }
@Before public void prepare() { baseDir = temp.getRoot(); builder = ImmutableMap.<String, String>builder() .put("sonar.task", "scan") .put("sonar.projectBaseDir", baseDir.getAbsolutePath()) .put("sonar.projectKey", "com.foo.project") .put("sonar.projectName", "Foo Project") .put("sonar.projectVersion", "1.0-SNAPSHOT") .put("sonar.projectDescription", "Description of Foo Project"); }
@BeforeClass public static void allocateServer() throws IOException { server = CommunityServerBuilder.serverOnRandomPorts() .usingDataDir( staticFolder.getRoot().getAbsolutePath() ) .withAutoIndexingEnabledForNodes( "foo", "bar" ) .build(); server.start(); functionalTestHelper = new FunctionalTestHelper( server ); }
@Test public void shouldWriteUrlArrayToFile() throws Exception { Cache cache = new CachedDependencyResolver.FileCache(temporaryFolder.getRoot(), 1000); URL[] urls = { new URL("http://localhost") }; assertTrue(cache.write(ID, urls)); Object actual = readFromCacheFile(); assertArrayEquals(urls, (URL[]) actual); }
@Test public void export() { exporter.setTargetFolder(folder.getRoot()); exporter.export(getClass().getPackage()); assertTrue(new File(folder.getRoot(), "com/querydsl/codegen/QExampleEmbeddable.java").exists()); assertTrue(new File(folder.getRoot(), "com/querydsl/codegen/QExampleEmbedded.java").exists()); assertTrue(new File(folder.getRoot(), "com/querydsl/codegen/QExampleEntity.java").exists()); assertTrue(new File(folder.getRoot(), "com/querydsl/codegen/QExampleEntityInterface.java").exists()); assertTrue(new File(folder.getRoot(), "com/querydsl/codegen/QExampleSupertype.java").exists()); assertTrue(new File(folder.getRoot(), "com/querydsl/codegen/sub/QExampleEntity2.java").exists()); }
@Test public void testMultipleYarnShipOptions() throws Exception { final String[] args = new String[]{"run", "--yarnship", tmp.newFolder().getAbsolutePath(), "--yarnship", tmp.newFolder().getAbsolutePath()}; final FlinkYarnSessionCli flinkYarnSessionCli = new FlinkYarnSessionCli( new Configuration(), tmp.getRoot().getAbsolutePath(), "y", "yarn"); final CommandLine commandLine = flinkYarnSessionCli.parseCommandLineOptions(args, false); AbstractYarnClusterDescriptor flinkYarnDescriptor = flinkYarnSessionCli.createClusterDescriptor(commandLine); assertEquals(2, flinkYarnDescriptor.shipFiles.size()); }
@Test public void shouldSetAValueForAuthStoreLocation() { File configFile = ConfigFileBuilder.builder( folder.getRoot() ) .withSetting( GraphDatabaseSettings.data_directory, "the-data-dir" ) .build(); Config config = Config.fromFile( configFile ).withHome( folder.getRoot() ).build(); assertThat( config.get( DatabaseManagementSystemSettings.auth_store_directory ), is( new File( folder.getRoot(), "the-data-dir/dbms" ).getAbsoluteFile() ) ); }
@Test // We allow malformed YAML files public void testInvalidYamlFile() throws IOException { final File confFile = tempFolder.newFile(GlobalConfiguration.FLINK_CONF_FILENAME); try (PrintWriter pw = new PrintWriter(confFile)) { pw.append("invalid"); } assertNotNull(GlobalConfiguration.loadConfiguration(tempFolder.getRoot().getAbsolutePath())); }
@SuppressWarnings("ResultOfMethodCallIgnored") @Before public void setUp() throws Exception { top = temporaryFolder.getRoot(); directory1 = new File(top, "directory1"); directory2 = new File(top, "directory2"); directory3 = new File(directory2, "directory3"); directory1.mkdir(); directory2.mkdir(); directory3.mkdir(); file1 = new File(directory1, "file1"); file2 = new File(directory2, "file2"); file3 = new File(top, "file3"); // Tests case with relative path file1ByRelativeDirectory2 = new File(top, "directory2/../directory1/file1"); file2ByRelativeDirectory1 = new File(top, "directory1/../directory2/file2"); FileUtils.touch(file1); FileUtils.touch(file2); FileUtils.touch(file3); }
@Before public void setup() { testingFatalErrorHandler = new TestingFatalErrorHandler(); flinkConfig = new Configuration(); flinkConfig.setInteger(ResourceManagerOptions.CONTAINERIZED_HEAP_CUTOFF_MIN, 100); File root = folder.getRoot(); File home = new File(root, "home"); boolean created = home.mkdir(); assertTrue(created); env = new HashMap<>(); env.put(ENV_APP_ID, "foo"); env.put(ENV_CLIENT_HOME_DIR, home.getAbsolutePath()); env.put(ENV_CLIENT_SHIP_FILES, ""); env.put(ENV_FLINK_CLASSPATH, ""); env.put(ENV_HADOOP_USER_NAME, "foo"); env.put(FLINK_JAR_PATH, root.toURI().toString()); }
@Test public void shouldLoadObjectWhenCacheExists() throws Exception { Cache cache = new CachedDependencyResolver.FileCache(temporaryFolder.getRoot(), 1000); String expectedValue = "some string"; writeToCacheFile(expectedValue); String value = cache.load(ID, String.class); assertEquals(expectedValue, value); }