Search in sources :

Example 31 with StringBufferInputStream

use of java.io.StringBufferInputStream in project vertigo by KleeGroup.

the class FileManagerTest method testCreateTempFileWithNoFile.

@Test
public void testCreateTempFileWithNoFile() {
    final String fileName = "monTestFile.txt";
    final String typeMime = "monTypeMime";
    final Instant lastModified = Instant.now();
    final long length = 123;
    final InputStreamBuilder inputStreamBuilder = new InputStreamBuilder() {

        @Override
        public InputStream createInputStream() {
            return new StringBufferInputStream("Contenu test");
        }
    };
    final VFile vFile = fileManager.createFile(fileName, typeMime, lastModified, length, inputStreamBuilder);
    checkVFile(vFile, fileName, lastModified, typeMime, length);
}
Also used : StringBufferInputStream(java.io.StringBufferInputStream) InputStreamBuilder(io.vertigo.dynamo.file.model.InputStreamBuilder) Instant(java.time.Instant) VFile(io.vertigo.dynamo.file.model.VFile) Test(org.junit.Test)

Example 32 with StringBufferInputStream

use of java.io.StringBufferInputStream in project vertigo by KleeGroup.

the class FileManagerTest method testCreateTempFileWithNoFileNoMime.

@Test
public void testCreateTempFileWithNoFileNoMime() {
    final String fileName = "monTestFile.txt";
    final Instant lastModified = Instant.now();
    final long length = 123;
    final InputStreamBuilder inputStreamBuilder = new InputStreamBuilder() {

        @Override
        public InputStream createInputStream() {
            return new StringBufferInputStream("Contenu test");
        }
    };
    final VFile vFile = fileManager.createFile(fileName, lastModified, length, inputStreamBuilder);
    checkVFile(vFile, fileName, lastModified, "text/plain", length);
}
Also used : StringBufferInputStream(java.io.StringBufferInputStream) InputStreamBuilder(io.vertigo.dynamo.file.model.InputStreamBuilder) Instant(java.time.Instant) VFile(io.vertigo.dynamo.file.model.VFile) Test(org.junit.Test)

Example 33 with StringBufferInputStream

use of java.io.StringBufferInputStream in project groovy-core by groovy.

the class DependencyTest method testDep.

public void testDep() {
    cu.addSource("testDep.gtest", new StringBufferInputStream("class C1 {}\n" + "class C2 {}\n" + "class C3 {}\n" + "class A1 {C1 x}\n" + "class A2 extends C2{}\n" + "class A3 {C1 foo(C2 x){new C3()}}\n"));
    cu.compile(Phases.CLASS_GENERATION);
    assertEquals(cache.get("C1").size(), 1);
    assertEquals(cache.get("C2").size(), 1);
    assertEquals(cache.get("C3").size(), 1);
    Set<String> dep = cache.get("A1");
    assertEquals(dep.size(), 2);
    assertTrue(dep.contains("C1"));
    dep = cache.get("A2");
    assertEquals(dep.size(), 2);
    assertTrue(dep.contains("C2"));
    dep = cache.get("A3");
    assertEquals(dep.size(), 4);
    assertTrue(dep.contains("C1"));
    assertTrue(dep.contains("C2"));
    assertTrue(dep.contains("C3"));
}
Also used : StringBufferInputStream(java.io.StringBufferInputStream)

Example 34 with StringBufferInputStream

use of java.io.StringBufferInputStream in project drill by apache.

the class LargeTableGen method generateTableWithIndex.

public void generateTableWithIndex(String tablePath, int recordNumber, String[] indexDef) throws Exception {
    // create index
    initRandVector(recordNumber);
    initDictionary();
    DBTests.setTableStatsSendInterval(1);
    if (admin.tableExists(tablePath)) {
    // admin.deleteTable(tablePath);
    }
    // create Json String
    int batch, i;
    int BATCH_SIZE = 2000;
    try (Table table = createOrGetTable(tablePath, recordNumber)) {
        // create index
        createIndex(table, indexDef);
        for (batch = 0; batch < recordNumber; batch += BATCH_SIZE) {
            int batchStop = Math.min(recordNumber, batch + BATCH_SIZE);
            StringBuffer strBuf = new StringBuffer();
            for (i = batch; i < batchStop; ++i) {
                strBuf.append(String.format("{\"rowid\": \"%d\", \"reverseid\": \"%d\", \"id\": {\"ssn\": \"%s\"}, \"contact\": {\"phone\": \"%s\", \"email\": \"%s\"}," + "\"address\": {\"city\": \"%s\", \"state\": \"%s\"}, \"name\": { \"fname\": \"%s\", \"lname\": \"%s\" }," + "\"personal\": {\"age\" : %s, \"income\": %s, \"birthdate\": {\"$dateDay\": \"%s\"} }," + "\"activity\": {\"irs\" : { \"firstlogin\":  \"%s\" } }," + "\"driverlicense\":{\"$numberLong\": %s} } \n", i + 1, recordNumber - i, getSSN(i), getPhone(i), getEmail(i), getAddress(i)[2], getAddress(i)[1], getFirstName(i), getLastName(i), getAge(i), getIncome(i), getBirthdate(i), getFirstLogin(i), getSSN(i)));
            }
            try (InputStream in = new StringBufferInputStream(strBuf.toString());
                DocumentStream stream = Json.newDocumentStream(in)) {
                try {
                    // insert a batch  of document in stream
                    table.insert(stream, "rowid");
                } catch (Exception e) {
                    System.out.println(stream.toString());
                    throw e;
                }
            }
        }
        table.flush();
        DBTests.waitForIndexFlush(table.getPath(), INDEX_FLUSH_TIMEOUT);
        Thread.sleep(200000);
    }
}
Also used : Table(com.mapr.db.Table) StringBufferInputStream(java.io.StringBufferInputStream) StringBufferInputStream(java.io.StringBufferInputStream) InputStream(java.io.InputStream) DocumentStream(org.ojai.DocumentStream)

Aggregations

StringBufferInputStream (java.io.StringBufferInputStream)34 Test (org.junit.Test)10 InputStream (java.io.InputStream)9 SQLException (java.sql.SQLException)6 IModelManager (org.eclipse.wst.sse.core.internal.provisional.IModelManager)5 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)5 BadLocationException (org.eclipse.jface.text.BadLocationException)3 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)3 InputStreamBuilder (io.vertigo.dynamo.file.model.InputStreamBuilder)2 VFile (io.vertigo.dynamo.file.model.VFile)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 IOException (java.io.IOException)2 Instant (java.time.Instant)2 Matchers.anyString (org.mockito.Matchers.anyString)2 KettleException (org.pentaho.di.core.exception.KettleException)2 RepositoryMeta (org.pentaho.di.repository.RepositoryMeta)2 Element (org.w3c.dom.Element)2 Table (com.mapr.db.Table)1 Description (io.qameta.allure.Description)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1