Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you
* may not use this file except in compliance with the License. You
* may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License. See accompanying
* LICENSE file.
*/
package com.gemstone.gemfire.internal.util;
import java.io.Closeable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.atomic.AtomicInteger;
import junit.framework.TestCase;
import com.gemstone.gemfire.internal.util.SingletonValue.SingletonBuilder;
public class SingletonValueJUnitTest extends TestCase {
public void testGet() throws Exception {
MockCallable call = new MockCallable(null, null, false);
SingletonValue cc = new SingletonValue(call);
assertEquals(call, cc.get());
assertTrue(cc.hasCachedValue());
}
public void testError() throws Exception {
MockCallable call = new MockCallable(null, null, true);
SingletonValue cc = new SingletonValue(call);
try {
cc.get();
fail("Expected IOException");
} catch (IOException e) {
}
}
public void testMultithread() throws Exception {
int count = 100;
ExecutorService exec = Executors.newFixedThreadPool(count);
final SynchronousQueue