List of usage examples for java.lang Object Object
@HotSpotIntrinsicCandidate
public Object()
From source file:com.nokia.dempsy.router.TestRouterInstantiation.java
@Test public void testDispatchBadMessage() throws Throwable { ApplicationDefinition app = new ApplicationDefinition("test"); Router router = new Router(app); Object o;/* w ww.j a va 2s. c o m*/ router.dispatch(o = new Object() { @SuppressWarnings("unused") @MessageKey public String getKey() { return "hello"; } }); assertTrue(router.stopTryingToSendTheseTypes.contains(o.getClass())); MessageThatFailsOnKeyRetrieve message = new MessageThatFailsOnKeyRetrieve(); router.dispatch(message); assertTrue(message.threw); router.dispatch(null); // this should just warn }
From source file:com.evolveum.polygon.scim.ErrorHandler.java
/** * Processes the provided parameters from which it creates error messages * describing the arisen error situation. * /*w w w . j av a2 s. c o m*/ * @param response * The HTTP query response object returned from the service * provider. * @param message * Additional string message providing and description of the * error. * @throws ParseException * @throws IOException */ public static String onNoSuccess(String responseString, Integer statusCode, String message) throws ParseException, IOException { boolean isJsonObject = true; StringBuilder exceptionStringBuilder = null; if (responseString != null && !responseString.isEmpty()) { LOGGER.error("Full Error response from the provider: {0}", responseString); try { new JSONObject(responseString); } catch (JSONException ex) { isJsonObject = false; } try { new JSONArray(responseString); } catch (JSONException arrayE) { isJsonObject = true; } if (isJsonObject) { JSONObject responseObject = new JSONObject(responseString); List<String> dictionary = new ArrayList<String>(); dictionary.add(ERRORS); dictionary.add("error"); for (String record : dictionary) { if (responseObject.has(record)) { Object returnedObject = new Object(); returnedObject = responseObject.get(record); if (returnedObject instanceof JSONObject) { responseObject = (JSONObject) returnedObject; exceptionStringBuilder = buildErrorMessage(responseObject, message, statusCode); break; } else if (returnedObject instanceof JSONArray) { for (Object messageObject : (JSONArray) returnedObject) { exceptionStringBuilder = buildErrorMessage((JSONObject) messageObject, message, statusCode); } break; } else if (returnedObject instanceof String) { if (responseString.contains("}")) { responseString = responseString.replace("}", ""); } if (responseString.contains("{")) { responseString = responseString.replace("{", ""); } exceptionStringBuilder = new StringBuilder("Query for ").append(message) .append(" was unsuccessful. Status code returned: ").append(statusCode) .append(". The provider response: ").append(responseString); break; } } else { exceptionStringBuilder = new StringBuilder("Query for ").append(message) .append(" was unsuccessful. Status code returned: ").append(statusCode); } } } else { JSONArray responseObject = new JSONArray(responseString); for (Object messageObject : (JSONArray) responseObject) { exceptionStringBuilder = buildErrorMessage((JSONObject) messageObject, message, statusCode); } } } else { exceptionStringBuilder = new StringBuilder("Query for ").append(message) .append(" was unsuccessful. No response object was returned."); } String exceptionString = exceptionStringBuilder.toString(); if (message == null) { message = "the full resource representation"; } LOGGER.error(exceptionString); if (statusCode != null) { LOGGER.info("An error has occurred. HTTP status: \"{0}\"", statusCode); } LOGGER.info(exceptionString); return exceptionString; }
From source file:org.jboss.arquillian.warp.extension.spring.container.SpringMvcResultImplTestCase.java
/** * <p>Tests both {@link SpringMvcResultImpl#setHandler(Object)} and {@link SpringMvcResultImpl#getHandler()} * method.</p>// ww w. j a v a2 s.co m */ @Test public void testHandlerProperty() { Object handler = new Object(); assertNull("The property has invalid value.", instance.getHandler()); instance.setHandler(handler); assertEquals("The property value is invalid.", handler, instance.getHandler()); }
From source file:com.job.portal.servlets.CompanyServlet.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); JSONObject obj = new JSONObject(); JSONArray arr = null;/* www . j a v a 2 s .c o m*/ String param = null; Map<String, String[]> m = request.getParameterMap(); CompanyManager cm = new CompanyManager(); HttpSession sess = request.getSession(false); UserDetails ud = (UserDetails) sess.getAttribute("user"); CompanyMaster cMaster = null; try { obj.put("status", false); if (request.getParameter("param") != null) { param = request.getParameter("param"); if (param.equalsIgnoreCase("addCompany")) { cMaster = cm.addCompany(m, ud); if (cMaster != null && cMaster.getCompanyId() > 0) { obj.put("status", true); obj.put("msg", "Company added"); } else { obj.put("msg", "There seems to be some problem try again later"); } } } } catch (Exception e) { LogOut.log.error("In " + new Object() { }.getClass().getEnclosingClass().getName() + "." + new Object() { }.getClass().getEnclosingMethod().getName() + " " + e); } finally { out.close(); } }
From source file:net.kemitix.spring.common.logging.LoggerPostProcessorTest.java
/** * Test of postProcessAfterInitialization method, of class * LoggerPostProcessor.//from w w w. j a va2s . c om */ @Test public void testPostProcessAfterInitialization() { System.out.println("postProcessAfterInitialization"); //given Object bean = new Object(); //when Object result = loggerPostProcessor.postProcessAfterInitialization(bean, null); //then assertThat(result, is(bean)); }
From source file:com.espertech.esper.event.bean.TestReflectionPropMethodGetter.java
public void testGetter() throws Exception { ReflectionPropMethodGetter getter = makeGetter(SupportBean.class, "getIntPrimitive"); assertEquals(10, getter.get(unitTestBean)); getter = makeGetter(SupportBean.class, "getTheString"); assertEquals("a", getter.get(unitTestBean)); getter = makeGetter(SupportBean.class, "getDoubleBoxed"); assertEquals(null, getter.get(unitTestBean)); try {/* w w w . j a va2s. c om*/ EventBean eventBean = SupportEventBeanFactory.createObject(new Object()); getter.get(eventBean); assertTrue(false); } catch (PropertyAccessException ex) { // Expected log.debug(".testGetter Expected exception, msg=" + ex.getMessage()); } }
From source file:com.adaptris.core.fs.AggregatingFsConsumeServiceTest.java
public void testService() throws Exception { Object o = new Object(); File tempFile = TempFileUtils.createTrackedFile(o); String url = "file://localhost/" + tempFile.getCanonicalPath().replaceAll("\\\\", "/"); ConsumeDestinationGenerator cdg = createConsumeDestination(url, null); AggregatingFsConsumer afc = createConsumer(cdg, new ReplaceWithFirstMessage()); AggregatingFsConsumeService service = createAggregatingService(afc); try {// w w w . j a va2 s . c o m writeDataMessage(tempFile); start(service); AdaptrisMessage msg = new DefaultMessageFactory().newMessage(INITIAL_PAYLOAD); service.doService(msg); assertNotSame(INITIAL_PAYLOAD, msg.getStringPayload()); assertEquals(DATA_PAYLOAD, msg.getStringPayload()); } finally { stop(service); } }
From source file:net.sf.morph.reflect.reflectors.DynaBeanReflectorTestCase.java
protected List createReflectableObjects() { List list = new ArrayList(); list.add(new WrapDynaBean(new Object())); list.add(new WrapDynaBean(TestClass.getEmptyObject())); list.add(new WrapDynaBean(TestClass.getPartialObject())); list.add(new WrapDynaBean(TestClass.getFullObject())); return list;/* w w w .j av a 2 s . co m*/ }
From source file:com.cloudbees.jenkins.support.timer.DeadlockTest.java
@Test public void detectDeadlock() throws Exception { File[] files = new File(j.getInstance().getRootDir(), "/deadlocks").listFiles(); int initialCount = files == null ? 0 : files.length; final Object object1 = new Object(); final Object object2 = new Object(); Thread t1 = new Thread(new Runnable() { public void run() { synchronized (object1) { sleep();// w ww . j a v a 2 s. c o m firstMethod(); } } void firstMethod() { secondMethod(20); } void secondMethod(int x) { if (x > 0) { secondMethod(x - 1); } else { synchronized (object2) { } } } }); Thread t2 = new Thread(new Runnable() { public void run() { synchronized (object2) { sleep(); synchronized (object1) { } } } }); t1.start(); try { t2.start(); try { Thread.sleep(1000 * 5); // Wait 5 seconds, then execute deadlock checker. // Force call deadlock checker DeadlockTrackChecker dtc = new DeadlockTrackChecker(); dtc.doRun(); // Reason for >= 1 is because depending on where the test unit is executed the deadlock detection thread could be // invoked twice. files = new File(j.getInstance().getRootDir(), "/deadlocks").listFiles(); assertNotNull("There should be at least one deadlock file", files); assertThat("A deadlock was detected and a new deadlock file created", files.length, greaterThan(initialCount)); String text = FileUtils.readFileToString(files[initialCount]); assertThat(text, Matchers.containsString("secondMethod")); assertThat(text, Matchers.containsString("firstMethod")); } finally { t2.stop(); } } finally { t1.stop(); } }
From source file:com.job.portal.servlets.JobsServlet.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); JSONObject obj = null;// w w w .ja va 2s .c o m JSONArray arr = null; try { String param = request.getParameter("param"); JobsManager jm = new JobsManager(); if (param != null) { if (param.equalsIgnoreCase("addJob")) { boolean flag = jm.addJob(request); obj = new JSONObject(); obj.put("status", flag); if (flag) { obj.put("msg", "Job created successfully"); } else { obj.put("msg", "Please try again after sometime"); } out.print(obj); } else if (param.equalsIgnoreCase("getJobDetails")) { obj = jm.getJobDetails(request); out.print(obj); } else if (param.equalsIgnoreCase("getJobApplicants")) { arr = jm.getJobApplicants(request); out.print(arr); } else if (param.equalsIgnoreCase("showAll")) { arr = jm.getAllJobs(request); out.print(arr); } } } catch (Exception e) { LogOut.log.error("In " + new Object() { }.getClass().getEnclosingClass().getName() + "." + new Object() { }.getClass().getEnclosingMethod().getName() + " " + e); } finally { out.close(); } }