Java Code Examples for org.apache.cxf.helpers.FileUtils

The following examples show how to use org.apache.cxf.helpers.FileUtils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: cxf   Source File: AegisJaxWsTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testBigList() throws Exception {
    int size = 1000;
    List<String> l = new ArrayList<>(size);
    for (int x = 0; x < size; x++) {
        l.add("Need to create a pretty big soap message to make sure we go over "
              + "some of the default buffer sizes and such so we can see what really"
              + "happens when we do that - " + x);
    }

    setupForTest(false);
    List<String> item = client.echoBigList(l);
    Assert.assertEquals(size, item.size());

    //CXF-2768
    File f = FileUtils.getDefaultTempDir();
    Assert.assertEquals(0, f.listFiles().length);
}
 
Example 2
Source Project: cxf   Source File: TrustedAuthorityValidatorTest.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void setUpCertificateRepo() throws CertificateException {
    File storageDir = new File("target/teststore_trusted_authority_validator");
    FileUtils.removeDir(storageDir);
    storageDir.mkdirs();
    certificateRepo = new FileCertificateRepo("target/teststore_trusted_authority_validator");

    UseKeyWithType rootKey = new UseKeyWithType();
    rootKey.setApplication(Applications.PKIX.getUri());
    String subjectDN = certificateRoot.getSubjectX500Principal().getName();
    rootKey.setIdentifier(subjectDN);
    certificateRepo.saveTrustedCACertificate(certificateRoot, rootKey);

    UseKeyWithType aliceKey = new UseKeyWithType();
    aliceKey.setApplication(Applications.PKIX.getUri());
    subjectDN = certificateAlice.getSubjectX500Principal().getName();
    aliceKey.setIdentifier(subjectDN);
    certificateRepo.saveCACertificate(certificateAlice, aliceKey);
}
 
Example 3
Source Project: cxf   Source File: WADLToJavaTest.java    License: Apache License 2.0 6 votes vote down vote up
private void verifyFiles(String ext, boolean subresourceExpected, boolean interfacesAndImpl,
                         String schemaPackage, String resourcePackage) {
    List<File> files = FileUtils.getFilesRecurseUsingSuffix(output, "." + ext);
    int size = interfacesAndImpl ? 11 : 10;
    if (!subresourceExpected) {
        size--;
    }
    assertEquals(size, files.size());
    doVerifyTypes(files, schemaPackage, ext);
    if (subresourceExpected) {
        assertTrue(checkContains(files, resourcePackage + ".FormInterface." + ext));
    }
    assertTrue(checkContains(files, resourcePackage + ".BookStore." + ext));
    if (interfacesAndImpl) {
        if (subresourceExpected) {
            assertTrue(checkContains(files, resourcePackage + ".FormInterfaceImpl." + ext));
        }
        assertTrue(checkContains(files, resourcePackage + ".BookStoreImpl." + ext));
    }
}
 
Example 4
Source Project: cxf   Source File: JAXRSContainerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testNoTargetNamespace() throws Exception {
    JAXRSContainer container = new JAXRSContainer(null);

    ToolContext context = new ToolContext();
    context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
    context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/resourceSchemaNoTargetNamespace.xml"));
    context.put(WadlToolConstants.CFG_SCHEMA_PACKAGENAME, "=custom");
    context.put(WadlToolConstants.CFG_COMPILE, "true");

    container.setContext(context);
    container.execute();

    assertNotNull(output.list());
    List<File> files = FileUtils.getFilesRecurseUsingSuffix(output, ".class");
    assertEquals(3, files.size());
    assertTrue(checkContains(files, "application" + ".Resource.class"));
    assertTrue(checkContains(files, "custom" + ".TestCompositeObject.class"));
    assertTrue(checkContains(files, "custom" + ".ObjectFactory.class"));
}
 
Example 5
Source Project: cxf   Source File: JAXRSContainerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testInheritParameters() throws Exception {
    JAXRSContainer container = new JAXRSContainer(null);

    ToolContext context = new ToolContext();
    context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
    context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/test.xml"));
    context.put(WadlToolConstants.CFG_COMPILE, "true");
    context.put(WadlToolConstants.CFG_SCHEMA_TYPE_MAP,
                "{http://www.w3.org/2001/XMLSchema}anyType="
                + "java.io.InputStream");
    context.put(WadlToolConstants.CFG_INHERIT_PARAMS, "last");
    context.put(WadlToolConstants.CFG_CREATE_JAVA_DOCS, "true");
    container.setContext(context);
    container.execute();

    assertNotNull(output.list());

    List<File> files = FileUtils.getFilesRecurseUsingSuffix(output, ".class");
    assertEquals(1, files.size());
}
 
Example 6
Source Project: cxf   Source File: JAXRSContainerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testCodeGenInterfacesWithJaxbClassNameSuffix() throws Exception {
    JAXRSContainer container = new JAXRSContainer(null);

    ToolContext context = new ToolContext();
    context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
    context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/bookstore.xml"));
    context.put(WadlToolConstants.CFG_JAXB_CLASS_NAME_SUFFIX, "DTO");
    context.put(WadlToolConstants.CFG_BINDING, getLocation("/wadl/jaxbSchemaBindings.xml"));
    context.put(WadlToolConstants.CFG_COMPILE, "true");

    container.setContext(context);
    container.execute();

    assertNotNull(output.list());
    List<File> schemafiles = FileUtils.getFilesRecurseUsingSuffix(output, ".java");
    assertEquals(10, schemafiles.size());
    doVerifyTypesWithSuffix(schemafiles, "superbooks", "java");

    List<File> classfiles = FileUtils.getFilesRecurseUsingSuffix(output, ".class");
    assertEquals(10, classfiles.size());
    doVerifyTypesWithSuffix(classfiles, "superbooks", "class");
}
 
Example 7
Source Project: cxf   Source File: JAXRSContainerTest.java    License: Apache License 2.0 6 votes vote down vote up
private void doTestInlinedSchemasWithImport(String loc) throws Exception {
    JAXRSContainer container = new JAXRSContainer(null);

    ToolContext context = new ToolContext();
    context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
    context.put(WadlToolConstants.CFG_WADLURL, getLocation(loc));
    context.put(WadlToolConstants.CFG_COMPILE, "true");

    container.setContext(context);
    container.execute();

    assertNotNull(output.list());

    List<File> files = FileUtils.getFilesRecurseUsingSuffix(output, ".class");
    assertEquals(7, files.size());
    assertTrue(checkContains(files, "org.apache.cxf.jaxrs.model.wadl" + ".BookStore.class"));
    assertTrue(checkContains(files, "superbooks" + ".Book.class"));
    assertTrue(checkContains(files, "superbooks" + ".ObjectFactory.class"));
    assertTrue(checkContains(files, "superbooks" + ".package-info.class"));
    assertTrue(checkContains(files, "superchapters" + ".Chapter.class"));
    assertTrue(checkContains(files, "superchapters" + ".ObjectFactory.class"));
    assertTrue(checkContains(files, "superchapters" + ".package-info.class"));
}
 
Example 8
Source Project: cxf   Source File: JAXRSContainerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testResourceWithEPR() throws Exception {
    JAXRSContainer container = new JAXRSContainer(null);

    ToolContext context = new ToolContext();
    context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
    context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/resourceWithEPR.xml"));
    context.put(WadlToolConstants.CFG_SCHEMA_TYPE_MAP,
                "{http://www.w3.org/2001/XMLSchema}date=javax.xml.datatype.XMLGregorianCalendar");
    context.put(WadlToolConstants.CFG_COMPILE, "true");

    container.setContext(context);
    container.execute();

    assertNotNull(output.list());

    List<File> files = FileUtils.getFilesRecurseUsingSuffix(output, ".class");
    assertEquals(4, files.size());
    assertTrue(checkContains(files, "application" + ".BookstoreResource.class"));
    assertTrue(checkContains(files, "superbooks" + ".Book.class"));
    assertTrue(checkContains(files, "superbooks" + ".ObjectFactory.class"));
    assertTrue(checkContains(files, "superbooks" + ".package-info.class"));
}
 
Example 9
Source Project: cxf   Source File: JAXRSContainerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testResourceWithEPRNoSchemaGen() throws Exception {
    JAXRSContainer container = new JAXRSContainer(null);

    ToolContext context = new ToolContext();
    context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
    context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/resourceWithEPR.xml"));
    context.put(WadlToolConstants.CFG_SCHEMA_TYPE_MAP,
        "{http://www.w3.org/2005/08/addressing}EndpointReferenceType="
        + "javax.xml.ws.wsaddressing.W3CEndpointReference");
    context.put(WadlToolConstants.CFG_NO_ADDRESS_BINDING, "true");
    context.put(WadlToolConstants.CFG_NO_TYPES, "true");

    context.put(WadlToolConstants.CFG_COMPILE, "true");

    container.setContext(context);
    container.execute();

    assertNotNull(output.list());

    List<File> files = FileUtils.getFilesRecurseUsingSuffix(output, ".class");
    assertEquals(1, files.size());
    assertTrue(checkContains(files, "application" + ".BookstoreResource.class"));
}
 
Example 10
Source Project: cxf   Source File: JAXRSContainerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testCodeGenNoIds() throws Exception {
    JAXRSContainer container = new JAXRSContainer(null);

    ToolContext context = new ToolContext();
    context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
    context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/singleResource.xml"));
    context.put(WadlToolConstants.CFG_RESOURCENAME, "CustomResource");
    context.put(WadlToolConstants.CFG_GENERATE_ENUMS, "true");
    context.put(WadlToolConstants.CFG_COMPILE, "true");

    container.setContext(context);
    container.execute();

    assertNotNull(output.list());

    List<File> javaFiles = FileUtils.getFilesRecurseUsingSuffix(output, ".java");
    assertEquals(2, javaFiles.size());
    assertTrue(checkContains(javaFiles, "application.CustomResource.java"));
    assertTrue(checkContains(javaFiles, "application.Theid.java"));

    List<File> classFiles = FileUtils.getFilesRecurseUsingSuffix(output, ".class");
    assertEquals(2, classFiles.size());
    assertTrue(checkContains(classFiles, "application.CustomResource.class"));
    assertTrue(checkContains(classFiles, "application.Theid.class"));
}
 
Example 11
Source Project: cxf   Source File: JAXRSContainerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testCodeGenNoIds2() throws Exception {
    JAXRSContainer container = new JAXRSContainer(null);

    ToolContext context = new ToolContext();
    context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
    context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/multipleResources.xml"));
    context.put(WadlToolConstants.CFG_COMPILE, "true");

    container.setContext(context);
    container.execute();

    assertNotNull(output.list());

    List<File> javaFiles = FileUtils.getFilesRecurseUsingSuffix(output, ".java");
    assertEquals(2, javaFiles.size());
    assertTrue(checkContains(javaFiles, "application.BookstoreResource.java"));
    assertTrue(checkContains(javaFiles, "application.BooksResource.java"));
    List<File> classFiles = FileUtils.getFilesRecurseUsingSuffix(output, ".class");
    assertEquals(2, classFiles.size());
    assertTrue(checkContains(classFiles, "application.BookstoreResource.class"));
    assertTrue(checkContains(classFiles, "application.BooksResource.class"));
}
 
Example 12
Source Project: cxf   Source File: JAXRSContainerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testCodeGenNoIds3() throws Exception {
    JAXRSContainer container = new JAXRSContainer(null);

    ToolContext context = new ToolContext();
    context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
    context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/resourcesNoId.xml"));
    context.put(WadlToolConstants.CFG_COMPILE, "true");
    context.put(WadlToolConstants.CFG_INHERIT_PARAMS, "true");

    container.setContext(context);
    container.execute();

    assertNotNull(output.list());

    List<File> javaFiles = FileUtils.getFilesRecurseUsingSuffix(output, ".java");
    assertEquals(1, javaFiles.size());
    assertTrue(checkContains(javaFiles, "application.TestRsResource.java"));
    List<File> classFiles = FileUtils.getFilesRecurseUsingSuffix(output, ".class");
    assertEquals(1, classFiles.size());
    assertTrue(checkContains(classFiles, "application.TestRsResource.class"));
}
 
Example 13
Source Project: cxf   Source File: JAXRSContainerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testCodeGenWithResourceSet() throws Exception {
    JAXRSContainer container = new JAXRSContainer(null);

    ToolContext context = new ToolContext();
    context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
    context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/singleResourceWithRefs.xml"));
    context.put(WadlToolConstants.CFG_RESOURCENAME, "CustomResource");
    context.put(WadlToolConstants.CFG_COMPILE, "true");

    container.setContext(context);
    container.execute();

    assertNotNull(output.list());

    List<File> javaFiles = FileUtils.getFilesRecurseUsingSuffix(output, ".java");
    assertEquals(1, javaFiles.size());
    assertTrue(checkContains(javaFiles, "application.CustomResource.java"));

    List<File> classFiles = FileUtils.getFilesRecurseUsingSuffix(output, ".class");
    assertEquals(1, classFiles.size());
    assertTrue(checkContains(classFiles, "application.CustomResource.class"));
}
 
Example 14
Source Project: cxf   Source File: JAXRSContainerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testCodeGenHyphen() throws Exception {
    JAXRSContainer container = new JAXRSContainer(null);

    ToolContext context = new ToolContext();
    context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
    context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/bookstoreHyphen.xml"));
    context.put(WadlToolConstants.CFG_IMPL, "true");
    context.put(WadlToolConstants.CFG_COMPILE, "true");

    container.setContext(context);
    container.execute();

    assertNotNull(output.list());

    List<File> files = FileUtils.getFilesRecurseUsingSuffix(output, ".class");
    assertEquals(3, files.size());
    assertTrue(checkContains(files, "application" + ".BookstoreResource.class"));
    assertTrue(checkContains(files, "generated" + ".TestCompositeObject.class"));
    assertTrue(checkContains(files, "generated" + ".ObjectFactory.class"));
}
 
Example 15
Source Project: cxf   Source File: JAXRSContainerTest.java    License: Apache License 2.0 6 votes vote down vote up
private void verifyFiles(String ext, boolean subresourceExpected, boolean interfacesAndImpl,
                         String schemaPackage, String resourcePackage, int expectedCount,
                         boolean enumTypeExpected) {
    List<File> files = FileUtils.getFilesRecurseUsingSuffix(output, "." + ext);
    int offset = enumTypeExpected ? 1 : 2;
    int size = interfacesAndImpl ? expectedCount : expectedCount - offset;
    if (!subresourceExpected) {
        size--;
    }
    assertEquals(size, files.size());
    doVerifyTypes(files, schemaPackage, ext);
    if (subresourceExpected) {
        assertTrue(checkContains(files, resourcePackage + ".FormInterface." + ext));
        assertTrue(checkContains(files, resourcePackage + ".FormInterface2." + ext));
    }
    assertTrue(checkContains(files, resourcePackage + ".BookStore." + ext));
    if (interfacesAndImpl) {
        if (subresourceExpected) {
            assertTrue(checkContains(files, resourcePackage + ".FormInterfaceImpl." + ext));
            assertTrue(checkContains(files, resourcePackage + ".FormInterface2Impl." + ext));
        }
        assertTrue(checkContains(files, resourcePackage + ".BookStoreImpl." + ext));
    }
}
 
Example 16
Source Project: cxf   Source File: AbstractCodegenMojo.java    License: Apache License 2.0 6 votes vote down vote up
private String[] createForkOnceArgs(List<List<String>> wargs) throws MojoExecutionException {
    try {
        File f = FileUtils.createTempFile("cxf-w2j", "args");
        PrintWriter fw = new PrintWriter(new FileWriter(f));
        for (List<String> args : wargs) {
            fw.println(Integer.toString(args.size()));
            for (String s : args) {
                fw.println(s);
            }
        }
        fw.println("-1");
        fw.close();
        return new String[] {
            f.getAbsolutePath()
        };
    } catch (IOException ex) {
        throw new MojoExecutionException("Could not create argument file", ex);
    }
}
 
Example 17
Source Project: cxf   Source File: WsdlOptionLoader.java    License: Apache License 2.0 6 votes vote down vote up
private static String[] readOptionsFromFile(File dir, String wsdlName) throws MojoExecutionException {
    String[] noOptions = new String[] {};
    List<File> files = FileUtils.getFiles(dir, wsdlName + WSDL_OPTIONS);
    if (files.isEmpty()) {
        return noOptions;
    }
    File optionsFile = files.iterator().next();
    if (optionsFile == null || !optionsFile.exists()) {
        return noOptions;
    }
    try {
        List<String> lines = FileUtils.readLines(optionsFile);
        if (lines.isEmpty()) {
            return noOptions;
        }
        return lines.iterator().next().split(" ");
    } catch (Exception e) {
        throw new MojoExecutionException("Error reading options from file "
                                         + optionsFile.getAbsolutePath(), e);
    }
}
 
Example 18
Source Project: cxf   Source File: AbstractCodeGeneratorMojo.java    License: Apache License 2.0 6 votes vote down vote up
private String[] createForkOnceArgs(List<List<String>> wargs) throws MojoExecutionException {
    try {
        File f = FileUtils.createTempFile("cxf-w2j", "args");
        PrintWriter fw = new PrintWriter(new FileWriter(f));
        for (List<String> args : wargs) {
            fw.println(Integer.toString(args.size()));
            for (String s : args) {
                fw.println(s);
            }
        }
        fw.println("-1");
        fw.close();
        return new String[] {f.getAbsolutePath()};
    } catch (IOException ex) {
        throw new MojoExecutionException("Could not create argument file", ex);
    }
}
 
Example 19
Source Project: cxf   Source File: OptionLoader.java    License: Apache License 2.0 6 votes vote down vote up
private static List<File> getWadlFiles(File dir, String[] includes, String[] excludes)
    throws MojoExecutionException {

    List<String> exList = new ArrayList<>();
    if (excludes != null) {
        Collections.addAll(exList, excludes);
    }
    Collections.addAll(exList, org.codehaus.plexus.util.FileUtils.getDefaultExcludes());

    String inc = joinWithComma(includes);
    String ex = joinWithComma(exList.toArray(new String[0]));

    try {
        List<?> newfiles = org.codehaus.plexus.util.FileUtils.getFiles(dir, inc, ex);
        return CastUtils.cast(newfiles);
    } catch (IOException exc) {
        throw new MojoExecutionException(exc.getMessage(), exc);
    }
}
 
Example 20
Source Project: cxf   Source File: OptionLoader.java    License: Apache License 2.0 6 votes vote down vote up
private static String[] readOptionsFromFile(File dir, String wsdlName) throws MojoExecutionException {
    String[] noOptions = new String[] {};
    List<File> files = FileUtils.getFiles(dir, wsdlName + WADL_OPTIONS);
    if (files.isEmpty()) {
        return noOptions;
    }
    File optionsFile = files.iterator().next();
    if (optionsFile == null || !optionsFile.exists()) {
        return noOptions;
    }
    try {
        List<String> lines = FileUtils.readLines(optionsFile);
        if (lines.isEmpty()) {
            return noOptions;
        }
        return lines.iterator().next().split(" ");
    } catch (Exception e) {
        throw new MojoExecutionException("Error reading options from file "
                                         + optionsFile.getAbsolutePath(), e);
    }
}
 
Example 21
Source Project: cxf   Source File: SSLUtils.java    License: Apache License 2.0 6 votes vote down vote up
public static TrustManager[] getDefaultTrustStoreManagers(Logger log) {
    String location = getTruststore(null, log);
    String trustStorePassword = getTruststorePassword(null, log);
    String trustStoreType = getTrustStoreType(null, log, DEFAULT_TRUST_STORE_TYPE);

    if (location != null) {
        File file = new File(location);
        try (InputStream is = FileUtils.exists(file) ? Files.newInputStream(file.toPath())
                : getResourceAsStream(location)) {
            if (is != null) {
                TrustManagerFactory tmf =
                    TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
                KeyStore ks = KeyStore.getInstance(trustStoreType);

                ks.load(is, (trustStorePassword != null) ? trustStorePassword.toCharArray() : null);
                tmf.init(ks);
                return tmf.getTrustManagers();
            } else {
                log.log(Level.FINER, "No default trust keystore {0}", location);
            }
        } catch (Exception e) {
            log.log(Level.WARNING, "Default trust managers cannot be initialized: " + e.getMessage(), e);
        }
    }
    return null;
}
 
Example 22
Source Project: openwebbeans-meecrowave   Source File: Classes.java    License: Apache License 2.0 5 votes vote down vote up
private static void doDump(final File base, final String name, final byte[] content) {
    final String target = "org/superbiz/app/" + name + ".class";
    final File targetFile = new File(base, target);
    FileUtils.mkDir(targetFile.getParentFile());
    try (final InputStream from = new ByteArrayInputStream(content);
         final OutputStream to = new FileOutputStream(targetFile)) {
        IO.copy(from, to);
    } catch (final IOException e) {
        fail();
    }
}
 
Example 23
Source Project: cxf   Source File: AbstractTomcatServer.java    License: Apache License 2.0 5 votes vote down vote up
public void tearDown() throws Exception {
    super.tearDown();

    if (server != null) {
        server.stop();
        server.destroy();
        server = null;
        FileUtils.removeDir(base.toFile());
    }
}
 
Example 24
Source Project: cxf   Source File: HWSAXSourcePayloadProvider.java    License: Apache License 2.0 5 votes vote down vote up
private File getSOAPBodyFile(Document doc) throws Exception {
    File file = FileUtils.createTempFile("cxf-systest", "xml");
    try (FileOutputStream out = new FileOutputStream(file)) {
        XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(out);
        StaxUtils.writeDocument(doc, writer, true);
        writer.close();
        return file;
    }
}
 
Example 25
Source Project: cxf   Source File: PolicyTestHelper.java    License: Apache License 2.0 5 votes vote down vote up
public static void updatePolicyRef(String file, String oldData,
                                   String newData) throws IOException {
    File f = FileUtils.getDefaultTempDir();
    InputStream in = PolicyTestHelper.class.getResourceAsStream(file);
    String s = IOUtils.readStringFromStream(in);
    s = s.replaceAll(oldData, newData);
    File newFile = new File(f, file);
    FileWriter fw = new FileWriter(newFile);
    fw.write(s);
    fw.close();
}
 
Example 26
Source Project: cxf   Source File: AbstractTomcatServer.java    License: Apache License 2.0 5 votes vote down vote up
public void tearDown() throws Exception {
    super.tearDown();

    if (server != null) {
        server.stop();
        server.destroy();
        server = null;
        FileUtils.removeDir(base.toFile());
    }
}
 
Example 27
Source Project: cxf   Source File: JAXRSMultipartTest.java    License: Apache License 2.0 5 votes vote down vote up
int countTempFiles() {
    File file = FileUtils.getDefaultTempDir();
    File[] files = file.listFiles();
    if (files == null) {
        return 0;
    }
    int count = 0;
    for (File f : files) {
        if (f.isFile()) {
            count++;
        }
    }
    return count;
}
 
Example 28
Source Project: cxf   Source File: TrustedAuthorityValidatorCRLTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setUpCertificateRepo() throws CertificateException {
    File storageDir = new File("target/teststore_trusted_authority_validator");
    FileUtils.removeDir(storageDir);
    storageDir.mkdirs();
    certificateRepo = new FileCertificateRepo("target/teststore_trusted_authority_validator");

    UseKeyWithType rootKey = new UseKeyWithType();
    rootKey.setApplication(Applications.PKIX.getUri());
    String subjectDN = certificateRoot.getSubjectX500Principal().getName();
    rootKey.setIdentifier(subjectDN);
    certificateRepo.saveTrustedCACertificate(certificateRoot, rootKey);

    UseKeyWithType aliceKey = new UseKeyWithType();
    aliceKey.setApplication(Applications.PKIX.getUri());
    subjectDN = certificateWss40Rev.getSubjectX500Principal().getName();
    aliceKey.setIdentifier(subjectDN);
    certificateRepo.saveCACertificate(certificateWss40Rev, aliceKey);

    UseKeyWithType bobKey = new UseKeyWithType();
    bobKey.setApplication(Applications.PKIX.getUri());
    subjectDN = certificateWss40.getSubjectX500Principal().getName();
    bobKey.setIdentifier(subjectDN);
    certificateRepo.saveCACertificate(certificateWss40, bobKey);

    UseKeyWithType crlKey = new UseKeyWithType();
    crlKey.setApplication(Applications.PKIX.getUri());
    crlKey.setIdentifier(crl.getIssuerX500Principal().getName());
    certificateRepo.saveCRL(crl, crlKey);
}
 
Example 29
Source Project: cxf   Source File: IDLToWSDLTest.java    License: Apache License 2.0 5 votes vote down vote up
@After
public void tearDown() throws Exception {
    // super.tearDown();
    try {
        FileUtils.removeDir(output);
    } catch (Exception e) {
        //ignore
    }
    output = null;
}
 
Example 30
Source Project: cxf   Source File: JavaToWSTest.java    License: Apache License 2.0 5 votes vote down vote up
@After
public void tearDown() {
    super.tearDown();
    System.setProperty("java.class.path", cp);
    FileUtils.removeDir(output);
    output = null;
}