org.testng.Assert#assertNotNull ( )源码实例Demo

下面列出了org.testng.Assert#assertNotNull ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Test(groups = {"wso2.esb"}, description = "higher number of messages than minimum count")
public void testMoreNumberThanMinimum() throws IOException, XMLStreamException {
    int responseCount=0;
    no_of_requests=8;
    aggregatedRequestClient.setNoOfIterations(no_of_requests);
    String Response= aggregatedRequestClient.getResponse();
    Assert.assertNotNull(Response);
    OMElement Response2= AXIOMUtil.stringToOM(Response);
    OMElement soapBody = Response2.getFirstElement();
    Iterator iterator =soapBody.getChildrenWithName(new QName("http://services.samples",
            "getQuoteResponse"));

    while (iterator.hasNext()) {
        responseCount++;
        OMElement getQuote = (OMElement) iterator.next();
        Assert.assertTrue(getQuote.toString().contains("IBM"));
    }
    Assert.assertTrue(minMessageCount<=responseCount&&responseCount<=no_of_requests);

}
 
源代码2 项目: che   文件: ETagResponseFilterTest.java
/** Check if ETag is generated for a list of JSON */
@Test
public void filterListEntityTest() throws Exception {

  final ContainerResponse response =
      resourceLauncher.service(
          HttpMethod.GET, SERVICE_PATH + "/list", BASE_URI, null, null, null);
  assertEquals(response.getStatus(), OK.getStatusCode());
  // check entity
  Assert.assertEquals(response.getEntity(), Arrays.asList("a", "b", "c"));
  // Check etag
  List<Object> headerTags = response.getHttpHeaders().get("ETag");
  Assert.assertNotNull(headerTags);
  Assert.assertEquals(headerTags.size(), 1);
  Assert.assertEquals(headerTags.get(0), new EntityTag("900150983cd24fb0d6963f7d28e17f72"));
}
 
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
@Test(groups = {"wso2.esb"}, description = "Test for DEFAULT_REQUEST_TYPE for nhttp transport")
public void testReturnContentType() throws Exception {
    try {
        String url = getApiInvocationURL("defaultRequestContentTypeApi").concat("?symbol=wso2");
        HttpUriRequest request = new HttpPut(url);
        DefaultHttpClient client = new DefaultHttpClient();

        ((HttpPut)request).setEntity(new StringEntity("<request/>"));

        HttpResponse response = client.execute(request);
        Assert.assertNotNull(response);
        Assert.assertTrue(getResponse(response).toString().contains("WSO2"));
    } catch (IOException e) {
        log.error("Error while sending the request to the endpoint. ", e);
    }

}
 
源代码4 项目: splicer   文件: TsdbResultMergerTests.java
@Test(expectedExceptions = MergeException.class)
public void tryMergeWithNullTagsInSecond()
{
	TsdbResult obj1 = get("a.b.c");
	TsdbResult obj2 = get("a.b.c");

	HashMap<String, String> t1 = new HashMap<>();
	t1.put("a1", "b1");
	obj1.setTags(new TsdbResult.Tags(t1));

	TsdbResult[] results = merger.merge(new TsdbResult[]{obj1}, new TsdbResult[]{obj2});
	Assert.assertNotNull(results);
	Assert.assertTrue(results.length == 1);
	Assert.assertEquals(results[0].getMetric(), "a.b.c");

	results = merger.merge(new TsdbResult[]{obj2}, new TsdbResult[]{obj1});
	Assert.assertNotNull(results);
	Assert.assertTrue(results.length == 1);
	Assert.assertEquals(results[0].getMetric(), "a.b.c");

	throw new RuntimeException("Should not reach here");
}
 
/**
 * This test will wait 10 seconds until the TransportManager server is available. Ideally the TransportManager
 * should be available after four seconds.
 */
@Test
public void testDelayedPendingCapabilityRegistration() {
    ServiceReference reference = null;
    for (int i = 0; i < 10; i++) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException ignore) {

        }
        reference = bundleContext.getServiceReference(TransportManager.class);
        if (reference != null) {
            break;
        }
    }
    Assert.assertNotNull(reference, "Service reference of TransportManager should not be null");
}
 
源代码6 项目: tasmo   文件: DeletesTest.java
@Test (dataProvider = "tasmoMaterializer", invocationCount = 1, singleThreaded = true)
public void testDeletes(TasmoMaterializerHarness t) throws Exception {
    String viewClassName = "Values";
    String viewFieldName = "userInfo";
    Views views = TasmoModelFactory.modelToViews(viewClassName + "::" + viewFieldName + "::User.userName,age");
    t.initModel(views);

    ObjectId user1 = t.write(EventBuilder.create(t.idProvider(), "User", tenantId, actorId).set("userName", "ted").build());

    ObjectNode view = t.readView(tenantId, actorId, new ObjectId(viewClassName, user1.getId()), Id.NULL);
    t.addExpectation(user1, viewClassName, viewFieldName, new ObjectId[]{ user1 }, "userName", "ted");
    t.assertExpectation(tenantIdAndCentricId);
    t.clearExpectations();

    Assert.assertNotNull(view);

    t.write(EventBuilder.update(user1, tenantId, actorId).set(ReservedFields.DELETED, true).build());

    view = t.readView(tenantId, actorId, new ObjectId(viewClassName, user1.getId()), Id.NULL);
    Assert.assertNull(view);

}
 
源代码7 项目: product-es   文件: AssertNotesESTestCase.java
@Test(groups = {"wso2.greg", "wso2.greg.es"}, alwaysRun = true,description = "Add note to asset test")
public void addNoteToAsset() throws JSONException, IOException {
    queryParamMap.put("type", "note");
    //  https://localhost:9443/publisher/apis/assets?type=note
    String dataBody = String.format(readFile(resourcePath + "publisherAddNoteRestResource.json")
            , assetType, "testservice1234", noteName);
    ClientResponse response =
            genericRestClient.geneticRestRequestPost(publisherUrl + "/assets",
                                                     MediaType.APPLICATION_JSON,
                                                     MediaType.APPLICATION_JSON, dataBody
                    , queryParamMap, headerMap, cookieHeaderPublisher);
    Assert.assertTrue((response.getStatusCode() == 201),
                      "Wrong status code ,Expected 201 OK ,Received " +
                      response.getStatusCode());
    JSONObject responseObj = new JSONObject(response.getEntity(String.class));
    Assert.assertTrue(responseObj.getJSONObject("attributes").get("overview_note").toString().contains(noteName), "Does not create a note");
    Assert.assertTrue(responseObj.getJSONObject("attributes").get("overview_resourcepath").toString().contains(assetType),"Fault resource path for note");
    noteOverviewHash = responseObj.getJSONObject("attributes").get("overview_hash").toString();
    Assert.assertNotNull(noteOverviewHash);
    noteAssetId =responseObj.get("id").toString();
}
 
源代码8 项目: atlas   文件: BaseSecurityTest.java
protected File startKDC() throws Exception {
    File target = Files.createTempDirectory("sectest").toFile();
    File kdcWorkDir = new File(target, "kdc");
    Properties kdcConf = MiniKdc.createConf();
    kdcConf.setProperty(MiniKdc.DEBUG, "true");
    kdc = new MiniKdc(kdcConf, kdcWorkDir);
    kdc.start();

    Assert.assertNotNull(kdc.getRealm());
    return kdcWorkDir;
}
 
@Test
public void emptySketch() {
  final CpcSketch sketch = new CpcSketch(12);
  final Double result = new GetEstimateUDF().evaluate(new BytesWritable(sketch.toByteArray()));
  Assert.assertNotNull(result);
  Assert.assertEquals(result, 0.0);
}
 
@Test
public void testListEnrichers() {
    Set<TypeSummary> enrichers = client().path("/catalog/types").query("supertype", "enricher")
            .get(new GenericType<Set<TypeSummary>>() {});

    assertTrue(enrichers.size() > 0);
    TypeSummary asp = null;
    for (TypeSummary p : enrichers) {
        if (Aggregator.class.getName().equals(p.getSymbolicName()))
            asp = p;
    }
    Assert.assertNotNull(asp, "didn't find Aggregator");
}
 
源代码11 项目: avro-util   文件: LegacyAvroSchemaTest.java
@Test
public void testMalformedSchemaWorks() throws Exception {
  if (AvroCompatibilityHelper.getRuntimeAvroVersion() != AvroVersion.AVRO_1_4) {
    throw new SkipException("test only valid under avro 1.4");
  }
  String id = "123";
  LegacyAvroSchema legacyAvroSchema = new LegacyAvroSchema(id, badSchemaJson);
  Assert.assertNotNull(legacyAvroSchema);
  Assert.assertEquals(id, legacyAvroSchema.getOriginalSchemaId());
  JSONAssert.assertEquals("minified json should be equal to input", badSchemaJson, legacyAvroSchema.getOriginalSchemaJson(), true);
  Assert.assertEquals(Schema.parse(badSchemaJson), legacyAvroSchema.getFixedSchema());
  Assert.assertNull(legacyAvroSchema.getIssue()); //nothing wrong with it
  Assert.assertTrue(legacyAvroSchema.getTransforms().isEmpty());
}
 
源代码12 项目: scheduler   文件: RelocatableVMTest.java
@Test
public void testRelocateDueToPreserve() throws SchedulerException {
    Model mo = new DefaultModel();
    Mapping map = mo.getMapping();

    final VM vm1 = mo.newVM();
    final VM vm2 = mo.newVM();
    final VM vm3 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();

    map.addOnlineNode(n1);
    map.addOnlineNode(n2);
    map.addRunningVM(vm1, n1);
    map.addRunningVM(vm2, n1);
    map.addRunningVM(vm3, n2);
    ShareableResource rc = new ShareableResource("cpu", 10, 10);
    rc.setCapacity(n1, 7);
    rc.setConsumption(vm1, 3);
    rc.setConsumption(vm2, 3);
    rc.setConsumption(vm3, 5);

    Preserve pr = new Preserve(vm1, "cpu", 5);
    ChocoScheduler cra = new DefaultChocoScheduler();
    mo.attach(rc);
    List<SatConstraint> cstrs = new ArrayList<>();
    cstrs.addAll(Online.newOnline(map.getAllNodes()));
    cstrs.addAll(Overbook.newOverbooks(map.getAllNodes(), "cpu", 1));
    cstrs.add(pr);
    ReconfigurationPlan p = cra.solve(mo, cstrs);
    Assert.assertNotNull(p);
}
 
源代码13 项目: carbon-device-mgt   文件: DeviceAgentServiceTest.java
@Test(description = "Test the get operation method with device management exception.")
public void testGetOperationsWithDeviceManagementException() throws DeviceManagementException {
    PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceManagementService"))
            .toReturn(this.deviceManagementProviderService);
    List<String> deviceTypes = new ArrayList<>();
    deviceTypes.add(TEST_DEVICE_TYPE);
    Mockito.when(this.deviceManagementProviderService.getAvailableDeviceTypes())
            .thenThrow(new DeviceManagementException());
    Response response = this.deviceAgentService.getOperationsByDeviceAndStatus(TEST_DEVICE_TYPE,
            TEST_DEVICE_IDENTIFIER, Operation.Status.COMPLETED);
    Assert.assertNotNull(response, "The response should not be null");
    Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
            "The response status should be 500");
    Mockito.reset(this.deviceManagementProviderService);
}
 
源代码14 项目: ratelimiter4j   文件: YamlRuleConfigParserTest.java
public void testParse() throws IOException {
  YamlRuleConfigParser parser = new YamlRuleConfigParser();
  UniformRuleConfigMapping result = parser.parse(VALID_YAML_1);
  Assert.assertNotNull(result);
  Assert.assertTrue(result.getConfigs().size() == 2);
  print(result);
  System.out.println(System.getProperty("line.separator"));
}
 
源代码15 项目: curator   文件: TestDistributedDelayQueue.java
@Test
public void     testSimple() throws Exception
{
    final int QTY = 10;

    Timing                          timing = new Timing();
    DistributedDelayQueue<Long>     queue = null;
    CuratorFramework                client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1));
    client.start();
    try
    {
        BlockingQueueConsumer<Long> consumer = new BlockingQueueConsumer<Long>(Mockito.mock(ConnectionStateListener.class));
        queue = QueueBuilder.builder(client, consumer, new LongSerializer(), "/test").buildDelayQueue();
        queue.start();

        Random random = new Random();
        for ( int i = 0; i < QTY; ++i )
        {
            long    delay = System.currentTimeMillis() + random.nextInt(100);
            queue.put(delay, delay);
        }

        long            lastValue = -1;
        for ( int i = 0; i < QTY; ++i )
        {
            Long        value = consumer.take(timing.forWaiting().seconds(), TimeUnit.SECONDS);
            Assert.assertNotNull(value);
            Assert.assertTrue(value >= lastValue);
            lastValue = value;
        }
    }
    finally
    {
        CloseableUtils.closeQuietly(queue);
        CloseableUtils.closeQuietly(client);
    }
}
 
@Test(dependsOnMethods = "createGeoStationaryAlert", description = "retrieve saved geo stationary-alert.")
public void getGeoStationaryAlerts() throws GeoLocationBasedServiceException {
    List<GeoFence> geoFences;
    geoFences = geoLocationProviderServiceImpl.getStationaryAlerts(getDeviceIdentifier(), device.getEnrolmentInfo().getOwner());
    Assert.assertNotNull(geoFences);
    GeoFence geoFenceNode = geoFences.get(0);
    Assert.assertEquals(geoFenceNode.getAreaName(), SAMPLE_AREA_NAME);
    Assert.assertEquals(geoFenceNode.getQueryName(), SAMPLE_QUERY_NAME);
    Assert.assertEquals(geoFenceNode.getStationaryTime(), SAMPLE_STATIONARY_TIME);
}
 
源代码17 项目: micro-integrator   文件: SendIntegrationTestCase.java
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
@Test(groups = "wso2.esb", description = "Test sending request to Load Balancing Endpoint With the WeightedRoundRobin Algorithm Receiving Sequence in Gov Registry while BuildMessage Enabled")
public void testSendingLoadBalancingEndpoint11() throws IOException {

    String response = lbClient.sendLoadBalanceRequest(getProxyServiceURLHttp("loadBalancingEndPoint11"),
            "http://localhost:9001/services/LBService1");
    Assert.assertNotNull(response);
    Assert.assertTrue(response.toString().contains("Response from server: Server_1"));

    response = lbClient.sendLoadBalanceRequest(getProxyServiceURLHttp("loadBalancingEndPoint11"),
            "http://localhost:9002/services/LBService1");
    Assert.assertNotNull(response);
    Assert.assertTrue(response.toString().contains("Response from server: Server_2"));

    response = lbClient.sendLoadBalanceRequest(getProxyServiceURLHttp("loadBalancingEndPoint11"),
            "http://localhost:9002/services/LBService1");
    Assert.assertNotNull(response);
    Assert.assertTrue(response.toString().contains("Response from server: Server_2"));

    response = lbClient.sendLoadBalanceRequest(getProxyServiceURLHttp("loadBalancingEndPoint11"),
            "http://localhost:9003/services/LBService1");
    Assert.assertNotNull(response);
    Assert.assertTrue(response.toString().contains("Response from server: Server_3"));

    response = lbClient.sendLoadBalanceRequest(getProxyServiceURLHttp("loadBalancingEndPoint11"),
            "http://localhost:9001/services/LBService1");
    Assert.assertNotNull(response);
    Assert.assertTrue(response.toString().contains("Response from server: Server_1"));
}
 
源代码18 项目: helix   文件: TestZkBaseDataAccessor.java
@Test
public void testSyncUpdate() {
  String className = TestHelper.getTestClassName();
  String methodName = TestHelper.getTestMethodName();
  String testName = className + "_" + methodName;

  System.out.println("START " + testName + " at " + new Date(System.currentTimeMillis()));

  String path = String.format("/%s/%s", _rootPath, "msg_0");
  ZNRecord record = new ZNRecord("msg_0");
  ZkBaseDataAccessor<ZNRecord> accessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);

  boolean success = accessor.update(path, new ZNRecordUpdater(record), AccessOption.PERSISTENT);
  Assert.assertTrue(success);
  ZNRecord getRecord = _gZkClient.readData(path);
  Assert.assertNotNull(getRecord);
  Assert.assertEquals(getRecord.getId(), "msg_0");

  record.setSimpleField("key0", "value0");
  success = accessor.update(path, new ZNRecordUpdater(record), AccessOption.PERSISTENT);
  Assert.assertTrue(success);
  getRecord = _gZkClient.readData(path);
  Assert.assertNotNull(getRecord);
  Assert.assertEquals(getRecord.getSimpleFields().size(), 1);
  Assert.assertNotNull(getRecord.getSimpleField("key0"));
  Assert.assertEquals(getRecord.getSimpleField("key0"), "value0");

  // test throw exception from updater
  success = accessor.update(path, new DataUpdater<ZNRecord>() {

    @Override
    public ZNRecord update(ZNRecord currentData) {
      throw new RuntimeException("IGNORABLE: test throw exception from updater");
    }
  }, AccessOption.PERSISTENT);
  Assert.assertFalse(success);
  getRecord = _gZkClient.readData(path);
  Assert.assertNotNull(getRecord);
  Assert.assertEquals(getRecord.getSimpleFields().size(), 1);

  System.out.println("END " + testName + " at " + new Date(System.currentTimeMillis()));
}
 
源代码19 项目: product-microgateway   文件: BasicGrpcTestCase.java
@Test(description = "Test BasicAuth Grpc Passthrough with transport security")
public void testBasicGrpcPassthrough() throws Exception {
    String response = testGrpcService("localhost:9595", "sample-request");
    Assert.assertNotNull(response);
    Assert.assertEquals(response, "response received :sample-request");
}
 
源代码20 项目: DataHubSystem   文件: FairQueueTest.java
@Test
public void testPoll2 () throws InterruptedException
{
   Assert.assertEquals (queue.size (), 0);
   FairQueueTestString s = queue.poll (5, TimeUnit.SECONDS);
   Assert.assertNull (s);

   new Thread (new Runnable ()
   {
      @Override
      public void run ()
      {
         try
         {
            Thread.sleep (3000);
         }
         catch (InterruptedException e)
         {
            // TODO Auto-generated catch block
            e.printStackTrace ();
         }
         queue.offer (new FairQueueTestString ("key1", "item1"));
      }
   }).start ();
   s = queue.poll (5, TimeUnit.SECONDS);
   ;
   Assert.assertNotNull (s);
   Assert.assertEquals (s.getItem (), "item1");

   queue.offer (new FairQueueTestString ("key1", "item1"));
   queue.offer (new FairQueueTestString ("key1", "item2"));
   queue.offer (new FairQueueTestString ("key1", "item3"));
   queue.offer (new FairQueueTestString ("key2", "item4"));
   queue.offer (new FairQueueTestString ("key2", "item5"));
   Assert.assertEquals (queue.size (), 5);
   s = queue.poll (5, TimeUnit.SECONDS);
   Assert.assertNotNull (s);
   Assert.assertEquals (s.getItem (), "item1");
   Assert.assertEquals (queue.size (), 4);
   s = queue.poll (5, TimeUnit.SECONDS);
   Assert.assertNotNull (s);
   Assert.assertEquals (s.getItem (), "item4");
   Assert.assertEquals (queue.size (), 3);
}