@Override public String getNamespacePrefix() { return getString(NAMESPACE_PREFIX_KEY); }
/** * @throws MalformedURLException * @see AdsServiceDescriptor#getEndpointAddress(String) */ @Override public String getEndpointAddress(String endpointServer) throws MalformedURLException { String serviceName = getServiceName(); String endpointServerUrl = new URL(endpointServer).toString(); if (endpointServerUrl.endsWith("/")) { endpointServerUrl = endpointServerUrl.substring(0, endpointServerUrl.length() - 1); } return endpointServerUrl + "/api/adwords/" + apiConfig.getServiceUrlGroup(version, serviceName) + "/" + version + "/" + serviceName; }
@Override protected void configure() { super.configure(); configureConfigurations(AdWordsApiConfiguration.class, Lists.<URL>newArrayList(AdWordsConfigurationModule.class .getResource("props/adwords-api.properties")), null, AdWordsLibConfiguration.class, null, null, Lists.<URL>newArrayList(AdWordsConfigurationModule.class .getResource("props/build.properties"))); } }
@Test public void testJarApiPropertiesFileIncludedInConfig() throws Exception { AdWordsApiConfiguration config = Guice.createInjector( new AdWordsModule()).getInstance(AdWordsApiConfiguration.class); assertEquals("https://adwords.google.com/api/adwords", config.getNamespacePrefix()); } }
/** * Constructor used by Guice. * * @param session Used to pull authentication data. * @param authorizationHeaderProvider Used to population the authentication data into a header. * @param userAgentCombiner Used to populate the User-Agent header. * @param adWordsLibConfiguration Used to obtain configuration options affecting report requests. * @param responseInterceptor Response interceptor to use for requests generated by this factory * helper. */ @Inject ReportRequestFactoryHelper(AdWordsSession session, AuthorizationHeaderProvider authorizationHeaderProvider, UserAgentCombiner userAgentCombiner, HttpTransport httpTransport, AdWordsLibConfiguration adWordsLibConfiguration, ReportResponseInterceptor responseInterceptor) { this.session = session; this.authorizationHeaderProvider = authorizationHeaderProvider; this.userAgentCombiner = userAgentCombiner; this.httpTransport = httpTransport; this.reportDownloadTimeout = (session.getReportingConfiguration() != null && session.getReportingConfiguration().getReportDownloadTimeout() != null) ? session.getReportingConfiguration().getReportDownloadTimeout() : adWordsLibConfiguration.getReportDownloadTimeout(); this.responseInterceptor = responseInterceptor; }
@Test public void testPropertyFileIncludedInConfig() throws Exception { File adsPropertiesFile = createPropertiesFile(); System.setProperty("user.home", adsPropertiesFile.getParentFile().getAbsolutePath()); AdWordsLibConfiguration config = Guice.createInjector(new AdWordsModule()).getInstance(AdWordsLibConfiguration.class); assertFalse(config.isAutoRefreshOAuth2TokenEnabled()); }
@Override protected void configure() { super.configure(); configureLogging(AdWordsServiceClient.class.getName()); install(new AdWordsConfigurationModule()); bind(HttpTransport.class).to(NetHttpTransport.class); bind(XmlFieldExtractor.class); }
AdWordsServiceDescriptor adWordsServiceDescriptor) { String requestHeaderNamespace = adWordsApiConfiguration.getNamespacePrefix() + "/" + adWordsServiceDescriptor.getPackageGroup() + "/" + adWordsServiceDescriptor.getVersion(); adWordsApiConfiguration.getNamespacePrefix() + "/cm/" + adWordsServiceDescriptor.getVersion();
/** * Constructor used by Guice. * * @param session Used to pull authentication data. * @param authorizationHeaderProvider Used to population the authentication data into a header. * @param userAgentCombiner Used to populate the User-Agent header. * @param adWordsLibConfiguration Used to obtain configuration options affecting report requests. * @param responseInterceptor Response interceptor to use for requests generated by this factory * helper. */ @Inject ReportRequestFactoryHelper(AdWordsSession session, AuthorizationHeaderProvider authorizationHeaderProvider, UserAgentCombiner userAgentCombiner, HttpTransport httpTransport, AdWordsLibConfiguration adWordsLibConfiguration, ReportResponseInterceptor responseInterceptor) { this.session = session; this.authorizationHeaderProvider = authorizationHeaderProvider; this.userAgentCombiner = userAgentCombiner; this.httpTransport = httpTransport; this.reportDownloadTimeout = (session.getReportingConfiguration() != null && session.getReportingConfiguration().getReportDownloadTimeout() != null) ? session.getReportingConfiguration().getReportDownloadTimeout() : adWordsLibConfiguration.getReportDownloadTimeout(); this.responseInterceptor = responseInterceptor; }
@Override public String getNamespacePrefix() { return getString(NAMESPACE_PREFIX_KEY); }
/** * @throws MalformedURLException * @see AdsServiceDescriptor#getEndpointAddress(String) */ @Override public String getEndpointAddress(String endpointServer) throws MalformedURLException { String serviceName = getServiceName(); String endpointServerUrl = new URL(endpointServer).toString(); if (endpointServerUrl.endsWith("/")) { endpointServerUrl = endpointServerUrl.substring(0, endpointServerUrl.length() - 1); } return endpointServerUrl + "/api/adwords/" + apiConfig.getServiceUrlGroup(version, serviceName) + "/" + version + "/" + serviceName; }
@Override protected void configure() { super.configure(); configureConfigurations(AdWordsApiConfiguration.class, Lists.<URL>newArrayList(AdWordsConfigurationModule.class .getResource("props/adwords-api.properties")), null, AdWordsLibConfiguration.class, null, null, Lists.<URL>newArrayList(AdWordsConfigurationModule.class .getResource("props/build.properties"))); } }
@Override protected void configure() { super.configure(); configureLogging(AdWordsServiceClient.class.getName()); install(new AdWordsConfigurationModule()); bind(HttpTransport.class).to(NetHttpTransport.class); bind(XmlFieldExtractor.class); }
adWordsApiConfiguration.getNamespacePrefix() + "/" + adWordsServiceDescriptor.getPackageGroup() + "/" + adWordsServiceDescriptor.getVersion();
/** * Tests that {@link AdHocReportDownloadHelper#getReportDownloadTimeout()} retrieves the global * timeout if not set on the helper. */ @Test public void testGetReportDownloadTimeout() { assertEquals( AdWordsInternals.getInstance().getAdWordsLibConfiguration().getReportDownloadTimeout(), helper.getReportDownloadTimeout()); }
adWordsApiConfiguration.getNamespacePrefix() + "/" + adWordsServiceDescriptor.getPackageGroup() + "/" + adWordsServiceDescriptor.getVersion();
/** * Tests that {@link AdHocReportDownloadHelper#setReportDownloadTimeout(int)} sets the * helper-specific timeout and does not affect the global timeout. */ @Test public void testSetReportDownloadTimeout() { int internalsTimeout = AdWordsInternals.getInstance().getAdWordsLibConfiguration().getReportDownloadTimeout(); assertEquals(internalsTimeout, helper.getReportDownloadTimeout()); int helperTimeout = internalsTimeout + 10; helper.setReportDownloadTimeout(helperTimeout); assertEquals("Timeout on helper does not reflect changes made via setReportDownloadTimeout", helperTimeout, helper.getReportDownloadTimeout()); assertEquals("Setting the timeout on a helper instance modified the global timeout", internalsTimeout, AdWordsInternals.getInstance().getAdWordsLibConfiguration().getReportDownloadTimeout()); }
throws ValidationException, AuthenticationException, IOException { final int timeoutFromLibConfig = 42; when(adWordsLibConfiguration.getReportDownloadTimeout()).thenReturn(timeoutFromLibConfig); AdWordsSession session = new AdWordsSession.Builder()