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

The following examples show how to use org.testng.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: TestNamespaceFacade.java    From xian with Apache License 2.0 6 votes vote down vote up
@Test
public void     testCache() throws Exception
{
    CuratorFramework    client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
    try
    {
        client.start();

        Assert.assertSame(client.usingNamespace("foo"), client.usingNamespace("foo"));
        Assert.assertNotSame(client.usingNamespace("foo"), client.usingNamespace("bar"));
    }
    finally
    {
        CloseableUtils.closeQuietly(client);
    }
}
 
Example 2
Source File: TestRepositoryManager.java    From sqoop-on-spark with Apache License 2.0 6 votes vote down vote up
@Test
public void testSystemNotInitialized() throws Exception {
  // Unset any configuration dir if it is set by another test
  System.getProperties().remove(ConfigurationConstants.SYSPROP_CONFIG_DIR);
  Properties bootProps = new Properties();
  bootProps.setProperty(ConfigurationConstants.BOOTCFG_CONFIG_PROVIDER,
      PropertiesConfigurationProvider.class.getCanonicalName());
  Properties configProps = new Properties();
  SqoopTestUtils.setupTestConfigurationUsingProperties(bootProps, configProps);
  try {
    SqoopConfiguration.getInstance().initialize();
    RepositoryManager.getInstance().initialize();
  } catch (Exception ex) {
    Assert.assertTrue(ex instanceof SqoopException);
    Assert.assertSame(((SqoopException) ex).getErrorCode(),
        RepositoryError.REPO_0001);
  }
}
 
Example 3
Source File: TestSqoopConfiguration.java    From sqoop-on-spark with Apache License 2.0 6 votes vote down vote up
@Test
public void testConfigurationProviderInvalid() throws Exception {
  boolean success = false;
  Properties bootProps = new Properties();
  bootProps.setProperty(ConfigurationConstants.BOOTCFG_CONFIG_PROVIDER,
      "foobar");
  SqoopTestUtils.setupTestConfigurationUsingProperties(bootProps, null);
  try {
    SqoopConfiguration.getInstance().initialize();
  } catch (Exception ex) {
    Assert.assertTrue(ex instanceof SqoopException);
    Assert.assertSame(((SqoopException) ex).getErrorCode(),
        CoreError.CORE_0004);

    success = true;
  }

  Assert.assertTrue(success);
}
 
Example 4
Source File: NucleotideUnitTest.java    From gatk with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void testLongFormNamesForTypos() {
    // We avoid a direct comparison of the constant value (rather than indirectly using its name)
    // because that would typos and here the names matter and are unlikely to change even in the long term.
    Assert.assertSame(constantNameToInstance("ADENINE"), Nucleotide.A);
    Assert.assertSame(constantNameToInstance("THYMINE"), Nucleotide.T);
    Assert.assertSame(constantNameToInstance("GUANINE"), Nucleotide.G);
    Assert.assertSame(constantNameToInstance("CYTOSINE"), Nucleotide.C);
    Assert.assertSame(constantNameToInstance("URACIL"), Nucleotide.U);
    Assert.assertSame(constantNameToInstance("ANY"), Nucleotide.N);
    Assert.assertSame(constantNameToInstance("PURINE"), Nucleotide.R);
    Assert.assertSame(constantNameToInstance("PYRIMIDINE"), Nucleotide.Y);
    Assert.assertSame(constantNameToInstance("INVALID"), Nucleotide.X);
    Assert.assertSame(constantNameToInstance("STRONG"), Nucleotide.S);
    Assert.assertSame(constantNameToInstance("WEAK"), Nucleotide.W);
    Assert.assertSame(constantNameToInstance("KETO"), Nucleotide.K);
    Assert.assertSame(constantNameToInstance("AMINO"), Nucleotide.M);
}
 
Example 5
Source File: DRPCPubSubTest.java    From bullet-storm with Apache License 2.0 6 votes vote down vote up
@Test
public void testQuerySubmissionOneInstanceIsTheSameInstance() throws Exception {
    config.set(DRPCConfig.PUBSUB_CONTEXT_NAME, PubSub.Context.QUERY_SUBMISSION.name());
    DRPCPubSub pubSub = new DRPCPubSub(config);

    Publisher publisher = pubSub.getPublisher();
    Subscriber subscriber = pubSub.getSubscriber();

    Assert.assertSame(publisher, subscriber);

    // All future calls just return the same instance
    Assert.assertSame(publisher, pubSub.getPublisher());
    Assert.assertSame(subscriber, pubSub.getSubscriber());
    Assert.assertSame(pubSub.getPublisher(), pubSub.getSubscriber());

    // So do calls to get multiples after
    List<Publisher> publishers = pubSub.getPublishers(42);
    List<Subscriber> subscribers = pubSub.getSubscribers(20);

    Assert.assertEquals(publishers.size(), 1);
    Assert.assertEquals(subscribers.size(), 1);
    Assert.assertEquals(publishers.get(0), publisher);
    Assert.assertEquals(subscribers.get(0), subscriber);
}
 
Example 6
Source File: Bug5072946.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test3() throws Exception {
    SAXTransformerFactory sf = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
    Transformer t = sf.newTransformer();

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    DocumentBuilder parser = dbf.newDocumentBuilder();
    Document dom = parser.parse(Bug5072946.class.getResourceAsStream("Bug5072946.xml"));

    DOMResult r = new DOMResult();

    t.transform(new DOMSource(dom), r);
    Assert.assertNotNull(r.getNode());

    Node n = r.getNode().getFirstChild();
    r.setNode(n);
    t.transform(new DOMSource(dom), r);
    Assert.assertNotNull(r.getNode());
    Assert.assertSame(r.getNode(), n);

    r.setNextSibling(r.getNode().getFirstChild());
    t.transform(new DOMSource(dom), r);
    Assert.assertNotNull(r.getNode());
    Assert.assertSame(r.getNode(), n);
}
 
Example 7
Source File: SeqTest.java    From jenetics with Apache License 2.0 5 votes vote down vote up
@Test
public void mapEmptyMSeq() {
	final Seq<Integer> integers = Seq.empty();
	final Seq<String> strings = integers.map(Object::toString);

	Assert.assertSame(integers, strings);
	Assert.assertSame(strings, Seq.empty());
}
 
Example 8
Source File: FastDatumReaderWriterUtilTest.java    From avro-util with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test (groups = "deserializationTest")
public void testIsSupportedForFastSpecificDatumReader() {
  Schema testWriterSchema = Schema.parse("{\"type\": \"record\", \"name\": \"test_record\", \"fields\":[]}");
  Schema testReaderSchema = Schema.parse("{\"type\": \"record\", \"name\": \"test_record\", \"fields\":[]}");
  FastSpecificDatumReader fastReader = FastDatumReaderWriterUtil.getFastSpecificDatumReader(testWriterSchema, testReaderSchema);
  Assert.assertNotNull(fastReader);
  FastSpecificDatumReader newFastReader = FastDatumReaderWriterUtil.getFastSpecificDatumReader(testWriterSchema, testReaderSchema);
  Assert.assertSame(fastReader, newFastReader);
}
 
Example 9
Source File: SVFastqUtilsUnitTest.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void assertMappingIsAsExpected(final SVFastqUtils.Mapping mapping, final String[] contig, final int[] start,
                                  final boolean[] forward, final Cigar[] cigarAlongRef,
                                  final int[] mappingQual, final int[] mismatches,
                                  final int[] alignmentScores) {
    Assert.assertEquals(mapping.getAllIntervals().size(), contig.length);
    Assert.assertEquals(mapping.isMapped(), contig.length > 0);
    if (!mapping.isMapped()) {
        Assert.assertNull(mapping.getPrimaryInterval());
        Assert.assertTrue(mapping.getSupplementaryIntervals().isEmpty());
        Assert.assertEquals(mapping.getCigar(), new Cigar());
        Assert.assertNull(mapping.getContig());
        Assert.assertEquals(mapping.getStart(), SAMRecord.NO_ALIGNMENT_START);
        Assert.assertEquals(mapping.getEnd(), SAMRecord.NO_ALIGNMENT_START);
    } else {
        Assert.assertEquals(mapping.getSupplementaryIntervals().size(), contig.length - 1);
        for (int i = 0; i < contig.length; i++) {
            final AlignmentInterval ai = mapping.getAllIntervals().get(i);
            Assert.assertNotNull(ai);
            Assert.assertEquals(ai.referenceSpan.getContig(), contig[i]);
            Assert.assertEquals(ai.referenceSpan.getStart(), start[i]);
            Assert.assertEquals(ai.forwardStrand, forward[i]);
            Assert.assertEquals(ai.cigarAlongReference(), cigarAlongRef[i]);
            Assert.assertEquals(ai.mapQual, mappingQual[i]);
            Assert.assertEquals(ai.mismatches, mismatches[i]);
            Assert.assertEquals(ai.alnScore, alignmentScores[i]);
            if (i == 0) {
                Assert.assertSame(ai, mapping.getPrimaryInterval());
                Assert.assertEquals(mapping.getCigar(), ai.cigarAlongReference());
                Assert.assertEquals(mapping.getContig(), ai.referenceSpan.getContig());
                Assert.assertEquals(mapping.getStart(), ai.referenceSpan.getStart());
                Assert.assertEquals(mapping.getEnd(), ai.referenceSpan.getEnd());
                Assert.assertEquals(mapping.isForwardStrand(), ai.forwardStrand);
            } else {
                Assert.assertSame(ai, mapping.getSupplementaryIntervals().get(i - 1));
            }
        }
    }

}
 
Example 10
Source File: XmlMementoSerializerTest.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
@Test
public void testConfigInheritanceVals() throws Exception {
    ConfigInheritance val = BasicConfigInheritance.NEVER_INHERITED;

    ConfigInheritance newVal = assertSerializeAndDeserialize(val);
    Assert.assertSame(val, newVal);
}
 
Example 11
Source File: DAOProviderUtilTest.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
@Test
public void testProviderReturnsSameInstance() {
  DAORegistry daoRegistry = DAORegistry.getInstance();
  MergedAnomalyResultManager m1 = daoRegistry.getMergedAnomalyResultDAO();
  MergedAnomalyResultManager m2 = daoRegistry.getMergedAnomalyResultDAO();
  Assert.assertSame(m1, m2);
}
 
Example 12
Source File: TestStorageCache.java    From PalDB with Apache License 2.0 5 votes vote down vote up
@Test
public void testPutTwice() {
  Integer second = 1;
  StorageCache cache = StorageCache.initCache(_configuration);
  cache.put(0, 1);
  cache.put(0, second);
  Assert.assertSame(cache.get(0), second);
}
 
Example 13
Source File: MysqlSchemaCodegenTest.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetMysqlMatchedStringDataType() {
    final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen();
    Assert.assertSame(codegen.getMysqlMatchedStringDataType(6, 6), "CHAR");
    Assert.assertSame(codegen.getMysqlMatchedStringDataType(0, 0), "CHAR");
    Assert.assertSame(codegen.getMysqlMatchedStringDataType(255, 255), "CHAR");

    Assert.assertSame(codegen.getMysqlMatchedStringDataType(null, 100), "VARCHAR");
    Assert.assertSame(codegen.getMysqlMatchedStringDataType(null, 255), "VARCHAR");
    Assert.assertSame(codegen.getMysqlMatchedStringDataType(50, 255), "VARCHAR");
    Assert.assertSame(codegen.getMysqlMatchedStringDataType(100, 20), "VARCHAR");

    Assert.assertSame(codegen.getMysqlMatchedStringDataType(null, null), "TEXT");
    Assert.assertSame(codegen.getMysqlMatchedStringDataType(100, null), "TEXT");
    Assert.assertSame(codegen.getMysqlMatchedStringDataType(255, null), "TEXT");
    Assert.assertSame(codegen.getMysqlMatchedStringDataType(null, 256), "TEXT");

    Assert.assertSame(codegen.getMysqlMatchedStringDataType(16777215, null), "MEDIUMTEXT");
    Assert.assertSame(codegen.getMysqlMatchedStringDataType(16777215, 100), "MEDIUMTEXT");
    Assert.assertSame(codegen.getMysqlMatchedStringDataType(null, 16777215), "MEDIUMTEXT");
    Assert.assertSame(codegen.getMysqlMatchedStringDataType(100, 16777215), "MEDIUMTEXT");

    Assert.assertSame(codegen.getMysqlMatchedStringDataType(16777216, null), "LONGTEXT");
    Assert.assertSame(codegen.getMysqlMatchedStringDataType(null, 16777216), "LONGTEXT");
    Assert.assertSame(codegen.getMysqlMatchedStringDataType(16777216, 16777216), "LONGTEXT");
    Assert.assertSame(codegen.getMysqlMatchedStringDataType(100, 16777216), "LONGTEXT");
    Assert.assertSame(codegen.getMysqlMatchedStringDataType(100, Integer.MAX_VALUE), "LONGTEXT");
}
 
Example 14
Source File: SeqTest.java    From jenetics with Apache License 2.0 5 votes vote down vote up
@Test
public void emptySeqPrepend() {
	final Seq<Integer> empty = Seq.empty();
	final Seq<Integer> seq = Seq.of(1, 2, 3, 4);
	final Seq<Integer> aseq = empty.prepend(seq);

	Assert.assertEquals(aseq, seq);
	Assert.assertSame(aseq, seq);
}
 
Example 15
Source File: TestSerializers.java    From PalDB with Apache License 2.0 5 votes vote down vote up
@Test
public void testRegister() {
  ColorSerializer i = new ColorSerializer();
  _serializers.registerSerializer(i);
  Assert.assertSame(_serializers.getSerializer(Color.class), i);
  Assert.assertEquals(_serializers.getIndex(Color.class), 0);
}
 
Example 16
Source File: TestSerializers.java    From PalDB with Apache License 2.0 5 votes vote down vote up
@Test
public void testRegisterTwice() {
  ColorSerializer i1 = new ColorSerializer();
  ColorSerializer i2 = new ColorSerializer();
  _serializers.registerSerializer(i1);
  _serializers.registerSerializer(i2);
  Assert.assertSame(_serializers.getSerializer(Color.class), i1);
}
 
Example 17
Source File: DataLineUnitTest.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test(dataProvider = "tableColumnsData")
public void testGetInt(final TableColumnCollection columns) {
    final DataLine subject = new DataLine(columns, IllegalArgumentException::new);
    for (int i = 0; i < columns.columnCount(); i++) {
        Assert.assertSame(subject.set(columns.nameAt(i), i), subject);
    }
    for (int i = 0; i < columns.columnCount(); i++) {
        Assert.assertEquals(subject.getInt(i), i);
    }
}
 
Example 18
Source File: DataLineUnitTest.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test(dataProvider = "tableColumnsData")
public void testSetAndGetBoolean(final TableColumnCollection columns) {
    final DataLine subject = new DataLine(columns, IllegalArgumentException::new);
    for (int i = 0; i < columns.columnCount(); i++) {
        Assert.assertSame(subject.set(columns.nameAt(i), (i & 1) == 0), subject);
    }
    for (int i = 0; i < columns.columnCount(); i++) {
        Assert.assertEquals(subject.getBoolean(i), 0 == (i & 1));
    }
}
 
Example 19
Source File: TableColumnCollectionUnitTest.java    From gatk with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Test(dataProvider= "correctColumnNamesData")
public void testCheckNamesOnCorrectData(final String[] names) {
    Assert.assertSame(TableColumnCollection.checkNames(names, IllegalArgumentException::new), names);
}
 
Example 20
Source File: TestSerializers.java    From PalDB with Apache License 2.0 4 votes vote down vote up
@Test
public void testInterfaceType() throws Throwable {
  SerializerWithInterface i = new SerializerWithInterface();
  _serializers.registerSerializer(i);
  Assert.assertSame(_serializers.getSerializer(AnInterface.class), i);
}