Java Code Examples for org.junit.jupiter.api.Assertions#assertNotEquals()

The following examples show how to use org.junit.jupiter.api.Assertions#assertNotEquals() . 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: TestPoolingDataSource.java    From commons-dbcp with Apache License 2.0 6 votes vote down vote up
@Test
public void testPoolGuardConnectionWrapperEqualsSameDelegate() throws Exception {
    // Get a maximal set of connections from the pool
    final Connection[] c = new Connection[getMaxTotal()];
    for (int i = 0; i < c.length; i++) {
        c[i] = newConnection();
    }
    // Close the delegate of one wrapper in the pool
    ((DelegatingConnection<?>) c[0]).getDelegate().close();

    // Grab a new connection - should get c[0]'s closed connection
    // so should be delegate-equivalent
    final Connection con = newConnection();
    Assertions.assertNotEquals(c[0], con);
    Assertions.assertEquals(
            ((DelegatingConnection<?>) c[0]).getInnermostDelegateInternal(),
            ((DelegatingConnection<?>) con).getInnermostDelegateInternal());
    for (final Connection element : c) {
        element.close();
    }
}
 
Example 2
Source File: AIROptionsParserTests.java    From vscode-as3mxml with Apache License 2.0 6 votes vote down vote up
@Test
void testAndroidPlatformSDK()
{
	String androidValue = "path/to/android_sdk";
	String iOSValue = "path/to/ios_sdk";
	ObjectNode options = JsonNodeFactory.instance.objectNode();
	ObjectNode android = JsonNodeFactory.instance.objectNode();
	android.set(AIROptions.PLATFORMSDK, JsonNodeFactory.instance.textNode(androidValue));
	options.set(AIRPlatform.ANDROID, android);
	ObjectNode ios = JsonNodeFactory.instance.objectNode();
	ios.set(AIROptions.PLATFORMSDK, JsonNodeFactory.instance.textNode(iOSValue));
	options.set(AIRPlatform.IOS, ios);
	ArrayList<String> result = new ArrayList<>();
	parser.parse(AIRPlatform.ANDROID, false, "application.xml", "content.swf", options, result);
	int optionIndex = result.indexOf("-" + AIROptions.PLATFORMSDK);
	Assertions.assertNotEquals(-1, optionIndex);
	Assertions.assertEquals(optionIndex + 1, result.indexOf(androidValue));
	Assertions.assertEquals(-1, result.indexOf(iOSValue));
}
 
Example 3
Source File: GemlockDetectableTest.java    From synopsys-detect with Apache License 2.0 6 votes vote down vote up
@Override
public void assertExtraction(@NotNull final Extraction extraction) {
    Assertions.assertNotEquals(0, extraction.getCodeLocations().size(), "A code location should have been generated.");

    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.RUBYGEMS, extraction.getCodeLocations().get(0).getDependencyGraph());
    graphAssert.hasRootSize(2);
    graphAssert.hasRootDependency("cocoapods", "1.2.1");
    graphAssert.hasRootDependency("cocoapods-keys", "2.0.0");

    graphAssert.hasDependency("RubyInline", "3.12.4");
    graphAssert.hasParentChildRelationship("RubyInline", "3.12.4", "ZenTest", "4.11.1");

    graphAssert.hasParentChildRelationship("activesupport", "4.2.8", "thread_safe", "0.3.6");
    graphAssert.hasParentChildRelationship("cocoapods", "1.2.1", "activesupport", "4.2.8");
    graphAssert.hasParentChildRelationship("cocoapods-keys", "2.0.0", "osx_keychain", "1.0.1");
}
 
Example 4
Source File: MosaicSearchCriteriaTest.java    From symbol-sdk-java with Apache License 2.0 6 votes vote down vote up
@Test
void shouldBeEquals() {

    Address address1 = Address.generateRandom(NetworkType.MIJIN_TEST);

    MosaicSearchCriteria criteria1 = new MosaicSearchCriteria()
        .order(OrderBy.ASC).pageSize(10).pageNumber(5).ownerAddress(address1).offset("abc");

    MosaicSearchCriteria criteria2 = new MosaicSearchCriteria()
        .order(OrderBy.ASC).pageSize(10).pageNumber(5).ownerAddress(address1).offset("abc");

    Assertions.assertEquals(new MosaicSearchCriteria(), new MosaicSearchCriteria());
    Assertions.assertEquals(criteria1, criteria2);
    Assertions.assertEquals(criteria1, criteria1);
    Assertions.assertEquals(criteria1.hashCode(), criteria2.hashCode());

    criteria1.pageNumber(30);
    Assertions.assertNotEquals(criteria1, criteria2);
    Assertions.assertNotEquals(criteria1.hashCode(), criteria2.hashCode());

    criteria2.pageNumber(100);
    Assertions.assertNotEquals(criteria1, criteria2);
    Assertions.assertNotEquals(criteria1.hashCode(), criteria2.hashCode());

    Assertions.assertNotEquals("ABC", criteria2);
}
 
Example 5
Source File: TestManagedDataSource.java    From commons-dbcp with Apache License 2.0 6 votes vote down vote up
@Test
public void testManagedConnectionEqualsSameDelegateNoUnderlyingAccess() throws Exception {
    // Get a maximal set of connections from the pool
    final Connection[] c = new Connection[getMaxTotal()];
    for (int i = 0; i < c.length; i++) {
        c[i] = newConnection();
    }
    // Close the delegate of one wrapper in the pool
    ((DelegatingConnection<?>) c[0]).getDelegate().close();

    // Disable access for the new connection
    ds.setAccessToUnderlyingConnectionAllowed(false);
    // Grab a new connection - should get c[0]'s closed connection
    // so should be delegate-equivalent
    final Connection con = newConnection();
    Assertions.assertNotEquals(c[0], con);
    Assertions.assertEquals(
            ((DelegatingConnection<?>) c[0]).getInnermostDelegateInternal(),
            ((DelegatingConnection<?>) con).getInnermostDelegateInternal());
    for (final Connection element : c) {
        element.close();
    }
    ds.setAccessToUnderlyingConnectionAllowed(true);
}
 
Example 6
Source File: AIROptionsParserTests.java    From vscode-as3mxml with Apache License 2.0 6 votes vote down vote up
@Test
void testApplicationContent()
{
	String filename = "content.swf";
	String dirPath = "path/to";
	String value = dirPath + "/" + filename;
	String formattedDirPath = Paths.get(dirPath).toString();
	ObjectNode options = JsonNodeFactory.instance.objectNode();
	ArrayList<String> result = new ArrayList<>();
	parser.parse(AIRPlatform.AIR, false, "application.xml", value, options, result);
	Assertions.assertFalse(result.contains(value),
		"AIROptionsParser.parse() incorrectly contains application content path.");
	int optionIndex = result.indexOf("-C");
	Assertions.assertNotEquals(-1, optionIndex);
	Assertions.assertEquals(optionIndex + 1, result.indexOf(formattedDirPath));
	Assertions.assertEquals(optionIndex + 2, result.indexOf(filename));
}
 
Example 7
Source File: OpenSessionOptionBuilderTest.java    From canon-sdk-java with MIT License 6 votes vote down vote up
@Test
void equalsAndHashcodeDefined() {
    final OpenSessionOption option = this.builder
        .setOpenSessionOnly(true)
        .setRegisterObjectEvent(false)
        .setRegisterPropertyEvent(false)
        .setRegisterStateEvent(false)
        .setCameraRef(cameraRef)
        .build();

    final OpenSessionOption optionEquals = builder
        .build();

    final OpenSessionOptionBuilder optionDifferent = builder.setRegisterObjectEvent(true);

    Assertions.assertEquals(option, optionEquals);
    Assertions.assertNotEquals(optionDifferent, option);

    Assertions.assertEquals(option.hashCode(), optionEquals.hashCode());
    Assertions.assertNotEquals(optionDifferent.hashCode(), option.hashCode());
}
 
Example 8
Source File: MonteCarloTest.java    From headlong with Apache License 2.0 6 votes vote down vote up
@Test
    public void testSignatureCollision() {
        String a = "O()";
        String b = "QChn()";

        Assertions.assertNotEquals(a, b);

        Function fa = Function.parse(a);
        Function fb = Function.parse(b);

//        System.out.println(fa.selectorHex() + " == " + fb.selectorHex());

        Assertions.assertEquals("a0ea32de", fa.selectorHex());

        Assertions.assertEquals(fa.selectorHex(), fb.selectorHex());
        Assertions.assertNotEquals(fa, fb);
    }
 
Example 9
Source File: BrentSolverTest.java    From commons-numbers with Apache License 2.0 6 votes vote down vote up
@Test
void testTooManyCalls() {
    final DoubleUnaryOperator func = new QuinticFunction();
    final BrentSolver solver = new BrentSolver(DEFAULT_ABSOLUTE_ACCURACY,
                                               DEFAULT_RELATIVE_ACCURACY,
                                               DEFAULT_FUNCTION_ACCURACY);

    // Very large bracket around 1 for testing fast growth behavior.
    final MonitoredFunction f = new MonitoredFunction(func);
    final double result = solver.findRoot(f, 0.85, 5);
    Assertions.assertEquals(1.0, result, DEFAULT_ABSOLUTE_ACCURACY);
    Assertions.assertTrue(f.getCallsCount() <= 15);

    final MonitoredFunction f2 = new MonitoredFunction(func, 10);
    final IllegalStateException ex = Assertions.assertThrows(IllegalStateException.class,
        () -> solver.findRoot(f2, 0.85, 5), "Expected too many calls condition");
    // Ensure expected error condition.
    Assertions.assertNotEquals(-1, ex.getMessage().indexOf("too many calls"));
}
 
Example 10
Source File: AIROptionsParserTests.java    From vscode-as3mxml with Apache License 2.0 5 votes vote down vote up
@Test
void testArch()
{
	String value = "x86";
	ObjectNode options = JsonNodeFactory.instance.objectNode();
	ObjectNode android = JsonNodeFactory.instance.objectNode();
	android.set(AIROptions.ARCH, JsonNodeFactory.instance.textNode(value));
	options.set(AIRPlatform.ANDROID, android);
	ArrayList<String> result = new ArrayList<>();
	parser.parse(AIRPlatform.ANDROID, false, "application.xml", "content.swf", options, result);
	int optionIndex = result.indexOf("-" + AIROptions.ARCH);
	Assertions.assertNotEquals(-1, optionIndex);
	Assertions.assertEquals(optionIndex + 1, result.indexOf(value));
}
 
Example 11
Source File: AIROptionsParserTests.java    From vscode-as3mxml with Apache License 2.0 5 votes vote down vote up
@Test
void testSigningOptionsKeystore()
{
	String value = "path/to/keystore.p12";
	ObjectNode options = JsonNodeFactory.instance.objectNode();
	ObjectNode signingOptions = JsonNodeFactory.instance.objectNode();
	signingOptions.set(AIRSigningOptions.KEYSTORE, JsonNodeFactory.instance.textNode(value));
	options.set(AIROptions.SIGNING_OPTIONS, signingOptions);
	ArrayList<String> result = new ArrayList<>();
	parser.parse(AIRPlatform.AIR, false, "application.xml", "content.swf", options, result);
	int optionIndex = result.indexOf("-" + AIRSigningOptions.KEYSTORE);
	Assertions.assertNotEquals(-1, optionIndex);
	Assertions.assertEquals(optionIndex + 1, result.indexOf(value));
}
 
Example 12
Source File: TestResourceRegistration.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testUraniumResource() {
    NamespacedKey key = new NamespacedKey(plugin, "uranium");
    GEOResource resource = testResource(key, "Small Chunks of Uranium", SlimefunItems.SMALL_URANIUM, true, 2);

    Assertions.assertNotEquals(0, resource.getDefaultSupply(Environment.NORMAL, Biome.MOUNTAINS));
    Assertions.assertEquals(0, resource.getDefaultSupply(Environment.NETHER, Biome.NETHER_WASTES));
    Assertions.assertEquals(0, resource.getDefaultSupply(Environment.THE_END, Biome.THE_END));
}
 
Example 13
Source File: AIROptionsParserTests.java    From vscode-as3mxml with Apache License 2.0 5 votes vote down vote up
@Test
void testSigningOptionsProviderName()
{
	String value = "className";
	ObjectNode options = JsonNodeFactory.instance.objectNode();
	ObjectNode signingOptions = JsonNodeFactory.instance.objectNode();
	signingOptions.set(AIRSigningOptions.PROVIDER_NAME, JsonNodeFactory.instance.textNode(value));
	options.set(AIROptions.SIGNING_OPTIONS, signingOptions);
	ArrayList<String> result = new ArrayList<>();
	parser.parse(AIRPlatform.AIR, false, "application.xml", "content.swf", options, result);
	int optionIndex = result.indexOf("-" + AIRSigningOptions.PROVIDER_NAME);
	Assertions.assertNotEquals(-1, optionIndex);
	Assertions.assertEquals(optionIndex + 1, result.indexOf(value));
}
 
Example 14
Source File: ComplexTest.java    From commons-numbers with Apache License 2.0 5 votes vote down vote up
@Test
void testMultiplyZeroByNegativeI() {
    // Depending on how we represent -I this does not work for 2/4 cases
    // but the cases are different. Here we test the negation of I.
    final Complex negI = Complex.I.negate();
    final double[] zeros = {-0.0, 0.0};
    for (final double a : zeros) {
        for (final double b : zeros) {
            final Complex c = Complex.ofCartesian(a, b);
            final Complex x = c.multiplyImaginary(-1.0);
            // Check verses algebra solution
            Assertions.assertEquals(b, x.getReal());
            Assertions.assertEquals(-a, x.getImaginary());
            final Complex z = c.multiply(negI);
            final Complex z2 = c.multiply(Complex.I).negate();
            // Does not work when imaginary part is -0.0.
            if (Double.compare(b, -0.0) == 0) {
                // (-0.0,-0.0).multiply( (-0.0,-1) ) => ( 0.0, 0.0) expected (-0.0,
                // 0.0)
                // ( 0.0,-0.0).multiply( (-0.0,-1) ) => (-0.0, 0.0) expected
                // (-0.0,-0.0)
                Assertions.assertEquals(0, z.getReal(), 0.0);
                Assertions.assertEquals(0, z.getImaginary(), 0.0);
                Assertions.assertNotEquals(x, z);
                // When multiply by I.negate() fails multiply by I then negate()
                // works!
                Assertions.assertEquals(x, z2);
            } else {
                Assertions.assertEquals(x, z);
                // When multiply by I.negate() works multiply by I then negate()
                // fails!
                Assertions.assertNotEquals(x, z2);
            }
        }
    }
}
 
Example 15
Source File: TestPStmtKey.java    From commons-dbcp with Apache License 2.0 5 votes vote down vote up
/**
 * Tests constructors with different catalog.
 */
@Test
public void testCtorDifferentCatalog() {
    Assertions.assertNotEquals(new PStmtKey("sql", "catalog1", "schema1"), new PStmtKey("sql", "catalog2", "schema1"));
    Assertions.assertNotEquals(new PStmtKey("sql", "catalog1", "schema1", 0),
            new PStmtKey("sql", "catalog2", "schema1", 0));
    Assertions.assertNotEquals(new PStmtKey("sql", "catalog1", "schema1", 0, 0),
            new PStmtKey("sql", "catalog2", "schema1", 0, 0));
    Assertions.assertNotEquals(new PStmtKey("sql", "catalog1", "schema1", 0, 0, 0),
            new PStmtKey("sql", "catalog2", "schema1", 0, 0, 0));
    //
    Assertions.assertNotEquals(new PStmtKey("sql", "catalog1", "schema1", 0, 0, 0, null),
            new PStmtKey("sql", "catalog2", "schema1", 0, 0, 0, null));
    Assertions.assertNotEquals(new PStmtKey("sql", "catalog1", "schema1", 0, 0, 0, StatementType.PREPARED_STATEMENT),
            new PStmtKey("sql", "catalog2", "schema1", 0, 0, 0, StatementType.PREPARED_STATEMENT));
    //
    Assertions.assertNotEquals(new PStmtKey("sql", "catalog1", "schema1", 0, 0, null),
            new PStmtKey("sql", "catalog2", "schema1", 0, 0, null));
    Assertions.assertNotEquals(new PStmtKey("sql", "catalog1", "schema1", 0, 0, StatementType.PREPARED_STATEMENT),
            new PStmtKey("sql", "catalog2", "schema1", 0, 0, StatementType.PREPARED_STATEMENT));
    //
    Assertions.assertNotEquals(new PStmtKey("sql", "catalog1", "schema1", (int[]) null),
            new PStmtKey("sql", "catalog2", "schema1", (int[]) null));
    Assertions.assertNotEquals(new PStmtKey("sql", "catalog1", "schema1", new int[1]),
            new PStmtKey("sql", "catalog2", "schema1", new int[1]));
    Assertions.assertNotEquals(new PStmtKey("sql", "catalog1", "schema1", (String[]) null),
            new PStmtKey("sql", "catalog2", "schema1", (String[]) null));
    Assertions.assertNotEquals(new PStmtKey("sql", "catalog1", "schema1", new String[] {"A" }),
            new PStmtKey("sql", "catalog2", "schema1", new String[] {"A" }));
    Assertions.assertNotEquals(new PStmtKey("sql", "catalog1", "schema1", StatementType.PREPARED_STATEMENT),
            new PStmtKey("sql", "catalog2", "schema1", StatementType.PREPARED_STATEMENT));
    Assertions.assertNotEquals(
            new PStmtKey("sql", "catalog1", "schema1", StatementType.PREPARED_STATEMENT, Integer.MAX_VALUE),
            new PStmtKey("sql", "catalog2", "schema1", StatementType.PREPARED_STATEMENT, Integer.MAX_VALUE));
}
 
Example 16
Source File: CanonCommandCopyTest.java    From canon-sdk-java with MIT License 5 votes vote down vote up
@Test
void canCopyCommand() {
    final Set<CanonCommand> commands = getAllCommands();

    for (final CanonCommand command : commands) {
        final CanonCommand copy = command.copy();

        Assertions.assertNotEquals(copy, command);
        Assertions.assertNotSame(copy, command);

        Assertions.assertEquals(command.getClass(), copy.getClass());
    }
}
 
Example 17
Source File: ComplexTest.java    From commons-numbers with Apache License 2.0 5 votes vote down vote up
@Test
void testSubtractFromImaginaryWithPosZeroReal() {
    final Complex x = Complex.ofCartesian(0.0, 4.0);
    final double y = 5.0;
    final Complex z = x.subtractFromImaginary(y);
    Assertions.assertEquals(-0.0, z.getReal(), "Expected sign inversion");
    Assertions.assertEquals(1.0, z.getImaginary());
    // Sign-inversion is a problem: 0.0 - 0.0 == 0.0
    Assertions.assertNotEquals(z, ofImaginary(y).subtract(x));
}
 
Example 18
Source File: AIROptionsParserTests.java    From vscode-as3mxml with Apache License 2.0 5 votes vote down vote up
@Test
void testSigningOptionsRelease()
{
	String debugKeystore = "path/to/debug_keystore.p12";
	String debugStoretype = "pkcs12";
	String releaseKeystore = "path/to/keystore.keystore";
	String releaseStoretype = "jks";

	ObjectNode options = JsonNodeFactory.instance.objectNode();

	ObjectNode signingOptions = JsonNodeFactory.instance.objectNode();

	ObjectNode debugSigningOptions = JsonNodeFactory.instance.objectNode();
	debugSigningOptions.set(AIRSigningOptions.KEYSTORE, JsonNodeFactory.instance.textNode(debugKeystore));
	debugSigningOptions.set(AIRSigningOptions.STORETYPE, JsonNodeFactory.instance.textNode(debugStoretype));
	signingOptions.set("debug", debugSigningOptions);

	ObjectNode releaseSigningOptions = JsonNodeFactory.instance.objectNode();
	releaseSigningOptions.set(AIRSigningOptions.KEYSTORE, JsonNodeFactory.instance.textNode(releaseKeystore));
	releaseSigningOptions.set(AIRSigningOptions.STORETYPE, JsonNodeFactory.instance.textNode(releaseStoretype));
	signingOptions.set("release", releaseSigningOptions);

	options.set(AIROptions.SIGNING_OPTIONS, signingOptions);
	ArrayList<String> result = new ArrayList<>();
	parser.parse(AIRPlatform.ANDROID, false, "application.xml", "content.swf", options, result);
	int optionIndex1 = result.indexOf("-" + AIRSigningOptions.STORETYPE);
	Assertions.assertNotEquals(-1, optionIndex1);
	Assertions.assertEquals(optionIndex1 + 1, result.indexOf(releaseStoretype));
	int optionIndex2 = optionIndex1 + 1 + result.subList(optionIndex1 + 1, result.size()).indexOf("-" + AIRSigningOptions.KEYSTORE);
	Assertions.assertEquals(optionIndex1 + 2, optionIndex2);
	Assertions.assertEquals(optionIndex2 + 1, result.indexOf(releaseKeystore));
}
 
Example 19
Source File: ComplexTest.java    From commons-numbers with Apache License 2.0 5 votes vote down vote up
/**
 * Test {@link Complex#equals(Object)}. It should be consistent with
 * {@link Arrays#equals(double[], double[])} called using the components of two
 * complex numbers.
 */
@Test
void testEqualsIsConsistentWithArraysEquals() {
    // Explicit check of the cases documented in the Javadoc:
    assertEqualsIsConsistentWithArraysEquals(Complex.ofCartesian(Double.NaN, 0.0),
        Complex.ofCartesian(Double.NaN, 1.0), "NaN real and different non-NaN imaginary");
    assertEqualsIsConsistentWithArraysEquals(Complex.ofCartesian(0.0, Double.NaN),
        Complex.ofCartesian(1.0, Double.NaN), "Different non-NaN real and NaN imaginary");
    assertEqualsIsConsistentWithArraysEquals(Complex.ofCartesian(0.0, 0.0), Complex.ofCartesian(-0.0, 0.0),
        "Different real zeros");
    assertEqualsIsConsistentWithArraysEquals(Complex.ofCartesian(0.0, 0.0), Complex.ofCartesian(0.0, -0.0),
        "Different imaginary zeros");

    // Test some values of edge cases
    final double[] values = {Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, -1, 0, 1};
    final ArrayList<Complex> list = createCombinations(values);

    for (final Complex c : list) {
        final double real = c.getReal();
        final double imag = c.getImaginary();

        // Check a copy is equal
        assertEqualsIsConsistentWithArraysEquals(c, Complex.ofCartesian(real, imag), "Copy complex");

        // Perform the smallest change to the two components
        final double realDelta = smallestChange(real);
        final double imagDelta = smallestChange(imag);
        Assertions.assertNotEquals(real, realDelta, "Real was not changed");
        Assertions.assertNotEquals(imag, imagDelta, "Imaginary was not changed");

        assertEqualsIsConsistentWithArraysEquals(c, Complex.ofCartesian(realDelta, imag), "Delta real");
        assertEqualsIsConsistentWithArraysEquals(c, Complex.ofCartesian(real, imagDelta), "Delta imaginary");
    }
}
 
Example 20
Source File: FactorialDoubleTest.java    From commons-numbers with Apache License 2.0 4 votes vote down vote up
@Test
void testLargestFactorialDouble() {
    final int n = 170;
    Assertions.assertNotEquals(
        Double.POSITIVE_INFINITY, FactorialDouble.create().value(n), () -> n + "!");
}