@Test(groups = "slow") public void testShouldBeAbleToPassNullForSomeFieldsToAvoidUpdate() throws Exception { final Account account = createTestAccount(); accountDao.create(account, internalCallContext); // Update the address and leave other fields null final MutableAccountData mutableAccountData = new DefaultMutableAccountData( null, null, null, 0, null, null, null, null, null, null, null, null, null, null, null, null, null, null, false, false); final String newAddress1 = UUID.randomUUID().toString(); mutableAccountData.setAddress1(newAddress1); final DefaultAccount newAccount = new DefaultAccount(account.getId(), mutableAccountData); accountDao.update(newAccount, internalCallContext); Assert.assertEquals( accountDao.getById(account.getId(), internalCallContext).getAddress1(), newAddress1); Assert.assertEquals( accountDao.getById(account.getId(), internalCallContext).getAddress2(), account.getAddress2()); Assert.assertEquals( accountDao.getById(account.getId(), internalCallContext).getCurrency(), account.getCurrency()); Assert.assertEquals( accountDao.getById(account.getId(), internalCallContext).getExternalKey(), account.getExternalKey()); Assert.assertEquals( accountDao.getById(account.getId(), internalCallContext).getBillCycleDay(), account.getBillCycleDay()); }
@Test public void testWholeIndelReadInIsolation() { final int firstLocus = 44367789; // create a test version of the Reads object ReadProperties readAttributes = createTestReadProperties(); SAMRecord indelOnlyRead = ArtificialSAMUtils.createArtificialRead(header, "indelOnly", 0, firstLocus, 76); indelOnlyRead.setReadBases(Utils.dupBytes((byte) 'A', 76)); indelOnlyRead.setBaseQualities(Utils.dupBytes((byte) '@', 76)); indelOnlyRead.setCigarString("76I"); List<SAMRecord> reads = Arrays.asList(indelOnlyRead); // create the iterator by state with the fake reads and fake records li = makeLTBS(reads, readAttributes); // Traditionally, reads that end with indels bleed into the pileup at the following locus. // Verify that the next pileup contains this read // and considers it to be an indel-containing read. Assert.assertTrue( li.hasNext(), "Should have found a whole-indel read in the normal base pileup without extended events enabled"); AlignmentContext alignmentContext = li.next(); Assert.assertEquals( alignmentContext.getLocation().getStart(), firstLocus, "Base pileup is at incorrect location."); ReadBackedPileup basePileup = alignmentContext.getBasePileup(); Assert.assertEquals(basePileup.getReads().size(), 1, "Pileup is of incorrect size"); Assert.assertSame(basePileup.getReads().get(0), indelOnlyRead, "Read in pileup is incorrect"); }
@Test public void queryGroupByAndOrderBy() { List<ODocument> result = database .command( new OSQLSynchQuery<ODocument>( "select location from Account group by location order by location")) .execute(); Assert.assertTrue(result.size() > 1); String last = null; for (ODocument d : result) { if (last != null) Assert.assertTrue(last.compareTo((String) d.field("location")) < 0); last = d.field("location"); } result = database .command( new OSQLSynchQuery<ODocument>( "select location from Account group by location order by location desc")) .execute(); Assert.assertTrue(result.size() > 1); last = null; for (ODocument d : result) { if (last != null) Assert.assertTrue(last.compareTo((String) d.field("location")) > 0); last = d.field("location"); } }
/** Positive test case for listUsers method with optional parameters. */ @Test( groups = {"wso2.esb"}, description = "tsheets {listUsers} integration test with optional parameters.") public void testListUsersWithOptionalParameters() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:listUsers"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_listUsers_optional.json"); JSONObject esbUsers = esbRestResponse.getBody().getJSONObject("results").getJSONObject("users"); String apiEndPoint = connectorProperties.getProperty("apiUrl") + "/api/v1/users?page=2&per_page=1"; RestResponse<JSONObject> apiRestResponse = sendJsonRestRequest(apiEndPoint, "GET", apiRequestHeadersMap); JSONObject apiUsers = apiRestResponse.getBody().getJSONObject("results").getJSONObject("users"); Iterator<String> esbUserKeySet = esbUsers.keys(); Assert.assertEquals(apiUsers.length(), esbUsers.length()); while (esbUserKeySet.hasNext()) { String userKey = esbUserKeySet.next(); JSONObject esbUser = esbUsers.getJSONObject(userKey); JSONObject apiUser = apiUsers.getJSONObject(userKey); Assert.assertEquals(apiUser.getString("first_name"), esbUser.getString("first_name")); Assert.assertEquals(apiUser.getString("last_name"), esbUser.getString("last_name")); Assert.assertEquals(apiUser.getString("username"), esbUser.getString("username")); Assert.assertEquals(apiUser.getString("email"), esbUser.getString("email")); } }
@Test public void includeAsClasses() throws Exception { String baseDir = testIssue("flexmojos-247").getBasedir(); File target = new File(baseDir, "target"); Assert.assertTrue(target.exists()); File swc = new File(target, "flexmojos-247-1.0-SNAPSHOT.swc"); Assert.assertTrue(swc.exists()); String catalog; ZipFile zf = new ZipFile(swc); try { InputStream in = zf.getInputStream(zf.getEntry("catalog.xml")); catalog = IOUtils.toString(in); in.close(); } finally { zf.close(); } // must have both classes and the uri MatcherAssert.assertThat(catalog, StringContains.containsString("AClass")); MatcherAssert.assertThat(catalog, StringContains.containsString("BClass")); MatcherAssert.assertThat( catalog, StringContains.containsString("http://flexmojos.sonatype.org/tests")); }
public void testParentRole() { database.open("admin", "admin"); final OSecurity security = database.getMetadata().getSecurity(); ORole writer = security.getRole("writer"); ORole writerChild = security.createRole("writerChild", writer, OSecurityRole.ALLOW_MODES.ALLOW_ALL_BUT); writerChild.save(); ORole writerGrandChild = security.createRole( "writerGrandChild", writerChild, OSecurityRole.ALLOW_MODES.ALLOW_ALL_BUT); writerGrandChild.save(); OUser child = security.createUser("writerChild", "writerChild", writerGrandChild); child.save(); Assert.assertTrue(child.hasRole("writer", true)); Assert.assertFalse(child.hasRole("wrter", true)); database.close(); if (!(database.getStorage() instanceof OStorageProxy)) { database.open("writerChild", "writerChild"); OSecurityUser user = database.getUser(); Assert.assertTrue(user.hasRole("writer", true)); Assert.assertFalse(user.hasRole("wrter", true)); database.close(); } }
@Override public void first() { String hql = "FROM Product WHERE processed IS FALSE ORDER BY id DESC"; Product product = dao.first(hql); Assert.assertNotNull(product); Assert.assertEquals(product.getId().intValue(), 4); }
@Test public void testTranslate() { String expectedLookUp = "lookUp"; String expectedKey = "foo"; String expectedLookUpKeyStr = "(" + expectedLookUp + ")" + expectedKey; LookUpKey expectedLookUpKey = new LookUpKey(expectedLookUp, expectedKey, expectedLookUpKeyStr); String expectedValue = "bar"; Property property = new Property(expectedLookUpKeyStr, expectedValue); LookUpKeyResolver lookUpKeyResolver = EasyMock.createStrictMock(LookUpKeyResolver.class); EasyMock.expect(lookUpKeyResolver.resolve(property.getKey())).andReturn(expectedLookUpKey); EasyMock.replay(lookUpKeyResolver); PropertyServiceImpl service = new PropertyServiceImpl(lookUpKeyResolver); ClearProperty clearProperty = service.translate(property); Assert.assertNotNull(clearProperty); Assert.assertNotNull(clearProperty.getLookUpKey()); Assert.assertNotNull(clearProperty.getKey()); Assert.assertNotNull(clearProperty.getValue()); Assert.assertNotNull(clearProperty.getLookUpKey().getKey()); Assert.assertNotNull(clearProperty.getLookUpKey().getLookUp()); Assert.assertEquals(clearProperty.getKey(), expectedKey); Assert.assertEquals(clearProperty.getValue(), expectedValue); Assert.assertEquals(clearProperty.getLookUpKey().getLookUp(), expectedLookUp); Assert.assertEquals(clearProperty.getLookUpKey().getLookUpKey(), expectedLookUpKeyStr); }
@Test public void testLiveInsert() { OLiveCommandExecutorSQLFactory.init(); ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:OLiveQueryTest"); db.activateOnCurrentThread(); db.create(); db.registerHook(new OLiveQueryHook(db)); try { db.getMetadata().getSchema().createClass("test"); db.getMetadata().getSchema().createClass("test2"); MyLiveQueryListener listener = new MyLiveQueryListener(); db.query(new OLiveQuery<ODocument>("live select from test", listener)); db.command(new OCommandSQL("insert into test set name = 'foo', surname = 'bar'")).execute(); db.command(new OCommandSQL("insert into test set name = 'foo', surname = 'baz'")).execute(); db.command(new OCommandSQL("insert into test2 set name = 'foo'")); try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } Assert.assertEquals(listener.ops.size(), 2); for (ORecordOperation doc : listener.ops) { Assert.assertEquals(doc.type, ORecordOperation.CREATED); Assert.assertEquals(((ODocument) doc.record).field("name"), "foo"); } } finally { db.drop(); } }
private void checkQuerySets(Context context) { QuerySet querySetOne = context.getQuerySetByPath("/xml/correct/query1.xml"); QuerySet querySetTwo = context.getQuerySetByPath("/xml/correct/query2.xml"); checkQuerySetOne(querySetOne); checkQuerySetTwo(querySetTwo); Query queryOne = getQueryByCompositeId(context, buildCompositeId(DB_TEST, COLLECTION_ONE, QUERY_1)); Query queryTwo = getQueryByCompositeId(context, buildCompositeId(DB_TEST, COLLECTION_ONE, QUERY_2)); Query queryThree = getQueryByCompositeId(context, buildCompositeId(DB_TEST_ROOT, COLLECTION_TWO, QUERY_3)); Query queryFour = getQueryByCompositeId(context, buildCompositeId(DB_TEST_ROOT, COLLECTION_TWO, QUERY_4)); Query notExist = getQueryByCompositeId( context, buildCompositeId(DB_TEST, COLLECTION_ONE, QUERY_NON_EXISTENT)); Assert.assertNotNull(queryOne); Assert.assertNotNull(queryTwo); Assert.assertNotNull(queryThree); Assert.assertNotNull(queryFour); Assert.assertNull(notExist); checkQueryOne(queryOne); checkQueryTwo(queryTwo); checkQueryThree(queryThree); checkQueryFour(queryFour); }
@Test public void arrayTest() { Assert.assertTrue(Number[].class.isAssignableFrom(Integer[].class)); List<Integer> integers = new ArrayList<Integer>(); List<Number> numbers = new ArrayList<Number>(); Assert.assertTrue(numbers.getClass().isAssignableFrom(integers.getClass())); }
private void checkQueryFour(Query query) { Assert.assertEquals(query.getId(), "query-4"); Assert.assertEquals( query.getBody(), "{'body' : 'query-4'},{'body' : 'query-4-fragment'},{'body' : 'query-4-continue'}"); Assert.assertTrue(CollectionUtils.isEmpty(query.getCases())); }
@Test public void testQueryIsolation() { OGraphDatabase db = new OGraphDatabase(url); db.open("admin", "admin"); try { db.begin(); ODocument v1 = db.createVertex(); v1.field("purpose", "testQueryIsolation"); v1.save(); if (!url.startsWith("remote")) { List<OIdentifiable> result = db.query( new OSQLSynchQuery<Object>("select from V where purpose = 'testQueryIsolation'")); Assert.assertEquals(result.size(), 1); } db.commit(); List<OIdentifiable> result = db.query( new OSQLSynchQuery<Object>("select from V where purpose = 'testQueryIsolation'")); Assert.assertEquals(result.size(), 1); } finally { db.close(); } }
@Test(groups = "slow") public void testShouldBeAbleToHandleOtherBCDClass() throws Exception { final Account account = createTestAccount(); accountDao.create(account, internalCallContext); final MutableAccountData otherAccount = account.toMutableAccountData(); otherAccount.setAddress1(UUID.randomUUID().toString()); otherAccount.setEmail(UUID.randomUUID().toString()); // Same BCD, but not .equals method otherAccount.setBillCycleDay( new BillCycleDay() { @Override public int getDayOfMonthUTC() { return account.getBillCycleDay().getDayOfMonthUTC(); } @Override public int getDayOfMonthLocal() { return account.getBillCycleDay().getDayOfMonthLocal(); } }); final DefaultAccount newAccount = new DefaultAccount(account.getId(), otherAccount); accountDao.update(newAccount, internalCallContext); final Account newFetchedAccount = accountDao.getById(account.getId(), internalCallContext); Assert.assertEquals(newFetchedAccount.getAddress1(), newAccount.getAddress1()); Assert.assertEquals(newFetchedAccount.getEmail(), newAccount.getEmail()); // Same BCD Assert.assertEquals(newFetchedAccount.getBillCycleDay(), account.getBillCycleDay()); }
/** {@inheritDoc} */ @Test public void testSingleElementUnmarshall() { Description name = (Description) unmarshallElement(singleElementFile); Assert.assertEquals(name.getValue(), expectValue, "Name was not expected value"); Assert.assertEquals(name.getXMLLang(), expectLang, "xml:lang was not expected value"); }
@Test public void TestControllerChange() throws Exception { String controllerName = CONTROLLER_PREFIX + "_0"; _controller.syncStop(); Thread.sleep(1000); // kill controller, participant should not know about the svc url for (int i = 0; i < NODE_NR; i++) { HelixDataAccessor accessor = _participants[i].getHelixDataAccessor(); ZKHelixDataAccessor zkAccessor = (ZKHelixDataAccessor) accessor; Assert.assertTrue( zkAccessor._zkPropertyTransferSvcUrl == null || zkAccessor._zkPropertyTransferSvcUrl.equals("")); } _controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName); _controller.syncStart(); Thread.sleep(1000); // create controller again, the svc url is notified to the participants for (int i = 0; i < NODE_NR; i++) { HelixDataAccessor accessor = _participants[i].getHelixDataAccessor(); ZKHelixDataAccessor zkAccessor = (ZKHelixDataAccessor) accessor; Assert.assertTrue( zkAccessor._zkPropertyTransferSvcUrl.equals( ZKPropertyTransferServer.getInstance().getWebserviceUrl())); } }
@Test public void testEncryptPassword() throws IOException { database.open("admin", "admin"); Integer updated = database .command(new OCommandSQL("update ouser set password = '******' where name = 'reader'")) .execute(); Assert.assertEquals(updated.intValue(), 1); List<ODocument> result = database.query(new OSQLSynchQuery<Object>("select from ouser where name = 'reader'")); Assert.assertFalse(result.get(0).field("password").equals("test")); // RESET OLD PASSWORD updated = database .command(new OCommandSQL("update ouser set password = '******' where name = 'reader'")) .execute(); Assert.assertEquals(updated.intValue(), 1); result = database.query(new OSQLSynchQuery<Object>("select from ouser where name = 'reader'")); Assert.assertFalse(result.get(0).field("password").equals("reader")); database.close(); }
@Test public void testPermissions() throws ApplicationsManagerException, MalformedURLException { UUID resourceId = UUID.randomUUID(); Application application = getApplication(applicationName); String apiKey = applicationsManager.registerApplication(application); Assert.assertTrue(applicationsManager.isAuthorized(apiKey)); Permission permission = new Permission(resourceId); permission.setPermission(Permission.Action.RETRIEVE, true); applicationsManager.grantPermission(applicationName, permission); Assert.assertFalse( applicationsManager.isAuthorized(apiKey, resourceId, Permission.Action.DELETE)); applicationsManager.grantPermission(applicationName, resourceId, Permission.Action.DELETE); Assert.assertTrue( applicationsManager.isAuthorized(apiKey, resourceId, Permission.Action.DELETE)); applicationsManager.deregisterApplication(applicationName); Application actual = applicationsManager.getApplication(applicationName); Assert.assertNull(actual); }
@Test public void testQuotedUserName() { database.open("admin", "admin"); OSecurity security = database.getMetadata().getSecurity(); ORole adminRole = security.getRole("admin"); OUser newUser = security.createUser("user'quoted", "foobar", adminRole); database.close(); database.open("user'quoted", "foobar"); database.close(); database.open("admin", "admin"); security = database.getMetadata().getSecurity(); OUser user = security.getUser("user'quoted"); Assert.assertNotNull(user); security.dropUser(user.getName()); database.close(); try { database.open("user'quoted", "foobar"); Assert.fail(); } catch (Exception e) { } }
@Test(dependsOnMethods = "testSubmit") public void testGetDefinition() throws Exception { for (HierarchicalTypeDefinition typeDefinition : typeDefinitions) { System.out.println("typeName = " + typeDefinition.typeName); WebResource resource = service.path("api/atlas/types").path(typeDefinition.typeName); ClientResponse clientResponse = resource .accept(Servlets.JSON_MEDIA_TYPE) .type(Servlets.JSON_MEDIA_TYPE) .method(HttpMethod.GET, ClientResponse.class); assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode()); String responseAsString = clientResponse.getEntity(String.class); Assert.assertNotNull(responseAsString); JSONObject response = new JSONObject(responseAsString); Assert.assertNotNull(response.get(AtlasClient.DEFINITION)); Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID)); String typesJson = response.getString(AtlasClient.DEFINITION); final TypesDef typesDef = TypesSerialization.fromJson(typesJson); List<HierarchicalTypeDefinition<ClassType>> hierarchicalTypeDefinitions = typesDef.classTypesAsJavaList(); for (HierarchicalTypeDefinition<ClassType> classType : hierarchicalTypeDefinitions) { for (AttributeDefinition attrDef : classType.attributeDefinitions) { if ("name".equals(attrDef.name)) { assertEquals(attrDef.isIndexable, true); assertEquals(attrDef.isUnique, true); } } } } }
@Test public void getOwerOfProduct() { User expectedUser = new User(); expectedUser.setUsername("koko"); Product product = dao.read(0L); Assert.assertNotNull(product); User user = dao.getOwnerOfProduct(product); // To be sure that both are equals... expectedUser.setUUID(user.getUUID()); Assert.assertNotNull(user); Assert.assertTrue( user.equals(expectedUser), "User " + user.getUsername() + "#" + user.getUUID() + " not expected (" + expectedUser.getUsername() + "#" + expectedUser.getUUID() + ")."); product = dao.read(6L); user = dao.getOwnerOfProduct(product); Assert.assertNull(user); }
@Test(dependsOnMethods = "testSubmit") public void testGetTypeNames() throws Exception { WebResource resource = service.path("api/atlas/types"); ClientResponse clientResponse = resource .accept(Servlets.JSON_MEDIA_TYPE) .type(Servlets.JSON_MEDIA_TYPE) .method(HttpMethod.GET, ClientResponse.class); assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode()); String responseAsString = clientResponse.getEntity(String.class); Assert.assertNotNull(responseAsString); JSONObject response = new JSONObject(responseAsString); Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID)); final JSONArray list = response.getJSONArray(AtlasClient.RESULTS); Assert.assertNotNull(list); // Verify that primitive and core types are not returned String typesString = list.join(" "); Assert.assertFalse(typesString.contains(" \"__IdType\" ")); Assert.assertFalse(typesString.contains(" \"string\" ")); }
/** Negative test case for addTimeSheets method . */ @Test( groups = {"wso2.esb"}, description = "tsheets {addTimeSheets} integration test with negative case.") public void testAddTimeSheetsWithNegativeCase() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:addTimeSheets"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest( proxyUrl, "POST", esbRequestHeadersMap, "esb_addTimeSheets_negative.json"); JSONObject esbResponseObject = esbRestResponse .getBody() .getJSONObject("results") .getJSONObject("timesheets") .getJSONObject("1"); String apiEndPoint = connectorProperties.getProperty("apiUrl") + "/api/v1/timesheets"; RestResponse<JSONObject> apiRestResponse = sendJsonRestRequest( apiEndPoint, "POST", apiRequestHeadersMap, "api_addTimeSheets_negative.json"); JSONObject apiResponseObject = apiRestResponse .getBody() .getJSONObject("results") .getJSONObject("timesheets") .getJSONObject("1"); Assert.assertEquals(apiRestResponse.getHttpStatusCode(), esbRestResponse.getHttpStatusCode()); Assert.assertEquals( apiResponseObject.getString("_status_code"), esbResponseObject.getString("_status_code")); Assert.assertEquals( apiResponseObject.getString("_status_message"), esbResponseObject.getString("_status_message")); }
@Test public void testSubmit() throws Exception { for (HierarchicalTypeDefinition typeDefinition : typeDefinitions) { String typesAsJSON = TypesSerialization.toJson(typeDefinition); System.out.println("typesAsJSON = " + typesAsJSON); WebResource resource = service.path("api/atlas/types"); ClientResponse clientResponse = resource .accept(Servlets.JSON_MEDIA_TYPE) .type(Servlets.JSON_MEDIA_TYPE) .method(HttpMethod.POST, ClientResponse.class, typesAsJSON); assertEquals(clientResponse.getStatus(), Response.Status.CREATED.getStatusCode()); String responseAsString = clientResponse.getEntity(String.class); Assert.assertNotNull(responseAsString); JSONObject response = new JSONObject(responseAsString); JSONArray typesAdded = response.getJSONArray(AtlasClient.TYPES); assertEquals(typesAdded.length(), 1); assertEquals(typesAdded.getJSONObject(0).getString("name"), typeDefinition.typeName); Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID)); } }
@Test(dependsOnMethods = "testGetMetrics") @SuppressWarnings("unchecked") public void testGetMetricsWithFilter() { MetricFilter filter = new MetricFilter() { @Override public boolean matches(String name, Metric metric) { return !name.equals(MetricContext.GOBBLIN_METRICS_NOTIFICATIONS_TIMER_NAME); } }; Map<String, Counter> counters = this.context.getCounters(filter); Assert.assertEquals(counters.size(), 1); Assert.assertTrue(counters.containsKey(RECORDS_PROCESSED)); Map<String, Meter> meters = this.context.getMeters(filter); Assert.assertEquals(meters.size(), 1); Assert.assertTrue(meters.containsKey(RECORD_PROCESS_RATE)); Map<String, Histogram> histograms = this.context.getHistograms(filter); Assert.assertEquals(histograms.size(), 1); Assert.assertTrue(histograms.containsKey(RECORD_SIZE_DISTRIBUTION)); Map<String, Timer> timers = this.context.getTimers(filter); Assert.assertEquals(timers.size(), 1); Assert.assertTrue(timers.containsKey(TOTAL_DURATION)); Map<String, Gauge> gauges = this.context.getGauges(filter); Assert.assertEquals(gauges.size(), 1); Assert.assertTrue(gauges.containsKey(QUEUE_SIZE)); }
@Test() public void testAutoRebalance() throws Exception { // kill 1 node String instanceName = PARTICIPANT_PREFIX + "_" + (START_PORT + 0); _startCMResultMap.get(instanceName)._manager.disconnect(); Thread.currentThread().sleep(1000); _startCMResultMap.get(instanceName)._thread.interrupt(); // verifyBalanceExternalView(); boolean result = ClusterStateVerifier.verifyByZkCallback( new ExternalViewBalancedVerifier(_zkClient, CLUSTER_NAME, TEST_DB)); Assert.assertTrue(result); // add 2 nodes for (int i = 0; i < 2; i++) { String storageNodeName = PARTICIPANT_PREFIX + ":" + (1000 + i); _setupTool.addInstanceToCluster(CLUSTER_NAME, storageNodeName); StartCMResult resultx = TestHelper.startDummyProcess(ZK_ADDR, CLUSTER_NAME, storageNodeName.replace(':', '_')); _startCMResultMap.put(storageNodeName, resultx); } Thread.sleep(1000); result = ClusterStateVerifier.verifyByZkCallback( new ExternalViewBalancedVerifier(_zkClient, CLUSTER_NAME, TEST_DB)); Assert.assertTrue(result); }
@Test public void queryGroupByNoNulls() { database.command(new OCommandSQL("create class GroupByTest extends V")).execute(); try { database.command(new OCommandSQL("insert into GroupByTest set location = 'Rome'")).execute(); database .command(new OCommandSQL("insert into GroupByTest set location = 'Austin'")) .execute(); database .command(new OCommandSQL("insert into GroupByTest set location = 'Austin'")) .execute(); final List<ODocument> result = database .command( new OSQLSynchQuery<ODocument>( "select location, count(*) from GroupByTest group by location")) .execute(); Assert.assertEquals(result.size(), 2); for (ODocument d : result) { Assert.assertNotNull(d.field("location"), "Found null in resultset with groupby"); } } finally { database.command(new OCommandSQL("delete vertex GroupByTest")).execute(); database.command(new OCommandSQL("drop class GroupByTest UNSAFE")).execute(); } }
@Test() public void testAutoRebalanceDisablePartition() throws Exception { // kill 1 node String instanceName = PARTICIPANT_PREFIX + "_" + (START_PORT + 3); HelixDataAccessor _accessor = _startCMResultMap.get(instanceName)._manager.getHelixDataAccessor(); ExternalView ev = _accessor.getProperty(_accessor.keyBuilder().externalView(TEST_DB)); for (int i = 0; i < 3; i++) { String partitionName = TEST_DB + "_" + i; List<String> list = new ArrayList<String>(); list.add(partitionName); String host = (String) (ev.getStateMap(partitionName).keySet().toArray()[0]); _startCMResultMap .get(instanceName) ._manager .getClusterManagmentTool() .enablePartition(false, CLUSTER_NAME, host, TEST_DB, list); } Thread.sleep(10000); ev = _accessor.getProperty(_accessor.keyBuilder().externalView(TEST_DB)); for (int i = 0; i < 3; i++) { String partitionName = TEST_DB + "_" + i; List<String> list = new ArrayList<String>(); list.add(partitionName); String host = (String) (ev.getStateMap(partitionName).keySet().toArray()[0]); Assert.assertTrue(ev.getStateMap(partitionName).get(host).equalsIgnoreCase("offline")); Assert.assertEquals(ev.getStateMap(partitionName).size(), 1); } }
protected void createPersonRefs() throws Exception { PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); // Create a temporary PersonAuthority resource, and its corresponding // refName by which it can be identified. PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance( PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName()); Response res = personAuthClient.create(multipart); try { int statusCode = res.getStatus(); Assert.assertTrue( testRequestType.isValidStatusCode(statusCode), invalidStatusCodeMessage(testRequestType, statusCode)); Assert.assertEquals(statusCode, STATUS_CREATED); personAuthCSID = extractId(res); } finally { res.close(); } String authRefName = PersonAuthorityClientUtils.getAuthorityRefName(personAuthCSID, null); // Create temporary Person resources, and their corresponding refNames // by which they can be identified. String csid = createPerson("Carrie", "ConditionChecker1", "carrieConditionChecker", authRefName); personIdsCreated.add(csid); conditionCheckerRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null); }
// TODO add test methods here. // The methods must be annotated with annotation @Test. For example: // @Test public void TestGrading() { // Make Chain GradeHandler gradeA = new GradeHandlerA(); GradeHandler gradeB = new GradHandlerB(); GradeHandler gradeC = new GradeHandlerC(); gradeA.setSuccessor(gradeB); gradeB.setSuccessor(gradeC); // Test for C grading Request request = new Request(60); gradeA.handleGrading(request); Assert.assertEquals(request.getGrading(), "C"); // Test for A grading request = new Request(80); gradeA.handleGrading(request); Assert.assertEquals(request.getGrading(), "A"); // Test for B grading request = new Request(70); gradeA.handleGrading(request); Assert.assertEquals(request.getGrading(), "B"); }