List of usage examples for java.util Arrays equals
public static boolean equals(Object[] a, Object[] a2)
From source file:gov.nih.nci.caarray.services.file.FileRetrievalServiceBeanTest.java
/** * Test method for/* w w w .j av a 2 s .c om*/ * {@link gov.nih.nci.caarray.services.file.FileRetrievalServiceBean#readFile(gov.nih.nci.caarray.domain.file.CaArrayFile)} * . */ @Test public void testReadFile() throws IOException { final FileAccessServiceStub fasStub = new FileAccessServiceStub(); Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(FileTypeRegistry.class).toInstance(fasStub.getTypeRegistry()); requestStaticInjection(CaArrayFile.class); } }); final CaArrayFile file = fasStub.add(MageTabDataFiles.GEDP_IDF); final SearchDao searchDao = mock(SearchDao.class); when(searchDao.query(any(CaArrayFile.class))).thenReturn(Lists.newArrayList(file)); final FileRetrievalServiceBean bean = new FileRetrievalServiceBean(); final DataStorageFacade dataStorageFacade = fasStub.createStorageFacade(); bean.setSearchDao(searchDao); bean.setDataStorageFacade(dataStorageFacade); final CaArrayFile caArrayFile = new CaArrayFile(); final byte[] bytes = bean.readFile(caArrayFile); final byte[] expectedBytes = FileUtils.readFileToByteArray(MageTabDataFiles.GEDP_IDF); assertTrue("retrieved file contents didn't match", Arrays.equals(expectedBytes, bytes)); }
From source file:com.bgh.myopeninvoice.db.model.AttachmentEntity.java
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; AttachmentEntity that = (AttachmentEntity) o; if (attachmentId != null ? !attachmentId.equals(that.attachmentId) : that.attachmentId != null) return false; if (invoiceId != null ? !invoiceId.equals(that.invoiceId) : that.invoiceId != null) return false; if (!Arrays.equals(content, that.content)) return false; if (filename != null ? !filename.equals(that.filename) : that.filename != null) return false; return true;/*from w ww . java2 s .c o m*/ }
From source file:org.sakuli.aop.SahiCommandExecutionAspect.java
/** * Due to the fact, the parsing of the sahi method {@link net.sf.sahi.util.Utils#getCommandTokens(String)} won't * work correctly, this {@link Around} advice use the Apache libary {@link CommandLine#parse(String)} to modify it. * See http://community.sahipro.com/forums/discussion/8552/sahi-os-5-0-and-chrome-user-data-dir-containing-spaces-not-working. * * @param joinPoint the {@link ProceedingJoinPoint} of the invoked method * @param commandString the original argument as{@link String} * @return the result of {@link CommandLine#parse(String)} *//*from w w w . j a va 2 s . c om*/ @Around("execution(* net.sf.sahi.util.Utils.getCommandTokens(..)) && args(commandString)") public String[] getCommandTokens(ProceedingJoinPoint joinPoint, String commandString) { Logger LOGGER = getLogger(joinPoint); CommandLine parsed = CommandLine.parse(commandString); String[] tokens = new String[] { parsed.getExecutable() }; tokens = ArrayUtils.addAll(tokens, parsed.getArguments()); try { Object result = joinPoint.proceed(); if (result instanceof String[] && !Arrays.equals(tokens, (String[]) result)) { if (commandString.startsWith("sh -c \'")) { //exclude this kind of arguments, because the won't parsed correctly //LOGGER.info("SAHI-RESULT {}", printArray((Object[]) result)); //LOGGER.info("SAKULI-RESULT {}", printArray(tokens)); return (String[]) result; } LOGGER.info("MODIFIED SAHI COMMAND TOKENS: {} => {}", printArray((String[]) result), printArray(tokens)); } } catch (Throwable e) { LOGGER.error("Exception during execution of JoinPoint net.sf.sahi.util.Utils.getCommandTokens", e); } return tokens; }
From source file:com.adeptj.runtime.server.CredentialMatcher.java
private static boolean fromOSGiManagerConfig(char[] password) { try {/*from w w w.ja va 2s . c om*/ return Arrays.equals(makeHash(password), OSGiConsolePasswordVault.INSTANCE.getPassword()); } catch (Exception ex) { // NOSONAR LOGGER.error(ex.getMessage(), ex); } return false; }
From source file:net.darkmist.clf.UtilTest.java
public void testInterleavedAB() throws Exception { Integer[] a = new Integer[] { 1, 3, 5, 7, 9 }; Integer[] b = new Integer[] { 2, 4, 6, 8 }; Integer[] expected = new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; Integer[] actual = new Integer[a.length + b.length]; Util.merge(a, b, actual, comparator); assertTrue(Arrays.equals(actual, expected)); }
From source file:com.cloudant.sync.datastore.BasicDBBodyTest.java
@Test public void constructor_emptyMap_objectWithEmptyJsonShouldBeCreated() { DocumentBody body = new BasicDocumentBody(new HashMap()); Assert.assertTrue(Arrays.equals("{}".getBytes(), body.asBytes())); Assert.assertNotNull(body.asMap());/*from w w w. ja v a 2s .c o m*/ Assert.assertTrue(body.asMap().size() == 0); }
From source file:ly.count.android.api.CountlyStoreTests.java
public void testConnections_prefIsNull() { // the clear() call in setUp ensures the pref is not present assertTrue(Arrays.equals(new String[0], store.connections())); }
From source file:org.jfree.data.function.PolynomialFunction2DTest.java
/** * Some checks for the getCoefficients() method. */// ww w .java2 s . com @Test public void testGetCoefficients() { PolynomialFunction2D f = new PolynomialFunction2D(new double[] { 1.0, 2.0 }); double[] c = f.getCoefficients(); assertTrue(Arrays.equals(new double[] { 1.0, 2.0 }, c)); // make sure that modifying the returned array doesn't change the // function c[0] = 99.9; assertTrue(Arrays.equals(new double[] { 1.0, 2.0 }, f.getCoefficients())); }
From source file:com.google.u2f.server.data.SecurityKeyData.java
@Override public boolean equals(Object obj) { if (!(obj instanceof SecurityKeyData)) { return false; }// w ww .j av a 2s. c o m SecurityKeyData that = (SecurityKeyData) obj; return Arrays.equals(this.keyHandle, that.keyHandle) && (this.enrollmentTime == that.enrollmentTime) && containSameTransports(this.transports, that.transports) && Arrays.equals(this.publicKey, that.publicKey) && Objects.equals(this.attestationCert, that.attestationCert) && Objects.equals(counter, counter); }
From source file:com.joyent.manta.client.crypto.SecretKeyUtilsTest.java
public void canLoadKeyFromURIPath() throws IOException { File file = File.createTempFile("ciphertext-", ".data"); FileUtils.forceDeleteOnExit(file);//w w w. j a v a 2s.co m FileUtils.writeByteArrayToFile(file, keyBytes); URI uri = file.toURI(); SecretKey expected = SecretKeyUtils.loadKey(keyBytes, AesGcmCipherDetails.INSTANCE_128_BIT); SecretKey actual = SecretKeyUtils.loadKeyFromPath(Paths.get(uri), AesGcmCipherDetails.INSTANCE_128_BIT); Assert.assertEquals(actual.getAlgorithm(), expected.getAlgorithm()); Assert.assertTrue(Arrays.equals(expected.getEncoded(), actual.getEncoded()), "Secret key loaded from URI doesn't match"); }