Examples of ClobType


Examples of org.apache.torque.test.dbobject.ClobType

     */
    public void testCreateAndReadClobs() throws Exception
    {
        ClobTypePeer.doDelete(new Criteria());

        ClobType clobType = fillAndSaveClobType(
                new ClobType(),
                40000,
                "1234567890abcdefghijklmnopqrstuvwxyz");

        // read the ClobTypes from the database
        // and check the values against the original values
        List<ClobType> clobTypeList = ClobTypePeer.doSelect(new Criteria());
        assertEquals(1, clobTypeList.size());

        ClobType readClobType = clobTypeList.get(0);
        assertEquals(clobType.getClobValue(), readClobType.getClobValue());
    }
View Full Code Here

Examples of org.apache.torque.test.dbobject.ClobType

     * @throws Exception if the test fails
     */
    public void testUpdateClobs() throws Exception
    {
        ClobTypePeer.doDelete(new Criteria());
        ClobType clobType = fillAndSaveClobType(
                new ClobType(),
                40000,
                "1234567890abcdefghijklmnopqrstuvwxyz");
        clobType = ClobTypePeer.doSelectSingleRecord(new Criteria());
        fillAndSaveClobType(
                clobType,
                50000,
                "0987654321abcdefghijklmnopqrstuvwxyz");

        // read the ClobTypes from the database
        // and check the values against the original values
        List<ClobType> clobTypeList = ClobTypePeer.doSelect(new Criteria());
        assertEquals(1, clobTypeList.size());

        ClobType readClobType = clobTypeList.get(0);
        assertEquals(clobType.getClobValue(), readClobType.getClobValue());
    }
View Full Code Here

Examples of org.teiid.core.types.ClobType

     * @return Outgoing value of target type
     * @throws TransformationException if value is an incorrect input type or
     * the transformation fails
     */
    public Object transformDirect(Object value) throws TransformationException {
        ClobType source = (ClobType)value;
       
        try {
            BufferedReader reader = new BufferedReader (source.getCharacterStream());
            StringBuffer contents = new StringBuffer();
           
            int chr = reader.read();
            while (chr != -1 && contents.length() < DataTypeManager.MAX_STRING_LENGTH) {
                contents.append((char)chr);
View Full Code Here

Examples of org.teiid.core.types.ClobType

                  //transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); //$NON-NLS-1$
                  // Feed the resultant I/O stream into the XSLT processor
          transformer.transform(xmlParam, new StreamResult(writer));
        }
      });
      return new ClobType(new ClobImpl(result.getStreamFactory(), -1));
    } finally {
      Util.closeSource(styleSource);
      Util.closeSource(xmlSource);
    }
    }
View Full Code Here

Examples of org.teiid.core.types.ClobType

  public void testLobPeristence() throws Exception{
   
    BufferManagerImpl buffMgr = BufferManagerFactory.createBufferManager();
    FileStore fs = buffMgr.createFileStore("temp");
   
    ClobType clob = new ClobType(new ClobImpl(new InputStreamFactory() {
      @Override
      public InputStream getInputStream() throws IOException {
        return new ReaderInputStream(new StringReader("Clob contents One"),  Charset.forName(Streamable.ENCODING));
      }
     
    }, -1));
   
    BlobType blob = new BlobType(new BlobImpl(new InputStreamFactory() {
      @Override
      public InputStream getInputStream() throws IOException {
        return new ReaderInputStream(new StringReader("Blob contents Two"),  Charset.forName(Streamable.ENCODING));
      }
     
    }));   
   
    LobManager lobManager = new LobManager();
    lobManager.updateReferences(new int[] {0,1}, Arrays.asList(clob, blob));
    lobManager.persist(fs);
   
    Streamable<?>lob = lobManager.getLobReference(clob.getReferenceStreamId());
    assertTrue(lob.getClass().isAssignableFrom(ClobType.class));
    ClobType clobRead = (ClobType)lob;
    assertEquals(ClobType.getString(clob), ClobType.getString(clobRead));
    assertTrue(clobRead.length() != -1);
   
    lob = lobManager.getLobReference(blob.getReferenceStreamId());
    assertTrue(lob.getClass().isAssignableFrom(BlobType.class));
    BlobType blobRead = (BlobType)lob;
    assertTrue(Arrays.equals(ObjectConverterUtil.convertToByteArray(blob.getBinaryStream()), ObjectConverterUtil.convertToByteArray(blobRead.getBinaryStream())));
View Full Code Here

Examples of org.teiid.core.types.ClobType

    public static Clob toChars(BlobType value, String encoding) {
      Charset cs = getCharset(encoding);
    BlobInputStreamFactory bisf = new BlobInputStreamFactory(value.getReference());
      ClobImpl clob = new ClobImpl(bisf, -1);
      clob.setCharset(cs);
      return new ClobType(clob);
    }
View Full Code Here

Examples of org.teiid.core.types.ClobType

   
   
  @Test public void testInvokeXslTransform() throws Exception {
        CommandContext c = new CommandContext();
        c.setBufferManager(BufferManagerFactory.getStandaloneBufferManager());
        ClobType result = (ClobType)helpInvokeMethod("xsltransform", new Class<?>[] {DataTypeManager.DefaultDataClasses.XML, DataTypeManager.DefaultDataClasses.XML},
            new Object[] {DataTypeManager.transformValue("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Catalogs xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Catalog><Items><Item ItemID=\"001\"><Name>Lamp</Name><Quantity>5</Quantity></Item></Items></Catalog></Catalogs>", DataTypeManager.DefaultDataClasses.XML),
            DataTypeManager.transformValue("<?xml version=\"1.0\" encoding=\"UTF-8\"?><xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"><xsl:template match=\"@*|node()\"><xsl:copy><xsl:apply-templates select=\"@*|node()\"/></xsl:copy></xsl:template><xsl:template match=\"Quantity\"/></xsl:stylesheet>", DataTypeManager.DefaultDataClasses.XML)}, c);
       
        String xml = ObjectConverterUtil.convertToString(result.getCharacterStream());
        assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Catalogs xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Catalog><Items><Item ItemID=\"001\"><Name>Lamp</Name></Item></Items></Catalog></Catalogs>", xml);
    }
View Full Code Here

Examples of org.teiid.core.types.ClobType

    String string = result.getSubString(1, (int)result.length());
    assertEquals("hello world", string);
  }
 
  @Test public void testToBytes() throws Exception {
    Blob result = (Blob)helpInvokeMethod("to_bytes", new Class<?>[] {DefaultDataClasses.CLOB, DefaultDataClasses.STRING}, new Object[] { new ClobType(new SerialClob("hello world".toCharArray())), "UTF32" }, null); //$NON-NLS-1$
    assertEquals(44, result.length()); //4 bytes / char
  }
View Full Code Here

Examples of org.teiid.core.types.ClobType

    String string = result.getSubString(1, (int)result.length());
    assertEquals("68656C6C6F20776F726C64", string);
  }
 
  @Test public void testToBytes2() throws Exception {
    Blob result = (Blob)helpInvokeMethod("to_bytes", new Class<?>[] {DefaultDataClasses.CLOB, DefaultDataClasses.STRING}, new Object[] { new ClobType(new SerialClob("68656C6C6F20776F726C64".toCharArray())), "HEX" }, null); //$NON-NLS-1$
    assertEquals("hello world", new String(ObjectConverterUtil.convertToCharArray(result.getBinaryStream(), -1, "ASCII")));
  }
View Full Code Here

Examples of org.teiid.core.types.ClobType

    Blob result = (Blob)helpInvokeMethod("to_bytes", new Class<?>[] {DefaultDataClasses.CLOB, DefaultDataClasses.STRING}, new Object[] { new ClobType(new SerialClob("68656C6C6F20776F726C64".toCharArray())), "HEX" }, null); //$NON-NLS-1$
    assertEquals("hello world", new String(ObjectConverterUtil.convertToCharArray(result.getBinaryStream(), -1, "ASCII")));
  }
 
  @Test(expected=FunctionExecutionException.class) public void testToBytes3() throws Exception {
    helpInvokeMethod("to_bytes", new Class<?>[] {DefaultDataClasses.CLOB, DefaultDataClasses.STRING}, new Object[] { new ClobType(new SerialClob("a".toCharArray())), "BASE64" }, null); //$NON-NLS-1$
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.