### Question:
GeoGigDataStore extends ContentDataStore implements DataStore { @Override public void createSchema(SimpleFeatureType featureType) throws IOException { if (!allowTransactions) { throw new IllegalStateException("Configured head " + refspec + " is not a branch; transactions are not supported."); } GeogigTransaction tx = getCommandLocator(null).command(TransactionBegin.class).call(); boolean abort = false; try { String treePath = featureType.getName().getLocalPart(); final String branch = getOrFigureOutBranch(); tx.command(CheckoutOp.class).setForce(true).setSource(branch).call(); WorkingTree workingTree = tx.workingTree(); workingTree.createTypeTree(treePath, featureType); tx.command(AddOp.class).addPattern(treePath).call(); tx.command(CommitOp.class).setMessage("Created feature type tree " + treePath).call(); tx.commit(); } catch (IllegalArgumentException alreadyExists) { abort = true; throw new IOException(alreadyExists.getMessage(), alreadyExists); } catch (Exception e) { abort = true; throw Throwables.propagate(e); } finally { if (abort) { tx.abort(); } } } GeoGigDataStore(GeoGIG geogig); @Override void dispose(); @Deprecated void setBranch(@Nullable final String branchName); void setHead(@Nullable final String refspec); @Deprecated String getOrFigureOutBranch(); String getOrFigureOutHead(); GeoGIG getGeogig(); @Deprecated String getConfiguredBranch(); @Nullable String getConfiguredHead(); boolean isAllowTransactions(); @Nullable String getCheckedOutBranch(); ImmutableList<String> getAvailableBranches(); Context getCommandLocator(@Nullable Transaction transaction); Name getDescriptorName(NodeRef treeRef); NodeRef findTypeRef(Name typeName, @Nullable Transaction tx); @Override void createSchema(SimpleFeatureType featureType); void removeSchema(Name name); void removeSchema(String name); SimpleFeatureSource getDiffFeatureSource(final String typeName, final String oldRoot,
            final ChangeType changeType);  }### Answer:
@Test public void testCreateSchema() throws IOException { final SimpleFeatureType featureType = super.linesType; dataStore.createSchema(featureType); List<String> typeNames; typeNames = getTypeNames(Ref.HEAD); assertEquals(1, typeNames.size()); assertEquals(linesName, typeNames.get(0)); dataStore.createSchema(super.pointsType); typeNames = getTypeNames(Ref.HEAD); assertEquals(2, typeNames.size()); assertTrue(typeNames.contains(linesName)); assertTrue(typeNames.contains(pointsName)); try { dataStore.createSchema(super.pointsType); fail("Expected IOException on existing type"); } catch (IOException e) { assertTrue(e.getMessage().contains("already exists")); } }
@Test public void testFeatureWriterAppend() throws Exception { dataStore.createSchema(linesType); Transaction tx = new DefaultTransaction(); FeatureWriter<SimpleFeatureType, SimpleFeature> fw = dataStore.getFeatureWriterAppend( linesTypeName.getLocalPart(), tx); LineString line = new GeometryBuilder().lineString(0, 0, 1, 1); SimpleFeature f = (SimpleFeature) fw.next(); f.setAttribute("sp", "foo"); f.setAttribute("ip", 10); f.setAttribute("pp", line); fw.write(); fw.close(); tx.commit(); FeatureSource<SimpleFeatureType, SimpleFeature> source = dataStore .getFeatureSource(linesTypeName); assertEquals(1, source.getCount(null)); FeatureReader<SimpleFeatureType, SimpleFeature> r = dataStore.getFeatureReader(new Query( linesTypeName.getLocalPart()), Transaction.AUTO_COMMIT); assertTrue(r.hasNext()); f = r.next(); assertEquals("foo", f.getAttribute("sp")); assertEquals(10, f.getAttribute("ip")); assertTrue(line.equals((Geometry) f.getAttribute("pp"))); }