|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license |
| 3 | + * agreements. See the NOTICE file distributed with this work for additional information regarding |
| 4 | + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the |
| 5 | + * "License"); you may not use this file except in compliance with the License. You may obtain a |
| 6 | + * copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software distributed under the License |
| 11 | + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
| 12 | + * or implied. See the License for the specific language governing permissions and limitations under |
| 13 | + * the License. |
| 14 | + */ |
| 15 | +package org.apache.geode.management.internal.web.controllers; |
| 16 | + |
| 17 | +import java.io.ByteArrayInputStream; |
| 18 | +import java.io.ByteArrayOutputStream; |
| 19 | +import java.io.ObjectOutputStream; |
| 20 | + |
| 21 | +import javax.management.Query; |
| 22 | +import javax.management.QueryExp; |
| 23 | + |
| 24 | +import org.apache.commons.io.serialization.ValidatingObjectInputStream; |
| 25 | +import org.junit.Test; |
| 26 | + |
| 27 | +public class QueryExpDeserializationTest { |
| 28 | + @Test |
| 29 | + public void testQueryExp() throws Exception { |
| 30 | + QueryExp query = Query.eq(Query.attr("Name"), Query.value("mock")); |
| 31 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
| 32 | + ObjectOutputStream oos = new ObjectOutputStream(baos); |
| 33 | + oos.writeObject(query); |
| 34 | + oos.close(); |
| 35 | + |
| 36 | + byte[] decoded = baos.toByteArray(); |
| 37 | + ValidatingObjectInputStream ois = |
| 38 | + new ValidatingObjectInputStream(new ByteArrayInputStream(decoded)); |
| 39 | + ois.accept("javax.management.*", "java.lang.*", "java.util.*"); |
| 40 | + |
| 41 | + QueryExp q = (QueryExp) ois.readObject(); |
| 42 | + System.out.println(q); |
| 43 | + } |
| 44 | +} |
0 commit comments