Java Code Examples for org.junit.jupiter.api.Assertions#assertNotSame()
The following examples show how to use
org.junit.jupiter.api.Assertions#assertNotSame() .
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: TestManagedDataSourceInTx.java From commons-dbcp with Apache License 2.0 | 6 votes |
@Override @Test public void testConnectionsAreDistinct() throws Exception { final Connection[] conn = new Connection[getMaxTotal()]; for(int i=0;i<conn.length;i++) { conn[i] = newConnection(); for(int j=0;j<i;j++) { // two connections should be distinct instances Assertions.assertNotSame(conn[j], conn[i]); // neither should they should be equivalent even though they are // sharing the same underlying connection Assertions.assertNotEquals(conn[j], conn[i]); // Check underlying connection is the same Assertions.assertEquals(((DelegatingConnection<?>) conn[j]).getInnermostDelegateInternal(), ((DelegatingConnection<?>) conn[i]).getInnermostDelegateInternal()); } } for (final Connection element : conn) { element.close(); } }
Example 2
Source File: CopyCommandTest.java From canon-sdk-java with MIT License | 6 votes |
@Test void copyByMethod2Decorator() { final ProductName command = new ProductName(); final DefaultValueOnErrorDecorator<String> decorated = new DefaultValueOnErrorDecorator<>(command, "default"); final DefaultValueOnErrorDecorator<String> decorated2 = new DefaultValueOnErrorDecorator<>(decorated, "default 2"); final DefaultValueOnErrorDecorator<String> copyDecorated2 = (DefaultValueOnErrorDecorator<String>) decorated2.copy(); Assertions.assertNotSame(copyDecorated2, decorated); Assertions.assertNotSame(copyDecorated2, decorated2); Assertions.assertNotSame(copyDecorated2.getRoot(), command); Assertions.assertNotNull(copyDecorated2.getRoot()); // TODO for later when command finished to impl // Assertions.assertEquals("default 2", decorated2.get()); // Assertions.assertEquals("default 2", copyDecorated2.get()); }
Example 3
Source File: JavaClassLoaderTest.java From cuba with Apache License 2.0 | 6 votes |
@Test public void testInnerClasses() throws Exception { JavaClassLoader javaClassLoader = new JavaClassLoader(null, "./test-data/javacl-sources/", "", new SpringBeanLoader()) { @Override protected Date getCurrentTimestamp() { return new Date(); } }; Class<?> class1 = javaClassLoader.loadClass("com.haulmont.cuba.core.sys.javacl.test3.OuterClass"); Class<?> innerClass1 = javaClassLoader.compiled.get("com.haulmont.cuba.core.sys.javacl.test3.OuterClass$InnerClass").clazz; Class<?> innerClass2 = javaClassLoader.compiled.get("com.haulmont.cuba.core.sys.javacl.test3.OuterClass$1").clazz; System.out.println("Class loaded"); Assertions.assertEquals(javaClassLoader.compiled.size(), 3); modifyFile("./test-data/javacl-sources/com/haulmont/cuba/core/sys/javacl/test3/OuterClass.java"); Class<?> class2 = javaClassLoader.loadClass("com.haulmont.cuba.core.sys.javacl.test3.OuterClass"); Class<?> innerClass3 = javaClassLoader.compiled.get("com.haulmont.cuba.core.sys.javacl.test3.OuterClass$InnerClass").clazz; Class<?> innerClass4 = javaClassLoader.compiled.get("com.haulmont.cuba.core.sys.javacl.test3.OuterClass$1").clazz; Assertions.assertNotSame(class1, class2); Assertions.assertNotSame(innerClass1, innerClass3); Assertions.assertNotSame(innerClass2, innerClass4); }
Example 4
Source File: JavaClassLoaderTest.java From cuba with Apache License 2.0 | 6 votes |
@Test public void testTwiceCompilation() throws Exception { JavaClassLoader javaClassLoader = new JavaClassLoader(null, "./test-data/javacl-sources/", "", new SpringBeanLoader()) { @Override protected Date getCurrentTimestamp() { return new Date(); } }; Class<?> class1 = javaClassLoader.loadClass("com.haulmont.cuba.core.sys.javacl.test2.DependentClass"); Class<?> dependencyClass1 = javaClassLoader.loadClass("com.haulmont.cuba.core.sys.javacl.test2.pack1.DependencyClass"); Class<?> dependency2Class1 = javaClassLoader.loadClass("com.haulmont.cuba.core.sys.javacl.test2.pack2.Dependency2Class"); System.out.println("Class loaded"); Assertions.assertEquals(javaClassLoader.compiled.size(), 3); modifyFile("./test-data/javacl-sources/com/haulmont/cuba/core/sys/javacl/test2/DependentClass.java"); modifyFile("./test-data/javacl-sources/com/haulmont/cuba/core/sys/javacl/test2/pack1/DependencyClass.java"); System.out.println("DependentClass modified"); System.out.println("DependencyClass modified"); Class<?> class2 = javaClassLoader.loadClass("com.haulmont.cuba.core.sys.javacl.test2.DependentClass"); Class<?> dependencyClass2 = javaClassLoader.loadClass("com.haulmont.cuba.core.sys.javacl.test2.pack1.DependencyClass"); Class<?> dependency2Class2 = javaClassLoader.loadClass("com.haulmont.cuba.core.sys.javacl.test2.pack2.Dependency2Class"); Assertions.assertNotSame(class1, class2); Assertions.assertNotSame(dependencyClass1, dependencyClass2); Assertions.assertSame(dependency2Class1, dependency2Class2); }
Example 5
Source File: CopyCommandTest.java From canon-sdk-java with MIT License | 5 votes |
@Test void copyByMethod() { final ProductName command = new ProductName(); final ProductName copy = (ProductName) command.copy(); Assertions.assertNotNull(copy); Assertions.assertNotSame(copy, command); }
Example 6
Source File: CompositeRegistryTest.java From spectator with Apache License 2.0 | 5 votes |
@Test public void testRegisterBadTypeAccessNoThrow() { Registry r = newRegistry(5, false); Counter c = new DefaultCounter(clock, r.createId("foo")); r.counter(c.id()); r.register(c); Assertions.assertNotSame(r.get(c.id()), c); }
Example 7
Source File: RegistryTest.java From spectator with Apache License 2.0 | 5 votes |
@Test public void testTimerHelpers() { Registry r = newRegistry(true, 10000); Timer c1 = r.timer("foo", "bar", "baz", "k", "v"); Timer c2 = r.timer("foo", ArrayTagSet.create("k", "v").add(new BasicTag("bar", "baz"))); Timer c3 = r.timer("foo"); Assertions.assertSame(unwrap(c1), unwrap(c2)); Assertions.assertNotSame(unwrap(c1), unwrap(c3)); }
Example 8
Source File: RegistryTest.java From spectator with Apache License 2.0 | 5 votes |
@Test public void testDistributionSummaryHelpers() { Registry r = newRegistry(true, 10000); DistributionSummary c1 = r.distributionSummary("foo", "bar", "baz", "k", "v"); DistributionSummary c2 = r.distributionSummary("foo", ArrayTagSet.create("k", "v").add(new BasicTag("bar", "baz"))); DistributionSummary c3 = r.distributionSummary("foo"); Assertions.assertSame(unwrap(c1), unwrap(c2)); Assertions.assertNotSame(unwrap(c1), unwrap(c3)); }
Example 9
Source File: RegistryTest.java From spectator with Apache License 2.0 | 5 votes |
@Test public void testCounterHelpers() { Registry r = newRegistry(true, 10000); Counter c1 = r.counter("foo", "bar", "baz", "k", "v"); Counter c2 = r.counter("foo", ArrayTagSet.create("k", "v").add(new BasicTag("bar", "baz"))); Counter c3 = r.counter("foo"); Assertions.assertSame(unwrap(c1), unwrap(c2)); Assertions.assertNotSame(unwrap(c1), unwrap(c3)); }
Example 10
Source File: ArrayTagSetTest.java From spectator with Apache License 2.0 | 5 votes |
@Test public void testMergeTagWithSameKey() { ArrayTagSet initial = ArrayTagSet.create("k1", "v1"); ArrayTagSet expected = ArrayTagSet.create("k1", "v2"); ArrayTagSet actual = initial.addAll(expected); Assertions.assertNotSame(expected, actual); Assertions.assertEquals(expected, actual); }
Example 11
Source File: JavaClassLoaderTest.java From cuba with Apache License 2.0 | 5 votes |
@Test public void testDependent() throws Exception { JavaClassLoader javaClassLoader = new JavaClassLoader(null, "./test-data/javacl-sources/", "", new SpringBeanLoader()) { @Override protected Date getCurrentTimestamp() { return new Date(); } }; Class<?> simpleClass4 = javaClassLoader.loadClass("com.haulmont.cuba.core.sys.javacl.test.pack4.SimpleClass4"); System.out.println("SimpleClass4 loaded " + simpleClass4.hashCode()); Class<?> simpleClass = javaClassLoader.loadClass("com.haulmont.cuba.core.sys.javacl.test.SimpleClass"); System.out.println("SimpleClass loaded " + simpleClass.hashCode()); modifyFile("./test-data/javacl-sources/com/haulmont/cuba/core/sys/javacl/test/SimpleClass.java"); Class<?> simpleClass_2 = javaClassLoader.loadClass("com.haulmont.cuba.core.sys.javacl.test.SimpleClass"); System.out.println("SimpleClass loaded " + simpleClass_2.hashCode()); Class<?> simpleClass4_2 = javaClassLoader.loadClass("com.haulmont.cuba.core.sys.javacl.test.pack4.SimpleClass4"); System.out.println("SimpleClass4 loaded " + simpleClass4_2.hashCode()); Assertions.assertNotSame(simpleClass, simpleClass_2); Assertions.assertNotSame(simpleClass4, simpleClass4_2); Class<?> simpleClass_3 = javaClassLoader.loadClass("com.haulmont.cuba.core.sys.javacl.test.SimpleClass"); System.out.println("SimpleClass loaded " + simpleClass_3.hashCode()); Class<?> simpleClass4_3 = javaClassLoader.loadClass("com.haulmont.cuba.core.sys.javacl.test.pack4.SimpleClass4"); System.out.println("SimpleClass4 loaded " + simpleClass4_3.hashCode()); Assertions.assertEquals(simpleClass_2, simpleClass_3); Assertions.assertEquals(simpleClass4_2, simpleClass4_3); }
Example 12
Source File: JavaClassLoaderTest.java From cuba with Apache License 2.0 | 5 votes |
@Test public void testDependencies() throws Exception { System.out.println(new File(".").getAbsolutePath()); JavaClassLoader javaClassLoader = new JavaClassLoader(null, "./test-data/javacl-sources/", "", new SpringBeanLoader()) { @Override protected Date getCurrentTimestamp() { return new Date(); } }; Class<?> class1 = javaClassLoader.loadClass("com.haulmont.cuba.core.sys.javacl.test.SimpleClass"); System.out.println("Class loaded"); modifyFile("./test-data/javacl-sources/com/haulmont/cuba/core/sys/javacl/test/SimpleClass.java"); System.out.println("SimpleClass modified"); Class<?> class2 = javaClassLoader.loadClass("com.haulmont.cuba.core.sys.javacl.test.SimpleClass"); Assertions.assertNotSame(class1, class2); Assertions.assertEquals(javaClassLoader.compiled.size(), 4); System.out.println("Class reloaded"); System.out.println("No changes"); Class<?> class3 = javaClassLoader.loadClass("com.haulmont.cuba.core.sys.javacl.test.SimpleClass"); Assertions.assertEquals(class2, class3); System.out.println("Class reloaded, same class received"); modifyFile("./test-data/javacl-sources/com/haulmont/cuba/core/sys/javacl/test/pack1/SimpleClass1.java"); System.out.println("SimpleClass1 modified"); Class<?> class4 = javaClassLoader.loadClass("com.haulmont.cuba.core.sys.javacl.test.SimpleClass"); Assertions.assertNotSame(class3, class4); System.out.println("Class reloaded"); }
Example 13
Source File: TestArrayTools.java From javageci with Apache License 2.0 | 5 votes |
@Test @DisplayName("Prepending zero length arrays returns new array") void prependZeroLengthArray() { final var a = new String[0]; final var b = new String[]{"a", "b", "c"}; final var result = ArrayTools.join(a, b); Assertions.assertNotSame(b, result); Assertions.assertArrayEquals(b, result); }
Example 14
Source File: TestArrayTools.java From javageci with Apache License 2.0 | 5 votes |
@Test @DisplayName("Appending zero length arrays returns new array") void appendZeroLengthArray() { final var a = new String[]{"a", "b", "c"}; final var b = new String[0]; final var result = ArrayTools.join(a, b); Assertions.assertNotSame(a, result); Assertions.assertArrayEquals(a, result); }
Example 15
Source File: ShootOptionBuilderTest.java From canon-sdk-java with MIT License | 5 votes |
@Disabled("Get PreconditionViolationException, why? You must configure at least one set of arguments for this @ParameterizedTest") @ParameterizedTest @MethodSource("differentBuilder") void shootOptionDefineProperEqualsHashCode(ShootOptionBuilder optionBuilder) { final ShootOption shootOption = optionBuilder.build(); final ShootOption shootOption2 = optionBuilder.build(); Assertions.assertNotNull(shootOption); Assertions.assertNotSame(shootOption, shootOption2); Assertions.assertEquals(shootOption, shootOption2); Assertions.assertEquals(shootOption.hashCode(), shootOption2.hashCode()); }
Example 16
Source File: ShootOptionBuilderTest.java From canon-sdk-java with MIT License | 5 votes |
@Test void builderIsReusable() { final ShootOption shootOption = builder.build(); final ShootOption shootOption2 = builder.build(); Assertions.assertNotNull(shootOption); Assertions.assertNotNull(shootOption2); Assertions.assertNotSame(shootOption, shootOption2); Assertions.assertEquals(shootOption, shootOption2); Assertions.assertEquals(shootOption.hashCode(), shootOption2.hashCode()); }
Example 17
Source File: CopyCommandTest.java From canon-sdk-java with MIT License | 5 votes |
@Test void copyByConstructor2Decorator() { final ProductName command = new ProductName(); final DefaultValueOnErrorDecorator<String> decorated = new DefaultValueOnErrorDecorator<>(command, "default"); final DefaultValueOnErrorDecorator<String> decorated2 = new DefaultValueOnErrorDecorator<>(decorated, "default 2"); final DefaultValueOnErrorDecorator<String> copyDecorated2 = new DefaultValueOnErrorDecorator<>(FAKE, decorated2); Assertions.assertNotSame(copyDecorated2.getRoot(), command); Assertions.assertNotNull(copyDecorated2.getRoot()); // TODO for later when command finished to impl // Assertions.assertEquals("default 2", decorated2.get()); // Assertions.assertEquals("default 2", copyDecorated2.get()); }
Example 18
Source File: CopyCommandTest.java From canon-sdk-java with MIT License | 5 votes |
@Test void copyByConstructor1Decorator() { final ProductName command = new ProductName(); final DefaultValueOnErrorDecorator<String> decorated = new DefaultValueOnErrorDecorator<>(command, "default"); final DefaultValueOnErrorDecorator<String> copyDecorated = new DefaultValueOnErrorDecorator<>(FAKE, decorated); Assertions.assertNotSame(copyDecorated.getRoot(), command); Assertions.assertNotNull(copyDecorated.getRoot()); // TODO for later when command finished to impl // Assertions.assertEquals("default", decorated.get()); // Assertions.assertEquals("default", copyDecorated.get()); }
Example 19
Source File: CanonCommandCopyTest.java From canon-sdk-java with MIT License | 5 votes |
@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 20
Source File: FactionTest.java From EagleFactions with MIT License | 4 votes |
@Test void builderBuildShouldReturnNewFactionInstance() { final Faction newFaction = faction.toBuilder().build(); Assertions.assertNotSame(faction, newFaction); }