Java tutorial
/* * Copyright 2007 Xebia and the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.amazon.webservices.awsecommerceservice._2007_07_16; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNotNull; import java.util.Map; import javax.xml.ws.BindingProvider; import org.junit.BeforeClass; 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; /** * @author <a href="mailto:cyrille.leclerc@pobox.com">Cyrille Le Clerc</a> */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:applicationContext.xml" }) public class AWSECommerceServiceSpringTest { static { System.err.println("set validation mode"); System.setProperty("org.apache.spring.validation.mode", "VALIDATION_NONE"); } @Autowired AWSECommerceServicePortType awseCommerceServicePortType; @Autowired ApplicationContext applicationContext; public void setAwseCommerceServicePortType(AWSECommerceServicePortType awseCommerceServicePortType) { this.awseCommerceServicePortType = awseCommerceServicePortType; } @Test public void testItemSearch() throws Exception { assertNotNull(this.awseCommerceServicePortType); for (String beanName : applicationContext.getBeanDefinitionNames()) { System.out.println("bean : " + beanName); } Map<String, Object> requestContext = ((BindingProvider) awseCommerceServicePortType).getRequestContext(); String endPointUrl = (String) requestContext.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY); assertEquals("endpointUrl", "http://localhost:8080/cxf-demo/services/AWSECommerceService", endPointUrl); ItemSearchRequest itemSearchRequest = new ItemSearchRequest(); itemSearchRequest.setSearchIndex("Books"); itemSearchRequest.setPower("title"); itemSearchRequest.setSort("salesrank"); ItemSearch itemSearch = new ItemSearch(); itemSearch.setSubscriptionId("0525E2PQ81DD7ZTWTK82"); itemSearch.setShared(itemSearchRequest); ItemSearchResponse itemSearchResponse = awseCommerceServicePortType.itemSearch(itemSearch); System.out.println("RESPONSE : " + itemSearchResponse); } }