/** * Checks if two given {@link SecurityPermissionSet} objects contain the same permissions. * Each permission belongs to one of three groups : cache, task or system. * * @param locPerms The first set of permissions. * @param rmtPerms The second set of permissions. * @return {@code True} if given parameters contain the same permissions, {@code False} otherwise. */ private boolean permissionsEqual(SecurityPermissionSet locPerms, SecurityPermissionSet rmtPerms) { boolean dfltAllowMatch = locPerms.defaultAllowAll() == rmtPerms.defaultAllowAll(); boolean bothHaveSamePerms = F.eqNotOrdered(rmtPerms.systemPermissions(), locPerms.systemPermissions()) && F.eqNotOrdered(rmtPerms.cachePermissions(), locPerms.cachePermissions()) && F.eqNotOrdered(rmtPerms.taskPermissions(), locPerms.taskPermissions()); return dfltAllowMatch && bothHaveSamePerms; }
/** {@inheritDoc} */ @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; QueryEntity entity = (QueryEntity)o; return F.eq(keyType, entity.keyType) && F.eq(valType, entity.valType) && F.eq(keyFieldName, entity.keyFieldName) && F.eq(valueFieldName, entity.valueFieldName) && F.eq(fields, entity.fields) && F.eq(keyFields, entity.keyFields) && F.eq(aliases, entity.aliases) && F.eqNotOrdered(idxs, entity.idxs) && F.eq(tableName, entity.tableName) && F.eq(_notNullFields, entity._notNullFields) && F.eq(defaultFieldValues, entity.defaultFieldValues) && F.eq(fieldsPrecision, entity.fieldsPrecision) && F.eq(fieldsScale, entity.fieldsScale); }
", nodes=" + F.nodeIds(nodes) + ']'; assert F.eqNotOrdered(nodes, owners); assert F.eqNotOrdered(owners, nodes); Collection<ClusterNode> m2 = mappings.get(j); assert F.eqNotOrdered(m1, m2) : "Mappings are not equal [m1=" + F.nodeIds(m1) + ", m2=" + F.nodeIds(m2) + ']'; assert F.eqNotOrdered(m2, m1) : "Mappings are not equal [m1=" + F.nodeIds(m1) + ", m2=" + F.nodeIds(m2) + ']';
if (!F.eqNotOrdered(allExpRows, allInfos)) fail("Returned incorrect rows [expected=" + allExpRows + ", actual=" + allInfos + "].");
/** * @throws Exception If failed. */ @Test public void testHostNames() throws Exception { Ignite ignite = grid(); Collection<String> locNodeHosts = ignite.cluster().localNode().hostNames(); Collection<String> clusterHosts = ignite.cluster().hostNames(); assertTrue(F.eqNotOrdered(locNodeHosts, clusterHosts)); boolean gotNpe = false; try { clusterHosts.add("valueShouldNotToBeAdded"); } catch (UnsupportedOperationException ignored) { gotNpe = true; } finally { assertTrue(gotNpe); } }
/** * @throws Exception If failed. */ @Test public void testMessaging() throws Exception { IgniteConfiguration cfg = optimize(getConfiguration("g1")); try (Ignite g1 = G.start(cfg)) { IgniteMessaging messaging = message(grid().cluster().forNode(g1.cluster().localNode())); messaging.send(null, "test"); GridMarshallerTestBean inBean = newTestBean(messaging); byte[] buf = marshal(inBean); GridMarshallerTestBean outBean = unmarshal(buf); assert inBean.getObjectField() != null; assert outBean.getObjectField() != null; assert inBean.getObjectField().getClass().equals(IgniteMessagingImpl.class); assert outBean.getObjectField().getClass().equals(IgniteMessagingImpl.class); assert inBean != outBean; assert inBean.equals(outBean); ClusterGroup inPrj = messaging.clusterGroup(); ClusterGroup outPrj = ((IgniteMessaging)outBean.getObjectField()).clusterGroup(); assert inPrj.getClass().equals(outPrj.getClass()); assert F.eqNotOrdered(inPrj.nodes(), outPrj.nodes()); outBean.checkNullResources(); } }
/** * @throws Exception If failed. */ @Test public void testCompute() throws Exception { IgniteConfiguration cfg = optimize(getConfiguration("g1")); try (Ignite g1 = G.start(cfg)) { IgniteCompute compute = compute(grid().cluster().forNode(g1.cluster().localNode())); compute.run(new IgniteRunnable() { @Override public void run() { // No-op. } }); GridMarshallerTestBean inBean = newTestBean(compute); byte[] buf = marshal(inBean); GridMarshallerTestBean outBean = unmarshal(buf); assert inBean.getObjectField() != null; assert outBean.getObjectField() != null; assert inBean.getObjectField().getClass().equals(IgniteComputeImpl.class); assert outBean.getObjectField().getClass().equals(IgniteComputeImpl.class); assert inBean != outBean; assert inBean.equals(outBean); ClusterGroup inPrj = compute.clusterGroup(); ClusterGroup outPrj = ((IgniteCompute)outBean.getObjectField()).clusterGroup(); assert inPrj.getClass().equals(outPrj.getClass()); assert F.eqNotOrdered(inPrj.nodes(), outPrj.nodes()); outBean.checkNullResources(); } }
/** * @throws Exception If failed. */ @Test public void testServices() throws Exception { IgniteConfiguration cfg = optimize(getConfiguration("g1")); try (Ignite g1 = G.start(cfg)) { IgniteServices services = grid().services(grid().cluster().forNode(g1.cluster().localNode())); services.deployNodeSingleton("test", new DummyService()); GridMarshallerTestBean inBean = newTestBean(services); byte[] buf = marshal(inBean); GridMarshallerTestBean outBean = unmarshal(buf); assert inBean.getObjectField() != null; assert outBean.getObjectField() != null; assert inBean.getObjectField().getClass().equals(IgniteServicesImpl.class); assert outBean.getObjectField().getClass().equals(IgniteServicesImpl.class); assert inBean != outBean; assert inBean.equals(outBean); ClusterGroup inPrj = services.clusterGroup(); ClusterGroup outPrj = ((IgniteServices)outBean.getObjectField()).clusterGroup(); assert inPrj.getClass().equals(outPrj.getClass()); assert F.eqNotOrdered(inPrj.nodes(), outPrj.nodes()); outBean.checkNullResources(); } }
/** * @throws Exception If failed. */ @Test public void testEvents() throws Exception { IgniteConfiguration cfg = optimize(getConfiguration("g1")); try (Ignite g1 = G.start(cfg)) { IgniteEvents evts = events(grid().cluster().forNode(g1.cluster().localNode())); evts.localListen(new IgnitePredicate<Event>() { @Override public boolean apply(Event gridEvt) { return true; } }, EVTS_CACHE); grid().cache(DEFAULT_CACHE_NAME).put(1, 1); GridMarshallerTestBean inBean = newTestBean(evts); byte[] buf = marshal(inBean); GridMarshallerTestBean outBean = unmarshal(buf); assert inBean.getObjectField() != null; assert outBean.getObjectField() != null; assert inBean.getObjectField().getClass().equals(IgniteEventsImpl.class); assert outBean.getObjectField().getClass().equals(IgniteEventsImpl.class); assert inBean != outBean; assert inBean.equals(outBean); ClusterGroup inPrj = evts.clusterGroup(); ClusterGroup outPrj = ((IgniteEvents)outBean.getObjectField()).clusterGroup(); assert inPrj.getClass().equals(outPrj.getClass()); assert F.eqNotOrdered(inPrj.nodes(), outPrj.nodes()); outBean.checkNullResources(); } }
/** * Checks if two given {@link SecurityPermissionSet} objects contain the same permissions. * Each permission belongs to one of three groups : cache, task or system. * * @param locPerms The first set of permissions. * @param rmtPerms The second set of permissions. * @return {@code True} if given parameters contain the same permissions, {@code False} otherwise. */ private boolean permissionsEqual(SecurityPermissionSet locPerms, SecurityPermissionSet rmtPerms) { boolean dfltAllowMatch = locPerms.defaultAllowAll() == rmtPerms.defaultAllowAll(); boolean bothHaveSamePerms = F.eqNotOrdered(rmtPerms.systemPermissions(), locPerms.systemPermissions()) && F.eqNotOrdered(rmtPerms.cachePermissions(), locPerms.cachePermissions()) && F.eqNotOrdered(rmtPerms.taskPermissions(), locPerms.taskPermissions()); return dfltAllowMatch && bothHaveSamePerms; }
/** {@inheritDoc} */ @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; QueryEntity entity = (QueryEntity)o; return F.eq(keyType, entity.keyType) && F.eq(valType, entity.valType) && F.eq(keyFieldName, entity.keyFieldName) && F.eq(valueFieldName, entity.valueFieldName) && F.eq(fields, entity.fields) && F.eq(keyFields, entity.keyFields) && F.eq(aliases, entity.aliases) && F.eqNotOrdered(idxs, entity.idxs) && F.eq(tableName, entity.tableName) && F.eq(_notNullFields, entity._notNullFields) && F.eq(defaultFieldValues, entity.defaultFieldValues) && F.eq(fieldsPrecision, entity.fieldsPrecision) && F.eq(fieldsScale, entity.fieldsScale); }