List of usage examples for java.lang Object Object
@HotSpotIntrinsicCandidate
public Object()
From source file:com.opentable.logging.LogMetadataTest.java
@Test public void testObjectMetadata() throws Exception { final Object embeddedObj = new Object() { public String getC() { return "d"; }/*from ww w . ja v a 2 s . c o m*/ }; context.getLogger("test").info(LogMetadata.of("a", "b").andInline(embeddedObj), ""); assertEquals(1, serializedEvents.size()); assertEquals("b", serializedEvents.get(0).get("a").textValue()); assertEquals("d", serializedEvents.get(0).get("c").textValue()); }
From source file:com.redhat.lightblue.metadata.types.BigIntegerTypeTest.java
@Test(expected = Error.class) public void testCastOther() { Object object = new Object(); bigIntegerType.cast(object); }
From source file:org.cloudcoder.healthmonitor.HealthMonitor.java
/** * Constructor. */ public HealthMonitor() { lock = new Object(); }
From source file:it.anyplace.sync.httprelay.server.HttpRelayServer.java
private RelaySessionConnection openConnection(String deviceId) throws Exception { RelayClient relayClient = new RelayClient(configuration); SessionInvitation sessionInvitation = relayClient.getSessionInvitation(relayServerAddress, deviceId); RelayConnection relayConnection = relayClient.openConnectionSessionMode(sessionInvitation); final RelaySessionConnection relaySessionConnection = new RelaySessionConnection(relayConnection); relayConnectionsBySessionId.put(relaySessionConnection.getSessionId(), relaySessionConnection); relaySessionConnection.getEventBus().register(new Object() { @Subscribe//www . ja v a 2 s. c o m public void handleConnectionClosedEvent(ConnectionClosedEvent event) { relayConnectionsBySessionId.remove(relaySessionConnection.getSessionId()); } }); relaySessionConnection.connect(); return relaySessionConnection; }
From source file:org.openmrs.web.taglib.OpenmrsMessageTagTest.java
/** * @see OpenmrsMessageTag#doEndTag()//from w ww. ja v a2 s. com */ @Test @Verifies(value = "resolve a message of the wrong type fails", method = "doEndTag()") public void doEndTag_shouldFailEvaluateRandomObjectMessage() throws Exception { final Object message = new Object() { @Override public String toString() { return "this is *only* a test."; } }; openmrsMessageTag.setMessage(message); checkDoEndTagEvaluationException(); }
From source file:com.thoughtworks.go.server.cache.GoCacheTest.java
@Test public void shouldBeAbleToRemoveAnObjectThatIsPutIntoIt() { Object o = new Object(); goCache.put("someKey", o); assertNotNull(goCache.get("someKey")); assertTrue(goCache.remove("someKey")); assertNull(goCache.get("someKey")); }
From source file:com.netflix.curator.framework.recipes.queue.TestBoundedDistributedQueue.java
@SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter") @Test/*from w w w .j a v a 2s .c o m*/ public void testMulti() throws Exception { final String PATH = "/queue"; final int CLIENT_QTY = 4; final int MAX_ITEMS = 10; final int ADD_ITEMS = MAX_ITEMS * 100; final int SLOP_FACTOR = 2; final QueueConsumer<String> consumer = new QueueConsumer<String>() { @Override public void consumeMessage(String message) throws Exception { Thread.sleep(10); } @Override public void stateChanged(CuratorFramework client, ConnectionState newState) { } }; final Timing timing = new Timing(); final ExecutorService executor = Executors.newCachedThreadPool(); ExecutorCompletionService<Void> completionService = new ExecutorCompletionService<Void>(executor); final CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1)); try { client.start(); client.create().forPath(PATH); final CountDownLatch isWaitingLatch = new CountDownLatch(1); final AtomicBoolean isDone = new AtomicBoolean(false); final List<Integer> counts = new CopyOnWriteArrayList<Integer>(); final Object lock = new Object(); executor.submit(new Callable<Void>() { @Override public Void call() throws Exception { Watcher watcher = new Watcher() { @Override public void process(WatchedEvent event) { synchronized (lock) { lock.notifyAll(); } } }; while (!Thread.currentThread().isInterrupted() && client.isStarted() && !isDone.get()) { synchronized (lock) { int size = client.getChildren().usingWatcher(watcher).forPath(PATH).size(); counts.add(size); isWaitingLatch.countDown(); lock.wait(); } } return null; } }); isWaitingLatch.await(); for (int i = 0; i < CLIENT_QTY; ++i) { final int index = i; completionService.submit(new Callable<Void>() { @Override public Void call() throws Exception { CuratorFramework client = null; DistributedQueue<String> queue = null; try { client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1)); client.start(); queue = QueueBuilder.builder(client, consumer, serializer, PATH).executor(executor) .maxItems(MAX_ITEMS).putInBackground(false).lockPath("/locks").buildQueue(); queue.start(); for (int i = 0; i < ADD_ITEMS; ++i) { queue.put("" + index + "-" + i); } } finally { IOUtils.closeQuietly(queue); IOUtils.closeQuietly(client); } return null; } }); } for (int i = 0; i < CLIENT_QTY; ++i) { completionService.take().get(); } isDone.set(true); synchronized (lock) { lock.notifyAll(); } for (int count : counts) { Assert.assertTrue(counts.toString(), count <= (MAX_ITEMS * SLOP_FACTOR)); } } finally { executor.shutdownNow(); IOUtils.closeQuietly(client); } }
From source file:com.redhat.lightblue.metadata.types.ContainerTypeTest.java
@Test public void testEqualsObject() { assertFalse(type.equals(new Object())); }
From source file:info.archinnov.achilles.internal.persistence.operations.EntityProxifierTest.java
@Test public void should_build_proxy_with_all_fields_loaded() throws Exception { long primaryKey = RandomUtils.nextLong(); PropertyMeta pm = mock(PropertyMeta.class); Object value = new Object(); CompleteBean entity = CompleteBeanTestBuilder.builder().id(primaryKey).name("name").buid(); proxifier = spy(proxifier);/*from ww w . j av a 2 s . c o m*/ doReturn(interceptor).when(proxifier).buildInterceptor(eq(context), eq(entity), anySetOf(Method.class)); when(context.getEntityMeta()).thenReturn(entityMeta); when(entityMeta.getIdMeta()).thenReturn(idMeta); when(entityMeta.getAllMetas()).thenReturn(Arrays.asList(pm)); when(pm.getValueFromField(entity)).thenReturn(value); when(instantiator.instantiate(Mockito.<Class<Factory>>any())).thenReturn(realProxy); Object proxy = proxifier.buildProxyWithAllFieldsLoadedExceptCounters(entity, context); assertThat(proxy).isNotNull(); assertThat(proxy).isInstanceOf(Factory.class); Factory factory = (Factory) proxy; assertThat(factory.getCallbacks()).hasSize(1); assertThat(factory.getCallback(0)).isInstanceOf(EntityInterceptor.class); verify(pm).getValueFromField(entity); verify(pm).setValueToField(realProxy, value); }
From source file:eu.delving.sip.base.VisualFeedback.java
public static String askQuestion(JDesktopPane desktop, String question, Object initialSelectionValue) { final JOptionPane pane = new JOptionPane(question, QUESTION_MESSAGE, OK_CANCEL_OPTION, null, null, null); pane.putClientProperty(new Object(), Boolean.TRUE); pane.setWantsInput(true);/*from w w w. j a va 2 s . c om*/ pane.setInitialSelectionValue(initialSelectionValue); JDialog frame = pane.createDialog(desktop, "Question"); pane.selectInitialValue(); frame.setVisible(true); acquireFocus(); Object value = pane.getInputValue(); return value == UNINITIALIZED_VALUE ? null : (String) value; }