core.service.test.proxy.TestServiceProxy.java Source code

Java tutorial

Introduction

Here is the source code for core.service.test.proxy.TestServiceProxy.java

Source

/**
 * Copyright 2009 Core Information Solutions LLC
 *
 * This file is part of Core Service Framework.
 *
 * Core Service Framework is free software: you can redistribute it 
 * and/or modify it under the terms of the GNU General Public License 
 * as published by the Free Software Foundation, either version 3 of 
 * the License, or (at your option) any later version.
 *
 * Core Service Framework is distributed in the hope that it will be
 * useful, but WITHOUT ANY WARRANTY; without even the implied 
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Core Service Framework.  If not, see 
 * <http://www.gnu.org/licenses/>.
 */
package core.service.test.proxy;

import junit.framework.Assert;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import core.service.proxy.ServiceProxy;
import core.service.test.mock.MathService;
import core.tooling.property.SystemPropertyFileReader;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "/test-core-service-context.xml")
public class TestServiceProxy {
    @Autowired
    private ApplicationContext context;

    @Before
    public void setup() {
    }

    @Test
    public void testInvoke() {

        MathService proxy = (MathService) ServiceProxy.newInstance(MathService.class, context);
        Integer sum = proxy.add(2, 2);

        Assert.assertEquals(new Integer(4), sum);
    }

}