List of usage examples for java.util Arrays equals
public static boolean equals(Object[] a, Object[] a2)
From source file:be.fedict.hsm.model.security.ApplicationSecurityBean.java
/** * Authenticates a given credential as a certain application. * // w ww .ja v a 2 s . c o m * @param username * the credential fingerprint. * @param encodedCredential * the actual credential. * @return the authenticated application identifier. */ public String getAuthenticatedApplication(String username, char[] encodedCredential) { LOG.debug("authenticating " + username); CredentialEntity credentialEntity = this.entityManager.find(CredentialEntity.class, username); if (null == credentialEntity) { LOG.warn("unknown application credential: " + username); this.securityAuditGeneratorBean.webServiceAuthenticationError(); return null; } byte[] credential; try { credential = Hex.decodeHex(encodedCredential); } catch (DecoderException e) { LOG.error("error decoding credential"); this.securityAuditGeneratorBean.webServiceAuthenticationError(username); return null; } byte[] expectedCredential = credentialEntity.getCredential(); if (false == Arrays.equals(expectedCredential, credential)) { LOG.error("credential mismatch"); this.securityAuditGeneratorBean.webServiceAuthenticationError(username); return null; } LOG.debug("credential matches"); ApplicationEntity applicationEntity = credentialEntity.getApplication(); LOG.debug("application id: " + applicationEntity.getId()); return Long.toString(applicationEntity.getId()); }
From source file:at.bitfire.davdroid.resource.ContactTest.java
public void testReferenceVCard3() throws IOException, InvalidResourceException { Contact c = parseVCF("reference-vcard3.vcf", Charset.forName(CharEncoding.UTF_8)); assertEquals("Gmp", c.familyName); assertEquals("Frrest", c.givenName); assertEquals("Frrest Gmp", c.displayName); assertEquals("Bubba Gump Shrimp Co.", c.organization.getValues().get(0)); assertEquals("Shrimp Man", c.jobTitle); Telephone phone1 = c.getPhoneNumbers().get(0); assertEquals("(111) 555-1212", phone1.getText()); assertEquals("WORK", phone1.getParameters("TYPE").get(0)); assertEquals("VOICE", phone1.getParameters("TYPE").get(1)); Telephone phone2 = c.getPhoneNumbers().get(1); assertEquals("(404) 555-1212", phone2.getText()); assertEquals("HOME", phone2.getParameters("TYPE").get(0)); assertEquals("VOICE", phone2.getParameters("TYPE").get(1)); Email email = c.getEmails().get(0);//from w ww.j a va2 s. co m assertEquals("forrestgump@example.com", email.getValue()); assertEquals("PREF", email.getParameters("TYPE").get(0)); assertEquals("INTERNET", email.getParameters("TYPE").get(1)); @Cleanup InputStream photoStream = assetMgr.open("davdroid-logo-192.png", AssetManager.ACCESS_STREAMING); byte[] expectedPhoto = IOUtils.toByteArray(photoStream); assertTrue(Arrays.equals(c.photo, expectedPhoto)); }
From source file:edu.oregonstate.eecs.mcplan.domains.taxi.PutdownAction.java
@Override public void doAction(final RandomGenerator rng_unused, final TaxiState s) { assert (!done_); old_passenger_ = s.passenger;//from w ww .j a v a2 s . c o m old_goal_ = s.goal; old_pickup_success_ = s.pickup_success; old_illegal_ = s.illegal_pickup_dropoff; s.pickup_success = false; // if( s.passenger == TaxiState.IN_TAXI ) { // for( int loc_i = 0; loc_i < s.locations.size(); ++loc_i ) { // final int[] loc = s.locations.get( loc_i ); // if( Arrays.equals( loc, s.taxi ) ) { // s.passenger = loc_i; // if( loc_i == s.destination ) { // s.goal = true; // } // done_ = true; // return; // } // } // } if (s.passenger == TaxiState.IN_TAXI) { for (int loc_i = 0; loc_i < s.locations.size(); ++loc_i) { final int[] loc = s.locations.get(loc_i); if (Arrays.equals(loc, s.taxi) && loc_i == s.destination) { s.passenger = loc_i; s.goal = true; done_ = true; return; } } } s.illegal_pickup_dropoff = true; done_ = true; }
From source file:ly.count.android.api.CountlyStoreTests.java
public void testConnections_prefHasSingleValue() { final String connStr = "blah"; store.addConnection(connStr);//from ww w.j a va2s. co m assertTrue(Arrays.equals(new String[] { connStr }, store.connections())); }
From source file:com.opengamma.maths.lowlevelapi.datatypes.primitive.PackedMatrixTest.java
@Test public void testBandedWithZeroRowLeftSideZerosAllowedConstructor() { double[] expectedData = { 1, 2, 3, 4, 5, 0, 0, 6, 7, 8, 0, 0, 0, 9, 10 }; PackedMatrix M = new PackedMatrix(_bandedwithzerorow, allowZerosOn.leftSide, 5, 5); assertTrue(Arrays.equals(M.getData(), expectedData)); }
From source file:edu.oregonstate.eecs.mcplan.domains.voyager.policies.FortifyPolicy.java
@Override public boolean equals(final Object obj) { if (obj == null || !(obj instanceof FortifyPolicy)) { return false; }//from w ww . j a v a 2 s . co m final FortifyPolicy that = (FortifyPolicy) obj; return player_ == that.player_ && Arrays.equals(planets_, that.planets_) && batch_ == that.batch_ && garrison_ == that.garrison_; }
From source file:edu.oregonstate.eecs.mcplan.domains.yahtzee2.KeepAction.java
@Override public boolean equals(final Object obj) { if (obj == null || !(obj instanceof KeepAction)) { return false; }//w w w . j a v a 2s . c o m final KeepAction that = (KeepAction) obj; return Arrays.equals(keepers, that.keepers); }
From source file:com.espertech.esper.collection.TestPermutationEnumeration.java
public static void testGetPermutation() { int[] factors = PermutationEnumeration.getFactors(4); int[] result = PermutationEnumeration.getPermutation(4, 21, factors); log.debug(".testGetPermutation result=" + Arrays.toString(result)); assertTrue(Arrays.equals(result, new int[] { 3, 1, 2, 0 })); }
From source file:com.opengamma.analytics.financial.provider.curve.SingleCurveBundle.java
@Override public boolean equals(final Object obj) { if (this == obj) { return true; }/*from ww w . j ava 2s . co m*/ if (obj == null) { return false; } if (!(obj instanceof SingleCurveBundle)) { return false; } final SingleCurveBundle<?> other = (SingleCurveBundle<?>) obj; if (_size != other._size) { return false; } if (!ObjectUtils.equals(_curveName, other._curveName)) { return false; } if (!Arrays.equals(_startingPoints, other._startingPoints)) { return false; } if (!Arrays.deepEquals(_derivatives, other._derivatives)) { return false; } if (!ObjectUtils.equals(_curveGenerator, other._curveGenerator)) { return false; } return true; }
From source file:io.viewserver.operators.transpose.TransposeOperator.java
@Override protected ITransposeConfig mergePendingConfig(ITransposeConfig pendingConfig, ITransposeConfig newConfig) { if (!ObjectUtils.equals(pendingConfig.getKeyColumns(), newConfig.getKeyColumns())) { throw new IllegalStateException("Cannot merge configs with conflicting key columns"); }/* w w w .jav a2s .c o m*/ if (!ObjectUtils.equals(pendingConfig.getPivotColumn(), newConfig.getPivotColumn())) { throw new IllegalStateException("Cannot merge configs with conflicting pivot columns"); } if ((pendingConfig.getPivotValues() != null || newConfig.getPivotValues() != null) && !Arrays.equals(pendingConfig.getPivotValues(), newConfig.getPivotValues())) { throw new IllegalStateException("Cannot merge configs with conflicting pivot values"); } return pendingConfig; }