Example usage for java.util.concurrent.atomic AtomicReference AtomicReference

List of usage examples for java.util.concurrent.atomic AtomicReference AtomicReference

Introduction

In this page you can find the example usage for java.util.concurrent.atomic AtomicReference AtomicReference.

Prototype

public AtomicReference(V initialValue) 

Source Link

Document

Creates a new AtomicReference with the given initial value.

Usage

From source file:com.machinepublishers.jbrowserdriver.JBrowserDriver.java

private String launchProcess(final Settings settings, final PortGroup portGroup) {
    final AtomicBoolean ready = new AtomicBoolean();
    final AtomicReference<String> logPrefix = new AtomicReference<String>("");
    new Thread(new Runnable() {
        @Override/* ww  w  .j  a va 2 s  .co m*/
        public void run() {
            List<String> myArgs = new ArrayList<String>();
            myArgs.add(settings.javaBinary() == null ? JAVA_BIN : settings.javaBinary());
            myArgs.addAll(inheritedArgs);
            if (!settings.customClasspath()) {
                myArgs.addAll(classpathArgs.get());
            }
            if (settings.javaExportModules()) {
                myArgs.add("-XaddExports:javafx.web/com.sun.webkit.network=ALL-UNNAMED");
                myArgs.add("-XaddExports:javafx.web/com.sun.webkit.network.about=ALL-UNNAMED");
                myArgs.add("-XaddExports:javafx.web/com.sun.webkit.network.data=ALL-UNNAMED");
                myArgs.add("-XaddExports:java.base/sun.net.www.protocol.http=ALL-UNNAMED");
                myArgs.add("-XaddExports:java.base/sun.net.www.protocol.https=ALL-UNNAMED");
                myArgs.add("-XaddExports:java.base/sun.net.www.protocol.file=ALL-UNNAMED");
                myArgs.add("-XaddExports:java.base/sun.net.www.protocol.ftp=ALL-UNNAMED");
                myArgs.add("-XaddExports:java.base/sun.net.www.protocol.jar=ALL-UNNAMED");
                myArgs.add("-XaddExports:java.base/sun.net.www.protocol.mailto=ALL-UNNAMED");
                myArgs.add("-XaddExports:javafx.graphics/com.sun.glass.ui=ALL-UNNAMED");
                myArgs.add("-XaddExports:javafx.web/com.sun.javafx.webkit=ALL-UNNAMED");
                myArgs.add("-XaddExports:javafx.web/com.sun.webkit=ALL-UNNAMED");
            }
            myArgs.add("-Djava.io.tmpdir=" + tmpDir.getAbsolutePath());
            myArgs.add("-Djava.rmi.server.hostname=" + settings.host());
            myArgs.addAll(settings.javaOptions());
            myArgs.add(JBrowserDriverServer.class.getName());
            myArgs.add(Long.toString(portGroup.child));
            myArgs.add(Long.toString(portGroup.parent));
            myArgs.add(Long.toString(portGroup.parentAlt));
            try {
                new ProcessExecutor().addListener(new ProcessListener() {
                    @Override
                    public void afterStart(Process proc, ProcessExecutor executor) {
                        process.set(proc);
                    }
                }).redirectOutput(new LogOutputStream() {
                    boolean done = false;

                    @Override
                    protected void processLine(String line) {
                        if (line != null && !line.isEmpty()) {
                            if (!done) {
                                synchronized (ready) {
                                    if (line.startsWith("ready on ports ")) {
                                        String[] parts = line.substring("ready on ports ".length()).split("/");
                                        actualPortGroup.set(new PortGroup(Integer.parseInt(parts[0]),
                                                Integer.parseInt(parts[1]), Integer.parseInt(parts[2])));
                                        logPrefix.set(new StringBuilder().append("[Instance ")
                                                .append(sessionIdCounter.incrementAndGet()).append("][Port ")
                                                .append(actualPortGroup.get().child).append("]").toString());
                                        ready.set(true);
                                        ready.notifyAll();
                                        done = true;
                                    } else {
                                        log(settings.logger(), logPrefix.get(), line);
                                    }
                                }
                            } else {
                                log(settings.logger(), logPrefix.get(), line);
                            }
                        }
                    }
                }).redirectError(new LogOutputStream() {
                    @Override
                    protected void processLine(String line) {
                        log(settings.logger(), logPrefix.get(), line);
                    }
                }).destroyOnExit().command(myArgs).execute();
            } catch (Throwable t) {
                Util.handleException(t);
            }
            synchronized (ready) {
                ready.set(true);
                ready.notifyAll();
            }
        }
    }).start();
    synchronized (ready) {
        while (!ready.get()) {
            try {
                ready.wait();
                break;
            } catch (InterruptedException e) {
            }
        }
    }
    return logPrefix.get();
}

From source file:info.archinnov.achilles.test.integration.tests.LWTOperationsIT.java

@Test
public void should_notify_listener_when_LWT_error_on_native_query() throws Exception {
    //Given/*from w  w w  . j av a 2  s .c o  m*/
    final AtomicReference<LWTResultListener.LWTResult> atomicLWTResult = new AtomicReference(null);
    LWTResultListener listener = new LWTResultListener() {
        @Override
        public void onSuccess() {
        }

        @Override
        public void onError(LWTResult lwtResult) {
            atomicLWTResult.compareAndSet(null, lwtResult);
        }
    };
    Map<String, Object> expectedCurrentValues = ImmutableMap.<String, Object>of("[applied]", false, "name",
            "John");

    CompleteBean entity = builder().randomId().name("John").buid();
    manager.insert(entity);

    final RegularStatement statement = update("CompleteBean").with(set("name", "Helen"))
            .where(eq("id", entity.getId())).onlyIf(eq("name", "Andrew"));

    //When
    final NativeQuery nativeQuery = manager.nativeQuery(statement, lwtResultListener(listener));
    nativeQuery.execute();

    //Then
    final LWTResultListener.LWTResult LWTResult = atomicLWTResult.get();

    assertThat(LWTResult).isNotNull();
    assertThat(LWTResult.operation()).isEqualTo(UPDATE);
    assertThat(LWTResult.currentValues()).isEqualTo(expectedCurrentValues);
}

From source file:org.zodiark.service.publisher.PublisherServiceImpl.java

/**
 * {@inheritDoc}/* w ww. ja v a  2 s . c  o m*/
 */
@Override
public PublisherEndpoint createSession(final Envelope e, final AtmosphereResource r) {

    if (!e.getMessage().hasData()) {
        error(e, r, utils.errorMessage("error", e.getMessage().getUUID()));
        return null;
    }

    final String uuid = e.getUuid();
    PublisherEndpoint p = endpoints.get(uuid);
    if (p == null) {
        p = context.newInstance(PublisherEndpoint.class);
        p.uuid(uuid).resource(r);
        endpoints.put(uuid, p);
        final AtomicReference<PublisherEndpoint> publisher = new AtomicReference<>(p);
        String data = e.getMessage().getData();

        e.getMessage().setData(injectIp(r.getRequest().getRemoteAddr(), data));

        eventBus.message(DB_POST_PUBLISHER_SESSION_CREATE, new RetrieveMessage(p.uuid(), e.getMessage()),
                new Reply<Status, String>() {
                    @Override
                    public void ok(final Status status) {
                        final PublisherEndpoint p = publisher.get();
                        logger.trace("{} succeed for {}", DB_POST_PUBLISHER_SESSION_CREATE, p);

                        eventBus.message(DB_ENDPOINT_STATE, new RetrieveMessage(p.uuid(), e.getMessage()),
                                new Reply<EndpointState, String>() {
                                    @Override
                                    public void ok(EndpointState state) {
                                        p.state(state);
                                        eventBus.message(DB_PUBLISHER_AVAILABLE_ACTIONS_PASSTHROUGHT,
                                                new RetrieveMessage(p.uuid(), e.getMessage()),
                                                new Reply<String, String>() {
                                                    @Override
                                                    public void ok(String passthrough) {
                                                        utils.succesPassThrough(e, p,
                                                                DB_PUBLISHER_AVAILABLE_ACTIONS_PASSTHROUGHT,
                                                                passthrough);

                                                        eventBus.message(DB_PUBLISHER_LOAD_CONFIG_GET,
                                                                new RetrieveMessage(p.uuid(), e.getMessage()),
                                                                new Reply<String, String>() {
                                                                    @Override
                                                                    public void ok(String passthrough) {
                                                                        utils.succesPassThrough(e, p,
                                                                                DB_PUBLISHER_LOAD_CONFIG,
                                                                                passthrough);
                                                                        utils.passthroughEvent(
                                                                                DB_PUBLISHER_LOAD_CONFIG_ERROR_PASSTHROUGHT,
                                                                                e, p);
                                                                    }

                                                                    @Override
                                                                    public void fail(
                                                                            ReplyException replyException) {
                                                                        utils.failPassThrough(e, p,
                                                                                replyException);
                                                                    }
                                                                });
                                                    }

                                                    @Override
                                                    public void fail(ReplyException replyException) {
                                                        utils.failPassThrough(e, p, replyException);
                                                    }
                                                });
                                    }

                                    @Override
                                    public void fail(ReplyException replyException) {
                                        error(e, publisher.get(),
                                                utils.errorMessage("error", e.getMessage().getUUID()));
                                    }
                                });

                    }

                    @Override
                    public void fail(ReplyException replyException) {
                        error(e, publisher.get(), utils.constructMessage(DB_POST_PUBLISHER_SESSION_CREATE,
                                "error", e.getMessage().getUUID()));
                    }
                });

    }

    r.addEventListener(new OnDisconnect() {
        @Override
        public void onDisconnect(AtmosphereResourceEvent event) {
            logger.debug("Publisher {} disconnected", uuid);
            endpoints.remove(uuid);
        }
    });
    return p;
}

From source file:com.yahoo.pulsar.broker.loadbalance.SimpleLoadManagerImplTest.java

@Test(enabled = true)
public void testDoLoadShedding() throws Exception {
    LoadManager loadManager = spy(new SimpleLoadManagerImpl(pulsar1));
    PulsarResourceDescription rd = new PulsarResourceDescription();
    rd.put("memory", new ResourceUsage(1024, 4096));
    rd.put("cpu", new ResourceUsage(10, 100));
    rd.put("bandwidthIn", new ResourceUsage(250 * 1024, 1024 * 1024));
    rd.put("bandwidthOut", new ResourceUsage(550 * 1024, 1024 * 1024));

    ResourceUnit ru1 = new SimpleResourceUnit("http://prod1-broker7.messaging.gq1.yahoo.com:8080", rd);
    ResourceUnit ru2 = new SimpleResourceUnit("http://prod2-broker7.messaging.gq1.yahoo.com:8080", rd);
    Set<ResourceUnit> rus = new HashSet<ResourceUnit>();
    rus.add(ru1);//  w  ww.  j  a  v a2 s  . c  o m
    rus.add(ru2);
    LoadRanker lr = new ResourceAvailabilityRanker();
    AtomicReference<Map<Long, Set<ResourceUnit>>> sortedRankingsInstance = new AtomicReference<>(
            Maps.newTreeMap());
    sortedRankingsInstance.get().put(lr.getRank(rd), rus);

    Field sortedRankings = SimpleLoadManagerImpl.class.getDeclaredField("sortedRankings");
    sortedRankings.setAccessible(true);
    sortedRankings.set(loadManager, sortedRankingsInstance);

    // inject the load report and rankings
    SystemResourceUsage systemResource = new SystemResourceUsage();
    systemResource.setBandwidthIn(new ResourceUsage(90, 100));
    Map<String, NamespaceBundleStats> stats = Maps.newHashMap();
    NamespaceBundleStats nsb1 = new NamespaceBundleStats();
    nsb1.msgRateOut = 10000;
    NamespaceBundleStats nsb2 = new NamespaceBundleStats();
    nsb2.msgRateOut = 10000;
    stats.put("property/cluster/namespace1/0x00000000_0xFFFFFFFF", nsb1);
    stats.put("property/cluster/namespace2/0x00000000_0xFFFFFFFF", nsb2);

    Map<ResourceUnit, com.yahoo.pulsar.common.policies.data.loadbalancer.LoadReport> loadReports = new HashMap<>();
    com.yahoo.pulsar.common.policies.data.loadbalancer.LoadReport loadReport1 = new com.yahoo.pulsar.common.policies.data.loadbalancer.LoadReport();
    loadReport1.setSystemResourceUsage(systemResource);
    loadReport1.setBundleStats(stats);
    com.yahoo.pulsar.common.policies.data.loadbalancer.LoadReport loadReport2 = new com.yahoo.pulsar.common.policies.data.loadbalancer.LoadReport();
    loadReport2.setSystemResourceUsage(new SystemResourceUsage());
    loadReport2.setBundleStats(stats);
    loadReports.put(ru1, loadReport1);
    loadReports.put(ru2, loadReport2);
    setObjectField(SimpleLoadManagerImpl.class, loadManager, "currentLoadReports", loadReports);

    ((SimpleLoadManagerImpl) loadManager).doLoadShedding();
    verify(loadManager, atLeastOnce()).doLoadShedding();
}

From source file:com.netflix.discovery.shared.Applications.java

/**
 * Shuffle the instances and filter for only {@link InstanceStatus#UP} if
 * required./*from  w w w . java 2  s.  c o m*/
 *
 */
private void shuffleAndFilterInstances(Map<String, AbstractQueue<InstanceInfo>> srcMap,
        Map<String, AtomicReference<List<InstanceInfo>>> destMap, Map<String, AtomicLong> vipIndexMap,
        boolean filterUpInstances) {
    for (Map.Entry<String, AbstractQueue<InstanceInfo>> entries : srcMap.entrySet()) {
        AbstractQueue<InstanceInfo> instanceInfoQueue = entries.getValue();
        List<InstanceInfo> l = new ArrayList<InstanceInfo>(instanceInfoQueue);
        if (filterUpInstances) {
            Iterator<InstanceInfo> it = l.iterator();

            while (it.hasNext()) {
                InstanceInfo instanceInfo = it.next();
                if (!InstanceStatus.UP.equals(instanceInfo.getStatus())) {
                    it.remove();
                }
            }
        }
        Collections.shuffle(l);
        AtomicReference<List<InstanceInfo>> instanceInfoList = destMap.get(entries.getKey());
        if (instanceInfoList == null) {
            instanceInfoList = new AtomicReference<List<InstanceInfo>>(l);
            destMap.put(entries.getKey(), instanceInfoList);
        }
        instanceInfoList.set(l);
        vipIndexMap.put(entries.getKey(), new AtomicLong(0));
    }

    // finally remove all vips that are completed deleted (i.e. missing) from the srcSet
    Set<String> srcVips = srcMap.keySet();
    Set<String> destVips = destMap.keySet();
    destVips.retainAll(srcVips);
}

From source file:com.facebook.RequestTests.java

@LargeTest
public void testExecuteUploadPhotoToAlbum() throws InterruptedException, JSONException {
    // first create an album
    Bundle params = new Bundle();
    params.putString("name", "Foo");
    GraphRequest request = new GraphRequest(AccessToken.getCurrentAccessToken(), "me/albums", params,
            HttpMethod.POST);//from   w  ww.ja  va  2 s  .  c om

    GraphResponse response = request.executeAndWait();
    JSONObject jsonResponse = response.getJSONObject();
    assertNotNull(jsonResponse);
    String albumId = jsonResponse.optString("id");
    assertNotNull(albumId);

    // upload an image to the album
    Bitmap image = createTestBitmap(128);
    SharePhoto photo = new SharePhoto.Builder().setBitmap(image).setUserGenerated(true).build();
    SharePhotoContent content = new SharePhotoContent.Builder().addPhoto(photo).build();
    final ShareApi shareApi = new ShareApi(content);
    shareApi.setGraphNode(albumId);
    final AtomicReference<String> imageId = new AtomicReference<>(null);
    getActivity().runOnUiThread(new Runnable() {
        @Override
        public void run() {
            shareApi.share(new FacebookCallback<Sharer.Result>() {
                @Override
                public void onSuccess(Sharer.Result result) {
                    imageId.set(result.getPostId());
                    notifyShareFinished();
                }

                @Override
                public void onCancel() {
                    notifyShareFinished();
                }

                @Override
                public void onError(FacebookException error) {
                    notifyShareFinished();
                }

                private void notifyShareFinished() {
                    synchronized (shareApi) {
                        shareApi.notifyAll();
                    }
                }
            });
        }
    });

    synchronized (shareApi) {
        shareApi.wait(REQUEST_TIMEOUT_MILLIS);
    }
    assertNotNull(imageId.get());

    // now check to see if the image is in the album
    GraphRequest listRequest = new GraphRequest(AccessToken.getCurrentAccessToken(), albumId + "/photos");

    GraphResponse listResponse = listRequest.executeAndWait();
    JSONObject listObject = listResponse.getJSONObject();
    assertNotNull(listObject);
    JSONArray jsonList = listObject.optJSONArray("data");
    assertNotNull(jsonList);

    boolean found = false;
    for (int i = 0; i < jsonList.length(); i++) {
        JSONObject imageObject = jsonList.getJSONObject(i);
        if (imageId.get().equals(imageObject.optString("id"))) {
            found = true;
        }
    }
    assertTrue(found);
}

From source file:com.facebook.RequestTests.java

@LargeTest
public void testUploadVideoFile() throws IOException, URISyntaxException {
    File tempFile = null;/*from   ww  w  .j  a v  a2 s  .  c o  m*/
    try {
        tempFile = createTempFileFromAsset("DarkScreen.mov");
        ShareVideo video = new ShareVideo.Builder().setLocalUrl(Uri.fromFile(tempFile)).build();
        ShareVideoContent content = new ShareVideoContent.Builder().setVideo(video).build();
        final ShareApi shareApi = new ShareApi(content);
        final AtomicReference<String> videoId = new AtomicReference<>(null);
        getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                shareApi.share(new FacebookCallback<Sharer.Result>() {
                    @Override
                    public void onSuccess(Sharer.Result result) {
                        videoId.set(result.getPostId());
                        notifyShareFinished();
                    }

                    @Override
                    public void onCancel() {
                        notifyShareFinished();
                    }

                    @Override
                    public void onError(FacebookException error) {
                        notifyShareFinished();
                    }

                    private void notifyShareFinished() {
                        synchronized (shareApi) {
                            shareApi.notifyAll();
                        }
                    }
                });
            }
        });

        synchronized (shareApi) {
            shareApi.wait(REQUEST_TIMEOUT_MILLIS);
        }
        assertNotNull(videoId.get());
    } catch (Exception ex) {
        fail();
    } finally {
        if (tempFile != null) {
            tempFile.delete();
        }
    }
}

From source file:com.sm.store.client.ClusterClient.java

/**
 *
 * @param invoker/*w  ww.j av  a  2  s.co  m*/
 * @param keys
 * @return future
 */
public Future clusterStoreProcFuture(final Invoker invoker, final List<Key> keys) {
    AtomicReference<FutureTask<List<Object>>> future = new AtomicReference<FutureTask<List<Object>>>(
            new FutureTask<List<Object>>(new Callable<List<Object>>() {
                public List<Object> call() {
                    return clusterStoreProc(invoker, keys);
                }
            }));
    futureExecutor.execute(future.get());
    return future.get();
}

From source file:com.facebook.RequestTests.java

@LargeTest
public void testUploadVideoFileToUserId() throws IOException, URISyntaxException {
    File tempFile = null;/*from   www  .  j av  a2  s .co  m*/
    try {
        GraphRequest meRequest = GraphRequest.newMeRequest(AccessToken.getCurrentAccessToken(), null);
        GraphResponse meResponse = meRequest.executeAndWait();
        JSONObject meJson = meResponse.getJSONObject();
        assertNotNull(meJson);

        String userId = meJson.optString("id");
        assertNotNull(userId);

        tempFile = createTempFileFromAsset("DarkScreen.mov");
        ShareVideo video = new ShareVideo.Builder().setLocalUrl(Uri.fromFile(tempFile)).build();
        ShareVideoContent content = new ShareVideoContent.Builder().setVideo(video).build();
        final ShareApi shareApi = new ShareApi(content);
        shareApi.setGraphNode(userId);
        final AtomicReference<String> videoId = new AtomicReference<>(null);
        getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                shareApi.share(new FacebookCallback<Sharer.Result>() {
                    @Override
                    public void onSuccess(Sharer.Result result) {
                        videoId.set(result.getPostId());
                        notifyShareFinished();
                    }

                    @Override
                    public void onCancel() {
                        notifyShareFinished();
                    }

                    @Override
                    public void onError(FacebookException error) {
                        notifyShareFinished();
                    }

                    private void notifyShareFinished() {
                        synchronized (shareApi) {
                            shareApi.notifyAll();
                        }
                    }
                });
            }
        });

        synchronized (shareApi) {
            shareApi.wait(REQUEST_TIMEOUT_MILLIS);
        }
        assertNotNull(videoId.get());
    } catch (Exception ex) {
        fail();
    } finally {
        if (tempFile != null) {
            tempFile.delete();
        }
    }
}

From source file:de.hybris.platform.servicelayer.tx.ItemModelTransactionTest.java

@Test
public void testManualInvalidationInsideTxRollbacking() throws Exception {
    if (Config.isHSQLDBUsed()) {
        return; //should work, but doesn't at the moment. thomas has stacktrace from bamboo. it hangs inside hsqldb
    }//from  ww  w.ja  v a  2s .co  m
    final MediaModel media = setupMedia("cat", "media", MIME_BEFORE);
    final Media jaloMedia = modelService.getSource(media);
    final PK mediaPK = media.getPk();
    assertEquals(mediaPK, jaloMedia.getPK());

    // check before
    assertEquals(MIME_BEFORE, media.getMime());
    assertEquals(MIME_BEFORE, jaloMedia.getMime());
    // read in other thread
    String[] outerMimes = getMimeFromOtherThread(mediaPK);
    assertEquals(MIME_BEFORE, outerMimes[0]);
    assertEquals(MIME_BEFORE, outerMimes[1]);
    // read direct
    assertEquals(MIME_BEFORE, readMimeViaJDBC(mediaPK));

    final Transaction tx = Transaction.current();
    final AtomicReference<Exception> rollbackExc = new AtomicReference<Exception>(null);
    try {
        tx.execute(//
                new TransactionBody() {

                    @Override
                    public Object execute() throws Exception {
                        // check before (again) inside tx
                        assertEquals(MIME_BEFORE, media.getMime());
                        assertEquals(MIME_BEFORE, jaloMedia.getMime());
                        // read direct inide tx
                        assertEquals(MIME_BEFORE, readMimeViaJDBC(mediaPK));

                        // update direct (not committed) -> caches stay untouched
                        changeMimeViaJDBC(mediaPK, MIME_AFTER);
                        // read direct again inside tx
                        assertEquals(MIME_AFTER, readMimeViaJDBC(mediaPK));
                        // read direct again outside tx
                        assertEquals(MIME_BEFORE, readMimeViaJDBC(mediaPK, false));

                        // must have the old values here
                        assertEquals(MIME_BEFORE, jaloMedia.getMime());
                        assertEquals(MIME_BEFORE, media.getMime());
                        modelService.refresh(media); // even after refreshing !
                        assertEquals(MIME_BEFORE, media.getMime());
                        // read in other thread
                        String[] outerMimes = getMimeFromOtherThread(mediaPK);
                        assertEquals(MIME_BEFORE, outerMimes[0]);
                        assertEquals(MIME_BEFORE, outerMimes[1]);

                        // now invalidate manually -> should be only effective inside this tx !!!
                        Utilities.invalidateCache(mediaPK);

                        // jalo must show new value immediately
                        assertEquals(MIME_AFTER, jaloMedia.getMime());
                        // model is still old but that's correct since it has not been refreshed yet
                        assertEquals(MIME_BEFORE, media.getMime());
                        modelService.refresh(media); // now refresh
                        assertEquals(MIME_AFTER, media.getMime());
                        // read in other thread-> both must show old value
                        outerMimes = getMimeFromOtherThread(mediaPK);
                        assertEquals(MIME_BEFORE, outerMimes[0]);
                        assertEquals(MIME_BEFORE, outerMimes[1]);

                        final RuntimeException ex = new RuntimeException("rollback please");
                        rollbackExc.set(ex);
                        throw ex;
                    }
                });
    } catch (final Exception e) {
        assertEquals(rollbackExc.get(), e);
    }
    // after commit all values must be correct
    assertEquals(MIME_BEFORE, readMimeViaJDBC(mediaPK));
    assertEquals(MIME_BEFORE, jaloMedia.getMime());
    // please note that media *is stale* after rollback !!!
    assertEquals(MIME_AFTER, media.getMime());
    modelService.refresh(media); // now refresh should correct it
    assertEquals(MIME_BEFORE, media.getMime());
    // read in other thread-> both must show old value
    outerMimes = getMimeFromOtherThread(mediaPK);
    assertEquals(MIME_BEFORE, outerMimes[0]);
    assertEquals(MIME_BEFORE, outerMimes[1]);
}