List of usage examples for java.lang Object Object
@HotSpotIntrinsicCandidate
public Object()
From source file:org.commonjava.rwx.http.httpclient4.ObjectResponseHandler.java
@Override public T handleResponse(final HttpResponse resp) throws ClientProtocolException, IOException { final StatusLine status = resp.getStatusLine(); System.out.println(status);// ww w . j a v a2s.c o m if (status.getStatusCode() > 199 && status.getStatusCode() < 203) { Logger logger = LoggerFactory.getLogger(getClass()); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); IOUtils.copy(resp.getEntity().getContent(), baos); if (logger.isTraceEnabled()) { File recording = null; FileOutputStream stream = null; try { recording = File.createTempFile("xml-rpc.response.", ".xml"); stream = new FileOutputStream(recording); stream.write(baos.toByteArray()); } catch (final IOException e) { logger.debug("Failed to record xml-rpc response to file.", e); // this is an auxilliary function. ignore errors. } finally { IOUtils.closeQuietly(stream); logger.info("\n\n\nRecorded response to: {}\n\n\n", recording); } } try { logger.trace("Got response: \n\n{}", new Object() { @Override public String toString() { try { return new String(baos.toByteArray(), "UTF-8"); } catch (final UnsupportedEncodingException e) { return new String(baos.toByteArray()); } } }); return bindery.parse(new ByteArrayInputStream(baos.toByteArray()), responseType); } catch (final XmlRpcException e) { error = e; return null; } } else { error = new XmlRpcException("Invalid response status: '" + status + "'."); return null; } }
From source file:org.jsconf.core.test.ExceptionTest.java
@Test(expected = BeanCreationException.class) public void testTryToProxyAClass() { ConfigurationFactory confFactory = new ConfigurationFactory() .withResourceName("org/jsconf/core/test/app_exception04.conf"); confFactory.setApplicationContext(mock(GenericApplicationContext.class)); confFactory.postProcessBeanFactory(mock(ConfigurableListableBeanFactory.class)); confFactory.postProcessBeforeInitialization(new Object(), "simpleConf"); }
From source file:com.redhat.lightblue.metadata.types.ContainerTypeTest.java
@Test(expected = UnsupportedOperationException.class) public void testCompare() { type.compare(new Object(), new Object()); }
From source file:com.opensymphony.xwork2.validator.URLValidatorTest.java
public void testInvalidValue() throws Exception { URLValidator validator = new URLValidator(); validator.setValidatorContext(new DummyValidatorContext(new Object(), tpf)); validator.setFieldName("testingUrl3"); validator.setValueStack(ActionContext.getContext().getValueStack()); validator.validate(new MyObject()); assertTrue(validator.getValidatorContext().hasErrors()); assertFalse(validator.getValidatorContext().hasActionErrors()); assertFalse(validator.getValidatorContext().hasActionMessages()); assertTrue(validator.getValidatorContext().hasFieldErrors()); }
From source file:jmona.random.RandomUtilsTester.java
/** * Test method for {@link jmona.random.RandomUtils#choice(Object[])}. *//*from w w w. j ava2 s .c o m*/ @Test public void testChoiceArray() { final Object object1 = new Object(); final Object object2 = new Object(); final Object object3 = new Object(); final Object[] array = new Object[] { object1, object2, object3 }; final Map<Object, Integer> selectionsMap = new HashMap<Object, Integer>(); Object choice = null; for (int i = 0; i < NUM_TESTS; ++i) { choice = RandomUtils.choice(array); 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:net.decix.jatlasx.test.HandlerTest.java
@Test public void testMeasurementIDHandler() { boolean receivedData = false; ResponseHandler<Long> handler = new MeasurementIDHandler(); JSONArray jsonTestArrayLong = new JSONArray(); jsonTestArrayLong.put(new Long(10)); jsonTestArrayLong.put(new Long(100)); jsonTestArrayLong.put(new Long(1000)); jsonTestArrayLong.put(new Long(10000)); jsonTestArrayLong.put(new Long(0)); JSONObject obj = new JSONObject(); obj.put("measurements", jsonTestArrayLong); obj.put("num", new Integer(100)); obj.put("balance", new Double(1000.21)); obj.put("is_vip", new Boolean(true)); obj.put("nickname", new Object()); String definitions = new JSONStringer().array().object().key("target").value("192.168.178.1").key("af") .value("4").endObject().object().key("newline").value("123").key("newline2").value("456") .endObject().endArray().toString(); String probes = new JSONStringer().array().object().key("value").value("21931").key("type").value("probes") .key("requested").value("1").endObject().endArray().toString(); String myString = new JSONStringer().object().key("definitions").value(definitions).key("probes") .value(probes).key("measurements").value(jsonTestArrayLong).key("is_oneoff").value(false) .endObject().toString();//from w w w.j a v a 2s .com List<Long> list = handler.handleResponse(myString); if (!list.isEmpty()) { if (PRINT_RESULTS) { System.out.println("TEST (HandlerTest) - MeasurementIDHandler " + list); } receivedData = true; } assertTrue(receivedData); }
From source file:org.slf4j.impl.PiazzaLogger.java
public void trace(String format) { processLogs(Severity.DEBUG, format, new Object()); }
From source file:ImageUtilities.java
/** * Starts loading the given images, returns only when all the images are done * loading. If you just need to preload one Image, use the preload(Image) method * instead.//from w w w .j a va 2s .c o m * * @return An array specifying the loading result of each image. Possible values * are {@link #COMPLETE}, {@link #ERRORED} and {@link #ABORTED}. * * @see #preload(Image) */ public static int[] preload(Image[] images, int[] results) { Object[] locks = new Object[images.length]; ImageLoadObserver[] loadObservers = new ImageLoadObserver[images.length]; if ((results == null) || (results.length < images.length)) results = new int[images.length]; Toolkit toolkit = Toolkit.getDefaultToolkit(); for (int i = 0; i < images.length; i++) { locks[i] = new Object(); loadObservers[i] = new ImageLoadObserver(locks[i]); toolkit.prepareImage(images[i], -1, -1, loadObservers[i]); } for (int i = 0; i < images.length; i++) { synchronized (locks[i]) { int result = toolkit.checkImage(images[i], -1, -1, null); if ((result & ImageObserver.ALLBITS) != 0) { results[i] = COMPLETE; continue; } if ((result & ImageObserver.ERROR) != 0) { results[i] = ERRORED; continue; } if ((result & ImageObserver.ABORT) != 0) { results[i] = ABORTED; continue; } try { locks[i].wait(); results[i] = loadObservers[i].getResult(); } catch (InterruptedException e) { results[i] = INTERRUPTED; } } } return results; }
From source file:com.job.portal.manager.JobsManager.java
public JSONObject getJobDetails(HttpServletRequest request) { JSONObject obj = null;/*from ww w . j a v a 2 s .c om*/ try { String jobId = request.getParameter("jobId"); if (ExpressionCheck.checkNumber(jobId)) { obj = jd.getJobDetails(jobId); } else { obj = new JSONObject(); } } catch (Exception e) { LogOut.log.error("In " + new Object() { }.getClass().getEnclosingClass().getName() + "." + new Object() { }.getClass().getEnclosingMethod().getName() + " " + e); } finally { return obj; } }