List of usage examples for java.lang Object Object
@HotSpotIntrinsicCandidate
public Object()
From source file:com.spectralogic.ds3client.helpers.channels.WindowedSeekableByteChannel_Test.java
@Test(timeout = 1000) public void closeChangesIsOpen() throws IOException { try (final SeekableByteChannel channel = stringToChannel("aabbbcccc")) { final Object lock = new Object(); final SeekableByteChannel window = new WindowedSeekableByteChannel(channel, lock, 0L, 2L); assertThat(window.isOpen(), is(true)); window.close();//from www. ja va2s. co m assertThat(window.isOpen(), is(false)); } }
From source file:TreeUtil.java
public void addNode(String name) { addNode(name, new Object()); }
From source file:limey.git.amqp.SampleAmqpSimpleApplication.java
@Bean public SimpleMessageListenerContainer container() { SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(this.connectionFactory); Object listener = new Object() { @SuppressWarnings("unused") public void handleMessage(String foo) { System.out.println(foo); }/*from ww w .jav a2s . c o m*/ }; MessageListenerAdapter adapter = new MessageListenerAdapter(listener); container.setMessageListener(adapter); container.setQueueNames("foo"); return container; }
From source file:io.helixservice.feature.restservice.marshal.JacksonMarshallerUnitTest.java
@Test(expected = MarshallerException.class) public void testMarshallException() throws JsonProcessingException { Object marshaledObject = new Object(); ObjectMapper objectMapper = mock(ObjectMapper.class); when(objectMapper.writeValueAsString(marshaledObject)).thenThrow(new NullPointerException("nope!")); JacksonMarshaller subject = new JacksonMarshaller(objectMapper); subject.marshal(marshaledObject);/*from w w w.j a v a 2 s.co m*/ }
From source file:com.quatico.base.aem.test.api.setup.SetupFactory.java
public T getSetup(final Object... implementors) { final Map<Class<?>, Object> interfaces = new HashMap<>(); for (Object implementor : implementors) { List<Class<?>> implementorInterfaces = ClassUtils.getAllInterfaces(implementor.getClass()); assert !implementorInterfaces.isEmpty(); for (Class<?> implementorInterface : implementorInterfaces) { interfaces.put(implementorInterface, implementor); }// w ww. j av a2s . c o m } @SuppressWarnings("unchecked") T result = (T) Proxy.newProxyInstance(this.interfaze.getClassLoader(), new Class<?>[] { this.interfaze }, new InvocationHandler() { private final Object fProxyObject = new Object() { @Override public String toString() { return "Proxy for: " + SetupFactory.this.interfaze.getDeclaringClass().getName(); //$NON-NLS-1$ } }; @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (method.getDeclaringClass().equals(Object.class)) { method.invoke(this.fProxyObject, args); } if (interfaces.containsKey(method.getDeclaringClass())) { return method.invoke(interfaces.get(method.getDeclaringClass()), args); } throw new UnsupportedOperationException( "Created proxy has not received an implementation that supports this method: " //$NON-NLS-1$ + method.getName()); } }); return result; }
From source file:org.jasig.cas.web.support.ThrottledSubmissionByIpAddressHandlerInterceptorAdapterTests.java
public void testSuccess() throws Exception { final MockHttpServletRequest request = new MockHttpServletRequest(); final ModelAndView modelAndView = new ModelAndView("redirect"); request.setMethod("GET"); request.setRemoteAddr("111.111.111.111"); this.adapter.postHandle(request, new MockHttpServletResponse(), new Object(), modelAndView); assertEquals("redirect", modelAndView.getViewName()); }
From source file:ar.com.zauber.commons.spring.exceptions.StatusSimpleMappingExceptionHandlerTest.java
/** test */ public final void testValueMustBeInteger() { final StatusSimpleMappingExceptionHandler h = new StatusSimpleMappingExceptionHandler(); final Properties status = new Properties(); status.put("test", new Object()); try {/*w w w . j ava 2s.com*/ h.setStatusMappings(status); fail(); } catch (IllegalArgumentException e) { // ok } }
From source file:jmona.random.RandomUtilsTester.java
/** * Test method for/*from ww w . ja va2s . c o m*/ * {@link jmona.random.RandomUtils#choice(java.util.Collection)}. */ @Test public void testChoice() { final Set<Object> set = new HashSet<Object>(); final Object object1 = new Object(); final Object object2 = new Object(); final Object object3 = new Object(); set.add(object1); set.add(object2); set.add(object3); Map<Object, Integer> selectionsMap = new HashMap<Object, Integer>(); Object choice = null; for (int i = 0; i < NUM_TESTS; ++i) { choice = RandomUtils.choice(set); if (selectionsMap.containsKey(choice)) { selectionsMap.put(choice, selectionsMap.get(choice) + 1); } else { selectionsMap.put(choice, 1); } } int sum = 0; for (final Integer selections : selectionsMap.values()) { sum += selections; } final double meanSelections = (double) sum / selectionsMap.size(); final double delta = meanSelections * 0.1; for (final Integer selection : selectionsMap.values()) { assertEquals(meanSelections, selection, delta); } }
From source file:br.com.autonomiccs.apacheCloudStack.client.ApacheCloudStackApiCommandParameterTest.java
@Test public void equalsTestDifferentTypeOfObject() { ApacheCloudStackApiCommandParameter apacheCloudStackApiCommandParameter = new ApacheCloudStackApiCommandParameter( "param1", "value"); Assert.assertNotEquals(apacheCloudStackApiCommandParameter, new Object()); }
From source file:javasnack.snacks.json.PojoEncodeJackson2.java
@Override public void run() { ObjectMapper objectMapper = new ObjectMapper(); try {/* w w w . ja v a 2s .c o m*/ System.out.println("------- without custom serializer -------"); Object pojo = new Object() { public int intv = 10; public EncodePojoEnum enum1 = EncodePojoEnum.ONE; public EncodePojoEnum2 enum2 = EncodePojoEnum2.DEF; }; System.out.println(objectMapper.writeValueAsString(pojo)); System.out.println("------- with custom serializer -------"); Object pojo2 = new Object() { public int intv = 10; @JsonSerialize(using = EncodePojoEnumJacksonSerializer.class) public EncodePojoEnum enum1 = EncodePojoEnum.ONE; @JsonSerialize(using = EncodePojoEnum2JacksonSerializer.class) public EncodePojoEnum2 enum2 = EncodePojoEnum2.DEF; }; System.out.println(objectMapper.writeValueAsString(pojo2)); } catch (JsonProcessingException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }