/** * Creates a {@code RemoteLoggingHelper} object for the given project id and JSON key input * stream. * * @param projectId id of the project to be used for running the tests * @param keyStream input stream for a JSON key * @return A {@code RemoteLoggingHelper} object for the provided options * @throws com.google.cloud.logging.testing.RemoteLoggingHelper.LoggingHelperException if {@code * keyStream} is not a valid JSON key stream */ public static RemoteLoggingHelper create(String projectId, InputStream keyStream) throws LoggingHelperException { try { GrpcTransportOptions transportOptions = LoggingOptions.getDefaultGrpcTransportOptions(); LoggingOptions storageOptions = LoggingOptions.newBuilder() .setCredentials(ServiceAccountCredentials.fromStream(keyStream)) .setProjectId(projectId) .setRetrySettings(retrySettings()) .setTransportOptions(transportOptions) .build(); return new RemoteLoggingHelper(storageOptions); } catch (IOException ex) { if (log.isLoggable(Level.WARNING)) { log.log(Level.WARNING, ex.getMessage()); } throw LoggingHelperException.translate(ex); } }
@Test public void testInvalidTransport() { thrown.expect(IllegalArgumentException.class); LoggingOptions.newBuilder().setTransportOptions(EasyMock.createMock(TransportOptions.class)); } }
/** * Creates a {@code RemoteLoggingHelper} object for the given project id and JSON key input * stream. * * @param projectId id of the project to be used for running the tests * @param keyStream input stream for a JSON key * @return A {@code RemoteLoggingHelper} object for the provided options * @throws com.google.cloud.logging.testing.RemoteLoggingHelper.LoggingHelperException if {@code * keyStream} is not a valid JSON key stream */ public static RemoteLoggingHelper create(String projectId, InputStream keyStream) throws LoggingHelperException { try { GrpcTransportOptions transportOptions = LoggingOptions.getDefaultGrpcTransportOptions(); LoggingOptions storageOptions = LoggingOptions.newBuilder() .setCredentials(ServiceAccountCredentials.fromStream(keyStream)) .setProjectId(projectId) .setRetrySettings(retrySettings()) .setTransportOptions(transportOptions) .build(); return new RemoteLoggingHelper(storageOptions); } catch (IOException ex) { if (log.isLoggable(Level.WARNING)) { log.log(Level.WARNING, ex.getMessage()); } throw LoggingHelperException.translate(ex); } }
/** * Creates a {@code RemoteLoggingHelper} object using default project id and authentication * credentials. */ public static RemoteLoggingHelper create() throws LoggingHelperException { GrpcTransportOptions transportOptions = LoggingOptions.getDefaultGrpcTransportOptions(); LoggingOptions loggingOptions = LoggingOptions.newBuilder() .setRetrySettings(retrySettings()) .setTransportOptions(transportOptions) .build(); return new RemoteLoggingHelper(loggingOptions); }
LoggingOptions.newBuilder() .setProjectId("p1") .setTransportOptions(transportOptions) .build(); return new Serializable[] {
/** * Creates a {@code RemoteLoggingHelper} object using default project id and authentication * credentials. */ public static RemoteLoggingHelper create() throws LoggingHelperException { GrpcTransportOptions transportOptions = LoggingOptions.getDefaultGrpcTransportOptions(); LoggingOptions loggingOptions = LoggingOptions.newBuilder() .setRetrySettings(retrySettings()) .setTransportOptions(transportOptions) .build(); return new RemoteLoggingHelper(loggingOptions); }