### Question:
SampleQueue implements TrackOutput { protected final void invalidateUpstreamFormatAdjustment() { pendingUpstreamFormatAdjustment = true; } SampleQueue(Allocator allocator, DrmSessionManager<?> drmSessionManager); @CallSuper void release(); final void reset(); @CallSuper void reset(boolean resetUpstreamFormat); final void sourceId(int sourceId); final void splice(); final int getWriteIndex(); final void discardUpstreamSamples(int discardFromIndex); @CallSuper void preRelease(); @CallSuper void maybeThrowError(); final int getFirstIndex(); final int getReadIndex(); final synchronized int peekSourceId(); final synchronized Format getUpstreamFormat(); final synchronized long getLargestQueuedTimestampUs(); final synchronized boolean isLastSampleQueued(); final synchronized long getFirstTimestampUs(); @SuppressWarnings("ReferenceEquality") // See comments in setUpstreamFormat @CallSuper synchronized boolean isReady(boolean loadingFinished); @CallSuper int read(
      FormatHolder formatHolder,
      DecoderInputBuffer buffer,
      boolean formatRequired,
      boolean loadingFinished,
      long decodeOnlyUntilUs); final synchronized boolean seekTo(int sampleIndex); final synchronized boolean seekTo(long timeUs, boolean allowTimeBeyondBuffer); final synchronized int advanceTo(long timeUs); final synchronized int advanceToEnd(); final void discardTo(long timeUs, boolean toKeyframe, boolean stopAtReadPosition); final void discardToRead(); final void discardToEnd(); final void setSampleOffsetUs(long sampleOffsetUs); final void setUpstreamFormatChangeListener(UpstreamFormatChangedListener listener); @Override final void format(Format unadjustedUpstreamFormat); @Override final int sampleData(ExtractorInput input, int length, boolean allowEndOfInput); @Override final void sampleData(ParsableByteArray buffer, int length); @Override final void sampleMetadata(
      long timeUs,
      @C.BufferFlags int flags,
      int size,
      int offset,
      @Nullable CryptoData cryptoData); synchronized long discardSampleMetadataToRead();  }### Answer:
@Test public void testInvalidateUpstreamFormatAdjustment() { AtomicReference<String> label = new AtomicReference<>("label1"); sampleQueue = new SampleQueue(allocator, mockDrmSessionManager) { @Override public Format getAdjustedUpstreamFormat(Format format) { return super.getAdjustedUpstreamFormat(format.copyWithLabel(label.get())); } }; writeFormat(FORMAT_1); writeSample(DATA, 0, BUFFER_FLAG_KEY_FRAME); label.set("label2"); sampleQueue.invalidateUpstreamFormatAdjustment(); writeSample(DATA, 1, 0); assertReadFormat( false, FORMAT_1.copyWithLabel("label1")); assertReadSample( 0, true, false, DATA, 0, DATA.length); assertReadFormat( false, FORMAT_1.copyWithLabel("label2")); assertReadSample( 1, false, false, DATA, 0, DATA.length); assertReadEndOfStream( false); }