@Test public void shouldNotBeEqualToNullOrOtherObjects() throws Exception { Token expected = new Token("access", "secret"); assertNotSame(expected, null); assertNotSame(expected, new Object()); }
@Test public void testUnCachedPrepared() throws Exception { BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); tm.setTransactionTimeout(60); tm.begin(); Connection connection = poolingDataSource2.getConnection(); PreparedStatement prepareStatement1 = connection.prepareStatement("SELECT 1 FROM nothing WHERE a=? AND b=? AND c=? AND d=?"); PreparedStatement prepareStatement2 = connection.prepareStatement("SELECT 1 FROM nothing WHERE a=? AND b=? AND c=? AND d=?"); Assert.assertNotSame(prepareStatement1, prepareStatement2); prepareStatement2.close(); prepareStatement2 = connection.prepareStatement("SELECT 1 FROM nothing WHERE a=? AND b=? AND c=? AND d=?"); Assert.assertNotSame(prepareStatement1, prepareStatement2); prepareStatement1.close(); prepareStatement2.close(); connection.close(); tm.shutdown(); }
@Test public void canAnswerLastGestureDetector() throws Exception { GestureDetector newDetector = new GestureDetector(Robolectric.application, null); assertNotSame(newDetector, ShadowGestureDetector.getLastActiveDetector()); newDetector.onTouchEvent(null); assertSame(newDetector, ShadowGestureDetector.getLastActiveDetector()); }
/** Test we can create an Buffer, then modify the direct bytes in native code. */ @Test public void testCanDirectlyModifyNativeBytes() { byte buffer[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; Buffer buf = Buffer.make(null, buffer, 0, buffer.length); assertNotNull(buf); assertEquals(buf.getBufferSize(), buffer.length); // this give us the native bytes java.nio.ByteBuffer nativeBytes = buf.getByteBuffer(0, buffer.length); assertNotNull(nativeBytes); for (int i = 0; i < buffer.length; i++) { nativeBytes.put(i, (byte) (9 - buffer[i])); // reverse the order of the integers } // we can release it. no "update" method should be required. It should // have modified the underlying C++ bytes. nativeBytes = null; // now, get a copy of the bytes in the Buffer and make sure // the order of bytes was reversed. byte outBuffer[] = buf.getByteArray(0, buffer.length); assertNotNull(outBuffer); assertEquals(outBuffer.length, buffer.length); assertNotSame(buf, outBuffer); for (int i = 0; i < buffer.length; i++) { assertEquals(9 - buffer[i], outBuffer[i]); } }
public void testAll() throws Exception { // Hash测试 Assert.assertEquals( "3ffda29e8fbc3756ded50aa496cf3019", UEncrypt.getHash(UEncrypt.HASH_TYPE_MD5, "ctyun")); Assert.assertEquals( "efd4ea5525e0116c1bc3267ec3b9cca0d6416a02", UEncrypt.getHash(UEncrypt.HASH_TYPE_SHA1, "ctyun")); Assert.assertEquals( "4b1d518cb87ec169ed3c29a9b2856266c9e72964f318ab3de376f98dc6f89df7", UEncrypt.getHash(UEncrypt.HASH_TYPE_SHA256, "ctyun")); // CheckCode测试 Assert.assertEquals( Long.valueOf(1603231608), UEncrypt.getCheckCodeNum(UEncrypt.CHECK_CODE_TYPE_CRC32, "ctyun")); Assert.assertEquals( "5f8f5f78", UEncrypt.getCheckCodeStr(UEncrypt.CHECK_CODE_TYPE_CRC32, "ctyun")); Assert.assertEquals( Long.valueOf(109511220), UEncrypt.getCheckCodeNum(UEncrypt.CHECK_CODE_TYPE_ADLER32, "ctyun")); Assert.assertEquals( "6870234", UEncrypt.getCheckCodeStr(UEncrypt.CHECK_CODE_TYPE_ADLER32, "ctyun")); // System.out.println(UEncrypt.getCheckCode(UEncrypt.CHECK_CODE_TYPE_CRC32, new // FileInputStream(new File("C:\\kvlogs\\info-127.0.0.1.log")))); // System.out.println(UEncrypt.getCheckCode(UEncrypt.CHECK_CODE_TYPE_ADLER32, new // FileInputStream(new File("C:\\kvlogs\\info-127.0.0.1.log")))); // rot13测试 Assert.assertEquals("abcDEFghi123", UEncrypt.rot13(UEncrypt.rot13("abcDEFghi123"))); // 随机数测试 Assert.assertNotSame(UEncrypt.getRandomInteger(4), UEncrypt.getRandomInteger(4)); Assert.assertEquals(4, UEncrypt.getRandomInteger(4).length()); }
/** * Allows the Interceptor to do some processing on the request before and/or after the rest of the * processing of the request by the DefaultActionInvocation or to short-circuit the processing and * just return a String return code. * * @param invocation * @return * @throws Exception */ public String intercept(ActionInvocation invocation) throws Exception { executed = true; Assert.assertNotSame(DEFAULT_FOO_VALUE, foo); Assert.assertEquals(expectedFoo, foo); return invocation.invoke(); }
@Test public void shouldReturnNullLocationWhenACriteriaFailsAndNoBestExists() { addCriteria(failsCriteria); Location location = bestLocationDelegate.getBestLastKnownLocation(); assertNull(location); assertNotSame(location, candidateLocation); }
@Test public void readImgCLogFileNameTest() { // when final String r = SystemPropertiesReader.readImgCLogFileName(); // then assertNotNull(r); assertNotSame(r, ""); }
@Test public void readImgCIgnorePathArgsKeyTest() { // when final String r = SystemPropertiesReader.readImgCIgnorePathArgsKey(); // then assertNotNull(r); assertNotSame(r, ""); }
@Test public void readImgCConfigurationFileArgsKeyTest() { // when final String r = SystemPropertiesReader.readImgCConfigurationFileArgsKey(); // then assertNotNull(r); assertNotSame(r, ""); }
@Test public void readImgCCacheFileDefaultTest() { // when final String r = SystemPropertiesReader.readImgCCacheFileDefault(); // then assertNotNull(r); assertNotSame(r, ""); }
@Test public void graphType() { Shell shell = new Shell(); Graph graph = interpreter.create(shell, SWT.NONE, "graph Sample{1;2;1--2}"); Assert.assertNotNull("Created graph must not be null", graph); Assert.assertNotSame(ZestStyles.CONNECTIONS_DIRECTED, graph.getConnectionStyle()); // open(shell); }
@Test public void testMouseOver() { driver.get(fixture("mouse.html")); OperaWebElement test = ((OperaWebElement) driver.findElementById("test")); String hash = test.getImageHash(); test.mouseOver(); Assert.assertNotSame(hash, test.getImageHash()); }
@Test public void testAllRowsReaderWithCancel() throws Exception { final AtomicLong counter = new AtomicLong(0); AllRowsReader<String, String> reader = new AllRowsReader.Builder<String, String>(keyspace, CF_STANDARD1) .withPageSize(3) .withConcurrencyLevel(2) .forEachRow( new Function<Row<String, String>, Boolean>() { @Override public Boolean apply(Row<String, String> row) { try { Thread.sleep(2000); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(e); } counter.incrementAndGet(); LOG.info("Got a row: " + row.getKey().toString()); return true; } }) .build(); Future<Boolean> future = Executors.newSingleThreadExecutor().submit(reader); Thread.sleep(1000); reader.cancel(); try { boolean result = future.get(); Assert.assertEquals(false, result); } catch (Exception e) { LOG.info("Failed to execute", e); } LOG.info("Before: " + counter.get()); Assert.assertNotSame(28, counter.get()); Thread.sleep(2000); LOG.info("After: " + counter.get()); Assert.assertNotSame(28, counter.get()); }
@Test public void getPropertiesFromFile() throws Exception { System.out.println("checking known properties"); assertEquals(runProcess("hostname"), BuildData.host); assertEquals(runProcess("whoami"), BuildData.user); assertEquals(runProcess("pwd"), BuildData.repo); System.out.println("checking other properties"); assertNotNull(BuildData.repo_status); assertNotSame(BuildData.RepoStatus.UNKNOWN, BuildData.repo_status); assertNotNull(BuildData.short_revision); assertNotSame("000001", BuildData.short_revision); assertNotNull(BuildData.timestamp); assertNotSame("000000001", BuildData.timestamp); }
@Test public void compareObjectsWithSameNameInDifferentContainers() { Container container1 = account.getContainer("alpha"); StoredObject object1 = container1.getObject("img1.png"); Container container2 = account.getContainer("beta"); StoredObject object2 = container2.getObject("img1.png"); assertNotSame(object1, object2); assertEquals(-1, object1.compareTo(object2)); assertEquals(1, object2.compareTo(object1)); }
private void testEncryptDecrypt(final CryptoUtil cryptoUtil, final String textToEncrypt) throws Exception { String encryptedText = cryptoUtil.encrypt(textToEncrypt); assertNotSame( "Encrypted text should not be the same as the plain text", textToEncrypt, encryptedText); String decryptedText = cryptoUtil.decrypt(encryptedText); assertEquals( "Decrypted text should be the same as the original text", textToEncrypt, decryptedText); }
@Test public void proxyPassesCallOnToDecoratedObject() { Tester rateLimitedTester = rateLimiterFactory.limitRate( mockTester, methodMatching(".*"), fixedCost(1), new RateLimit(10, 10, perSecond(0))); rateLimitedTester.rateLimitMe(11); verify(mockTester).rateLimitMe(11); assertNotSame(rateLimitedTester, mockTester); }
@Test public void testRegistryFactoryGroupCache() throws Exception { Registry registry1 = registryFactory.getRegistry( URL.valueOf("dubbo://" + NetUtils.getLocalHost() + ":2233?group=aaa")); Registry registry2 = registryFactory.getRegistry( URL.valueOf("dubbo://" + NetUtils.getLocalHost() + ":2233?group=bbb")); Assert.assertNotSame(registry1, registry2); }
/** * Asserts that an expected {@link Activity} is currently active one, with the possibility to * verify that the expected {@code Activity} is a new instance of the {@code Activity}. * * @param message the message that should be displayed if the assert fails * @param expectedClass the {@code Class} object that is expected to be active e.g. {@code * MyActivity.class} * @param isNewInstance {@code true} if the expected {@code Activity} is a new instance of the * {@code Activity} */ public void assertCurrentActivity( String message, Class<? extends Activity> expectedClass, boolean isNewInstance) { boolean found = false; assertCurrentActivity(message, expectedClass); Activity activity = activityUtils.getCurrentActivity(); for (int i = 0; i < activityUtils.getAllOpenedActivities().size() - 1; i++) { String instanceString = activityUtils.getAllOpenedActivities().get(i).toString(); if (instanceString.equals(activity.toString())) found = true; } Assert.assertNotSame(message + ", isNewInstance: actual and ", isNewInstance, found); }
@Test public void testWhenPageSizeChanged() { int newPageSize = PipelinedLeaderboard.DEFAULT_PAGE_SIZE / 2; assertNotSame(newPageSize, PipelinedLeaderboard.DEFAULT_PAGE_SIZE); underTest.setPageSize(newPageSize); List<Entry> found = underTest.aroundMe(leaderboardName, MID_RANKED_USER); Assert.assertNotNull("Should have returned a list of users", found); assertEquals("Should have the modified page size of users", newPageSize, found.size()); testEntriesAreOrdered(found); testEntriesAreCorrect(found, underTest.isUseZeroIndexForRank()); }
@Test public void testEquals() throws Exception { assertEquals("Should be equal to itself", METADATA_1, METADATA_1); EditLogLedgerMetadata allFieldsMatch = new EditLogLedgerMetadata( METADATA_1.getLogVersion(), METADATA_1.getLedgerId(), METADATA_1.getFirstTxId(), METADATA_1.getLastTxId()); assertEquals("Should be equal if all fields match", METADATA_1, allFieldsMatch); assertNotSame("Should not be equal if fields do not match", METADATA_1, METADATA_2); }
@Test public void testUnique() { class Test { @AutoWire(name = "test", unique = true) DoubleNode mWriter; } Test t1 = new Test(); Test t2 = new Test(); DatastreamManager.autowire(t1); DatastreamManager.autowire(t2); Assert.assertNotSame(t1.mWriter, t2.mWriter); }
@Test public void testConstructor_fromDsObject() throws Exception { AccountProperty accountProperty = new AccountProperty(); AdapterProperty property = AdapterProperty.getAdapter(accountProperty); Assert.assertEquals(accountProperty, property.getAssociatedObject()); AccountProperty accountProperty2 = new AccountProperty(); AdapterProperty property2 = AdapterProperty.getAdapter(accountProperty2); Assert.assertNotSame(property, property2); AdapterProperty property3 = AdapterProperty.getAdapter(accountProperty); Assert.assertEquals(property, property3); }
@Test public void testGetDifferentSession() throws UnknownHostException { MessagePack messagePack = new MessagePack(); EventLoop loop = EventLoop.start(messagePack); SessionPool sp = new SessionPool(loop); Session s1 = sp.getSession("localhost", 8840); Session s2 = sp.getSession("localhost", 8841); Assert.assertNotSame(s1, s2); }
@Test public void testSingleBond() { IAtomContainer container = makeSingleBond(); // generate the single line element IRenderingElement root = generator.generate(container, model); List<IRenderingElement> elements = elementUtil.getAllSimpleElements(root); Assert.assertEquals(1, elements.size()); // test that the endpoints are distinct LineElement line = (LineElement) elements.get(0); Assert.assertNotSame(0, AbstractGeneratorTest.length(line)); }
/** * Test that we can create a Buffer from a Java byte[] array, and that we can copy the same data * out of an Buffer (via copy). */ @Test public void testCreateFromBytes() { byte buffer[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; Buffer buf = Buffer.make(null, buffer, 0, buffer.length); assertNotNull(buf); assertEquals(buf.getBufferSize(), buffer.length); byte outBuffer[] = buf.getByteArray(0, buffer.length); assertNotNull(outBuffer); assertEquals(outBuffer.length, buffer.length); assertNotSame(buf, outBuffer); for (int i = 0; i < buffer.length; i++) { assertEquals(buffer[i], outBuffer[i]); } }
@Test public void testNegative() throws InvalidFormatException { OutputStream stream = new ByteArrayOutputStream(); TokenizerEvaluationMonitor listener = new TokenEvaluationErrorListener(stream); TokenizerEvaluator eval = new TokenizerEvaluator(new DummyTokenizer(TokenSampleTest.createGoldSample()), listener); eval.evaluateSample(TokenSampleTest.createPredSample()); assertEquals(.5d, eval.getFMeasure().getFMeasure(), .1d); assertNotSame(0, stream.toString().length()); }
@Test public void testUsersGetInfo() throws Exception { FacebookJaxbRestClient client = FacebookSessionTestUtils.getValidClient(FacebookJaxbRestClient.class); long logged = client.users_getLoggedInUser(); List<Long> users = Collections.singletonList(logged); EnumSet<ProfileField> fields = EnumSet.allOf(ProfileField.class); UsersGetInfoResponse response = client.users_getInfo(users, fields); String name = response.getUser().get(0).getName(); Assert.assertNotNull(name); Assert.assertNotSame("", name); }
@Test public void chargingStationConfiguredEvent() { eventHandler.handle( new ChargingStationCreatedEvent( CHARGING_STATION_ID, USER_IDENTITIES_WITH_ALL_PERMISSIONS, NULL_USER_IDENTITY_CONTEXT)); ChargingStation cs = chargingStationRepository.findOne(CHARGING_STATION_ID.getId()); assertFalse(cs.isConfigured()); assertNotSame(cs.getNumberOfEvses(), EVSES.size()); eventHandler.handle( new ChargingStationConfiguredEvent(CHARGING_STATION_ID, EVSES, NULL_USER_IDENTITY_CONTEXT)); cs = chargingStationRepository.findOne(CHARGING_STATION_ID.getId()); assertTrue(cs.isConfigured()); assertEquals(cs.getNumberOfEvses(), EVSES.size()); }