List of usage examples for java.lang Error Error
public Error(Throwable cause)
From source file:edu.unc.lib.dl.ingest.AIPIngestPipelineTest.java
@Test public void testProcessAIP() { // testing for successful conversion of SIP w/simple content model File testFile = tempCopy(new File("src/test/resources/simple.zip")); DepositRecord record = new DepositRecord("test", "test", DepositMethod.Unspecified); METSPackageSIP sip = null;/*from w w w.j a v a 2s. co m*/ ArchivalInformationPackage aip = null; String containerPath = "/test/container/path"; PID containerPID = new PID("test:1"); try { sip = new METSPackageSIP(containerPID, testFile, true); } catch (IOException e) { throw new Error(e); } // SETUP MOCK TRIPLES! ArrayList<URI> ans = new ArrayList<URI>(); ans.add(ContentModelHelper.Model.CONTAINER.getURI()); when(this.tripleStoreQueryService.lookupContentModels(any(PID.class))).thenReturn(ans); when(this.tripleStoreQueryService.lookupRepositoryPath(eq(containerPID))).thenReturn(containerPath); when(this.tripleStoreQueryService.fetchByRepositoryPath(eq(containerPath))).thenReturn(containerPID); when(this.tripleStoreQueryService.verify(eq(containerPID))).thenReturn(containerPID); try { aip = this.getMetsPackageSIPProcessor().createAIP(sip, record); } catch (IngestException e) { throw new Error(e); } assertNotNull("The result ingest context is null.", aip); int count = aip.getPIDs().size(); assertTrue("There should be 14 PIDs in the resulting AIP, found " + count, count == 14); try { aip = this.getAipIngestPipeline().processAIP(aip); aip.prepareIngest(); } catch (IngestException e) { log.error("ingest exception during test", e); fail("get exception processing AIP" + e.getMessage()); } }
From source file:com.joyent.manta.config.TestConfigContext.java
/** * Some test cases need a direct reference to a KeyPair along with it's associated config. Manually calling * KeyPairFactory with a half-baked config can get cumbersome, so let's build a ConfigContext which has * everything ready and supplies the relevant KeyPair. * * @return the generated keypair and a config which uses a serialized version of that keypair *///from w ww.j av a 2s. c om public static ImmutablePair<KeyPair, BaseChainedConfigContext> generateKeyPairBackedConfig( final String passphrase) { final KeyPair keyPair; try { keyPair = KeyPairGenerator.getInstance("RSA").generateKeyPair(); } catch (final NoSuchAlgorithmException impossible) { throw new Error(impossible); // "RSA" is always provided } final Object keySerializer; if (passphrase != null) { try { keySerializer = new JcaMiscPEMGenerator(keyPair.getPrivate(), new JcePEMEncryptorBuilder("AES-128-CBC").build(passphrase.toCharArray())); } catch (IOException e) { throw new RuntimeException(e); } } else { keySerializer = keyPair.getPrivate(); } final String keyContent; try (final StringWriter content = new StringWriter(); final JcaPEMWriter writer = new JcaPEMWriter(content)) { writer.writeObject(keySerializer); writer.flush(); keyContent = content.toString(); } catch (IOException e) { throw new RuntimeException(e); } final BaseChainedConfigContext config = new ChainedConfigContext(DEFAULT_CONFIG) // we need to unset the key path in case one exists at ~/.ssh/id_rsa // see the static initializer in DefaultsConfigContext .setMantaKeyPath(null).setPrivateKeyContent(keyContent) .setMantaKeyId(KeyFingerprinter.md5Fingerprint(keyPair)); if (passphrase != null) { config.setPassword(passphrase); } return new ImmutablePair<>(keyPair, config); }
From source file:net.sourceforge.jabm.learning.StatelessQLearner.java
public Object protoClone() { try {// w w w .ja v a 2 s . c o m StatelessQLearner cloned = (StatelessQLearner) this.clone(); cloned.qLearner = (QLearner) this.qLearner.protoClone(); return cloned; } catch (CloneNotSupportedException e) { throw new Error(e); } }
From source file:com.jeffrodriguez.webtools.client.URLConnectionWebClientImpl.java
@Override public void setAuthorization(String username, String password) { String userPass = username + ":" + password; try {//from ww w. j av a2s. co m authorization = "Basic " + Base64.encodeBase64String(userPass.getBytes("ISO-8859-1")); } catch (UnsupportedEncodingException e) { throw new Error(e); } }
From source file:net.sourceforge.fenixedu.applicationTier.Servico.teacher.onlineTests.InsertDistributedTest.java
protected void run(String executionCourseId, String testId, String testInformation, String evaluationTitle, Calendar beginDate, Calendar beginHour, Calendar endDate, Calendar endHour, TestType testType, CorrectionAvailability correctionAvaiability, Boolean imsFeedback, List<InfoStudent> infoStudentList) throws FenixServiceException { ExecutionCourse executionCourse = FenixFramework.getDomainObject(executionCourseId); if (executionCourse == null) { throw new InvalidArgumentsServiceException(); }//from w w w .j a v a2s .c o m Test test = FenixFramework.getDomainObject(testId); if (test == null) { throw new InvalidArgumentsServiceException(); } try { final DistributedTestCreator distributedTestCreator = new DistributedTestCreator(executionCourse, test, testInformation, evaluationTitle, beginDate, beginHour, endDate, endHour, testType, correctionAvaiability, imsFeedback, Authenticate.getUser()); distributedTestCreator.start(); distributedTestCreator.join(); final String distributedTestId = distributedTestCreator.distributedTestId; if (distributedTestId == null) { throw new Error("Creator thread was unable to create a distributed test!"); } Distributor.runThread(infoStudentList, distributedTestId, test.getExternalId()); } catch (InterruptedException e) { throw new Error(e); } return; }
From source file:net.hamnaberg.json.Collection.java
public Optional<Error> getError() { return hasError() ? of(new Error((ObjectNode) delegate.get("error"))) : Optional.<Error>empty(); }
From source file:hudson.util.Secret.java
/** * Reverse operation of {@link #getEncryptedValue()}. Returns null * if the given cipher text was invalid. *//*from w w w .j a va2s .c o m*/ public static Secret decrypt(String data) { if (data == null) return null; try { byte[] in = Base64.decode(data.toCharArray()); Secret s = tryDecrypt(KEY.decrypt(), in); if (s != null) return s; // try our historical key for backward compatibility Cipher cipher = getCipher("AES"); cipher.init(Cipher.DECRYPT_MODE, getLegacyKey()); return tryDecrypt(cipher, in); } catch (GeneralSecurityException e) { return null; } catch (UnsupportedEncodingException e) { throw new Error(e); // impossible } catch (IOException e) { return null; } }
From source file:edu.unc.lib.dl.util.JRDFGraphUtil.java
public static List<String> getRelationshipLiteralObjects(Graph graph, PID pid, URI predicate) { List<String> result = new ArrayList<String>(); ClosableIterator<Triple> tripleIter = null; try {/*w w w . ja va 2 s. c o m*/ URIReference subject = graph.getElementFactory().createResource(new URI("info:fedora/" + pid.getPid())); URIReference pred = graph.getElementFactory().createResource(predicate); Triple findTop = graph.getTripleFactory().createTriple(subject, pred, ANY_OBJECT_NODE); tripleIter = graph.find(findTop); while (tripleIter.hasNext()) { Triple t = tripleIter.next(); if (t.getObject() instanceof Literal) { Literal n = (Literal) t.getObject(); result.add(n.getLexicalForm()); } if (t.getObject() instanceof URIReference) { URIReference n = (URIReference) t.getObject(); result.add(n.getURI().toString()); } } } catch (GraphException e) { log.error("programmer error: ", e); throw new Error(e); } catch (TripleFactoryException e) { log.error("programmer error: ", e); throw new Error(e); } catch (GraphElementFactoryException e) { log.error("programmer error: ", e); throw new Error(e); } catch (URISyntaxException e) { log.error("programmer error: ", e); throw new Error(e); } finally { if (tripleIter != null) tripleIter.close(); } return result; }