/** * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package test.sdo21.vendor.tuscany.testHelper; import static org.junit.Assert.fail; import java.io.InputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.OutputStream; import java.util.Collection; import java.util.List; import java.util.logging.Logger; import javax.xml.stream.XMLStreamWriter; import org.apache.tuscany.sdo.util.SDOUtil; import test.sdo21.framework.DataObjectFactory; import test.sdo21.framework.TestHelper; import commonj.sdo.DataGraph; import commonj.sdo.DataObject; import commonj.sdo.Type; import commonj.sdo.helper.HelperContext; import commonj.sdo.helper.TypeHelper; /** * Implementation of TestHelper for Tuscany. */ public class TuscanyTestHelper implements TestHelper { private static List staticArtifacts = null; private static final Logger logger = Logger.getLogger(TuscanyTestHelper.class.getName()); public void init() { } public DataObject createTypeDef(String uri, String name, boolean open, HelperContext helperContext) { throw new IllegalStateException("This method is deprecated in the TestHelper interface and we should not introduce dependencies on it in the test suite"); } public DataObject createPropertyDef(DataObject typeDef, String propertyName, Type type, boolean isMany, boolean isContainment) { throw new IllegalStateException("This method is deprecated in the TestHelper interface and we should not introduce dependencies on it in the test suite"); } public DataObject createPropertyDef(DataObject typeDef, String propertyName, String typeName, boolean isMany, boolean isContainment, HelperContext helperContext) { throw new IllegalStateException("This method is deprecated in the TestHelper interface and we should not introduce dependencies on it in the test suite"); } public String createUniqueName() { return "name-" + System.currentTimeMillis() + "-" + ((int)(1000 * Math.random())); } /** * Create an empty data graph. * * @return the new data graph instance. */ public DataGraph createDataGraph() { return SDOUtil.createDataGraph(); } /** * Create a new HelperContext, a new scope * @return the new HelperContext instance. */ public HelperContext createHelperContext() { return SDOUtil.createHelperContext(); } /** * Create a new ObjectOutputStream * * @return the new ObjectOutputStream instance. */ public ObjectOutputStream createObjectOutputStream(OutputStream os, HelperContext helperContext) { try { return SDOUtil.createObjectOutputStream(os, helperContext); } catch (java.io.IOException e) { fail("IOException during createObjectOutputStream."); return null; } } /** * Create a new ObjectInputStream * * @return the new ObjectInputStream instance. */ public ObjectInputStream createObjectInputStream(InputStream is, HelperContext helperContext) { try { return SDOUtil.createObjectInputStream(is, helperContext); } catch (java.io.IOException e) { fail("IOException during createObjectOutputStream."); return null; } } /** * Serialize a DataObject using an XMLStreamHelper */ public void serializeViaXMLStreamHelper(TypeHelper typeHelper, DataObject dataObject, XMLStreamWriter serializer) { try { SDOUtil.createXMLStreamHelper(typeHelper).saveObject(dataObject, serializer); } catch (javax.xml.stream.XMLStreamException e) { fail("XMLStreamException during saveObject."); } } public DataObjectFactory createDataObjectFactory(String factory, HelperContext helperContext) { throw new IllegalStateException("This method is deprecated in the TestHelper interface and we should not introduce dependencies on it in the test suite"); } public Collection getParamatizedDataObject() { throw new IllegalStateException("This method is deprecated in the TestHelper interface and we should not introduce dependencies on it in the test suite"); } }