flink-cdc-e2e-tests/src/test/java/com/ververica/cdc/connectors/tests/MongoE2eITCase.java
private String executeCommandFileInMongoDB(String fileNameIgnoreSuffix, String databaseName) {
        final String dbName = databaseName != null ? databaseName : fileNameIgnoreSuffix;
        final String ddlFile = String.format("ddl/%s.js", fileNameIgnoreSuffix);
        final URL ddlTestFile = MongoDBTestBase.class.getClassLoader().getResource(ddlFile);
        assertNotNull("Cannot locate " + ddlFile, ddlTestFile);

        try {
            // use database;
            String command0 = String.format("db = db.getSiblingDB('%s');\n", dbName);
            String command1 =
                    Files.readAllLines(Paths.get(ddlTestFile.toURI())).stream()
                            .map(String::trim)
                            .filter(x -> !x.startsWith("//") && !x.isEmpty())
                            .map(
                                    x -> {
                                        final Matcher m = COMMENT_PATTERN.matcher(x);
                                        return m.matches() ? m.group(1) : x;
                                    })
                            .collect(Collectors.joining("\n"));

            mongodb.executeCommand(command0 + command1);

            return dbName;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
/** Executes a mongo command file, specify a database name. */
Executes a mongo command file, specify a database name.
Executes a mongo command file specify a database name .
private String executeCommandFileInMongoDB(String fileNameIgnoreSuffix, String databaseName) {
        final String dbName = databaseName != null ? databaseName : fileNameIgnoreSuffix;
        final String ddlFile = String.format("ddl/%s.js", fileNameIgnoreSuffix);
        final URL ddlTestFile = MongoDBTestBase.class.getClassLoader().getResource(ddlFile);
        assertNotNull("Cannot locate " + ddlFile, ddlTestFile);
        try {
            String command0 = String.format("db = db.getSiblingDB('%s');\n", dbName);
            String command1 =
                    Files.readAllLines(Paths.get(ddlTestFile.toURI())).stream()
                            .map(String::trim)
                            .filter(x -> !x.startsWith("//") && !x.isEmpty())
                            .map(
                                    x -> {
                                        final Matcher m = COMMENT_PATTERN.matcher(x);
                                        return m.matches() ? m.group(1) : x;
                                    })
                            .collect(Collectors.joining("\n"));
            mongodb.executeCommand(command0 + command1);
            return dbName;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
private String executeCommandFileInMongoDB ( String fileNameIgnoreSuffix , String databaseName ) { final String dbName = databaseName != null ? databaseName : fileNameIgnoreSuffix ; final String ddlFile = String . format ( "ddl/%s.js" , fileNameIgnoreSuffix ) ; final URL ddlTestFile = MongoDBTestBase . class . getClassLoader ( ) . getResource ( ddlFile ) ; assertNotNull ( "Cannot locate " + ddlFile , ddlTestFile ) ; try { String command0 = String . format ( "db = db.getSiblingDB('%s');\n" , dbName ) ; String command1 = Files . readAllLines ( Paths . get ( ddlTestFile . toURI ( ) ) ) . stream ( ) . map ( String :: trim ) . filter ( x -> ! x . startsWith ( "//" ) && ! x . isEmpty ( ) ) . map ( x -> { final Matcher m = COMMENT_PATTERN . matcher ( x ) ; return m . matches ( ) ? m . group ( 1 ) : x ; } ) . collect ( Collectors . joining ( "\n" ) ) ; mongodb . executeCommand ( command0 + command1 ) ; return dbName ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }
Executes a mongo command file, specify a database name.
Executes a mongo command file specify a database name .
// use database;