Package com.thoughtworks.proxy.toys.echo

Source Code of com.thoughtworks.proxy.toys.echo.CglibEchoingTest

/*
* Copyright (C) 2005 J�rg Schaible
* Created on 23.07.2005 by J�rg Schaible
*/
package com.thoughtworks.proxy.toys.echo;

import com.thoughtworks.proxy.ProxyFactory;
import com.thoughtworks.proxy.ProxyTestCase;
import com.thoughtworks.proxy.factory.CglibProxyFactory;

import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;


public class CglibEchoingTest extends ProxyTestCase {
    protected ProxyFactory createProxyFactory() {
        return new CglibProxyFactory();
    }

    public void testShouldProxyRealInstance() {
        final StringWriter out = new StringWriter();
        final List list = (List)Echoing.object(List.class, new ArrayList(), new PrintWriter(out), createProxyFactory());
        list.add(new File("."));
        final File file = (File)list.get(0);
        file.exists();
        assertContains("java.io.File.exists()", out);
    }

    private static void assertContains(String expected, Object textObject) {
        String text = textObject.toString();
        assertTrue("Expected [" + expected + "] in text:\n[" + text + "]", text.indexOf(expected) != -1);
    }
}
TOP

Related Classes of com.thoughtworks.proxy.toys.echo.CglibEchoingTest

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.