Java Code Examples for org.junit.Assert#assertSame()

The following examples show how to use org.junit.Assert#assertSame() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EmbeddedTreePlaneSubsetTest.java    From commons-geometry with Apache License 2.0 6 votes vote down vote up
@Test
public void testSplit_intersects_minusOnly() {
    // arrange
    EmbeddedTreePlaneSubset ps = new EmbeddedTreePlaneSubset(XY_PLANE, false);
    ps.getSubspaceRegion().union(
            Parallelogram.axisAligned(Vector2D.of(-1, -1), Vector2D.of(1, 1), TEST_PRECISION).toTree());

    Plane splitter = Planes.fromPointAndNormal(Vector3D.of(0, 0, 1), Vector3D.of(0.1, 0, -1), TEST_PRECISION);

    // act
    Split<EmbeddedTreePlaneSubset> split = ps.split(splitter);

    // assert
    Assert.assertEquals(SplitLocation.PLUS, split.getLocation());

    Assert.assertNull(split.getMinus());
    Assert.assertSame(ps, split.getPlus());
}
 
Example 2
Source File: CamelPropertiesHelperTest.java    From camel-spring-boot with Apache License 2.0 6 votes vote down vote up
@Test
public void testSetCamelPropertiesType() throws Exception {
    MyClass target = new MyClass();

    Map<String, Object> map = new HashMap<>();
    map.put("id", "123");
    map.put("name", "Donald Duck");
    map.put("option", "myCoolOption");
    map.put("camelContext", "#type:org.apache.camel.CamelContext");

    CamelPropertiesHelper.setCamelProperties(camelContext, target, map, true);

    Assert.assertEquals("Should configure all options", 0, map.size());
    Assert.assertEquals(123, target.getId());
    Assert.assertEquals("Donald Duck", target.getName());
    Assert.assertSame(context.getBean("myCoolOption"), target.getOption());
    Assert.assertSame(camelContext, target.getCamelContext());
}
 
Example 3
Source File: RefreshableMicroserviceCacheTest.java    From servicecomb-java-chassis with Apache License 2.0 6 votes vote down vote up
@Test
public void refresh_error_in_setInstances() {
  microserviceCache = new RefreshableMicroserviceCache(
      consumerService,
      MicroserviceCacheKey.builder().env("env").appId("app").serviceName("svc").build(),
      srClient,
      false) {
    @Override
    protected Set<MicroserviceInstance> mergeInstances(List<MicroserviceInstance> pulledInstances) {
      throw new IllegalStateException("a mock exception");
    }
  };

  List<MicroserviceInstance> oldInstanceList = microserviceCache.getInstances();
  Assert.assertEquals(MicroserviceCacheStatus.INIT, microserviceCache.getStatus());

  microserviceCache.refresh();

  Assert.assertEquals(MicroserviceCacheStatus.SETTING_CACHE_ERROR, microserviceCache.getStatus());
  List<MicroserviceInstance> newInstanceList = microserviceCache.getInstances();
  Assert.assertEquals(0, newInstanceList.size());
  Assert.assertSame(oldInstanceList, newInstanceList);
}
 
Example 4
Source File: LinePathTest.java    From commons-geometry with Apache License 2.0 6 votes vote down vote up
@Test
public void testSimplify_subsequentCallsToReturnedObjectReturnSameObject() {
    // arrange
    Builder builder = LinePath.builder(TEST_PRECISION);
    LinePath path = builder.appendVertices(
                Vector2D.ZERO,
                Vector2D.of(1, 0),
                Vector2D.of(2, 0))
            .build();

    // act
    LinePath result = path.simplify();

    // assert
    Assert.assertNotSame(path, result);
    Assert.assertSame(result, result.simplify());
}
 
Example 5
Source File: GreatArcTest.java    From commons-geometry with Apache License 2.0 6 votes vote down vote up
@Test
public void testSplit_full() {
    // arrange
    GreatArc arc = GreatCircles.fromPoints(Point2S.PLUS_I, Point2S.PLUS_J, TEST_PRECISION).span();
    GreatCircle splitter = GreatCircles.fromPole(Vector3D.of(-1, 0, 1), TEST_PRECISION);

    // act
    Split<GreatArc> split = arc.split(splitter);

    // assert
    Assert.assertEquals(SplitLocation.BOTH, split.getLocation());

    GreatArc minus = split.getMinus();
    Assert.assertSame(arc.getCircle(), minus.getCircle());
    checkArc(minus, Point2S.PLUS_J, Point2S.MINUS_J);
    checkClassify(minus, RegionLocation.OUTSIDE, Point2S.PLUS_I);
    checkClassify(minus, RegionLocation.INSIDE, Point2S.MINUS_I);

    GreatArc plus = split.getPlus();
    Assert.assertSame(arc.getCircle(), plus.getCircle());
    checkArc(plus, Point2S.MINUS_J, Point2S.PLUS_J);
    checkClassify(plus, RegionLocation.INSIDE, Point2S.PLUS_I);
    checkClassify(plus, RegionLocation.OUTSIDE, Point2S.MINUS_I);
}
 
Example 6
Source File: LineConvexSubsetTest.java    From commons-geometry with Apache License 2.0 5 votes vote down vote up
@Test
public void testSplit_full() {
    // arrange
    Vector2D p1 = Vector2D.of(1, 1);
    Vector2D p2 = Vector2D.of(3, 2);
    Vector2D middle = p1.lerp(p2, 0.5);

    Line line = Lines.fromPoints(p1, p2, TEST_PRECISION);

    LineConvexSubset seg = Lines.subsetFromInterval(line, Interval.full());

    // act/assert
    Split<LineConvexSubset> both = seg.split(Lines.fromPointAndDirection(middle, Vector2D.of(1, -2), TEST_PRECISION));
    checkInfinite(both.getMinus(), line,  middle, null);
    checkInfinite(both.getPlus(), line, null, middle);

    Split<LineConvexSubset> bothReversed = seg.split(Lines.fromPointAndDirection(middle, Vector2D.of(-1, 2), TEST_PRECISION));
    checkInfinite(bothReversed.getMinus(), line,  null, middle);
    checkInfinite(bothReversed.getPlus(), line, middle, null);

    Split<LineConvexSubset> minusOnlyParallel = seg.split(Lines.fromPointAndDirection(Vector2D.ZERO, Vector2D.of(2, 1), TEST_PRECISION));
    Assert.assertSame(seg, minusOnlyParallel.getMinus());
    Assert.assertNull(minusOnlyParallel.getPlus());

    Split<LineConvexSubset> plusOnlyParallel = seg.split(Lines.fromPointAndDirection(Vector2D.ZERO, Vector2D.of(-2, -1), TEST_PRECISION));
    Assert.assertNull(plusOnlyParallel.getMinus());
    Assert.assertSame(seg, plusOnlyParallel.getPlus());

    Split<LineConvexSubset> hyper = seg.split(Lines.fromPointAndDirection(p1, Vector2D.of(2, 1), TEST_PRECISION));
    Assert.assertNull(hyper.getMinus());
    Assert.assertNull(hyper.getPlus());
}
 
Example 7
Source File: JsonSubTypesResolverLookUpTest.java    From jsonschema-generator with Apache License 2.0 5 votes vote down vote up
private void assertErasedSubtypesAreEquals(List<Class<?>> erasedSubtypes, List<ResolvedType> subtypes) {
    if (erasedSubtypes == null) {
        Assert.assertNull(subtypes);
    } else {
        Assert.assertNotNull(subtypes);
        Assert.assertEquals(erasedSubtypes.size(), subtypes.size());
        for (int index = 0; index < erasedSubtypes.size(); index++) {
            Assert.assertSame(erasedSubtypes.get(index), subtypes.get(index).getErasedType());
        }
    }
}
 
Example 8
Source File: LinePathTest.java    From commons-geometry with Apache License 2.0 5 votes vote down vote up
@Test
public void testBuilder_prependAndAppend_segments() {
    // arrange
    Vector2D p1 = Vector2D.ZERO;
    Vector2D p2 = Vector2D.of(1, 0);
    Vector2D p3 = Vector2D.of(1, 1);
    Vector2D p4 = Vector2D.of(1, 0);

    Segment a = Lines.segmentFromPoints(p1, p2, TEST_PRECISION);
    Segment b = Lines.segmentFromPoints(p2, p3, TEST_PRECISION);
    Segment c = Lines.segmentFromPoints(p3, p4, TEST_PRECISION);
    Segment d = Lines.segmentFromPoints(p4, p1, TEST_PRECISION);

    Builder builder = LinePath.builder(null);

    // act
    builder.prepend(b)
        .append(c)
        .prepend(a)
        .append(d);

    LinePath path = builder.build();

    // assert
    List<LineConvexSubset> segments = path.getElements();
    Assert.assertEquals(4, segments.size());
    Assert.assertSame(a, segments.get(0));
    Assert.assertSame(b, segments.get(1));
    Assert.assertSame(c, segments.get(2));
    Assert.assertSame(d, segments.get(3));
}
 
Example 9
Source File: ConvexArea2STest.java    From commons-geometry with Apache License 2.0 5 votes vote down vote up
@Test
public void testFromVertexLoop_empty() {
    // act
    ConvexArea2S area = ConvexArea2S.fromVertexLoop(Collections.emptyList(), TEST_PRECISION);

    // assert
    Assert.assertSame(ConvexArea2S.full(), area);
}
 
Example 10
Source File: TestDiscoveryTree.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@Test
public void getOrCreateRoot_expired() {
  Deencapsulation.setField(discoveryTree, "root", parent);

  VersionedCache inputCache = new VersionedCache().cacheVersion(parent.cacheVersion() + 1);
  DiscoveryTreeNode root = discoveryTree.getOrCreateRoot(inputCache);

  Assert.assertEquals(inputCache.cacheVersion(), root.cacheVersion());
  Assert.assertSame(Deencapsulation.getField(discoveryTree, "root"), root);
}
 
Example 11
Source File: TestAbstractRestInvocation.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@Test
public void findRestOperationNormal(@Mocked MicroserviceMeta microserviceMeta,
    @Mocked ServicePathManager servicePathManager, @Mocked OperationLocator locator) {
  restInvocation = new AbstractRestInvocationForTest() {
    @Override
    protected OperationLocator locateOperation(ServicePathManager servicePathManager) {
      return locator;
    }
  };

  requestEx = new AbstractHttpServletRequest() {
  };
  restInvocation.requestEx = requestEx;
  Map<String, String> pathVars = new HashMap<>();
  new Expectations(ServicePathManager.class) {
    {
      ServicePathManager.getServicePathManager(microserviceMeta);
      result = servicePathManager;
      locator.getPathVarMap();
      result = pathVars;
      locator.getOperation();
      result = restOperation;
    }
  };

  restInvocation.findRestOperation(microserviceMeta);
  Assert.assertSame(restOperation, restInvocation.restOperationMeta);
  Assert.assertSame(pathVars, requestEx.getAttribute(RestConst.PATH_PARAMETERS));
}
 
Example 12
Source File: TestSwaggerLoader.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@Test
public void registerSwagger() {
  Swagger swagger = SwaggerGenerator.generate(Hello.class);
  RegistrationManager.INSTANCE.getSwaggerLoader().registerSwagger("default:ms2", schemaId, swagger);

  Microservice microservice = appManager.getOrCreateMicroserviceVersions(appId, serviceName)
      .getVersions().values().iterator().next().getMicroservice();
  Assert.assertSame(swagger, RegistrationManager.INSTANCE
      .getSwaggerLoader().loadSwagger(microservice, null, schemaId));
}
 
Example 13
Source File: SchemaGeneratorConfigPartTest.java    From jsonschema-generator with Apache License 2.0 5 votes vote down vote up
@Test
public void testIgnoreCheck() {
    Assert.assertFalse(this.instance.shouldIgnore(this.field1));

    Assert.assertSame(this.instance, this.instance.withIgnoreCheck(member -> member == this.field1));
    Assert.assertTrue(this.instance.shouldIgnore(this.field1));
    Assert.assertFalse(this.instance.shouldIgnore(this.field2));

    Assert.assertSame(this.instance, this.instance.withIgnoreCheck(member -> member == this.field2));
    Assert.assertTrue(this.instance.shouldIgnore(this.field1));
    Assert.assertTrue(this.instance.shouldIgnore(this.field2));
    Assert.assertFalse(this.instance.shouldIgnore(this.field3));
}
 
Example 14
Source File: ComplexTest.java    From hipparchus with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddNaN() {
    Complex x = new Complex(3.0, 4.0);
    Complex z = x.add(Complex.NaN);
    Assert.assertSame(Complex.NaN, z);
    z = new Complex(1, nan);
    Complex w = x.add(z);
    Assert.assertSame(Complex.NaN, w);
    Assert.assertSame(Complex.NaN, Complex.NaN.add(Double.NaN));
}
 
Example 15
Source File: TestRestOperationMeta.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateProduceProcessorsTextAndWildcardWithView() {
  findOperation("textPlainWithView");

  Assert.assertSame(ProduceProcessorManager.INSTANCE.findPlainProcessorByViewClass(Object.class),
      operationMeta.ensureFindProduceProcessor(MediaType.WILDCARD));
  Assert.assertSame(ProduceProcessorManager.INSTANCE.findPlainProcessorByViewClass(Object.class),
      operationMeta.ensureFindProduceProcessor(MediaType.TEXT_PLAIN));
  Assert.assertNull(operationMeta.ensureFindProduceProcessor(MediaType.APPLICATION_JSON));
  Assert.assertSame(ProduceProcessorManager.INSTANCE.findPlainProcessorByViewClass(Object.class),
      operationMeta.ensureFindProduceProcessor(
          MediaType.APPLICATION_JSON + "," + MediaType.APPLICATION_XML + "," + MediaType.WILDCARD));
}
 
Example 16
Source File: TestDiscoveryContext.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@Test
public void contextParameters() {
  String name = "name";
  Object value = new Object();
  context.putContextParameter(name, value);

  Assert.assertSame(value, context.getContextParameter(name));
  Assert.assertNull(context.getContextParameter("notExist"));
}
 
Example 17
Source File: RouteServiceTest.java    From Mycat2 with GNU General Public License v3.0 4 votes vote down vote up
@Test
public void test(){
    String sql = "select 1";
    String text = route(sql);
    Assert.assertSame(text,"");
}
 
Example 18
Source File: TestTransaction.java    From iceberg with Apache License 2.0 4 votes vote down vote up
@Test
public void testMultipleOperationTransactionFromTable() {
  Assert.assertEquals("Table should be on version 0", 0, (int) version());

  TableMetadata base = readMetadata();

  Transaction txn = table.newTransaction();

  Assert.assertSame("Base metadata should not change when commit is created",
      base, readMetadata());
  Assert.assertEquals("Table should be on version 0 after txn create", 0, (int) version());

  txn.newAppend()
      .appendFile(FILE_A)
      .appendFile(FILE_B)
      .commit();

  Assert.assertSame("Base metadata should not change when commit is created",
      base, readMetadata());
  Assert.assertEquals("Table should be on version 0 after txn create", 0, (int) version());

  Snapshot appendSnapshot = txn.table().currentSnapshot();

  txn.table().newDelete()
      .deleteFile(FILE_A)
      .commit();

  Snapshot deleteSnapshot = txn.table().currentSnapshot();

  Assert.assertSame("Base metadata should not change when an append is committed",
      base, readMetadata());
  Assert.assertEquals("Table should be on version 0 after append", 0, (int) version());

  txn.commitTransaction();

  Assert.assertEquals("Table should be on version 1 after commit", 1, (int) version());
  Assert.assertEquals("Table should have one manifest after commit",
      1, readMetadata().currentSnapshot().allManifests().size());
  Assert.assertEquals("Table snapshot should be the delete snapshot",
      deleteSnapshot, readMetadata().currentSnapshot());
  validateManifestEntries(readMetadata().currentSnapshot().allManifests().get(0),
      ids(deleteSnapshot.snapshotId(), appendSnapshot.snapshotId()),
      files(FILE_A, FILE_B), statuses(Status.DELETED, Status.EXISTING));

  Assert.assertEquals("Table should have a snapshot for each operation",
      2, readMetadata().snapshots().size());
  validateManifestEntries(readMetadata().snapshots().get(0).allManifests().get(0),
      ids(appendSnapshot.snapshotId(), appendSnapshot.snapshotId()),
      files(FILE_A, FILE_B), statuses(Status.ADDED, Status.ADDED));
}
 
Example 19
Source File: MLEnvironmentFactoryTest.java    From Alink with Apache License 2.0 4 votes vote down vote up
@Test
public void registerMLEnvironment() {
	MLEnvironment mlEnvironment = new MLEnvironment();
	Long mlEnvironmentId = MLEnvironmentFactory.registerMLEnvironment(mlEnvironment);
	Assert.assertSame(MLEnvironmentFactory.get(mlEnvironmentId), mlEnvironment);
}
 
Example 20
Source File: RuntimeClassoaderFactoryTest.java    From crnk-framework with Apache License 2.0 4 votes vote down vote up
@Test
public void checkTypescriptModelExposed() throws ClassNotFoundException {
	Assert.assertSame(TSMember.class, classLoader.loadClass(TSMember.class.getName()));
	Assert.assertSame(TSClassType.class, classLoader.loadClass(TSClassType.class.getName()));
	Assert.assertSame(TSImport.class, classLoader.loadClass(TSImport.class.getName()));
}