Example usage for junit.framework Assert assertNotSame

List of usage examples for junit.framework Assert assertNotSame

Introduction

In this page you can find the example usage for junit.framework Assert assertNotSame.

Prototype

static public void assertNotSame(Object expected, Object actual) 

Source Link

Document

Asserts that two objects do not refer to the same object.

Usage

From source file:com.test.onesignal.GenerateNotificationRunner.java

@Test
@Config(sdk = 17)//from   ww w. j a  v a2s.co m
public void notificationExtenderServiceOverridePropertiesWithSummaryApi17() throws Exception {
    testNotificationExtenderServiceOverridePropertiesWithSummary();

    Map<Integer, PostedNotification> postedNotifs = ShadowRoboNotificationManager.notifications;
    Iterator<Map.Entry<Integer, PostedNotification>> postedNotifsIterator = postedNotifs.entrySet().iterator();

    // Test - First notification should be the summary with the custom sound set.
    PostedNotification postedSummaryNotification = postedNotifsIterator.next().getValue();
    Assert.assertNotSame(Notification.DEFAULT_SOUND,
            postedSummaryNotification.notif.flags & Notification.DEFAULT_SOUND);
    Assert.assertEquals("content://media/internal/audio/media/32",
            postedSummaryNotification.notif.sound.toString());

    Assert.assertEquals(1, postedNotifs.size());
}

From source file:com.test.onesignal.GenerateNotificationRunner.java

@Test
@Config(sdk = 21)//  w  ww  .  ja  v  a  2s  . com
public void notificationExtenderServiceOverridePropertiesWithSummary() throws Exception {
    testNotificationExtenderServiceOverridePropertiesWithSummary();

    Map<Integer, PostedNotification> postedNotifs = ShadowRoboNotificationManager.notifications;
    Iterator<Map.Entry<Integer, PostedNotification>> postedNotifsIterator = postedNotifs.entrySet().iterator();

    // Test - First notification should be the summary with the custom sound set.
    PostedNotification postedSummaryNotification = postedNotifsIterator.next().getValue();
    Assert.assertNotSame(Notification.DEFAULT_SOUND,
            postedSummaryNotification.notif.flags & Notification.DEFAULT_SOUND);
    Assert.assertEquals("content://media/internal/audio/media/32",
            postedSummaryNotification.notif.sound.toString());

    // Test - individual notification 1 should not play a sound
    PostedNotification notification = postedNotifsIterator.next().getValue();
    Assert.assertNotSame(Notification.DEFAULT_SOUND, notification.notif.flags & Notification.DEFAULT_SOUND);
    Assert.assertNull(notification.notif.sound);

    // Test - individual notification 2 should not play a sound
    notification = postedNotifsIterator.next().getValue();
    Assert.assertNotSame(Notification.DEFAULT_SOUND, notification.notif.flags & Notification.DEFAULT_SOUND);
    Assert.assertNull(notification.notif.sound);
}

From source file:com.test.onesignal.GenerateNotificationRunner.java

@Test
@Config(shadows = { ShadowOneSignal.class })
public void shouldFireNotificationExtenderService() throws Exception {
    // Test that GCM receiver starts the NotificationExtenderServiceTest when it is in the AndroidManifest.xml
    Bundle bundle = getBaseNotifBundle();

    Intent serviceIntent = new Intent();
    serviceIntent.setPackage("com.onesignal.example");
    serviceIntent.setAction("com.onesignal.NotificationExtender");
    ResolveInfo resolveInfo = new ResolveInfo();
    resolveInfo.serviceInfo = new ServiceInfo();
    resolveInfo.serviceInfo.name = "com.onesignal.example.NotificationExtenderServiceTest";
    RuntimeEnvironment.getRobolectricPackageManager().addResolveInfoForIntent(serviceIntent, resolveInfo);

    boolean ret = OneSignalPackagePrivateHelper.GcmBroadcastReceiver_processBundle(blankActivity, bundle);
    Assert.assertTrue(ret);/*  www.  j  a  va 2  s.c  om*/

    Intent intent = Shadows.shadowOf(blankActivity).getNextStartedService();
    Assert.assertEquals("com.onesignal.NotificationExtender", intent.getAction());

    // Test that all options are set.
    NotificationExtenderServiceTest service = (NotificationExtenderServiceTest) startNotificationExtender(
            createInternalPayloadBundle(getBundleWithAllOptionsSet()), NotificationExtenderServiceTest.class);

    OSNotificationReceivedResult notificationReceived = service.notification;
    OSNotificationPayload notificationPayload = notificationReceived.payload;
    Assert.assertEquals("Test H", notificationPayload.title);
    Assert.assertEquals("Test B", notificationPayload.body);
    Assert.assertEquals("9764eaeb-10ce-45b1-a66d-8f95938aaa51", notificationPayload.notificationID);

    Assert.assertEquals(0, notificationPayload.lockScreenVisibility);
    Assert.assertEquals("FF0000FF", notificationPayload.smallIconAccentColor);
    Assert.assertEquals("703322744261", notificationPayload.fromProjectNumber);
    Assert.assertEquals("FFFFFF00", notificationPayload.ledColor);
    Assert.assertEquals("big_picture", notificationPayload.bigPicture);
    Assert.assertEquals("large_icon", notificationPayload.largeIcon);
    Assert.assertEquals("small_icon", notificationPayload.smallIcon);
    Assert.assertEquals("test_sound", notificationPayload.sound);
    Assert.assertEquals("You test $[notif_count] MSGs!", notificationPayload.groupMessage);
    Assert.assertEquals("http://google.com", notificationPayload.launchURL);
    Assert.assertEquals(10, notificationPayload.priority);
    Assert.assertEquals("a_key", notificationPayload.collapseId);

    Assert.assertEquals("id1", notificationPayload.actionButtons.get(0).id);
    Assert.assertEquals("button1", notificationPayload.actionButtons.get(0).text);
    Assert.assertEquals("ic_menu_share", notificationPayload.actionButtons.get(0).icon);
    Assert.assertEquals("id2", notificationPayload.actionButtons.get(1).id);
    Assert.assertEquals("button2", notificationPayload.actionButtons.get(1).text);
    Assert.assertEquals("ic_menu_send", notificationPayload.actionButtons.get(1).icon);

    Assert.assertEquals("test_image_url", notificationPayload.backgroundImageLayout.image);
    Assert.assertEquals("FF000000", notificationPayload.backgroundImageLayout.titleTextColor);
    Assert.assertEquals("FFFFFFFF", notificationPayload.backgroundImageLayout.bodyTextColor);

    JSONObject additionalData = notificationPayload.additionalData;
    Assert.assertEquals("myValue", additionalData.getString("myKey"));
    Assert.assertEquals("nValue", additionalData.getJSONObject("nested").getString("nKey"));

    Assert.assertNotSame(-1, service.notificationId);

    // Test a basic notification without anything special.
    startNotificationExtender(createInternalPayloadBundle(getBaseNotifBundle()),
            NotificationExtenderServiceTest.class);
    Assert.assertFalse(ShadowOneSignal.messages.contains("Error assigning"));

    // Test that a notification is still displayed if the developer's code in onNotificationProcessing throws an Exception.
    NotificationExtenderServiceTest.throwInAppCode = true;
    startNotificationExtender(createInternalPayloadBundle(getBaseNotifBundle("NewUUID1")),
            NotificationExtenderServiceTest.class);

    Assert.assertTrue(ShadowOneSignal.messages.contains("onNotificationProcessing throw an exception"));
    Map<Integer, PostedNotification> postedNotifs = ShadowRoboNotificationManager.notifications;
    Assert.assertEquals(3, postedNotifs.size());
}

From source file:fragment.web.AbstractProductsControllerTest.java

@Test
public void testEditProduct1() throws Exception {

    Product product = productsService.locateProductByCode("CODEsmallRunningVm2");

    Long discriminatorId = 1L;//  ww  w.j  a  v  a2  s  .co  m

    String jsonString = "{conversionFactor: " + 1 + ", operator: COMBINE, usageTypeId: " + 1L;
    if (true) {
        jsonString = jsonString + ", discriminatorVals: [ {discriminatorId: " + discriminatorId
                + ", discriminatorValue: 125, operator: EQUAL_TO, discriminatorValueName: " + "Running VM"
                + " } ]";
    }
    jsonString = jsonString + " }";
    org.json.JSONObject mediationJason = new org.json.JSONObject(jsonString);
    String productMediationRules = "[" + mediationJason.toString() + "]";

    ServiceInstance serviceInstance = serviceInstanceDao.find("1");
    Service service = serviceInstance.getService();
    Category category = productService.getCategory(1L);

    ProductForm form = new ProductForm(product);
    form.setProductMediationRules(productMediationRules);
    form.setStartDate(new Date());
    form.setServiceUUID(service.getUuid());
    form.setServiceInstanceUUID(serviceInstanceDao.find(1L).getUuid());
    form.setCategoryID(category.getId().toString());
    form.setConversionFactor("1");
    BindingResult result = validate(form);
    Assert.assertNotNull(result);
    String oldDescription = product.getDescription();
    String newDescription = "New Description.";
    product.setDescription(newDescription);
    productsController.editProduct(form, result, map);
    product = productsService.locateProductByCode("CODEsmallRunningVm2");
    Assert.assertEquals(newDescription, product.getDescription());
    Assert.assertNotSame(oldDescription, newDescription);
}

From source file:net.sourceforge.seqware.common.metadata.MetadataWSTest.java

/**
 * Test of add_task_group method, of class MetadataWS.
 *///from   www.java2s .  c  om
//@Test
public void testAdd_task_group() {
    logger.info("add_task_group");
    Date beforeDate = new Timestamp(System.currentTimeMillis());
    int[] parentIDs = { 5, 7 };
    int[] childIDs = { 10, 12 };
    String algorithm = "metadataWSTest";
    String description = "Testing the MetadataWS";
    int expResult = 0;
    ReturnValue result = instance.add_task_group(parentIDs, childIDs, algorithm, description);
    Assert.assertNotSame(expResult, result.getReturnValue());
    testTimestamp("select max(create_tstmp), task_group from processing " + "where processing_id in "
            + "(select distinct child_id from processing_relationship " + "where parent_id IN (5,7)) "
            + "AND processing_id in " + "(select distinct parent_id from processing_relationship "
            + "where child_id IN (10,12)) GROUP BY task_group", "max", beforeDate);
}

From source file:net.sourceforge.seqware.common.metadata.MetadataWSTest.java

/**
 * Test of add_workflow_run method, of class MetadataWS.
 *//*  w  w w. ja v  a 2  s .  c o  m*/
//@Test
public void testAdd_workflow_run() {
    logger.info("add_workflow_run");
    Date beforeDate = new Timestamp(System.currentTimeMillis());
    int workflowAccession = 2860;
    int expResult = 0;
    int result = instance.add_workflow_run(workflowAccession);
    Assert.assertNotSame(expResult, result);
    testTimestamp("select max(create_tstmp) from workflow_run " + "where workflow_id = 15", "max", beforeDate);
}

From source file:org.apache.jackrabbit.oak.plugins.blob.ClusterRepositoryInfoTest.java

@Test
public void differentCluster() throws Exception {
    DocumentNodeStore ds1 = builderProvider.newBuilder().setAsyncDelay(0)
            .setDocumentStore(new MemoryDocumentStore()).setBlobStore(blobStore).getNodeStore();
    String repoId1 = ClusterRepositoryInfo.getOrCreateId(ds1);

    DocumentNodeStore ds2 = builderProvider.newBuilder().setAsyncDelay(0)
            .setDocumentStore(new MemoryDocumentStore()).setBlobStore(blobStore).getNodeStore();
    String repoId2 = ClusterRepositoryInfo.getOrCreateId(ds2);

    Assert.assertNotSame(repoId1, repoId2);
}

From source file:org.fosstrak.llrp.commander.util.test.UtilityTest.java

@Test
public void testStackTraceNice() {
    Exception ex = new Exception("hello");
    String result = Utility.stackTraceNice(ex);
    Assert.assertNotNull(result);//from w  w  w . jav  a2 s .c o m
    Assert.assertNotSame(StringUtils.EMPTY, result);
}

From source file:org.jasig.portal.portlet.rendering.PortletRendererImplTest.java

/**
 * Mimic workflow when data cached portlet data using "validation" method is available.
 * /*from w w w.  j a v a 2s .  c  om*/
 * @throws PortletContainerException 
 * @throws IOException 
 * @throws PortletException 
 */
@Test
public void doRenderMarkupCachedContentValidationMethodExpiredTest()
        throws PortletException, IOException, PortletContainerException {
    MockHttpServletRequest request = new MockHttpServletRequest();
    MockHttpServletResponse response = new MockHttpServletResponse();
    Date now = new Date();
    CacheControlImpl cacheControl = new CacheControlImpl();
    // by setting useCachedContent to true, we are saying even though content is expired, replay it anyways (since etag is still valid)
    cacheControl.setUseCachedContent(true);
    cacheControl.setETag("123456");
    cacheControl.setExpirationTime(300);
    CachedPortletData cachedPortletData = new CachedPortletData();
    cachedPortletData.setStringData("<p>Some content</p>");
    cachedPortletData.setEtag("123456");
    cachedPortletData.setExpirationTimeSeconds(cacheControl.getExpirationTime());
    // set the time stored to be a time that will trigger the content to be expired
    Date expiredTime = DateUtils.addSeconds(now, -301);
    cachedPortletData.setTimeStored(expiredTime);

    setupPortletExecutionMocks(request);

    when(portletCacheControlService.getPortletRenderCacheControl(portletWindowId, request))
            .thenReturn(cacheControl);
    when(portletCacheControlService.getCachedPortletRenderOutput(portletWindowId, request))
            .thenReturn(cachedPortletData);
    when(portalRequestInfo.getTargetedPortletWindowId()).thenReturn(portletWindowId);

    StringWriter writer = new StringWriter();
    portletRenderer.doRenderMarkup(portletWindowId, request, response, writer);
    Assert.assertEquals("<p>Some content</p>", writer.toString());
    // verify the expiration time has been updated
    Assert.assertNotSame(expiredTime, cachedPortletData.getTimeStored());
    // context is expired, triggers doRender
    verify(portletContainer, times(1)).doRender(isA(PortletWindow.class),
            isA(PortletHttpServletRequestWrapper.class), isA(PortletHttpServletResponseWrapper.class));
    // verify we never enter the other branch of the "should render cached output" if statement
    verify(portletCacheControlService, never()).shouldOutputBeCached(isA(CacheControl.class));
}

From source file:org.jasypt.properties.EncryptablePropertiesTest.java

public void testEncryptablePropertiesSerialization() throws Exception {

    final BasicTextEncryptor enc01 = new BasicTextEncryptor();
    enc01.setPassword("jasypt");

    final String msg01 = "Message one";
    final String msgEnc01 = "ENC(eZpONwIfFb5muu5Dc8ABsTPu/0OP95p4)";

    final String msg02 = "Message two";
    final String msgEnc02 = "ENC(LKyQ65EYz3+ekDPpnLjLGyPK07Gt+UZH)";

    final EncryptableProperties prop01 = new EncryptableProperties(enc01);
    prop01.setProperty("p1", msgEnc01);
    prop01.setProperty("p2", msgEnc02);

    Assert.assertEquals(prop01.getProperty("p1"), msg01);
    Assert.assertEquals(prop01.getProperty("p2"), msg02);

    final byte[] ser01 = SerializationUtils.serialize(prop01);

    final EncryptableProperties prop02 = (EncryptableProperties) SerializationUtils.deserialize(ser01);

    Assert.assertEquals(prop02.getProperty("p1"), msg01);
    Assert.assertEquals(prop02.getProperty("p2"), msg02);

    Assert.assertNotSame(prop01, prop02);

}