Package org.apache.wicket.core.util.objects.checker

Examples of org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream


  {
    Logger logger = LogManager.getLogger(CheckingObjectOutputStream.class);
    logger.setLevel(Level.WARN);
    Log4jEventHistory logHistory = new Log4jEventHistory();
    logger.addAppender(logHistory);
    CheckingObjectOutputStream checker = new CheckingObjectOutputStream(new ByteArrayOutputStream(),
        new ObjectSerializationChecker(new NotSerializableException()));
    try
    {
      checker.writeObject(new TestType1());
      String expectedMessage = "Wasn't possible to check the object 'class org.apache.wicket.util.io.SerializableCheckerTest$ProblematicType' possible due an problematic implementation of equals method";
      assertTrue(logHistory.contains(Level.WARN, expectedMessage));
    }
    catch (TestException notMeaningfulException)
    {
View Full Code Here


   * @throws IOException
   */
  @Test
  public void nonSerializableTypeDetection() throws IOException
  {
    CheckingObjectOutputStream checker = new CheckingObjectOutputStream(new ByteArrayOutputStream(),
      new ObjectSerializationChecker(new NotSerializableException()));
    String exceptionMessage = null;
    try
    {
      checker.writeObject(new TestType2());
    }
    catch (CheckingObjectOutputStream.ObjectCheckException e)
    {
      exceptionMessage = e.getMessage();
    }
View Full Code Here

   * @throws IOException
   */
  @Test
  public void valueMap() throws IOException
  {
    CheckingObjectOutputStream checker = new CheckingObjectOutputStream(new ByteArrayOutputStream(),
        new ObjectSerializationChecker(new NotSerializableException()));
    checker.writeObject(new ValueMap());
  }
View Full Code Here

      catch (NotSerializableException nsx)
      {
        if (CheckingObjectOutputStream.isAvailable())
        {
          // trigger serialization again, but this time gather some more info
          CheckingObjectOutputStream checkingObjectOutputStream =
              new CheckingObjectOutputStream(outputStream, new ObjectSerializationChecker(nsx));
          checkingObjectOutputStream.writeObject(obj);

          // if we get here, we didn't fail, while we should
          throw nsx;
        }
        throw nsx;
View Full Code Here

    {
      @Override
      protected ObjectOutputStream newObjectOutputStream(OutputStream out) throws IOException
      {
        IObjectChecker checker = new NotDetachedModelChecker();
        return new CheckingObjectOutputStream(out, checker);
      }
    };

    IModel<String> model = new NotDetachedModel();
    model.getObject();
View Full Code Here

  {
    JavaSerializer serializer = new JavaSerializer("JavaSerializerTest-normal") {
      @Override
      protected ObjectOutputStream newObjectOutputStream(OutputStream out) throws IOException
      {
        return new CheckingObjectOutputStream(out);
      }
    };
    byte[] bytes = serializer.serialize("Something to serialize");
    assertEquals(57, bytes.length);
  }
View Full Code Here

TOP

Related Classes of org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream

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.