Package nexj.core.util

Examples of nexj.core.util.Binary


            convertColumnType((Primitive)array[i], false, (Primitive)array[j], false, array[i + 1]);
         }
      }

      // Binary conversion only supported to/from String
      Binary bin = new Binary(new byte[]{1,2,3});

      convertColumnType(Primitive.BINARY, false, Primitive.STRING, false, bin);
      convertColumnType(Primitive.BINARY, true, Primitive.STRING, true, bin);
      convertColumnType(Primitive.STRING, false, Primitive.BINARY, false, "abcd");
      convertColumnType(Primitive.STRING, true, Primitive.BINARY, true, "abcd");
View Full Code Here


   /**
    * Tests parsing of a file created by 7Zip.
    */
   public void testFrom7ZipFile() throws Exception
   {
      Binary zipBin = Binary.parse("504b03040a0000000000756f44380000" +
                   "00000000000000000000090000007365" +
                   "696e66656c642f504b03040a00000000" +
                   "00756f44380000000000000000000000" +
                   "00140000007365696e66656c642f6368" +
                   "61726163746572732f504b03040a0000" +
                   "000000656f4438d49ad5361300000013" +
                   "0000001e0000007365696e66656c642f" +
                   "636861726163746572732f67656f7267" +
                   "652e747874436f6e74656e7473206f66" +
                   "2067656f7267652e504b03040a000000" +
                   "0000676f4438f96918f2120000001200" +
                   "00001d0000007365696e66656c642f63" +
                   "6861726163746572732f6a657272792e" +
                   "747874436f6e74656e7473206f66206a" +
                   "657272792e504b010214000a00000000" +
                   "00756f44380000000000000000000000" +
                   "00090000000000000000001000000000" +
                   "0000007365696e66656c642f504b0102" +
                   "14000a0000000000756f443800000000" +
                   "00000000000000001400000000000000" +
                   "000010000000270000007365696e6665" +
                   "6c642f636861726163746572732f504b" +
                   "010214000a0000000000656f4438d49a" +
                   "d53613000000130000001e0000000000" +
                   "0000000020000000590000007365696e" +
                   "66656c642f636861726163746572732f" +
                   "67656f7267652e747874504b01021400" +
                   "0a0000000000676f4438f96918f21200" +
                   "0000120000001d000000000000000000" +
                   "20000000a80000007365696e66656c64" +
                   "2f636861726163746572732f6a657272" +
                   "792e747874504b050600000000040004" +
                   "0010010000f500000000000a");

      TransferObject root = m_parser.parse(new ObjectInput(zipBin), m_message);
      List filesList = (List)root.getValue("files");

      assertEquals("Zip_AllMapped", root.getClassName());
      assertNotNull(filesList);
      assertEquals(4, filesList.size());

      TransferObject file;

      file = (TransferObject)filesList.get(0);
      assertEquals("seinfeld" + SysUtil.FILE_SEP, file.getValue("fileName"));
      assertTrue(((Boolean)file.getValue("isDirectory")).booleanValue());
      assertEquals(0, ((Long)file.getValue("fileSize")).longValue());
      assertNull(file.getValue("data"));

      file = (TransferObject)filesList.get(1);
      assertEquals("seinfeld" + SysUtil.FILE_SEP + "characters"  + SysUtil.FILE_SEP, file.getValue("fileName"));
      assertTrue(((Boolean)file.getValue("isDirectory")).booleanValue());
      assertEquals(0, ((Long)file.getValue("fileSize")).longValue());
      assertNull(file.getValue("data"));

      file = (TransferObject)filesList.get(2);
      assertEquals("seinfeld" + SysUtil.FILE_SEP + "characters" + SysUtil.FILE_SEP + "george.txt", file.getValue("fileName"));
      assertFalse(((Boolean)file.getValue("isDirectory")).booleanValue());
      assertEquals(19, ((Long)file.getValue("fileSize")).longValue());
      assertEquals(new Binary("Contents of george.".getBytes("UTF-8")), file.getValue("data"));

      file = (TransferObject)filesList.get(3);
      assertEquals("seinfeld" + SysUtil.FILE_SEP + "characters" + SysUtil.FILE_SEP + "jerry.txt", file.getValue("fileName"));
      assertFalse(((Boolean)file.getValue("isDirectory")).booleanValue());
      assertEquals(18, ((Long)file.getValue("fileSize")).longValue());
      assertEquals(new Binary("Contents of jerry.".getBytes("UTF-8")), file.getValue("data"));
   }
View Full Code Here

      TransferObject file;

      file = (TransferObject)filesList.get(0);
      assertEquals("a", file.getValue("fileName"));
      assertEquals(new Binary("Contents of file a.".getBytes("UTF-8")), file.getValue("data"));
      assertEquals(19, ((Long)file.getValue("fileSize")).longValue());
      assertFalse(((Boolean)file.getValue("isDirectory")).booleanValue());
      assertNull(file.getValue("extra"));

      file = (TransferObject)filesList.get(1);
      assertEquals("b" + SysUtil.FILE_SEP, file.getValue("fileName"));
      assertTrue(((Boolean)file.getValue("isDirectory")).booleanValue());
      assertNull(file.getValue("data"));

      file = (TransferObject)filesList.get(2);
      assertEquals("b" + SysUtil.FILE_SEP + "c", file.getValue("fileName"));
      assertEquals(new Binary("Contents of file c in directory b.".getBytes("UTF-8")), file.getValue("data"));
      assertEquals(34, ((Long)file.getValue("fileSize")).longValue());
      assertFalse(((Boolean)file.getValue("isDirectory")).booleanValue());
      assertNull(file.getValue("extra"));
   }
View Full Code Here

      TransferObject file;

      file = (TransferObject)filesList.get(0);
      assertEquals("a", file.getValue("fileName"));
      assertEquals(new Binary("Contents of file a.".getBytes("UTF-8")), file.getValue("data"));
      assertFalse(((Boolean)file.getValue("isDirectory")).booleanValue());
      assertNull(file.getValue("extra"));

      file = (TransferObject)filesList.get(1);
      assertEquals("b" + SysUtil.FILE_SEP, file.getValue("fileName"));
      assertTrue(((Boolean)file.getValue("isDirectory")).booleanValue());
      assertNull(file.getValue("data"));

      file = (TransferObject)filesList.get(2);
      assertEquals("b" + SysUtil.FILE_SEP + "c", file.getValue("fileName"));
      assertEquals(new Binary("Contents of file c in directory b.".getBytes("UTF-8")), file.getValue("data"));
      assertFalse(((Boolean)file.getValue("isDirectory")).booleanValue());
      assertNull(file.getValue("extra"));
   }
View Full Code Here

      contact.setValue("float", new Float(0.625f));
      contact.setValue("double", new Double(1.625));
      contact.setValue("decimal", new BigDecimal("1.2345"));
      contact.setValue("timestamp", new Timestamp(12345));
      contact.setValue("boolean", Boolean.TRUE);
      contact.setValue("binary", new Binary(new byte[]{1, 2, 3, 4, 5}));
      contact.setValue("binary2", new Binary(new byte[]{1, 2, 3, 4, 5, 6, 7}));
      contact.setValue("binary3", new Binary(new byte[]{1, 2}));
      contact.setValue("symbol", Symbol.define("sym"));
      contact.setValue("pair", new Pair("A", new Pair("B")));
      contact.setValue("cvector", new char[]{'a', 'b', 'c'});
      contact.setValue("bvector", new byte[]{0, (byte)0xAB, 0x12});
      contact.setValue("svector", new String[]{"a", "b", "c"});
View Full Code Here

      assertEquals(new Float(0.625f), contact.getValue("float"));
      assertEquals(new Double(1.625), contact.getValue("double"));
      assertEquals(new BigDecimal("1.2345"), contact.getValue("decimal"));
      assertEquals(new Timestamp(12345), contact.getValue("timestamp"));
      assertEquals(Boolean.TRUE, contact.getValue("boolean"));
      assertEquals(new Binary(new byte[]{1, 2, 3, 4, 5}), contact.getValue("binary"));
      assertEquals(new Binary(new byte[]{1, 2, 3, 4, 5, 6, 7}), contact.getValue("binary2"));
      assertEquals(new Binary(new byte[]{1, 2}), contact.getValue("binary3"));
      assertEquals("sym", ((Symbol)contact.getValue("symbol")).getName());
      assertSame(Symbol.define("sym"), contact.getValue("symbol"));
     
      Pair pairA = (Pair)contact.getValue("pair");
      assertEquals("A", pairA.getHead());
View Full Code Here

     
      checkAttach(fConn, "data1");
      assertFalse(new File(m_outgoingDirectory, "data1").exists());
     
      byte[] data = new byte[] {0x41, 0x42, 0x43, 0x00, (byte)0xFF, 0x0d, 0x0a};
      fConn.write(new Binary(data));
     
      assertFalse(new File(m_outgoingDirectory, "data1").exists());
      assertTrue(new File(m_outgoingTempDirectory, "data1").exists());

     
View Full Code Here

      checkAttach(fConn, "data1");
      assertFalse(new File(m_outgoingDirectory, "data1").exists());

      byte[] data = new byte[] {0x41, 0x42, 0x43, 0x00, (byte)0xFF, 0x0d, 0x0a};
      fConn.write(new Binary(data));

      assertFalse(new File(m_outgoingDirectory, "data1").exists());
      assertTrue(new File(m_outgoingTempDirectory, "data1").exists());

View Full Code Here

      txT.enlistResource(xar);
     
      checkAttach(fConn, "data1");
     
      byte[] data = new byte[] {0x41, 0x42, 0x43, 0x00, (byte)0xFF, 0x0d, 0x0a};
      fConn.write(new Binary(data));
     
      assertTrue(new File(m_outgoingTempDirectory, "data1").exists());

     
      //Now unattach
View Full Code Here

      FileConnection fConn = connection.getConnection();

      checkAttach(fConn, "data1");

      byte[] data = new byte[] {0x41, 0x42, 0x43, 0x00, (byte)0xFF, 0x0d, 0x0a};
      fConn.write(new Binary(data));

      assertTrue(new File(m_outgoingTempDirectory, "data1").exists());


      //Now unattach (no transaction case does commit here)
View Full Code Here

TOP

Related Classes of nexj.core.util.Binary

Copyright © 2018 www.massapicom. 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.