Example usage for org.springframework.util SerializationUtils deserialize

List of usage examples for org.springframework.util SerializationUtils deserialize

Introduction

In this page you can find the example usage for org.springframework.util SerializationUtils deserialize.

Prototype

@Nullable
public static Object deserialize(@Nullable byte[] bytes) 

Source Link

Document

Deserialize the byte array into an object.

Usage

From source file:fr.mby.saml2.sp.opensaml.core.OpenSaml20IdpConnectorTest.java

@Test
public void testBuildQuerySloResponse() throws Exception {
    final QuerySloResponse query = this.idpConnector.buildQuerySloResponse(this.sloRequestId);

    Assert.assertNotNull("Query cannot be null !", query);
    Assert.assertNotNull("QuerySloResponse's Id !", query.getId());
    Assert.assertEquals("QuerySloResponse's InResponseTo Id !", this.sloRequestId, query.getInResponseToId());

    // Test Serialization
    final byte[] serialized = SerializationUtils.serialize(query);
    final QuerySloResponse deserializedQuery = (QuerySloResponse) SerializationUtils.deserialize(serialized);

    Assert.assertEquals("Serialization / Deserialization problem !", query.getId(), deserializedQuery.getId());
    Assert.assertEquals("Serialization / Deserialization problem !", query.getInResponseToId(),
            deserializedQuery.getInResponseToId());
}

From source file:fr.mby.saml2.sp.opensaml.core.OpenSaml20IdpConnectorTest.java

@Test
public void testBuildQuerySloRequest() throws Exception {
    final QuerySloRequest query = this.idpConnector.buildQuerySloRequest();

    Assert.assertNotNull("Query cannot be null !", query);
    Assert.assertNotNull("QuerySloResponse's Id !", query.getId());
    Assert.assertNotNull("QueryAuthnRequest's IdPConnectorBuilder cannot be null !",
            query.getIdpConnectorBuilder());

    // Test Serialization
    final byte[] serialized = SerializationUtils.serialize(query);
    final QuerySloRequest deserializedQuery = (QuerySloRequest) SerializationUtils.deserialize(serialized);

    Assert.assertEquals("Serialization / Deserialization problem !", query.getId(), deserializedQuery.getId());
    Assert.assertNotNull("Serialization / Deserialization problem !",
            deserializedQuery.getIdpConnectorBuilder());
    Assert.assertEquals("Serialization / Deserialization problem !", query.getIdpConnectorBuilder(),
            deserializedQuery.getIdpConnectorBuilder());
}

From source file:com.baidu.rigel.biplatform.ma.ds.service.impl.DataSourceServiceImpl.java

/**
 * //from   w w w .ja  v  a 2  s.  c  om
 * ???
 * 
 * @param productLine
 * @param listFile
 * @return
 * @throws FileManageOperationException
 * @throws UnsupportedEncodingException
 */
private DataSourceDefine buildResult(String file) throws FileServiceException {

    byte[] content = (byte[]) fileService.read(genDsFilePath(file));
    return (DataSourceDefine) SerializationUtils.deserialize(content);
}

From source file:org.terasoluna.gfw.common.message.ResultMessagesTest.java

@Test
public void testSerialization() {
    try {/*from w  w w  . j  ava2 s  .  c  o  m*/
        byte[] serialized = SerializationUtils.serialize(new ResultMessages((ResultMessageType) ERROR));
        SerializationUtils.deserialize(serialized);
    } catch (SerializationFailedException e) {
        fail();
    }
}

From source file:org.terasoluna.gfw.web.pagination.PaginationTagTest.java

@Test
public void testSerialization() {
    try {/*from  w ww  . j ava2s.  co  m*/
        byte[] serialized = SerializationUtils.serialize(new PaginationTag());
        SerializationUtils.deserialize(serialized);
    } catch (SerializationFailedException e) {
        fail();
    }
}

From source file:net.sourceforge.seqware.pipeline.plugins.PluginRunnerET.java

@BeforeClass
public static void createAndInstallArchetypes() throws IOException {
    clearStaticVariables();//w ww. j a  va 2  s  .c  o  m

    File bundleFile = new File(System.getProperty("java.io.tmpdir"), "PluginRunnerIT_bundleLocations.bin");
    File installedWorkflowsFile = new File(System.getProperty("java.io.tmpdir"),
            "PluginRunnerIT_installedWorkflows.bin");
    if (DEBUG_SKIP) {
        if (bundleFile.exists() && installedWorkflowsFile.exists()) {
            byte[] bundleLocationsBinary = Files.toByteArray(bundleFile);
            byte[] installedWorkflowsBinary = Files.toByteArray(installedWorkflowsFile);
            bundleLocations = (Map<String, File>) SerializationUtils.deserialize(bundleLocationsBinary);
            installedWorkflows = (Map<String, Integer>) SerializationUtils
                    .deserialize(installedWorkflowsBinary);
            return;
        }
    }
    createSharedTempDir();

    Log.info("Trying to build and test archetypes at: " + tempDir.getAbsolutePath());
    PluginRunner it = new PluginRunner();
    String SEQWARE_VERSION = it.getClass().getPackage().getImplementationVersion();
    Assert.assertTrue("unable to detect seqware version", SEQWARE_VERSION != null);
    Log.info("SeqWare version detected as: " + SEQWARE_VERSION);

    // for all tests, we're going to need to create and install our basic archetypes
    //String[] archetypes = {"java-workflow", "simplified-ftl-workflow", "legacy-ftl-workflow", "simple-legacy-ftl-workflow"};
    // starting with the 1.0.x series we are deprecating the FTL workflows and the Pegasus backend so skip testing them
    // we are now only testing Java workflows on the Oozie-* backends
    String[] archetypes = { "java-workflow" };
    buildAndInstallArchetypes(archetypes, SEQWARE_VERSION, true, true);
    Assert.assertTrue("could not locate installed workflows", installedWorkflows.size() == archetypes.length);
    Assert.assertTrue("could not locate installed workflow paths",
            installedWorkflows.size() == bundleLocations.size());

    if (DEBUG_SKIP) {
        // dump data to a permanent map just in case we want to re-run tests without waiting
        byte[] bundleLocationsBinary = SerializationUtils.serialize(bundleLocations);
        byte[] installedWorkflowsBinary = SerializationUtils.serialize(installedWorkflows);
        Files.write(bundleLocationsBinary, bundleFile);
        Files.write(installedWorkflowsBinary, installedWorkflowsFile);
    }
    // SEQWARE-1684 - Try to keep workflow bundle size under 8G limit
    Log.stderr(PluginRunnerET.class.getName() + " Cleaning up " + tempDir.getAbsolutePath());
}

From source file:net.sourceforge.seqware.pipeline.plugins.PluginRunnerIT.java

@BeforeClass
public static void createAndInstallArchetypes() throws IOException {
    clearStaticVariables();//from   w w  w .j a va2s. c o  m

    File bundleFile = new File(System.getProperty("java.io.tmpdir"), "PluginRunnerIT_bundleLocations.bin");
    File installedWorkflowsFile = new File(System.getProperty("java.io.tmpdir"),
            "PluginRunnerIT_installedWorkflows.bin");
    if (DEBUG_SKIP) {
        if (bundleFile.exists() && installedWorkflowsFile.exists()) {
            byte[] bundleLocationsBinary = Files.toByteArray(bundleFile);
            byte[] installedWorkflowsBinary = Files.toByteArray(installedWorkflowsFile);
            bundleLocations = (Map<String, File>) SerializationUtils.deserialize(bundleLocationsBinary);
            installedWorkflows = (Map<String, Integer>) SerializationUtils
                    .deserialize(installedWorkflowsBinary);
            return;
        }
    }

    tempDir = Files.createTempDir();
    Log.info("Trying to build and test archetypes at: " + tempDir.getAbsolutePath());
    PluginRunner it = new PluginRunner();
    String SEQWARE_VERSION = it.getClass().getPackage().getImplementationVersion();
    Assert.assertTrue("unable to detect seqware version", SEQWARE_VERSION != null);
    Log.info("SeqWare version detected as: " + SEQWARE_VERSION);

    // for all tests, we're going to need to create and install our basic archetypes
    String[] archetypes = { "java-workflow", "simplified-ftl-workflow", "legacy-ftl-workflow",
            "simple-legacy-ftl-workflow" };
    buildAndInstallArchetypes(archetypes, SEQWARE_VERSION);
    Assert.assertTrue("could not locate installed workflows", installedWorkflows.size() == archetypes.length);
    Assert.assertTrue("could not locate installed workflow paths",
            installedWorkflows.size() == bundleLocations.size());

    if (DEBUG_SKIP) {
        // dump data to a permanent map just in case we want to re-run tests without waiting
        byte[] bundleLocationsBinary = SerializationUtils.serialize(bundleLocations);
        byte[] installedWorkflowsBinary = SerializationUtils.serialize(installedWorkflows);
        Files.write(bundleLocationsBinary, bundleFile);
        Files.write(installedWorkflowsBinary, installedWorkflowsFile);
    }

}

From source file:org.geoserver.security.iride.identity.IrideIdentityTest.java

/**
 * Test method for {@link org.geoserver.security.iride.entity.IrideIdentity} serialization.
 *///  w  w  w  .j av  a  2  s .  c o m
@Test
public void testIrideIdentitySuccesfulDeserialization() {
    final String value = StringUtils.join(this.tokens, IrideIdentityToken.SEPARATOR);

    LOGGER.trace("BEGIN {}::testIrideIdentitySuccesfulDeserialization - {}", this.getClass().getName(), value);
    try {
        final IrideIdentity irideIdentity1 = IrideIdentity.parseIrideIdentity(value);

        final byte[] serialized = SerializationUtils.serialize(irideIdentity1);

        assertThat(serialized, is(not(nullValue())));
        assertThat(ArrayUtils.toObject(serialized), is(arrayWithSize(greaterThan(0))));

        final Object deserialized = SerializationUtils.deserialize(serialized);

        assertThat(deserialized, is(not(nullValue())));
        assertThat(deserialized, is(instanceOf(IrideIdentity.class)));

        final IrideIdentity irideIdentity2 = (IrideIdentity) deserialized;

        assertThat(irideIdentity1, is(not(sameInstance(irideIdentity2))));
        assertThat(irideIdentity1, is(equalTo(irideIdentity2)));
        assertThat(irideIdentity1.compareTo(irideIdentity2), is(0));
    } finally {
        LOGGER.trace("END {}::testIrideIdentitySuccesfulDeserialization", this.getClass().getName());
    }
}

From source file:org.springframework.batch.jsr.item.CheckpointSupport.java

private Object deepCopy(Serializable orig) {
    Object obj = orig;//from w ww  . j ava  2s  . c om

    try {
        obj = SerializationUtils.deserialize(SerializationUtils.serialize(orig));
    } catch (Exception e) {
        logger.warn("Unable to copy checkpoint object.  Updating the instance passed may cause side effects");
    }

    return obj;
}