Example usage for org.hibernate.lob ReaderInputStream ReaderInputStream

List of usage examples for org.hibernate.lob ReaderInputStream ReaderInputStream

Introduction

In this page you can find the example usage for org.hibernate.lob ReaderInputStream ReaderInputStream.

Prototype

public ReaderInputStream(Reader reader) 

Source Link

Document

Constructs a ReaderInputStream from a Reader

Usage

From source file:com.zutubi.pulse.master.tove.config.project.types.VersionedTypeConfigurationTest.java

License:Apache License

@Override
protected void setUp() throws Exception {
    super.setUp();
    configuration = new VersionedTypeConfiguration();
    configuration.setPulseFileName(VERSIONED_PULSE_FILE_PATH);

    mockResolver = mock(FileResolver.class);
    InputStream inputStream = new ReaderInputStream(new StringReader(VERSIONED_PULSE_FILE_CONTENT));
    stub(mockResolver.resolve(VERSIONED_PULSE_FILE_PATH)).toReturn(inputStream);
}

From source file:edu.harvard.med.screensaver.model.AttachedFileTest.java

License:Open Source License

public void testScreenRelationship() throws IOException {
    schemaUtil.truncateTables();//  w  w w  .ja  v a  2s.  c o  m
    Screen screen = dataFactory.newInstance(Screen.class);
    ScreenAttachedFileType attachedFileType = new ScreenAttachedFileType("Application");
    genericEntityDao.persistEntity(attachedFileType);
    screen.createAttachedFile("filename1", attachedFileType, new LocalDate(),
            new ReaderInputStream(new StringReader("file contents 1")));
    screen.createAttachedFile("filename2", attachedFileType, new LocalDate(), "file contents 2");
    screen = genericEntityDao.mergeEntity(screen);

    screen = genericEntityDao.reloadEntity(screen, true, Screen.attachedFiles.to(AttachedFile.screen));
    for (AttachedFile attachedFile : screen.getAttachedFiles()) {
        assertEquals(screen, attachedFile.getScreen());
    }
}

From source file:edu.harvard.med.screensaver.model.AttachedFileTest.java

License:Open Source License

public void testScreeningUserRelationship() throws IOException {
    schemaUtil.truncateTables();/*from   w w  w .j ava2s.c o  m*/
    ScreeningRoomUser user = dataFactory.newInstance(ScreeningRoomUser.class);
    UserAttachedFileType attachedFileType = new UserAttachedFileType("Application");
    genericEntityDao.persistEntity(attachedFileType);
    user.createAttachedFile("filename1", attachedFileType, new LocalDate(),
            new ReaderInputStream(new StringReader("file contents 1")));
    user.createAttachedFile("filename2", attachedFileType, new LocalDate(), "file contents 2");
    user = genericEntityDao.mergeEntity(user);

    user = genericEntityDao.reloadEntity(user, true,
            ScreeningRoomUser.attachedFiles.to(AttachedFile.screeningRoomUser));
    for (AttachedFile attachedFile : user.getAttachedFiles()) {
        assertEquals(user, attachedFile.getScreeningRoomUser());
    }
}

From source file:edu.harvard.med.screensaver.model.AttachedFileTest.java

License:Open Source License

public void testReagentRelationship() throws IOException {
    schemaUtil.truncateTables();//ww  w .j a  va2  s . c  om
    Reagent reagent = dataFactory.newInstance(SmallMoleculeReagent.class);
    ReagentAttachedFileType attachedFileType = new ReagentAttachedFileType("Application");
    genericEntityDao.saveOrUpdateEntity(attachedFileType);
    AttachedFile attachedFile1 = reagent.createAttachedFile("filename1", attachedFileType, new LocalDate(),
            new ReaderInputStream(new StringReader("file contents 1")));
    AttachedFile attachedFile2 = reagent.createAttachedFile("filename2", attachedFileType, new LocalDate(),
            "file contents 2");
    genericEntityDao.saveOrUpdateEntity(reagent.getLibraryContentsVersion().getLibrary());

    reagent = genericEntityDao.reloadEntity(reagent);
    AttachedFile attachedFile1b = genericEntityDao.findEntityById(AttachedFile.class,
            attachedFile1.getEntityId(), true, AttachedFile.reagent);
    AttachedFile attachedFile2b = genericEntityDao.findEntityById(AttachedFile.class,
            attachedFile2.getEntityId(), true, AttachedFile.reagent);
    assertEquals(reagent, attachedFile1b.getReagent());
    assertEquals(reagent, attachedFile2b.getReagent());
}

From source file:org.opennms.netmgt.poller.monitors.MailTransportMonitorTest.java

License:Open Source License

@Test
public void testLoadXmlProperties() throws InvalidPropertiesFormatException, IOException {
    Properties props = new Properties();

    Reader reader = new StringReader("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
            + "<!DOCTYPE properties SYSTEM \"http://java.sun.com/dtd/properties.dtd\">\n" + "<properties>\n"
            + "<comment>Hi</comment>\n" + "<entry key=\"foo\">1</entry>\n" + "<entry key=\"fu\">baz</entry>\n"
            + "</properties>");
    InputStream stream = new ReaderInputStream(reader);
    props.loadFromXML(stream);/*w w  w.j a  va  2  s  .c o  m*/
    assertEquals("1", props.get("foo"));
}

From source file:org.sonar.api.batch.AbstractViolationsStaxParserTest.java

License:Open Source License

@Test
public void testDoNotSaveViolationsOnUnexistedResource() throws XMLStreamException {
    SensorContext context = mock(SensorContext.class);
    MyViolationParser violationParser = new MyViolationParser(context, null);
    violationParser.setDoSaveViolationsOnUnexistedResource(false);
    violationParser.parse(new ReaderInputStream(new StringReader("<root><file/></root>")));
}

From source file:org.sonar.api.batch.AbstractViolationsStaxParserTest.java

License:Open Source License

@Test(expected = CursorForViolationsMethodHasBeenCalled.class)
public void testDoSaveViolationsOnUnexistedResource() throws XMLStreamException {
    SensorContext context = mock(SensorContext.class);
    MyViolationParser violationParser = new MyViolationParser(context, null);
    violationParser.parse(new ReaderInputStream(new StringReader("<root><file/></root>")));
}