Beispiel #1
0
	{
		a1 = new A();
		
		a2 = a1.foo1();
		(System.printS("Null pointer coming!"));
		i1 = a2.geti1(); // error en tiempo de ejecucion
    	}
  @Override
  public boolean equals(final Object obj) {
    if (this == obj) {
      return true;
    }

    if (!Association.class.isInstance(obj)) {
      return false;
    }

    try {
      @SuppressWarnings("unchecked")
      Association<K, L, A, M, D> other = (Association<K, L, A, M, D>) obj;
      A other_a = other.getAntecendent();
      A this_a = this.getAntecendent();
      if (this_a == other_a || (this_a != null && this_a.equals(other_a))) {
        D other_d = other.getDependent();
        D this_d = this.getDependent();
        if (this_d == other_d || (this_d != null && this_d.equals(other_d))) {
          return true;
        }
      }
    } catch (ClassCastException ex) {
      return false;
    }

    return false;
  }
  /**
   * Test that the contents of an allele-list are the ones expected.
   *
   * <p>
   *
   * <p>This method perform various consistency check involving all the {@link
   * org.broadinstitute.gatk.utils.genotyper.AlleleList} interface methods. Therefore calling this
   * method is equivalent to a thorough check of the {@link
   * org.broadinstitute.gatk.utils.genotyper.AlleleList} aspect of the {@code actual} argument.
   *
   * @param actual the sample-list to assess.
   * @param expected the expected sample-list.
   * @throws IllegalArgumentException if {@code expected} is {@code null} or contains {@code null}s
   *     which is an indication of an bug in the testing code.
   * @throws RuntimeException if there is some testing assertion exception which is an indication of
   *     an actual bug the code that is been tested.
   */
  public static <A extends Allele> void assertAlleleList(
      final AlleleList<A> actual, final List<A> expected) {
    if (expected == null) throw new IllegalArgumentException("the expected list cannot be null");
    final Set<A> expectedAlleleSet = new HashSet<>(expected.size());
    Assert.assertNotNull(actual);
    Assert.assertEquals(actual.alleleCount(), expected.size());
    for (int i = 0; i < expected.size(); i++) {
      final A expectedAllele = expected.get(i);
      if (expectedAllele == null)
        throw new IllegalArgumentException("the expected sample cannot be null");
      if (expectedAllele.equals(NEVER_USE_ALLELE))
        throw new IllegalArgumentException("you cannot use the forbidden sample name");
      if (expectedAlleleSet.contains(expected.get(i)))
        throw new IllegalArgumentException(
            "repeated allele in the expected list, this is a test bug");
      final A actualAllele = actual.alleleAt(i);
      Assert.assertNotNull(actualAllele, "allele cannot be null");
      Assert.assertFalse(
          expectedAlleleSet.contains(actualAllele), "repeated allele: " + actualAllele);
      Assert.assertEquals(actualAllele, expectedAllele, "wrong allele order; index = " + i);
      Assert.assertEquals(actual.alleleIndex(actualAllele), i, "allele index mismatch");
      expectedAlleleSet.add(actualAllele);
    }

    Assert.assertEquals(actual.alleleIndex((A) NEVER_USE_ALLELE), -1);
  }
Beispiel #4
0
 public static void main(String[] args) {
   A a = new B();
   B.a();
   a.a(); // 输出结果是a,说明静态方法不能再子类之中被覆盖。
   System.out.println(B.num); // 通过类名调用被覆盖的静态变量可以显示子类的被覆盖的静态变量。
   System.out.println(a.num); // 输出2,说明静态变量是不能被在子类中被覆盖的。
 }
Beispiel #5
0
  @Ignore("alias property not supported yet")
  public void testBCollection() throws Exception {
    CompassSession session = openSession();

    A a = new A();
    a.id = 1;
    a.value = "value";
    a.bs = new ArrayList<B>();
    B b = new B();
    b.value = "bvalue11";
    b.value2 = "bvalue12";
    a.bs.add(b);
    b = new B();
    b.value = "bvalue21";
    b.value = "bvalue22";
    a.bs.add(b);
    session.save(a);

    Resource resource = session.loadResource(A.class, 1);
    assertNotNull(resource);
    assertEquals(7, resource.getProperties().length);
    assertEquals("A", resource.getAlias());
    assertEquals(4, resource.getProperties("value").length);

    session.close();
  }
  public static void main(String[] args) {
    B b = new B();
    b.aMethod();

    A a = (A) b;
    a.aMethod();
  }
Beispiel #7
0
  @Ignore("alias property not supported yet")
  public void testBwoValues() throws Exception {
    CompassSession session = openSession();

    A a = new A();
    a.id = 1;
    a.value = "value";
    B b = new B();
    b.value = "bvalue";
    b.value2 = "bvalue2";
    a.b = b;
    session.save(a);

    Resource resource = session.loadResource(A.class, 1);
    assertNotNull(resource);
    assertEquals(6, resource.getProperties().length);
    assertEquals("A", resource.getAlias());
    assertEquals(3, resource.getProperties("value").length);

    a = (A) session.load(A.class, 1);
    assertEquals(1, a.id.longValue());
    assertNull(a.value);
    assertNull(a.b);

    session.close();
  }
 /**
  * Assert that the given object is lenient equals by ignoring null fields value on other object.
  *
  * @param info contains information about the assertion.
  * @param actual the given object.
  * @param other the object to compare {@code actual} to.
  * @throws NullPointerException if the actual type is {@code null}.
  * @throws NullPointerException if the other type is {@code null}.
  * @throws AssertionError if the actual and the given object are not lenient equals.
  * @throws AssertionError if the other object is not an instance of the actual type.
  */
 public <A> void assertIsLenientEqualsToByIgnoringNullFields(
     AssertionInfo info, A actual, A other) {
   assertIsInstanceOf(info, other, actual.getClass());
   List<String> fieldsNames = new LinkedList<String>();
   List<Object> values = new LinkedList<Object>();
   List<String> nullFields = new LinkedList<String>();
   for (Field field : actual.getClass().getDeclaredFields()) {
     try {
       Object otherFieldValue =
           propertySupport.propertyValue(field.getName(), field.getType(), other);
       if (otherFieldValue != null) {
         Object actualFieldValue =
             propertySupport.propertyValue(field.getName(), field.getType(), actual);
         if (!otherFieldValue.equals(actualFieldValue)) {
           fieldsNames.add(field.getName());
           values.add(otherFieldValue);
         }
       } else {
         nullFields.add(field.getName());
       }
     } catch (IntrospectionError e) {
       // Not readeable field, skip.
     }
   }
   if (fieldsNames.isEmpty()) return;
   throw failures.failure(
       info, shouldBeLenientEqualByIgnoring(actual, fieldsNames, values, nullFields));
 }
 protected final <A extends Annotation> void assertAnnotation(
     PropertyInfo<?, ?> property,
     Class<A> annotationClass,
     Map<String, Object> expectedAnnotation) {
   A ann1 = property.getAnnotation(annotationClass);
   assertNotNull(ann1);
   Map<String, Object> values = new HashMap<String, Object>();
   for (Method m : ann1.getClass().getDeclaredMethods()) {
     if (m.getName().equals("equals")
         && m.getParameterTypes().length == 1
         && m.getParameterTypes()[0] == Object.class) {
       continue;
     }
     if (m.getName().equals("hashCode") && m.getParameterTypes().length == 0) {
       continue;
     }
     if (m.getName().equals("toString") && m.getParameterTypes().length == 0) {
       continue;
     }
     if (m.getName().equals("annotationType") && m.getParameterTypes().length == 0) {
       continue;
     }
     try {
       Object value = m.invoke(ann1);
       values.put(m.getName(), value);
     } catch (Exception e) {
       AssertionFailedError afe =
           new AssertionFailedError("Could not invoke annotation value " + m);
       afe.initCause(e);
       throw afe;
     }
   }
   assertEquals(expectedAnnotation, values);
 }
 /**
  * Assert that the given object is lenient equals by ignoring fields.
  *
  * @param info contains information about the assertion.
  * @param actual the given object.
  * @param other the object to compare {@code actual} to.
  * @param fields the fields to ignore in comparison
  * @throws NullPointerException if the actual type is {@code null}.
  * @throws NullPointerException if the other type is {@code null}.
  * @throws AssertionError if the actual and the given object are not lenient equals.
  * @throws AssertionError if the other object is not an instance of the actual type.
  */
 public <A> void assertIsLenientEqualsToByIgnoringFields(
     AssertionInfo info, A actual, A other, String... fields) {
   assertIsInstanceOf(info, other, actual.getClass());
   List<String> fieldsNames = new LinkedList<String>();
   List<Object> expectedValues = new LinkedList<Object>();
   Set<String> ignoredFields = set(fields);
   for (Field field : actual.getClass().getDeclaredFields()) {
     try {
       if (!ignoredFields.contains(field.getName())) {
         String fieldName = field.getName();
         Object actualFieldValue = propertySupport.propertyValue(fieldName, Object.class, actual);
         Object otherFieldValue = propertySupport.propertyValue(fieldName, Object.class, other);
         if (!org.fest.util.Objects.areEqual(actualFieldValue, otherFieldValue)) {
           fieldsNames.add(fieldName);
           expectedValues.add(otherFieldValue);
         }
       }
     } catch (IntrospectionError e) {
       // Not readeable field, skip.
     }
   }
   if (fieldsNames.isEmpty()) return;
   throw failures.failure(
       info, shouldBeLenientEqualByIgnoring(actual, fieldsNames, expectedValues, list(fields)));
 }
 /**
  * Respond to the environment change and ensure that the neighbourhood best entities are updated.
  * This method (Template Method) calls two other methods in turn:
  *
  * <ul>
  *   <li>{@link #performReaction(PopulationBasedAlgorithm)}
  *   <li>{@link #updateNeighbourhoodBestEntities(Topology)}
  * </ul>
  *
  * @param algorithm some {@link PopulationBasedAlgorithm population based algorithm}
  */
 public <P extends Particle, A extends SinglePopulationBasedAlgorithm<P>> void respond(
     A algorithm) {
   performReaction(algorithm);
   if (hasMemory) {
     updateNeighbourhoodBestEntities(algorithm.getTopology(), algorithm.getNeighbourhood());
   }
 }
  /** Test InlineEnclosure */
  @Test
  public void autos6() {
    TestPage p = new TestPage();
    p.setPageMarkup(
        "<div wicket:enclosure='a'><div wicket:id='a'></div><div wicket:id='b'></div></div>");
    A a = new A();
    B b = new B();
    p.queue(a, b);
    tester.startPage(p);

    assertTrue(a.getParent() instanceof Enclosure);
    assertTrue(b.getParent() instanceof Enclosure);

    // A is visible, enclosure renders

    assertEquals(
        "<div wicket:enclosure=\"a\" id=\"wicket__InlineEnclosure_01\"><div wicket:id=\"a\"></div><div wicket:id=\"b\"></div></div>",
        tester.getLastResponseAsString());

    // A is not visible, inline enclosure render only itself (the placeholder tag)

    a.setVisible(false);
    tester.startPage(p);
    assertEquals(
        "<div id=\"wicket__InlineEnclosure_01\" style=\"display:none\"></div>",
        tester.getLastResponseAsString());
  }
  public static void main(String[] args) throws IOException {

    A b = new B();
    System.out.println(b.a);
    b.doSomethimg();
    System.out.println(b.getA());
  }
 private void nowAttemptToUpdateRow() {
   Session s = sessionFactory().openSession();
   s.beginTransaction();
   try {
     // load with write lock to deal with databases that block (wait indefinitely) direct attempts
     // to write a locked row
     A it =
         (A)
             s.get(
                 A.class,
                 1,
                 new LockOptions(LockMode.PESSIMISTIC_WRITE).setTimeOut(LockOptions.NO_WAIT));
     it.setValue("changed");
     s.flush();
     fail("Pessimistic lock not obtained/held");
   } catch (Exception e) {
     // grr, exception can be any number of types based on database
     // 		see HHH-6887
     if (LockAcquisitionException.class.isInstance(e)
         || GenericJDBCException.class.isInstance(e)
         || PessimisticLockException.class.isInstance(e)) {
       // "ok"
     } else {
       fail("Unexpected error type testing pessimistic locking : " + e.getClass().getName());
     }
   } finally {
     s.getTransaction().rollback();
     s.close();
   }
 }
  @Test
  public void autos5() {
    TestPage p = new TestPage();
    p.setPageMarkup(
        "<wicket:enclosure child='a'><div wicket:id='a'></div><div wicket:id='b'></div></wicket:enclosure>");
    A a = new A();
    B b = new B();
    p.queue(a);
    p.add(b);
    tester.startPage(p);

    assertTrue(a.getParent() instanceof Enclosure);
    assertTrue(b.getParent() instanceof TestPage);

    // A is visible, enclosure renders

    assertEquals(
        "<wicket:enclosure child=\"a\"><div wicket:id=\"a\"></div><div wicket:id=\"b\"></div></wicket:enclosure>",
        tester.getLastResponseAsString());

    // A is not visible, enclosure does not render

    a.setVisible(false);
    tester.startPage(p);
    assertEquals("", tester.getLastResponseAsString());
  }
Beispiel #16
0
Datei: B.java Projekt: wuschu/P1
  public static void main(String args[]) {
    // create a new object a1 of the class A (value 3)
    A a1 = new A();
    // create a new object a2 of the class A (value 3)
    A a2 = new A();
    // increment the value of a1 by 1 (new value 4)
    a1.increment();
    System.out.println(a1 + "/" + a2);
    // give all the settings of a1 to a2
    a2 = a1;
    // increment the value of a2 by one (a2=a1, so the same for a1)
    a2.increment();
    System.out.println(a1 + "/" + a2);

    // create a String s1 containing the uppercase word ROCK
    String s1 = "ROCK";
    // create a String s2 and give it the same value (ROCK)
    String s2 = s1;
    // change the word "ROCK" in s2 to "rock"
    s2 = s2.toLowerCase();
    System.out.println(s1 + "/" + s2);

    // create an int j with the value 1
    int j = 1;
    // create an int i and give it the value of j
    int i = j;
    // increment the value of j by one
    j++;
    System.out.println(j + "/" + i);
  }
  @Override
  public ClosestPair getClosestPair(A shapeA, Matrix4 transA, B shapeB, Matrix4 transB) {
    ClosestPair unjittered = wrapped.getClosestPair(shapeA, transA, shapeB, transB);
    if (unjittered != null) {
      // no jittering required to find a solution
      return unjittered;
    } else {
      // apply random jitters to one transform
      for (int i = 0; i < MAX_JITTERS; i++) {
        jitter.set(
            Math.random() * shapeA.getMargin(),
            Math.random() * shapeA.getMargin(),
            Math.random() * shapeA.getMargin());

        jitteredTransform.set(transA);
        jitteredTransform.m03 += jitter.x;
        jitteredTransform.m13 += jitter.y;
        jitteredTransform.m23 += jitter.z;

        ClosestPair jittered = wrapped.getClosestPair(shapeA, jitteredTransform, shapeB, transB);
        if (jittered != null) {
          // remove any jittering from the two closest points
          // - since we translated the shape by jitter, the point in a
          //   moves in the opposite direction of untranslating the shape
          //   by jitter (which is just adding the jitter)
          Vector3 newPointOnA = new Vector3(jittered.getClosestPointOnA()).add(jitter);
          return new ClosestPair(newPointOnA, jittered.getContactNormal(), jittered.getDistance());
        }
      }

      // jittering did not find a solution
      return null;
    }
  }
Beispiel #18
0
 public static void main(String[] args) {
   A p = g(0, 5);
   p.f();
   System.out.println("---");
   p = g(2, 1);
   p.f();
 }
Beispiel #19
0
  @Override
  public boolean instantiateTo(int value, ICause cause, boolean informCause)
      throws ContradictionException {
    if (informCause) {
      cause = Cause.Null;
    }
    if (this.instantiated()) {
      if (value != this.getValue()) {
        this.contradiction(cause, MSG_INST);
      }
      return false;
    } else if (contains(value)) {
      // todo: delta
      this.LB.set(value);
      this.UB.set(value);
      this.SIZE.set(1);

      A.updateUpperBound(value, this, false);
      B.updateUpperBound(value, this, false);
      if (!A.contains(value)) {
        B.instantiateTo(value, this, false);
      }
      if (!B.contains(value)) {
        A.instantiateTo(value, this, false);
      }

      this.notifyPropagators(EventType.INSTANTIATE, cause);
      return true;
    } else {
      this.contradiction(cause, MSG_UNKNOWN);
      return false;
    }
  }
Beispiel #20
0
 public static void main(String[] args) {
   A pa = g();
   try {
     pa.f();
   } catch (Exception1 e) {
   }
 }
  public static void main(String args[]) {
    Pair p;

    p = new Pair(2, new Pair(88, null));

    System.out.println(p.car());
    System.out.println(p.cdr().car());
    System.out.println(p.ww);
    System.out.println(p.yy);
    System.out.println(p.car);
    System.out.println(p.cdr.car);
    System.out.println(p.V4[0]);
    System.out.println(p.V4[1]);
    System.out.println(p.V3[0]);
    System.out.println(p.V3[1]);

    System.out.println(SpecialPair.w);
    System.out.println(SpecialPair.x);

    System.out.println(SpecialPair.V1[0]);
    System.out.println(SpecialPair.V1.length);

    System.out.println(A.fa());

    A a = new A();
    A[] va = new A[2];
    System.out.println(a.fb());
    System.out.println(a.w);
    // A strange case, should we generate code for va[0]?
    // System.out.println(va[0].w);
  }
 public void testRepeatFactor() {
   RQ rq = new RQ(A.numRows(), A.numColumns());
   rq.factor(new DenseMatrix(A));
   assertEquals(A, rq);
   rq.factor(new DenseMatrix(A));
   assertEquals(A, rq);
 }
Beispiel #23
0
 public static void main(String[] args) {
   A a = new A();
   A b = new A();
   a.setI(41);
   b.setI(42);
   assert a.i != 41;
 }
Beispiel #24
0
 public static void main(String[] args) {
   A a = new A();
   a.set(new A());
   a = a.set(new A()).get();
   a = a.get();
   C c = new C();
   c = c.setAndGet(new C());
 }
Beispiel #25
0
 public Ecaille() {
   A.add(new Attribut("ResFroid", -10));
   A.add(new Attribut("ResChaud", 10));
   A.add(new Attribut("Combat", 10));
   Nom = "Ecaille";
   I.add(new Interdit("Plumage"));
   I.add(new Interdit("Fourrure"));
 }
Beispiel #26
0
  public static void main(String[] args) {

    A ob = new B();
    ob.AA();
    // B ob1=new A();		//Error due to incompatible types as sub class cannot cast into super class
    // ob1.AA();

  }
 /**
  * @see
  *     org.openmrs.customdatatype.Customizable#getActiveAttributes(org.openmrs.customdatatype.CustomValueDescriptor)
  */
 @Override
 public java.util.List<A> getActiveAttributes(CustomValueDescriptor ofType) {
   List<A> ret = new ArrayList<A>();
   if (getAttributes() != null)
     for (A attr : getAttributes())
       if (attr.getAttributeType().equals(ofType) && !attr.isVoided()) ret.add(attr);
   return ret;
 }
Beispiel #28
0
 public void testF() {
   A instance = new A();
   instance.f();
   String[] temp = outContent.toString().split(System.getProperty("line.separator"));
   assertEquals("A", temp[1]);
   // TODO review the generated test code and remove the default call to fail.
   // fail("The test case is a prototype.");
 }
 private <A extends RestAction<?>> void buildBody(RequestBuilder requestBuilder, A action)
     throws ActionException {
   if (action.hasFormParams()) {
     requestBuilder.setRequestData(buildQueryString(action.getFormParams()));
   } else if (action.hasBodyParam()) {
     requestBuilder.setRequestData(getSerializedValue(action, action.getBodyParam()));
   }
 }
 public static void main(String[] args)
     throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
   A a = new A();
   a.name = "yangliang";
   B b = new B();
   // BeanUtils.copyProperties(a, b);
   System.out.println(b.name);
 }