List of usage examples for java.lang Object Object
@HotSpotIntrinsicCandidate
public Object()
From source file:com.simiacryptus.mindseye.test.unit.SerializationTest.java
@Nullable @Override/* ww w . j a v a 2s .c o m*/ public ToleranceStatistics test(@Nonnull final NotebookOutput log, @Nonnull final Layer layer, final Tensor... inputPrototype) { log.h1("Serialization"); log.p("This apply will demonstrate the key's JSON serialization, and verify deserialization integrity."); String prettyPrint = ""; log.h2("Raw Json"); try { prettyPrint = log.eval(() -> { final JsonObject json = layer.getJson(); @Nonnull final Layer echo = Layer.fromJson(json); if (echo == null) throw new AssertionError("Failed to deserialize"); if (layer == echo) throw new AssertionError("Serialization did not copy"); if (!layer.equals(echo)) throw new AssertionError("Serialization not equal"); echo.freeRef(); return new GsonBuilder().setPrettyPrinting().create().toJson(json); }); @Nonnull String filename = layer.getClass().getSimpleName() + "_" + log.getName() + ".json"; log.p(log.file(prettyPrint, filename, String.format("Wrote Model to %s; %s characters", filename, prettyPrint.length()))); } catch (RuntimeException e) { e.printStackTrace(); Util.sleep(1000); } catch (OutOfMemoryError e) { e.printStackTrace(); Util.sleep(1000); } log.p(""); @Nonnull Object outSync = new Object(); if (prettyPrint.isEmpty() || prettyPrint.length() > 1024 * 64) Arrays.stream(SerialPrecision.values()).parallel().forEach(precision -> { try { @Nonnull File file = new File(log.getResourceDir(), log.getName() + "_" + precision.name() + ".zip"); layer.writeZip(file, precision); @Nonnull final Layer echo = Layer.fromZip(new ZipFile(file)); getModels().put(precision, echo); synchronized (outSync) { log.h2(String.format("Zipfile %s", precision.name())); log.p(log.link(file, String.format("Wrote Model apply %s precision to %s; %.3fMiB bytes", precision, file.getName(), file.length() * 1.0 / (0x100000)))); } if (!isPersist()) file.delete(); if (echo == null) throw new AssertionError("Failed to deserialize"); if (layer == echo) throw new AssertionError("Serialization did not copy"); if (!layer.equals(echo)) throw new AssertionError("Serialization not equal"); } catch (RuntimeException e) { e.printStackTrace(); } catch (OutOfMemoryError e) { e.printStackTrace(); } catch (ZipException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }); return null; }
From source file:edu.xjtu.qxcamerabridge.Qx10ServiceDelegatorImpl.java
@Override public boolean startMovieRec() { String service = "camera"; String serviceName = new Object() { }.getClass().getEnclosingMethod().getName(); JSONObject replyJson = JSONActionWrapper.jsonrpc(service, serviceName, new ArrayList<>()); int result = replyJson.getJSONArray("result").getInt(0); return result == 0; }
From source file:org.springmodules.validation.validator.CompoundValidatorTests.java
public void testValidate_WhenNoValidatorSupports() throws Exception { Object object = new Object(); BindException errors = new BindException(object, "name"); validatorControl1.expectAndReturn(validator1.supports(object.getClass()), false); validatorControl2.expectAndReturn(validator2.supports(object.getClass()), false); validatorControl1.replay();/*from w w w. j a va 2 s. c o m*/ validatorControl2.replay(); validator.validate(object, errors); validatorControl1.verify(); validatorControl2.verify(); }
From source file:jmona.random.RandomUtilsTester.java
/** * Test for randomly selecting an Object uniformly from a set with only one * element.//from w w w . j ava 2s.c o m */ @Test public void testRandomFromSingletonSet() { final Set<Object> set = new HashSet<Object>(); final Object object = new Object(); set.add(object); Object choice = null; for (int i = 0; i < NUM_TESTS; ++i) { choice = RandomUtils.choice(set); assertSame(object, choice); } }
From source file:eu.delving.sip.base.VisualFeedback.java
public static boolean askOption(JDesktopPane desktop, Object message, String title, int optionType, int messageType) { JOptionPane pane = new JOptionPane(message, messageType, optionType, null, null, null); pane.putClientProperty(new Object(), Boolean.TRUE); JDialog frame = pane.createDialog(desktop, title); pane.selectInitialValue();/* w ww.ja va 2 s. co m*/ frame.setVisible(true); acquireFocus(); Object selectedValue = pane.getValue(); return selectedValue != null && selectedValue instanceof Integer && (Integer) selectedValue == YES_OPTION; }
From source file:jp.terasoluna.fw.beans.jxpath.BeanPointerExTest.java
/** * testGetPropertyPointer01() <br> * <br>/*from w w w. ja va2 s. com*/ * () <br> * A <br> * <br> * () this.beanInfo:not null<br> * <br> * () PropertyPointer:new BeanPropertyPointerEx{<br> * parent=this<br> * beanInfo=?????beanInfo<br> * }<br> * <br> * ???? <br> * @throws Exception ????? */ @Test public void testGetPropertyPointer01() throws Exception { // ?? QName qName = new QName("name"); Object bean = new Object(); JXPathBeanInfo beanInfo = new JXPathBasicBeanInfo(bean.getClass()); Locale locale = new Locale("ja"); BeanPointerEx beanPointer = new BeanPointerEx(qName, bean, beanInfo, locale); // PropertyPointer result = beanPointer.getPropertyPointer(); // assertSame(BeanPropertyPointerEx.class, result.getClass()); assertSame(beanPointer, result.getParent()); assertSame(beanInfo, ReflectionTestUtils.getField(result, "beanInfo")); }
From source file:com.redhat.lightblue.metadata.types.DoubleTypeTest.java
@Test public void testCompareV2Null() { assertEquals(doubleType.compare(new Object(), null), 1); }
From source file:com.redhat.lightblue.metadata.types.BigDecimalTypeTest.java
@Test public void testCompareV1Null() { assertEquals(bigDecimalType.compare(null, new Object()), -1); }
From source file:com.opensymphony.xwork2.validator.URLValidatorTest.java
public void testValidUrl2() throws Exception { URLValidator validator = new URLValidator(); validator.setValidatorContext(new DummyValidatorContext(new Object(), tpf)); validator.setFieldName("testingUrl5"); validator.setValueStack(ActionContext.getContext().getValueStack()); validator.validate(new MyObject()); assertFalse(validator.getValidatorContext().hasErrors()); assertFalse(validator.getValidatorContext().hasActionErrors()); assertFalse(validator.getValidatorContext().hasActionMessages()); assertFalse(validator.getValidatorContext().hasFieldErrors()); }
From source file:org.springmodules.validation.bean.BeanValidatorTests.java
public void testValidateObjectGraphConstraints_WithArrayProperty() throws Exception { final Object object = new Object(); final Object[] propertyValue = new Object[0]; final Set validatedObjects = new HashSet(); // creating the bean with stub methods BeanValidator validator = new BeanValidator(loader) { protected void applyBeanValidation(BeanValidationConfiguration conf, Object obj, Errors errors) { assertSame(configuration, conf); assertSame(object, obj);//w w w. j a v a2 s .co m assertSame(BeanValidatorTests.this.errors, errors); } protected BeanWrapper wrapBean(Object bean) { return wrapper; } protected void validateArrayProperty(Object root, Object array, String propertyName, Errors errors, Set validatedObjs) { assertSame(object, root); assertSame(propertyValue, array); assertEquals("array", propertyName); assertSame(BeanValidatorTests.this.errors, errors); assertSame(validatedObjects, validatedObjs); } }; validator.setErrorCodeConverter(converter); // configuring the expectations of the bean wrapper that will be used to extract the array property wrapperControl.expectAndReturn(wrapper.getPropertyType("array"), Object[].class); wrapperControl.expectAndReturn(wrapper.getPropertyValue("array"), propertyValue); CascadeValidation[] cascadeValidations = new CascadeValidation[] { new CascadeValidation("array") }; configurationControl.expectAndReturn(configuration.getCascadeValidations(), cascadeValidations); loaderControl.expectAndReturn(loader.loadConfiguration(Object.class), configuration); replay(); validator.validateObjectGraphConstraints(object, object, errors, validatedObjects); assertFalse(validatedObjects.isEmpty()); assertEquals(object, validatedObjects.iterator().next()); verify(); }