@Before public void setUp() throws IOException { URL url = new URL("http://www.last.fm/"); when(mockDestination.getPath()).thenReturn(url); when(mockHttpFactory.newConnection(url)).thenReturn(mockHttpConnection); when(mockHttpConnection.getInputStream()).thenReturn(mockInputStream); when(mockHttpConnection.getOutputStream()).thenReturn(mockOutputStream); when(mockHttpConnection.getResponseMessage()).thenReturn("message"); when(mockHttpConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_OK); when(mockTrackerFactory.getTracker()).thenReturn(mockTracker); when(address.size()).thenReturn(1); when(mockTrackerFactory.getAddresses()).thenReturn(address); stream = new FileUploadOutputStream( mockTrackerFactory, mockHttpFactory, KEY, DOMAIN, mockDestination, mockWriteLock); }
Executor(TrackerFactory trackerFactory) { this.trackerFactory = trackerFactory; maxAttempts = trackerFactory.getAddresses().size(); }